aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/acpi/acconfig.h15
-rw-r--r--include/acpi/acdebug.h2
-rw-r--r--include/acpi/acdisasm.h38
-rw-r--r--include/acpi/acdispat.h31
-rw-r--r--include/acpi/acevents.h2
-rw-r--r--include/acpi/acexcep.h2
-rw-r--r--include/acpi/acglobal.h38
-rw-r--r--include/acpi/achware.h2
-rw-r--r--include/acpi/acinterp.h15
-rw-r--r--include/acpi/aclocal.h10
-rw-r--r--include/acpi/acmacros.h71
-rw-r--r--include/acpi/acnames.h2
-rw-r--r--include/acpi/acnamesp.h5
-rw-r--r--include/acpi/acobject.h5
-rw-r--r--include/acpi/acopcode.h6
-rw-r--r--include/acpi/acoutput.h2
-rw-r--r--include/acpi/acparser.h4
-rw-r--r--include/acpi/acpi.h2
-rw-r--r--include/acpi/acpiosxf.h2
-rw-r--r--include/acpi/acpixf.h7
-rw-r--r--include/acpi/acresrc.h3
-rw-r--r--include/acpi/acstruct.h5
-rw-r--r--include/acpi/actables.h2
-rw-r--r--include/acpi/actbl.h2
-rw-r--r--include/acpi/actbl1.h561
-rw-r--r--include/acpi/actypes.h93
-rw-r--r--include/acpi/acutils.h4
-rw-r--r--include/acpi/amlcode.h2
-rw-r--r--include/acpi/amlresrc.h2
-rw-r--r--include/acpi/platform/acenv.h2
-rw-r--r--include/acpi/platform/acgcc.h2
-rw-r--r--include/acpi/platform/aclinux.h2
-rw-r--r--include/asm-alpha/bitops.h5
-rw-r--r--include/asm-alpha/bug.h16
-rw-r--r--include/asm-alpha/byteorder.h2
-rw-r--r--include/asm-alpha/ide.h11
-rw-r--r--include/asm-alpha/pgtable.h2
-rw-r--r--include/asm-alpha/semaphore.h150
-rw-r--r--include/asm-alpha/topology.h3
-rw-r--r--include/asm-alpha/unaligned.h13
-rw-r--r--include/asm-arm/arch-at91/at91_ecc.h10
-rw-r--r--include/asm-arm/arch-at91/at91_pmc.h15
-rw-r--r--include/asm-arm/arch-at91/at91_shdwc.h2
-rw-r--r--include/asm-arm/arch-at91/at91cap9_ddrsdr.h100
-rw-r--r--include/asm-arm/arch-at91/at91sam9_sdramc.h (renamed from include/asm-arm/arch-at91/at91sam926x_mc.h)68
-rw-r--r--include/asm-arm/arch-at91/at91sam9_smc.h73
-rw-r--r--include/asm-arm/arch-ep93xx/gpio.h21
-rw-r--r--include/asm-arm/arch-iop13xx/adma.h5
-rw-r--r--include/asm-arm/arch-ks8695/devices.h5
-rw-r--r--include/asm-arm/arch-mxc/board-mx31ads.h124
-rw-r--r--include/asm-arm/arch-mxc/dma.h7
-rw-r--r--include/asm-arm/arch-mxc/hardware.h33
-rw-r--r--include/asm-arm/arch-mxc/io.h15
-rw-r--r--include/asm-arm/arch-mxc/irqs.h21
-rw-r--r--include/asm-arm/arch-mxc/memory.h13
-rw-r--r--include/asm-arm/arch-mxc/mx31.h30
-rw-r--r--include/asm-arm/arch-mxc/mxc.h11
-rw-r--r--include/asm-arm/arch-mxc/system.h18
-rw-r--r--include/asm-arm/arch-mxc/vmalloc.h14
-rw-r--r--include/asm-arm/arch-ns9xxx/board.h28
-rw-r--r--include/asm-arm/arch-ns9xxx/clock.h71
-rw-r--r--include/asm-arm/arch-ns9xxx/entry-macro.S6
-rw-r--r--include/asm-arm/arch-ns9xxx/irqs.h67
-rw-r--r--include/asm-arm/arch-ns9xxx/module.h60
-rw-r--r--include/asm-arm/arch-ns9xxx/processor-ns9360.h32
-rw-r--r--include/asm-arm/arch-ns9xxx/processor.h31
-rw-r--r--include/asm-arm/arch-ns9xxx/regs-sys-common.h31
-rw-r--r--include/asm-arm/arch-ns9xxx/regs-sys-ns9360.h (renamed from include/asm-arm/arch-ns9xxx/regs-sys.h)25
-rw-r--r--include/asm-arm/arch-ns9xxx/system.h17
-rw-r--r--include/asm-arm/arch-ns9xxx/uncompress.h143
-rw-r--r--include/asm-arm/arch-omap/board-osk.h11
-rw-r--r--include/asm-arm/arch-omap/clock.h75
-rw-r--r--include/asm-arm/arch-omap/control.h191
-rw-r--r--include/asm-arm/arch-omap/entry-macro.S2
-rw-r--r--include/asm-arm/arch-omap/gpio.h57
-rw-r--r--include/asm-arm/arch-omap/io.h70
-rw-r--r--include/asm-arm/arch-omap/mmc.h2
-rw-r--r--include/asm-arm/arch-omap/mux.h66
-rw-r--r--include/asm-arm/arch-omap/omap24xx.h96
-rw-r--r--include/asm-arm/arch-omap/sdrc.h75
-rw-r--r--include/asm-arm/arch-omap/usb.h5
-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/orion.h165
-rw-r--r--include/asm-arm/arch-orion/timex.h12
-rw-r--r--include/asm-arm/arch-orion5x/debug-macro.S (renamed from include/asm-arm/arch-orion/debug-macro.S)8
-rw-r--r--include/asm-arm/arch-orion5x/dma.h (renamed from include/asm-arm/arch-orion/dma.h)0
-rw-r--r--include/asm-arm/arch-orion5x/entry-macro.S (renamed from include/asm-arm/arch-orion/entry-macro.S)4
-rw-r--r--include/asm-arm/arch-orion5x/gpio.h (renamed from include/asm-arm/arch-orion/gpio.h)8
-rw-r--r--include/asm-arm/arch-orion5x/hardware.h (renamed from include/asm-arm/arch-orion/hardware.h)10
-rw-r--r--include/asm-arm/arch-orion5x/io.h67
-rw-r--r--include/asm-arm/arch-orion5x/irqs.h62
-rw-r--r--include/asm-arm/arch-orion5x/memory.h (renamed from include/asm-arm/arch-orion/memory.h)7
-rw-r--r--include/asm-arm/arch-orion5x/orion5x.h159
-rw-r--r--include/asm-arm/arch-orion5x/system.h (renamed from include/asm-arm/arch-orion/system.h)13
-rw-r--r--include/asm-arm/arch-orion5x/timex.h13
-rw-r--r--include/asm-arm/arch-orion5x/uncompress.h (renamed from include/asm-arm/arch-orion/uncompress.h)8
-rw-r--r--include/asm-arm/arch-orion5x/vmalloc.h (renamed from include/asm-arm/arch-orion/vmalloc.h)2
-rw-r--r--include/asm-arm/arch-pxa/camera.h48
-rw-r--r--include/asm-arm/arch-pxa/gumstix.h96
-rw-r--r--include/asm-arm/arch-pxa/irda.h2
-rw-r--r--include/asm-arm/arch-pxa/irqs.h8
-rw-r--r--include/asm-arm/arch-pxa/magician.h94
-rw-r--r--include/asm-arm/arch-pxa/mfp-pxa25x.h161
-rw-r--r--include/asm-arm/arch-pxa/mfp-pxa27x.h432
-rw-r--r--include/asm-arm/arch-pxa/mfp-pxa2xx.h132
-rw-r--r--include/asm-arm/arch-pxa/pxa-regs.h526
-rw-r--r--include/asm-arm/arch-pxa/pxa27x_keypad.h2
-rw-r--r--include/asm-arm/arch-pxa/pxa2xx-gpio.h357
-rw-r--r--include/asm-arm/arch-pxa/pxa3xx-regs.h9
-rw-r--r--include/asm-arm/arch-pxa/pxa3xx_nand.h18
-rw-r--r--include/asm-arm/arch-pxa/pxafb.h71
-rw-r--r--include/asm-arm/arch-pxa/regs-lcd.h171
-rw-r--r--include/asm-arm/arch-pxa/system.h2
-rw-r--r--include/asm-arm/arch-pxa/tosa.h40
-rw-r--r--include/asm-arm/arch-pxa/zylonite.h2
-rw-r--r--include/asm-arm/arch-realview/board-eb.h20
-rw-r--r--include/asm-arm/arch-realview/board-pb1176.h152
-rw-r--r--include/asm-arm/arch-realview/board-pb11mp.h186
-rw-r--r--include/asm-arm/arch-realview/debug-macro.S2
-rw-r--r--include/asm-arm/arch-realview/hardware.h2
-rw-r--r--include/asm-arm/arch-realview/irqs.h2
-rw-r--r--include/asm-arm/arch-realview/platform.h27
-rw-r--r--include/asm-arm/arch-realview/scu.h11
-rw-r--r--include/asm-arm/arch-realview/uncompress.h38
-rw-r--r--include/asm-arm/arch-s3c2410/regs-clock.h2
-rw-r--r--include/asm-arm/arch-s3c2410/regs-gpio.h4
-rw-r--r--include/asm-arm/arch-s3c2410/regs-s3c2412-mem.h29
-rw-r--r--include/asm-arm/arch-s3c2410/system-reset.h64
-rw-r--r--include/asm-arm/arch-s3c2410/system.h46
-rw-r--r--include/asm-arm/arch-sa1100/gpio.h31
-rw-r--r--include/asm-arm/arch-sa1100/ide.h6
-rw-r--r--include/asm-arm/cpu-multi32.h4
-rw-r--r--include/asm-arm/div64.h2
-rw-r--r--include/asm-arm/glue.h87
-rw-r--r--include/asm-arm/hardware/arm_scu.h15
-rw-r--r--include/asm-arm/hardware/iop3xx-adma.h12
-rw-r--r--include/asm-arm/hardware/iop3xx.h9
-rw-r--r--include/asm-arm/hardware/iop_adma.h2
-rw-r--r--include/asm-arm/hardware/scoop.h5
-rw-r--r--include/asm-arm/hwcap.h1
-rw-r--r--include/asm-arm/ide.h8
-rw-r--r--include/asm-arm/mach/pci.h1
-rw-r--r--include/asm-arm/memory.h3
-rw-r--r--include/asm-arm/page.h8
-rw-r--r--include/asm-arm/pgtable.h3
-rw-r--r--include/asm-arm/plat-orion/ehci-orion.h19
-rw-r--r--include/asm-arm/plat-orion/irq.h17
-rw-r--r--include/asm-arm/plat-orion/orion_nand.h (renamed from include/asm-arm/arch-orion/platform.h)11
-rw-r--r--include/asm-arm/plat-orion/pcie.h31
-rw-r--r--include/asm-arm/plat-orion/time.h17
-rw-r--r--include/asm-arm/plat-s3c/nand.h5
-rw-r--r--include/asm-arm/semaphore-helper.h84
-rw-r--r--include/asm-arm/semaphore.h99
-rw-r--r--include/asm-arm/sparsemem.h10
-rw-r--r--include/asm-arm/thread_info.h3
-rw-r--r--include/asm-arm/unaligned.h174
-rw-r--r--include/asm-arm/unistd.h4
-rw-r--r--include/asm-avr32/arch-at32ap/board.h9
-rw-r--r--include/asm-avr32/arch-at32ap/pm.h48
-rw-r--r--include/asm-avr32/arch-at32ap/time.h112
-rw-r--r--include/asm-avr32/asm.h8
-rw-r--r--include/asm-avr32/intc.h128
-rw-r--r--include/asm-avr32/irq.h5
-rw-r--r--include/asm-avr32/page.h8
-rw-r--r--include/asm-avr32/pgtable.h8
-rw-r--r--include/asm-avr32/semaphore.h109
-rw-r--r--include/asm-avr32/serial.h13
-rw-r--r--include/asm-avr32/unaligned.h13
-rw-r--r--include/asm-avr32/xor.h6
-rw-r--r--include/asm-blackfin/.gitignore1
-rw-r--r--include/asm-blackfin/bfin-global.h10
-rw-r--r--include/asm-blackfin/bug.h13
-rw-r--r--include/asm-blackfin/cplb.h26
-rw-r--r--include/asm-blackfin/dma-mapping.h15
-rw-r--r--include/asm-blackfin/dma.h4
-rw-r--r--include/asm-blackfin/gptimers.h150
-rw-r--r--include/asm-blackfin/ide.h4
-rw-r--r--include/asm-blackfin/mach-bf527/anomaly.h80
-rw-r--r--include/asm-blackfin/mach-bf527/bfin_serial_5xx.h48
-rw-r--r--include/asm-blackfin/mach-bf527/bfin_sir.h133
-rw-r--r--include/asm-blackfin/mach-bf527/blackfin.h15
-rw-r--r--include/asm-blackfin/mach-bf527/cdefBF52x_base.h90
-rw-r--r--include/asm-blackfin/mach-bf527/dma.h3
-rw-r--r--include/asm-blackfin/mach-bf533/anomaly.h10
-rw-r--r--include/asm-blackfin/mach-bf533/bfin_serial_5xx.h50
-rw-r--r--include/asm-blackfin/mach-bf533/bfin_sir.h120
-rw-r--r--include/asm-blackfin/mach-bf533/blackfin.h15
-rw-r--r--include/asm-blackfin/mach-bf533/cdefBF532.h31
-rw-r--r--include/asm-blackfin/mach-bf533/defBF532.h29
-rw-r--r--include/asm-blackfin/mach-bf533/dma.h3
-rw-r--r--include/asm-blackfin/mach-bf533/mem_init.h10
-rw-r--r--include/asm-blackfin/mach-bf537/anomaly.h17
-rw-r--r--include/asm-blackfin/mach-bf537/bfin_serial_5xx.h48
-rw-r--r--include/asm-blackfin/mach-bf537/bfin_sir.h133
-rw-r--r--include/asm-blackfin/mach-bf537/blackfin.h39
-rw-r--r--include/asm-blackfin/mach-bf537/cdefBF534.h65
-rw-r--r--include/asm-blackfin/mach-bf537/dma.h3
-rw-r--r--include/asm-blackfin/mach-bf548/anomaly.h1
-rw-r--r--include/asm-blackfin/mach-bf548/bfin_serial_5xx.h48
-rw-r--r--include/asm-blackfin/mach-bf548/bfin_sir.h149
-rw-r--r--include/asm-blackfin/mach-bf548/blackfin.h38
-rw-r--r--include/asm-blackfin/mach-bf548/cdefBF542.h12
-rw-r--r--include/asm-blackfin/mach-bf548/cdefBF544.h33
-rw-r--r--include/asm-blackfin/mach-bf548/cdefBF547.h33
-rw-r--r--include/asm-blackfin/mach-bf548/cdefBF548.h33
-rw-r--r--include/asm-blackfin/mach-bf548/cdefBF549.h35
-rw-r--r--include/asm-blackfin/mach-bf548/cdefBF54x_base.h418
-rw-r--r--include/asm-blackfin/mach-bf548/dma.h2
-rw-r--r--include/asm-blackfin/mach-bf548/mem_init.h20
-rw-r--r--include/asm-blackfin/mach-bf561/anomaly.h6
-rw-r--r--include/asm-blackfin/mach-bf561/bfin_serial_5xx.h50
-rw-r--r--include/asm-blackfin/mach-bf561/bfin_sir.h120
-rw-r--r--include/asm-blackfin/mach-bf561/blackfin.h14
-rw-r--r--include/asm-blackfin/mach-bf561/cdefBF561.h34
-rw-r--r--include/asm-blackfin/mach-bf561/defBF561.h31
-rw-r--r--include/asm-blackfin/mach-bf561/dma.h3
-rw-r--r--include/asm-blackfin/portmux.h4
-rw-r--r--include/asm-blackfin/processor.h5
-rw-r--r--include/asm-blackfin/semaphore-helper.h82
-rw-r--r--include/asm-blackfin/semaphore.h106
-rw-r--r--include/asm-blackfin/signal.h2
-rw-r--r--include/asm-blackfin/thread_info.h11
-rw-r--r--include/asm-blackfin/time.h36
-rw-r--r--include/asm-blackfin/timex.h17
-rw-r--r--include/asm-blackfin/trace.h4
-rw-r--r--include/asm-blackfin/uaccess.h4
-rw-r--r--include/asm-blackfin/unaligned.h13
-rw-r--r--include/asm-blackfin/unistd.h26
-rw-r--r--include/asm-cris/arch-v10/ide.h11
-rw-r--r--include/asm-cris/pgtable.h4
-rw-r--r--include/asm-cris/semaphore-helper.h78
-rw-r--r--include/asm-cris/semaphore.h134
-rw-r--r--include/asm-cris/unaligned.h17
-rw-r--r--include/asm-frv/pgtable.h2
-rw-r--r--include/asm-frv/semaphore.h156
-rw-r--r--include/asm-frv/system.h5
-rw-r--r--include/asm-frv/topology.h4
-rw-r--r--include/asm-frv/unaligned.h192
-rw-r--r--include/asm-generic/bitops.h4
-rw-r--r--include/asm-generic/bitops/__fls.h43
-rw-r--r--include/asm-generic/bitops/find.h2
-rw-r--r--include/asm-generic/bitops/fls64.h22
-rw-r--r--include/asm-generic/div64.h7
-rw-r--r--include/asm-generic/futex.h5
-rw-r--r--include/asm-generic/gpio.h15
-rw-r--r--include/asm-generic/ioctl.h33
-rw-r--r--include/asm-generic/iomap.h4
-rw-r--r--include/asm-generic/memory_model.h2
-rw-r--r--include/asm-generic/page.h2
-rw-r--r--include/asm-generic/rtc.h3
-rw-r--r--include/asm-generic/topology.h14
-rw-r--r--include/asm-generic/unaligned.h124
-rw-r--r--include/asm-h8300/semaphore-helper.h85
-rw-r--r--include/asm-h8300/semaphore.h191
-rw-r--r--include/asm-h8300/unaligned.h20
-rw-r--r--include/asm-ia64/acpi.h33
-rw-r--r--include/asm-ia64/bitops.h16
-rw-r--r--include/asm-ia64/cputime.h104
-rw-r--r--include/asm-ia64/dma-mapping.h28
-rw-r--r--include/asm-ia64/dmi.h5
-rw-r--r--include/asm-ia64/elf.h31
-rw-r--r--include/asm-ia64/futex.h2
-rw-r--r--include/asm-ia64/gcc_intrin.h12
-rw-r--r--include/asm-ia64/hugetlb.h79
-rw-r--r--include/asm-ia64/ide.h10
-rw-r--r--include/asm-ia64/io.h5
-rw-r--r--include/asm-ia64/kprobes.h7
-rw-r--r--include/asm-ia64/kregs.h3
-rw-r--r--include/asm-ia64/kvm.h205
-rw-r--r--include/asm-ia64/kvm_host.h524
-rw-r--r--include/asm-ia64/kvm_para.h29
-rw-r--r--include/asm-ia64/machvec.h50
-rw-r--r--include/asm-ia64/machvec_hpzx1.h16
-rw-r--r--include/asm-ia64/machvec_hpzx1_swiotlb.h16
-rw-r--r--include/asm-ia64/machvec_sn2.h16
-rw-r--r--include/asm-ia64/mca.h1
-rw-r--r--include/asm-ia64/meminit.h3
-rw-r--r--include/asm-ia64/numa.h2
-rw-r--r--include/asm-ia64/page.h6
-rw-r--r--include/asm-ia64/pal.h72
-rw-r--r--include/asm-ia64/pgtable.h5
-rw-r--r--include/asm-ia64/processor.h63
-rw-r--r--include/asm-ia64/sal.h21
-rw-r--r--include/asm-ia64/semaphore.h100
-rw-r--r--include/asm-ia64/smp.h3
-rw-r--r--include/asm-ia64/sn/nodepda.h1
-rw-r--r--include/asm-ia64/sn/xp.h485
-rw-r--r--include/asm-ia64/sn/xpc.h1267
-rw-r--r--include/asm-ia64/system.h30
-rw-r--r--include/asm-ia64/thread_info.h19
-rw-r--r--include/asm-ia64/tlb.h26
-rw-r--r--include/asm-ia64/tlbflush.h1
-rw-r--r--include/asm-ia64/topology.h9
-rw-r--r--include/asm-ia64/unaligned.h7
-rw-r--r--include/asm-ia64/uncached.h6
-rw-r--r--include/asm-m32r/ide.h10
-rw-r--r--include/asm-m32r/pgtable.h10
-rw-r--r--include/asm-m32r/semaphore.h145
-rw-r--r--include/asm-m32r/unaligned.h27
-rw-r--r--include/asm-m68k/div64.h1
-rw-r--r--include/asm-m68k/motorola_pgtable.h2
-rw-r--r--include/asm-m68k/semaphore-helper.h142
-rw-r--r--include/asm-m68k/semaphore.h164
-rw-r--r--include/asm-m68k/sun3_pgtable.h2
-rw-r--r--include/asm-m68k/unaligned.h17
-rw-r--r--include/asm-m68knommu/dma.h3
-rw-r--r--include/asm-m68knommu/param.h7
-rw-r--r--include/asm-m68knommu/semaphore-helper.h82
-rw-r--r--include/asm-m68knommu/semaphore.h154
-rw-r--r--include/asm-m68knommu/unaligned.h22
-rw-r--r--include/asm-mips/bitops.h5
-rw-r--r--include/asm-mips/cmp.h18
-rw-r--r--include/asm-mips/cpu.h9
-rw-r--r--include/asm-mips/dec/ioasic.h2
-rw-r--r--include/asm-mips/div64.h6
-rw-r--r--include/asm-mips/ds1287.h27
-rw-r--r--include/asm-mips/futex.h2
-rw-r--r--include/asm-mips/gcmpregs.h117
-rw-r--r--include/asm-mips/gic.h487
-rw-r--r--include/asm-mips/io.h2
-rw-r--r--include/asm-mips/jmr3927/jmr3927.h4
-rw-r--r--include/asm-mips/jmr3927/tx3927.h2
-rw-r--r--include/asm-mips/jmr3927/txx927.h12
-rw-r--r--include/asm-mips/mach-au1x00/au1000.h26
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx_ide.h42
-rw-r--r--include/asm-mips/mach-db1x00/db1200.h18
-rw-r--r--include/asm-mips/mach-generic/gpio.h6
-rw-r--r--include/asm-mips/mach-generic/ide.h10
-rw-r--r--include/asm-mips/mach-ip27/topology.h2
-rw-r--r--include/asm-mips/mach-pb1x00/pb1200.h18
-rw-r--r--include/asm-mips/mips-boards/generic.h1
-rw-r--r--include/asm-mips/mips-boards/launch.h35
-rw-r--r--include/asm-mips/mips-boards/malta.h23
-rw-r--r--include/asm-mips/mips-boards/maltaint.h27
-rw-r--r--include/asm-mips/mips-boards/maltasmp.h36
-rw-r--r--include/asm-mips/mipsmtregs.h8
-rw-r--r--include/asm-mips/pgtable-32.h4
-rw-r--r--include/asm-mips/pgtable-bits.h91
-rw-r--r--include/asm-mips/pgtable.h59
-rw-r--r--include/asm-mips/r4k-timer.h30
-rw-r--r--include/asm-mips/semaphore.h109
-rw-r--r--include/asm-mips/smp-ops.h1
-rw-r--r--include/asm-mips/smtc.h1
-rw-r--r--include/asm-mips/smvp.h19
-rw-r--r--include/asm-mips/traps.h2
-rw-r--r--include/asm-mips/tx4938/rbtx4938.h58
-rw-r--r--include/asm-mips/tx4938/tx4938.h38
-rw-r--r--include/asm-mips/tx4938/tx4938_mips.h54
-rw-r--r--include/asm-mips/txx9pio.h29
-rw-r--r--include/asm-mips/unaligned.h37
-rw-r--r--include/asm-mips/vr41xx/siu.h8
-rw-r--r--include/asm-mips/vr41xx/vr41xx.h8
-rw-r--r--include/asm-mn10300/div64.h3
-rw-r--r--include/asm-mn10300/pgtable.h3
-rw-r--r--include/asm-mn10300/semaphore.h170
-rw-r--r--include/asm-mn10300/unaligned.h130
-rw-r--r--include/asm-parisc/bitops.h1
-rw-r--r--include/asm-parisc/futex.h2
-rw-r--r--include/asm-parisc/ide.h2
-rw-r--r--include/asm-parisc/pgtable.h2
-rw-r--r--include/asm-parisc/semaphore-helper.h89
-rw-r--r--include/asm-parisc/semaphore.h146
-rw-r--r--include/asm-parisc/unaligned.h12
-rw-r--r--include/asm-powerpc/Kbuild2
-rw-r--r--include/asm-powerpc/abs_addr.h3
-rw-r--r--include/asm-powerpc/bitops.h37
-rw-r--r--include/asm-powerpc/cpm.h14
-rw-r--r--include/asm-powerpc/cpm1.h13
-rw-r--r--include/asm-powerpc/cpm2.h11
-rw-r--r--include/asm-powerpc/cputhreads.h2
-rw-r--r--include/asm-powerpc/dcr-native.h17
-rw-r--r--include/asm-powerpc/dcr-regs.h78
-rw-r--r--include/asm-powerpc/exception.h6
-rw-r--r--include/asm-powerpc/fixmap.h106
-rw-r--r--include/asm-powerpc/fsl_lbc.h311
-rw-r--r--include/asm-powerpc/futex.h2
-rw-r--r--include/asm-powerpc/gpio.h56
-rw-r--r--include/asm-powerpc/highmem.h41
-rw-r--r--include/asm-powerpc/hugetlb.h79
-rw-r--r--include/asm-powerpc/hw_irq.h13
-rw-r--r--include/asm-powerpc/ide.h57
-rw-r--r--include/asm-powerpc/immap_qe.h3
-rw-r--r--include/asm-powerpc/io-defs.h101
-rw-r--r--include/asm-powerpc/io.h8
-rw-r--r--include/asm-powerpc/irq.h2
-rw-r--r--include/asm-powerpc/irqflags.h37
-rw-r--r--include/asm-powerpc/iseries/alpaca.h31
-rw-r--r--include/asm-powerpc/iseries/it_lp_reg_save.h85
-rw-r--r--include/asm-powerpc/kdump.h5
-rw-r--r--include/asm-powerpc/kvm.h53
-rw-r--r--include/asm-powerpc/kvm_asm.h55
-rw-r--r--include/asm-powerpc/kvm_host.h152
-rw-r--r--include/asm-powerpc/kvm_para.h37
-rw-r--r--include/asm-powerpc/kvm_ppc.h88
-rw-r--r--include/asm-powerpc/lmb.h82
-rw-r--r--include/asm-powerpc/machdep.h5
-rw-r--r--include/asm-powerpc/macio.h2
-rw-r--r--include/asm-powerpc/mediabay.h6
-rw-r--r--include/asm-powerpc/mmu-40x.h2
-rw-r--r--include/asm-powerpc/mmu-44x.h2
-rw-r--r--include/asm-powerpc/mmu-8xx.h2
-rw-r--r--include/asm-powerpc/mmu-fsl-booke.h6
-rw-r--r--include/asm-powerpc/mmu-hash32.h2
-rw-r--r--include/asm-powerpc/mmu-hash64.h3
-rw-r--r--include/asm-powerpc/paca.h13
-rw-r--r--include/asm-powerpc/page.h44
-rw-r--r--include/asm-powerpc/page_32.h8
-rw-r--r--include/asm-powerpc/page_64.h7
-rw-r--r--include/asm-powerpc/pasemi_dma.h77
-rw-r--r--include/asm-powerpc/pci-bridge.h4
-rw-r--r--include/asm-powerpc/pgtable-ppc32.h11
-rw-r--r--include/asm-powerpc/pgtable-ppc64.h3
-rw-r--r--include/asm-powerpc/phyp_dump.h47
-rw-r--r--include/asm-powerpc/pmi.h2
-rw-r--r--include/asm-powerpc/ppc4xx.h18
-rw-r--r--include/asm-powerpc/processor.h6
-rw-r--r--include/asm-powerpc/ps3.h7
-rw-r--r--include/asm-powerpc/ptrace.h9
-rw-r--r--include/asm-powerpc/qe.h12
-rw-r--r--include/asm-powerpc/rio.h (renamed from include/asm-ppc/rio.h)0
-rw-r--r--include/asm-powerpc/rwsem.h35
-rw-r--r--include/asm-powerpc/semaphore.h95
-rw-r--r--include/asm-powerpc/sparsemem.h1
-rw-r--r--include/asm-powerpc/spinlock.h1
-rw-r--r--include/asm-powerpc/string.h2
-rw-r--r--include/asm-powerpc/system.h25
-rw-r--r--include/asm-powerpc/thread_info.h8
-rw-r--r--include/asm-powerpc/topology.h3
-rw-r--r--include/asm-powerpc/types.h7
-rw-r--r--include/asm-powerpc/unaligned.h11
-rw-r--r--include/asm-ppc/mmu.h2
-rw-r--r--include/asm-ppc/mpc8260.h4
-rw-r--r--include/asm-ppc/mpc8xx.h4
-rw-r--r--include/asm-ppc/ocp.h1
-rw-r--r--include/asm-ppc/pgtable.h3
-rw-r--r--include/asm-s390/Kbuild1
-rw-r--r--include/asm-s390/bitops.h1
-rw-r--r--include/asm-s390/ccwgroup.h7
-rw-r--r--include/asm-s390/cio.h4
-rw-r--r--include/asm-s390/cpu.h8
-rw-r--r--include/asm-s390/debug.h5
-rw-r--r--include/asm-s390/extmem.h11
-rw-r--r--include/asm-s390/hardirq.h2
-rw-r--r--include/asm-s390/hugetlb.h183
-rw-r--r--include/asm-s390/kvm.h41
-rw-r--r--include/asm-s390/kvm_host.h234
-rw-r--r--include/asm-s390/kvm_para.h150
-rw-r--r--include/asm-s390/kvm_virtio.h53
-rw-r--r--include/asm-s390/lowcore.h26
-rw-r--r--include/asm-s390/mmu.h1
-rw-r--r--include/asm-s390/mmu_context.h8
-rw-r--r--include/asm-s390/page.h49
-rw-r--r--include/asm-s390/pgtable.h127
-rw-r--r--include/asm-s390/processor.h2
-rw-r--r--include/asm-s390/ptrace.h2
-rw-r--r--include/asm-s390/qdio.h1
-rw-r--r--include/asm-s390/semaphore.h108
-rw-r--r--include/asm-s390/setup.h38
-rw-r--r--include/asm-s390/smp.h15
-rw-r--r--include/asm-s390/sparsemem.h18
-rw-r--r--include/asm-s390/sysinfo.h121
-rw-r--r--include/asm-s390/system.h20
-rw-r--r--include/asm-s390/thread_info.h2
-rw-r--r--include/asm-s390/timex.h13
-rw-r--r--include/asm-s390/tlbflush.h37
-rw-r--r--include/asm-s390/topology.h27
-rw-r--r--include/asm-s390/unaligned.h25
-rw-r--r--include/asm-sh/bitops.h1
-rw-r--r--include/asm-sh/bugs.h2
-rw-r--r--include/asm-sh/cpu-sh4/freq.h6
-rw-r--r--include/asm-sh/cpu-sh4/rtc.h5
-rw-r--r--include/asm-sh/futex.h2
-rw-r--r--include/asm-sh/hugetlb.h91
-rw-r--r--include/asm-sh/i2c-sh7760.h22
-rw-r--r--include/asm-sh/ide.h3
-rw-r--r--include/asm-sh/migor.h58
-rw-r--r--include/asm-sh/mpc1211/pci.h2
-rw-r--r--include/asm-sh/pgtable_32.h3
-rw-r--r--include/asm-sh/pgtable_64.h10
-rw-r--r--include/asm-sh/processor.h5
-rw-r--r--include/asm-sh/r7780rp.h22
-rw-r--r--include/asm-sh/se7721.h70
-rw-r--r--include/asm-sh/se7722.h2
-rw-r--r--include/asm-sh/semaphore-helper.h89
-rw-r--r--include/asm-sh/semaphore.h116
-rw-r--r--include/asm-sh/sh_keysc.h13
-rw-r--r--include/asm-sh/system.h2
-rw-r--r--include/asm-sh/topology.h2
-rw-r--r--include/asm-sh/uaccess_32.h5
-rw-r--r--include/asm-sh/unaligned.h20
-rw-r--r--include/asm-sparc/Kbuild1
-rw-r--r--include/asm-sparc/a.out-core.h52
-rw-r--r--include/asm-sparc/a.out.h97
-rw-r--r--include/asm-sparc/device.h2
-rw-r--r--include/asm-sparc/floppy.h2
-rw-r--r--include/asm-sparc/head.h42
-rw-r--r--include/asm-sparc/ide.h2
-rw-r--r--include/asm-sparc/ioctls.h2
-rw-r--r--include/asm-sparc/kgdb.h116
-rw-r--r--include/asm-sparc/mman.h13
-rw-r--r--include/asm-sparc/namei.h15
-rw-r--r--include/asm-sparc/pconf.h25
-rw-r--r--include/asm-sparc/pgtable.h7
-rw-r--r--include/asm-sparc/processor.h7
-rw-r--r--include/asm-sparc/prom.h5
-rw-r--r--include/asm-sparc/semaphore.h193
-rw-r--r--include/asm-sparc/smp.h2
-rw-r--r--include/asm-sparc/socket.h3
-rw-r--r--include/asm-sparc/solerrno.h132
-rw-r--r--include/asm-sparc/svr4.h119
-rw-r--r--include/asm-sparc/system.h2
-rw-r--r--include/asm-sparc/termios.h5
-rw-r--r--include/asm-sparc/unaligned.h10
-rw-r--r--include/asm-sparc/user.h56
-rw-r--r--include/asm-sparc64/Kbuild1
-rw-r--r--include/asm-sparc64/a.out-core.h31
-rw-r--r--include/asm-sparc64/a.out.h1
-rw-r--r--include/asm-sparc64/bitops.h1
-rw-r--r--include/asm-sparc64/floppy.h84
-rw-r--r--include/asm-sparc64/futex.h2
-rw-r--r--include/asm-sparc64/hugetlb.h84
-rw-r--r--include/asm-sparc64/ide.h2
-rw-r--r--include/asm-sparc64/ioctls.h2
-rw-r--r--include/asm-sparc64/iommu.h3
-rw-r--r--include/asm-sparc64/isa.h47
-rw-r--r--include/asm-sparc64/kgdb.h1
-rw-r--r--include/asm-sparc64/lmb.h10
-rw-r--r--include/asm-sparc64/mman.h13
-rw-r--r--include/asm-sparc64/mmzone.h17
-rw-r--r--include/asm-sparc64/namei.h15
-rw-r--r--include/asm-sparc64/numnodes.h6
-rw-r--r--include/asm-sparc64/page.h2
-rw-r--r--include/asm-sparc64/pconf.h25
-rw-r--r--include/asm-sparc64/pgtable.h10
-rw-r--r--include/asm-sparc64/pil.h7
-rw-r--r--include/asm-sparc64/ptrace.h41
-rw-r--r--include/asm-sparc64/semaphore.h54
-rw-r--r--include/asm-sparc64/socket.h3
-rw-r--r--include/asm-sparc64/solerrno.h132
-rw-r--r--include/asm-sparc64/sparsemem.h2
-rw-r--r--include/asm-sparc64/svr4.h120
-rw-r--r--include/asm-sparc64/system.h5
-rw-r--r--include/asm-sparc64/termios.h5
-rw-r--r--include/asm-sparc64/thread_info.h6
-rw-r--r--include/asm-sparc64/topology.h73
-rw-r--r--include/asm-sparc64/ttable.h38
-rw-r--r--include/asm-sparc64/unaligned.h10
-rw-r--r--include/asm-sparc64/unistd.h10
-rw-r--r--include/asm-sparc64/user.h61
-rw-r--r--include/asm-um/div64.h1
-rw-r--r--include/asm-um/pgtable.h10
-rw-r--r--include/asm-um/semaphore.h7
-rw-r--r--include/asm-um/unaligned.h6
-rw-r--r--include/asm-v850/semaphore.h85
-rw-r--r--include/asm-v850/unaligned.h124
-rw-r--r--include/asm-x86/Kbuild1
-rw-r--r--include/asm-x86/a.out-core.h12
-rw-r--r--include/asm-x86/acpi.h8
-rw-r--r--include/asm-x86/alternative.h32
-rw-r--r--include/asm-x86/apic.h7
-rw-r--r--include/asm-x86/apicdef.h69
-rw-r--r--include/asm-x86/atomic_32.h143
-rw-r--r--include/asm-x86/atomic_64.h251
-rw-r--r--include/asm-x86/bios_ebda.h (renamed from include/asm-x86/mach-default/bios_ebda.h)2
-rw-r--r--include/asm-x86/bitops.h201
-rw-r--r--include/asm-x86/bitops_32.h164
-rw-r--r--include/asm-x86/bitops_64.h162
-rw-r--r--include/asm-x86/boot.h8
-rw-r--r--include/asm-x86/bootparam.h14
-rw-r--r--include/asm-x86/bug.h34
-rw-r--r--include/asm-x86/byteorder.h39
-rw-r--r--include/asm-x86/cacheflush.h80
-rw-r--r--include/asm-x86/checksum_32.h152
-rw-r--r--include/asm-x86/checksum_64.h118
-rw-r--r--include/asm-x86/cmpxchg_32.h253
-rw-r--r--include/asm-x86/cmpxchg_64.h134
-rw-r--r--include/asm-x86/compat.h2
-rw-r--r--include/asm-x86/cpufeature.h8
-rw-r--r--include/asm-x86/current_32.h2
-rw-r--r--include/asm-x86/current_64.h12
-rw-r--r--include/asm-x86/desc.h61
-rw-r--r--include/asm-x86/desc_defs.h15
-rw-r--r--include/asm-x86/div64.h61
-rw-r--r--include/asm-x86/dma-mapping.h238
-rw-r--r--include/asm-x86/dma-mapping_32.h187
-rw-r--r--include/asm-x86/dma-mapping_64.h202
-rw-r--r--include/asm-x86/dma.h45
-rw-r--r--include/asm-x86/dmi.h1
-rw-r--r--include/asm-x86/dwarf2_64.h9
-rw-r--r--include/asm-x86/e820_32.h6
-rw-r--r--include/asm-x86/e820_64.h27
-rw-r--r--include/asm-x86/edac.h4
-rw-r--r--include/asm-x86/efi.h2
-rw-r--r--include/asm-x86/elf.h112
-rw-r--r--include/asm-x86/fixmap.h8
-rw-r--r--include/asm-x86/fixmap_32.h24
-rw-r--r--include/asm-x86/fixmap_64.h24
-rw-r--r--include/asm-x86/floppy.h93
-rw-r--r--include/asm-x86/futex.h103
-rw-r--r--include/asm-x86/genapic_32.h106
-rw-r--r--include/asm-x86/genapic_64.h10
-rw-r--r--include/asm-x86/geode.h40
-rw-r--r--include/asm-x86/highmem.h2
-rw-r--r--include/asm-x86/hugetlb.h91
-rw-r--r--include/asm-x86/hw_irq_64.h15
-rw-r--r--include/asm-x86/hypertransport.h15
-rw-r--r--include/asm-x86/i387.h60
-rw-r--r--include/asm-x86/i8259.h29
-rw-r--r--include/asm-x86/ia32.h62
-rw-r--r--include/asm-x86/ide.h10
-rw-r--r--include/asm-x86/io.h14
-rw-r--r--include/asm-x86/io_32.h148
-rw-r--r--include/asm-x86/io_64.h116
-rw-r--r--include/asm-x86/io_apic.h12
-rw-r--r--include/asm-x86/ioctls.h13
-rw-r--r--include/asm-x86/ipcbuf.h3
-rw-r--r--include/asm-x86/ipi.h11
-rw-r--r--include/asm-x86/irq_32.h2
-rw-r--r--include/asm-x86/irq_64.h4
-rw-r--r--include/asm-x86/irqflags.h59
-rw-r--r--include/asm-x86/kdebug.h5
-rw-r--r--include/asm-x86/kexec.h71
-rw-r--r--include/asm-x86/kgdb.h81
-rw-r--r--include/asm-x86/kprobes.h12
-rw-r--r--include/asm-x86/kvm.h41
-rw-r--r--include/asm-x86/kvm_host.h123
-rw-r--r--include/asm-x86/kvm_para.h55
-rw-r--r--include/asm-x86/kvm_x86_emulate.h28
-rw-r--r--include/asm-x86/lguest.h11
-rw-r--r--include/asm-x86/lguest_hcall.h5
-rw-r--r--include/asm-x86/linkage.h3
-rw-r--r--include/asm-x86/local.h105
-rw-r--r--include/asm-x86/mach-bigsmp/mach_apic.h18
-rw-r--r--include/asm-x86/mach-default/mach_apic.h94
-rw-r--r--include/asm-x86/mach-default/mach_apicdef.h9
-rw-r--r--include/asm-x86/mach-default/mach_ipi.h10
-rw-r--r--include/asm-x86/mach-default/mach_mpparse.h11
-rw-r--r--include/asm-x86/mach-default/mach_reboot.h61
-rw-r--r--include/asm-x86/mach-default/smpboot_hooks.h9
-rw-r--r--include/asm-x86/mach-es7000/mach_apic.h20
-rw-r--r--include/asm-x86/mach-es7000/mach_mpparse.h11
-rw-r--r--include/asm-x86/mach-generic/mach_apic.h1
-rw-r--r--include/asm-x86/mach-generic/mach_mpparse.h5
-rw-r--r--include/asm-x86/mach-numaq/mach_apic.h10
-rw-r--r--include/asm-x86/mach-numaq/mach_mpparse.h23
-rw-r--r--include/asm-x86/mach-summit/mach_apic.h14
-rw-r--r--include/asm-x86/mach-summit/mach_mpparse.h11
-rw-r--r--include/asm-x86/mach-visws/mach_apic.h2
-rw-r--r--include/asm-x86/mach-visws/smpboot_hooks.h4
-rw-r--r--include/asm-x86/mach_apic.h29
-rw-r--r--include/asm-x86/mc146818rtc.h16
-rw-r--r--include/asm-x86/mca_dma.h34
-rw-r--r--include/asm-x86/mmu.h4
-rw-r--r--include/asm-x86/mmu_context_32.h12
-rw-r--r--include/asm-x86/mmu_context_64.h21
-rw-r--r--include/asm-x86/mmx.h2
-rw-r--r--include/asm-x86/mmzone_32.h4
-rw-r--r--include/asm-x86/mmzone_64.h24
-rw-r--r--include/asm-x86/mpspec.h47
-rw-r--r--include/asm-x86/mpspec_def.h46
-rw-r--r--include/asm-x86/msidef.h12
-rw-r--r--include/asm-x86/msr-index.h4
-rw-r--r--include/asm-x86/msr.h89
-rw-r--r--include/asm-x86/mtrr.h73
-rw-r--r--include/asm-x86/mutex_32.h66
-rw-r--r--include/asm-x86/mutex_64.h73
-rw-r--r--include/asm-x86/nmi.h94
-rw-r--r--include/asm-x86/nmi_32.h61
-rw-r--r--include/asm-x86/nmi_64.h90
-rw-r--r--include/asm-x86/nops.h2
-rw-r--r--include/asm-x86/numa_64.h8
-rw-r--r--include/asm-x86/numaq.h9
-rw-r--r--include/asm-x86/olpc.h132
-rw-r--r--include/asm-x86/page.h5
-rw-r--r--include/asm-x86/page_32.h9
-rw-r--r--include/asm-x86/page_64.h10
-rw-r--r--include/asm-x86/param.h4
-rw-r--r--include/asm-x86/paravirt.h97
-rw-r--r--include/asm-x86/parport.h6
-rw-r--r--include/asm-x86/pat.h16
-rw-r--r--include/asm-x86/pci-direct.h2
-rw-r--r--include/asm-x86/pci.h10
-rw-r--r--include/asm-x86/pci_64.h15
-rw-r--r--include/asm-x86/pda.h81
-rw-r--r--include/asm-x86/percpu.h104
-rw-r--r--include/asm-x86/pgalloc.h111
-rw-r--r--include/asm-x86/pgalloc_32.h95
-rw-r--r--include/asm-x86/pgalloc_64.h133
-rw-r--r--include/asm-x86/pgtable-2level.h18
-rw-r--r--include/asm-x86/pgtable-3level.h48
-rw-r--r--include/asm-x86/pgtable.h251
-rw-r--r--include/asm-x86/pgtable_32.h126
-rw-r--r--include/asm-x86/pgtable_64.h153
-rw-r--r--include/asm-x86/posix_types_32.h47
-rw-r--r--include/asm-x86/posix_types_64.h54
-rw-r--r--include/asm-x86/processor.h744
-rw-r--r--include/asm-x86/proto.h10
-rw-r--r--include/asm-x86/ptrace.h48
-rw-r--r--include/asm-x86/reboot.h5
-rw-r--r--include/asm-x86/resume-trace.h15
-rw-r--r--include/asm-x86/rio.h87
-rw-r--r--include/asm-x86/rwsem.h169
-rw-r--r--include/asm-x86/scatterlist.h2
-rw-r--r--include/asm-x86/segment.h3
-rw-r--r--include/asm-x86/semaphore.h6
-rw-r--r--include/asm-x86/semaphore_32.h175
-rw-r--r--include/asm-x86/semaphore_64.h180
-rw-r--r--include/asm-x86/setup.h8
-rw-r--r--include/asm-x86/sigcontext.h7
-rw-r--r--include/asm-x86/sigcontext32.h4
-rw-r--r--include/asm-x86/signal.h48
-rw-r--r--include/asm-x86/smp.h209
-rw-r--r--include/asm-x86/smp_32.h165
-rw-r--r--include/asm-x86/smp_64.h101
-rw-r--r--include/asm-x86/sparsemem.h6
-rw-r--r--include/asm-x86/spinlock.h117
-rw-r--r--include/asm-x86/srat.h2
-rw-r--r--include/asm-x86/string_32.h2
-rw-r--r--include/asm-x86/string_64.h66
-rw-r--r--include/asm-x86/suspend_32.h12
-rw-r--r--include/asm-x86/suspend_64.h5
-rw-r--r--include/asm-x86/swiotlb.h28
-rw-r--r--include/asm-x86/sync_bitops.h77
-rw-r--r--include/asm-x86/system.h115
-rw-r--r--include/asm-x86/tce.h2
-rw-r--r--include/asm-x86/thread_info.h9
-rw-r--r--include/asm-x86/thread_info_32.h101
-rw-r--r--include/asm-x86/thread_info_64.h95
-rw-r--r--include/asm-x86/time.h1
-rw-r--r--include/asm-x86/tlbflush.h5
-rw-r--r--include/asm-x86/topology.h65
-rw-r--r--include/asm-x86/trampoline.h21
-rw-r--r--include/asm-x86/tsc.h4
-rw-r--r--include/asm-x86/uaccess_32.h316
-rw-r--r--include/asm-x86/uaccess_64.h376
-rw-r--r--include/asm-x86/unaligned.h31
-rw-r--r--include/asm-x86/unistd_32.h2
-rw-r--r--include/asm-x86/unistd_64.h2
-rw-r--r--include/asm-x86/user32.h7
-rw-r--r--include/asm-x86/user_32.h6
-rw-r--r--include/asm-x86/user_64.h16
-rw-r--r--include/asm-x86/uv/uv_hub.h284
-rw-r--r--include/asm-x86/uv/uv_mmrs.h373
-rw-r--r--include/asm-x86/vdso.h23
-rw-r--r--include/asm-x86/vga.h4
-rw-r--r--include/asm-x86/vm86.h23
-rw-r--r--include/asm-x86/vmi.h88
-rw-r--r--include/asm-x86/voyager.h51
-rw-r--r--include/asm-x86/xen/events.h22
-rw-r--r--include/asm-x86/xen/grant_table.h7
-rw-r--r--include/asm-x86/xen/hypercall.h6
-rw-r--r--include/asm-x86/xen/interface.h28
-rw-r--r--include/asm-x86/xen/page.h168
-rw-r--r--include/asm-x86/xor_32.h494
-rw-r--r--include/asm-x86/xor_64.h294
-rw-r--r--include/asm-xtensa/pgtable.h4
-rw-r--r--include/asm-xtensa/semaphore.h100
-rw-r--r--include/asm-xtensa/unaligned.h35
-rw-r--r--include/crypto/aes.h8
-rw-r--r--include/crypto/scatterwalk.h4
-rw-r--r--include/keys/rxrpc-type.h2
-rw-r--r--include/linux/Kbuild21
-rw-r--r--include/linux/acpi.h5
-rw-r--r--include/linux/aer.h5
-rw-r--r--include/linux/agp_backend.h3
-rw-r--r--include/linux/aio.h19
-rw-r--r--include/linux/arcdevice.h4
-rw-r--r--include/linux/ata_platform.h3
-rw-r--r--include/linux/atalk.h2
-rw-r--r--include/linux/atmel_tc.h252
-rw-r--r--include/linux/attribute_container.h30
-rw-r--r--include/linux/audit.h57
-rw-r--r--include/linux/backing-dev.h102
-rw-r--r--include/linux/binfmts.h4
-rw-r--r--include/linux/bio.h4
-rw-r--r--include/linux/bitmap.h7
-rw-r--r--include/linux/bitops.h51
-rw-r--r--include/linux/blkdev.h60
-rw-r--r--include/linux/bootmem.h2
-rw-r--r--include/linux/bsg.h16
-rw-r--r--include/linux/buffer_head.h1
-rw-r--r--include/linux/byteorder/Kbuild6
-rw-r--r--include/linux/byteorder/big_endian.h2
-rw-r--r--include/linux/byteorder/generic.h8
-rw-r--r--include/linux/byteorder/little_endian.h2
-rw-r--r--include/linux/cache.h4
-rw-r--r--include/linux/calc64.h49
-rw-r--r--include/linux/capability.h15
-rw-r--r--include/linux/cdev.h2
-rw-r--r--include/linux/cdrom.h5
-rw-r--r--include/linux/cgroup.h80
-rw-r--r--include/linux/cgroup_subsys.h6
-rw-r--r--include/linux/clocksource.h3
-rw-r--r--include/linux/coda_fs_i.h2
-rw-r--r--include/linux/coda_linux.h3
-rw-r--r--include/linux/compat.h3
-rw-r--r--include/linux/compiler-gcc.h14
-rw-r--r--include/linux/concap.h3
-rw-r--r--include/linux/configfs.h4
-rw-r--r--include/linux/console.h4
-rw-r--r--include/linux/console_struct.h1
-rw-r--r--include/linux/cpu.h3
-rw-r--r--include/linux/cpufreq.h6
-rw-r--r--include/linux/cpumask.h47
-rw-r--r--include/linux/cpuset.h17
-rw-r--r--include/linux/crc-ccitt.h2
-rw-r--r--include/linux/crypto.h7
-rw-r--r--include/linux/dcache.h7
-rw-r--r--include/linux/debugobjects.h90
-rw-r--r--include/linux/device-mapper.h97
-rw-r--r--include/linux/device.h134
-rw-r--r--include/linux/device_cgroup.h12
-rw-r--r--include/linux/devpts_fs.h4
-rw-r--r--include/linux/dlm.h7
-rw-r--r--include/linux/dlm_device.h11
-rw-r--r--include/linux/dlm_plock.h50
-rw-r--r--include/linux/dlmconstants.h4
-rw-r--r--include/linux/dm-dirty-log.h131
-rw-r--r--include/linux/dm-io.h85
-rw-r--r--include/linux/dm-kcopyd.h47
-rw-r--r--include/linux/dma-attrs.h74
-rw-r--r--include/linux/dma-mapping.h17
-rw-r--r--include/linux/dmaengine.h38
-rw-r--r--include/linux/dmi.h1
-rw-r--r--include/linux/dvb/dmx.h3
-rw-r--r--include/linux/edac.h14
-rw-r--r--include/linux/efi.h7
-rw-r--r--include/linux/elf.h2
-rw-r--r--include/linux/enclosure.h11
-rw-r--r--include/linux/eventfd.h5
-rw-r--r--include/linux/exportfs.h2
-rw-r--r--include/linux/ext4_fs.h1207
-rw-r--r--include/linux/ext4_fs_extents.h232
-rw-r--r--include/linux/ext4_fs_i.h167
-rw-r--r--include/linux/ext4_fs_sb.h148
-rw-r--r--include/linux/ext4_jbd2.h231
-rw-r--r--include/linux/fb.h44
-rw-r--r--include/linux/file.h4
-rw-r--r--include/linux/filter.h35
-rw-r--r--include/linux/fs.h75
-rw-r--r--include/linux/fsl_devices.h4
-rw-r--r--include/linux/fsnotify.h4
-rw-r--r--include/linux/generic_serial.h2
-rw-r--r--include/linux/gfp.h50
-rw-r--r--include/linux/hdreg.h4
-rw-r--r--include/linux/hdsmart.h126
-rw-r--r--include/linux/hid.h21
-rw-r--r--include/linux/hidraw.h1
-rw-r--r--include/linux/hil_mlc.h2
-rw-r--r--include/linux/hrtimer.h17
-rw-r--r--include/linux/hugetlb.h46
-rw-r--r--include/linux/hw_random.h14
-rw-r--r--include/linux/i2c-algo-pca.h37
-rw-r--r--include/linux/i2c-id.h4
-rw-r--r--include/linux/i2c-pca-platform.h12
-rw-r--r--include/linux/i2c.h17
-rw-r--r--include/linux/i2c/tps65010.h30
-rw-r--r--include/linux/i2o.h10
-rw-r--r--include/linux/icmpv6.h11
-rw-r--r--include/linux/ide.h393
-rw-r--r--include/linux/idr.h3
-rw-r--r--include/linux/ieee80211.h41
-rw-r--r--include/linux/if_arp.h6
-rw-r--r--include/linux/if_macvlan.h3
-rw-r--r--include/linux/if_pppox.h1
-rw-r--r--include/linux/if_tunnel.h22
-rw-r--r--include/linux/if_vlan.h6
-rw-r--r--include/linux/if_wanpipe.h124
-rw-r--r--include/linux/igmp.h38
-rw-r--r--include/linux/in6.h34
-rw-r--r--include/linux/inet.h2
-rw-r--r--include/linux/inetdevice.h8
-rw-r--r--include/linux/init.h2
-rw-r--r--include/linux/init_task.h6
-rw-r--r--include/linux/input.h8
-rw-r--r--include/linux/interrupt.h20
-rw-r--r--include/linux/io.h4
-rw-r--r--include/linux/ioport.h5
-rw-r--r--include/linux/ipc_namespace.h24
-rw-r--r--include/linux/ipmi.h85
-rw-r--r--include/linux/ipmi_smi.h10
-rw-r--r--include/linux/ipv6.h48
-rw-r--r--include/linux/irq.h10
-rw-r--r--include/linux/irqflags.h6
-rw-r--r--include/linux/isapnp.h10
-rw-r--r--include/linux/iscsi_ibft.h50
-rw-r--r--include/linux/isdn.h6
-rw-r--r--include/linux/isicom.h7
-rw-r--r--include/linux/jbd.h2
-rw-r--r--include/linux/jbd2.h2
-rw-r--r--include/linux/jiffies.h20
-rw-r--r--include/linux/kbuild.h15
-rw-r--r--include/linux/kernel.h102
-rw-r--r--include/linux/kernelcapi.h1
-rw-r--r--include/linux/key.h30
-rw-r--r--include/linux/keyboard.h1
-rw-r--r--include/linux/keyctl.h1
-rw-r--r--include/linux/kfifo.h5
-rw-r--r--include/linux/kgdb.h281
-rw-r--r--include/linux/klist.h40
-rw-r--r--include/linux/kobj_map.h4
-rw-r--r--include/linux/kobject.h3
-rw-r--r--include/linux/kprobes.h34
-rw-r--r--include/linux/kref.h3
-rw-r--r--include/linux/ktime.h6
-rw-r--r--include/linux/kvm.h130
-rw-r--r--include/linux/kvm_host.h59
-rw-r--r--include/linux/kvm_para.h11
-rw-r--r--include/linux/kvm_types.h2
-rw-r--r--include/linux/leds.h16
-rw-r--r--include/linux/libata.h733
-rw-r--r--include/linux/list.h67
-rw-r--r--include/linux/lm_interface.h10
-rw-r--r--include/linux/lmb.h87
-rw-r--r--include/linux/lock_dlm_plock.h41
-rw-r--r--include/linux/lockd/lockd.h26
-rw-r--r--include/linux/lockd/sm_inter.h1
-rw-r--r--include/linux/math64.h84
-rw-r--r--include/linux/mbus.h36
-rw-r--r--include/linux/mca-legacy.h1
-rw-r--r--include/linux/memcontrol.h16
-rw-r--r--include/linux/memory.h12
-rw-r--r--include/linux/memory_hotplug.h33
-rw-r--r--include/linux/mempolicy.h156
-rw-r--r--include/linux/memstick.h2
-rw-r--r--include/linux/meye.h2
-rw-r--r--include/linux/mfd/htc-egpio.h57
-rw-r--r--include/linux/mfd/htc-pasic3.h55
-rw-r--r--include/linux/miscdevice.h10
-rw-r--r--include/linux/mlx4/cmd.h2
-rw-r--r--include/linux/mlx4/cq.h19
-rw-r--r--include/linux/mlx4/device.h44
-rw-r--r--include/linux/mlx4/driver.h3
-rw-r--r--include/linux/mlx4/qp.h19
-rw-r--r--include/linux/mm.h73
-rw-r--r--include/linux/mm_types.h20
-rw-r--r--include/linux/mmzone.h187
-rw-r--r--include/linux/mnt_namespace.h12
-rw-r--r--include/linux/mod_devicetable.h11
-rw-r--r--include/linux/module.h19
-rw-r--r--include/linux/mount.h17
-rw-r--r--include/linux/mroute.h25
-rw-r--r--include/linux/mroute6.h228
-rw-r--r--include/linux/msdos_fs.h10
-rw-r--r--include/linux/msg.h14
-rw-r--r--include/linux/msi.h1
-rw-r--r--include/linux/mtd/inftl.h5
-rw-r--r--include/linux/mtd/jedec.h66
-rw-r--r--include/linux/mtd/mtd.h6
-rw-r--r--include/linux/mtd/nftl.h5
-rw-r--r--include/linux/mtd/onenand.h3
-rw-r--r--include/linux/mtd/plat-ram.h5
-rw-r--r--include/linux/mtd/pmc551.h5
-rw-r--r--include/linux/mtio.h1
-rw-r--r--include/linux/nbd.h10
-rw-r--r--include/linux/ncp_fs.h7
-rw-r--r--include/linux/ncp_fs_i.h4
-rw-r--r--include/linux/net.h3
-rw-r--r--include/linux/netdevice.h36
-rw-r--r--include/linux/netfilter.h85
-rw-r--r--include/linux/netfilter/nf_conntrack_dccp.h40
-rw-r--r--include/linux/netfilter/nf_conntrack_sip.h185
-rw-r--r--include/linux/netfilter/nfnetlink_conntrack.h8
-rw-r--r--include/linux/netfilter/x_tables.h4
-rw-r--r--include/linux/netfilter/xt_sctp.h84
-rw-r--r--include/linux/netfilter_arp/arp_tables.h17
-rw-r--r--include/linux/netfilter_bridge/ebt_nflog.h21
-rw-r--r--include/linux/netfilter_ipv4.h2
-rw-r--r--include/linux/netlink.h1
-rw-r--r--include/linux/nfs3.h2
-rw-r--r--include/linux/nfs_fs.h5
-rw-r--r--include/linux/nfs_fs_sb.h10
-rw-r--r--include/linux/nfs_xdr.h10
-rw-r--r--include/linux/nfsd/Kbuild4
-rw-r--r--include/linux/nfsd/cache.h2
-rw-r--r--include/linux/nfsd/nfsd.h13
-rw-r--r--include/linux/nl80211.h218
-rw-r--r--include/linux/nodemask.h22
-rw-r--r--include/linux/notifier.h5
-rw-r--r--include/linux/of.h1
-rw-r--r--include/linux/of_device.h2
-rw-r--r--include/linux/of_gpio.h69
-rw-r--r--include/linux/of_i2c.h24
-rw-r--r--include/linux/oom.h4
-rw-r--r--include/linux/page-flags.h319
-rw-r--r--include/linux/parport.h2
-rw-r--r--include/linux/pci-aspm.h56
-rw-r--r--include/linux/pci.h47
-rw-r--r--include/linux/pci_ids.h3
-rw-r--r--include/linux/pci_regs.h8
-rw-r--r--include/linux/pcounter.h74
-rw-r--r--include/linux/percpu.h1
-rw-r--r--include/linux/personality.h4
-rw-r--r--include/linux/phantom.h11
-rw-r--r--include/linux/phy.h85
-rw-r--r--include/linux/pid.h8
-rw-r--r--include/linux/pid_namespace.h2
-rw-r--r--include/linux/pim.h45
-rw-r--r--include/linux/pm.h47
-rw-r--r--include/linux/pm_wakeup.h90
-rw-r--r--include/linux/pnp.h212
-rw-r--r--include/linux/pnpbios.h151
-rw-r--r--include/linux/poison.h7
-rw-r--r--include/linux/prctl.h15
-rw-r--r--include/linux/proc_fs.h61
-rw-r--r--include/linux/profile.h4
-rw-r--r--include/linux/proportions.h13
-rw-r--r--include/linux/ptrace.h4
-rw-r--r--include/linux/quota.h32
-rw-r--r--include/linux/quotaops.h137
-rw-r--r--include/linux/raid/md.h2
-rw-r--r--include/linux/raid/md_k.h4
-rw-r--r--include/linux/raid/raid5.h7
-rw-r--r--include/linux/raid_class.h12
-rw-r--r--include/linux/rcuclassic.h3
-rw-r--r--include/linux/rcupdate.h3
-rw-r--r--include/linux/rcupreempt.h3
-rw-r--r--include/linux/rcupreempt_trace.h2
-rw-r--r--include/linux/reiserfs_fs.h1
-rw-r--r--include/linux/reiserfs_fs_sb.h1
-rw-r--r--include/linux/res_counter.h29
-rw-r--r--include/linux/resource.h1
-rw-r--r--include/linux/rio.h41
-rw-r--r--include/linux/rio_drv.h3
-rw-r--r--include/linux/rtnetlink.h4
-rw-r--r--include/linux/rwsem.h3
-rw-r--r--include/linux/scatterlist.h5
-rw-r--r--include/linux/sched.h95
-rw-r--r--include/linux/securebits.h25
-rw-r--r--include/linux/security.h1149
-rw-r--r--include/linux/selinux.h134
-rw-r--r--include/linux/semaphore.h51
-rw-r--r--include/linux/seq_file.h21
-rw-r--r--include/linux/seq_file_net.h27
-rw-r--r--include/linux/seqlock.h46
-rw-r--r--include/linux/serial_8250.h1
-rw-r--r--include/linux/serial_core.h10
-rw-r--r--include/linux/serio.h1
-rw-r--r--include/linux/shmem_fs.h3
-rw-r--r--include/linux/signal.h2
-rw-r--r--include/linux/skbuff.h207
-rw-r--r--include/linux/slab.h10
-rw-r--r--include/linux/slub_def.h18
-rw-r--r--include/linux/smb.h1
-rw-r--r--include/linux/smb_fs_i.h2
-rw-r--r--include/linux/smb_fs_sb.h4
-rw-r--r--include/linux/smc91x.h13
-rw-r--r--include/linux/spi/ads7846.h3
-rw-r--r--include/linux/spinlock.h37
-rw-r--r--include/linux/ssb/ssb.h50
-rw-r--r--include/linux/ssb/ssb_driver_chipcommon.h7
-rw-r--r--include/linux/ssb/ssb_driver_gige.h174
-rw-r--r--include/linux/ssb/ssb_driver_pci.h19
-rw-r--r--include/linux/string.h2
-rw-r--r--include/linux/sunrpc/auth.h17
-rw-r--r--include/linux/sunrpc/auth_gss.h1
-rw-r--r--include/linux/sunrpc/cache.h1
-rw-r--r--include/linux/sunrpc/clnt.h9
-rw-r--r--include/linux/sunrpc/gss_krb5.h6
-rw-r--r--include/linux/sunrpc/sched.h41
-rw-r--r--include/linux/sunrpc/svc.h1
-rw-r--r--include/linux/sunrpc/svcauth.h5
-rw-r--r--include/linux/sunrpc/svcsock.h4
-rw-r--r--include/linux/sunrpc/xprt.h10
-rw-r--r--include/linux/suspend.h15
-rw-r--r--include/linux/svga.h3
-rw-r--r--include/linux/swap.h4
-rw-r--r--include/linux/synclink.h4
-rw-r--r--include/linux/syscalls.h31
-rw-r--r--include/linux/sysctl.h14
-rw-r--r--include/linux/sysdev.h17
-rw-r--r--include/linux/sysfs.h25
-rw-r--r--include/linux/sysv_fs.h6
-rw-r--r--include/linux/tcp.h7
-rw-r--r--include/linux/textsearch.h4
-rw-r--r--include/linux/thermal.h39
-rw-r--r--include/linux/thread_info.h39
-rw-r--r--include/linux/timer.h23
-rw-r--r--include/linux/timex.h46
-rw-r--r--include/linux/topology.h46
-rw-r--r--include/linux/transport_class.h11
-rw-r--r--include/linux/tty.h34
-rw-r--r--include/linux/tty_driver.h108
-rw-r--r--include/linux/uaccess.h22
-rw-r--r--include/linux/udf_fs.h51
-rw-r--r--include/linux/udf_fs_i.h31
-rw-r--r--include/linux/udf_fs_sb.h117
-rw-r--r--include/linux/udp.h19
-rw-r--r--include/linux/unaligned/access_ok.h67
-rw-r--r--include/linux/unaligned/be_byteshift.h70
-rw-r--r--include/linux/unaligned/be_memmove.h36
-rw-r--r--include/linux/unaligned/be_struct.h36
-rw-r--r--include/linux/unaligned/generic.h68
-rw-r--r--include/linux/unaligned/le_byteshift.h70
-rw-r--r--include/linux/unaligned/le_memmove.h36
-rw-r--r--include/linux/unaligned/le_struct.h36
-rw-r--r--include/linux/unaligned/memmove.h45
-rw-r--r--include/linux/unaligned/packed_struct.h46
-rw-r--r--include/linux/usb.h196
-rw-r--r--include/linux/usb/atmel_usba_udc.h22
-rw-r--r--include/linux/usb/audio.h2
-rw-r--r--include/linux/usb/cdc.h4
-rw-r--r--include/linux/usb/ch9.h17
-rw-r--r--include/linux/usb/g_printer.h4
-rw-r--r--include/linux/usb/gadget.h2
-rw-r--r--include/linux/usb/gadgetfs.h16
-rw-r--r--include/linux/usb/input.h8
-rw-r--r--include/linux/usb/iowarrior.h6
-rw-r--r--include/linux/usb/isp116x.h6
-rw-r--r--include/linux/usb/midi.h2
-rw-r--r--include/linux/usb/net2280.h9
-rw-r--r--include/linux/usb/otg.h6
-rw-r--r--include/linux/usb/quirks.h5
-rw-r--r--include/linux/usb/rndis_host.h9
-rw-r--r--include/linux/usb/serial.h21
-rw-r--r--include/linux/usb/sl811.h5
-rw-r--r--include/linux/usb/usbnet.h8
-rw-r--r--include/linux/usb_usual.h1
-rw-r--r--include/linux/usbdevice_fs.h7
-rw-r--r--include/linux/videodev2.h55
-rw-r--r--include/linux/vmalloc.h5
-rw-r--r--include/linux/vmstat.h6
-rw-r--r--include/linux/wireless.h1
-rw-r--r--include/linux/wm97xx.h314
-rw-r--r--include/linux/writeback.h3
-rw-r--r--include/linux/xattr.h6
-rw-r--r--include/linux/xfrm.h11
-rw-r--r--include/media/ir-common.h3
-rw-r--r--include/media/soc_camera.h179
-rw-r--r--include/media/tuner-types.h17
-rw-r--r--include/media/tuner.h2
-rw-r--r--include/media/v4l2-chip-ident.h7
-rw-r--r--include/media/v4l2-common.h4
-rw-r--r--include/media/v4l2-dev.h4
-rw-r--r--include/media/v4l2-i2c-drv-legacy.h2
-rw-r--r--include/media/v4l2-i2c-drv.h2
-rw-r--r--include/media/videobuf-core.h24
-rw-r--r--include/media/videobuf-dma-sg.h17
-rw-r--r--include/media/videobuf-dvb.h3
-rw-r--r--include/media/videobuf-vmalloc.h4
-rw-r--r--include/mtd/Kbuild1
-rw-r--r--include/mtd/ubi-header.h372
-rw-r--r--include/net/addrconf.h122
-rw-r--r--include/net/cfg80211.h159
-rw-r--r--include/net/compat.h6
-rw-r--r--include/net/dst.h10
-rw-r--r--include/net/fib_rules.h1
-rw-r--r--include/net/icmp.h9
-rw-r--r--include/net/ieee80211.h1
-rw-r--r--include/net/ieee80211softmac.h373
-rw-r--r--include/net/ieee80211softmac_wx.h99
-rw-r--r--include/net/inet_common.h11
-rw-r--r--include/net/inet_connection_sock.h5
-rw-r--r--include/net/inet_frag.h6
-rw-r--r--include/net/inet_hashtables.h29
-rw-r--r--include/net/inet_sock.h7
-rw-r--r--include/net/inet_timewait_sock.h18
-rw-r--r--include/net/ip.h10
-rw-r--r--include/net/ip6_fib.h18
-rw-r--r--include/net/ip6_route.h56
-rw-r--r--include/net/ip_vs.h3
-rw-r--r--include/net/ipip.h10
-rw-r--r--include/net/ipv6.h93
-rw-r--r--include/net/irda/irlan_eth.h1
-rw-r--r--include/net/llc_if.h5
-rw-r--r--include/net/mac80211.h560
-rw-r--r--include/net/mip6.h3
-rw-r--r--include/net/ndisc.h31
-rw-r--r--include/net/neighbour.h31
-rw-r--r--include/net/net_namespace.h75
-rw-r--r--include/net/netfilter/nf_conntrack.h39
-rw-r--r--include/net/netfilter/nf_conntrack_core.h4
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h22
-rw-r--r--include/net/netfilter/nf_conntrack_helper.h5
-rw-r--r--include/net/netfilter/nf_conntrack_l3proto.h19
-rw-r--r--include/net/netfilter/nf_conntrack_l4proto.h13
-rw-r--r--include/net/netfilter/nf_conntrack_tuple.h106
-rw-r--r--include/net/netfilter/nf_nat_helper.h3
-rw-r--r--include/net/netfilter/nf_nat_protocol.h46
-rw-r--r--include/net/netfilter/nf_nat_rule.h3
-rw-r--r--include/net/netlabel.h15
-rw-r--r--include/net/netns/core.h16
-rw-r--r--include/net/netns/dccp.h11
-rw-r--r--include/net/netns/generic.h49
-rw-r--r--include/net/netns/ipv4.h11
-rw-r--r--include/net/netns/ipv6.h18
-rw-r--r--include/net/pkt_cls.h2
-rw-r--r--include/net/protocol.h3
-rw-r--r--include/net/raw.h4
-rw-r--r--include/net/request_sock.h9
-rw-r--r--include/net/route.h7
-rw-r--r--include/net/rtnetlink.h1
-rw-r--r--include/net/sctp/command.h3
-rw-r--r--include/net/sctp/sctp.h5
-rw-r--r--include/net/sctp/sm.h8
-rw-r--r--include/net/sctp/structs.h10
-rw-r--r--include/net/sock.h118
-rw-r--r--include/net/tcp.h35
-rw-r--r--include/net/tipc/tipc_bearer.h9
-rw-r--r--include/net/tipc/tipc_port.h13
-rw-r--r--include/net/udp.h15
-rw-r--r--include/net/wireless.h186
-rw-r--r--include/net/xfrm.h95
-rw-r--r--include/rdma/ib_umem.h4
-rw-r--r--include/rdma/ib_user_verbs.h5
-rw-r--r--include/rdma/ib_verbs.h70
-rw-r--r--include/scsi/iscsi_proto.h6
-rw-r--r--include/scsi/libiscsi.h1
-rw-r--r--include/scsi/libsas.h3
-rw-r--r--include/scsi/sas_ata.h4
-rw-r--r--include/scsi/scsi_cmnd.h17
-rw-r--r--include/scsi/scsi_device.h13
-rw-r--r--include/scsi/scsi_eh.h5
-rw-r--r--include/scsi/scsi_host.h8
-rw-r--r--include/scsi/scsi_transport.h2
-rw-r--r--include/scsi/scsi_transport_fc.h14
-rw-r--r--include/scsi/scsi_transport_sas.h12
-rw-r--r--include/scsi/sd.h4
-rw-r--r--include/sound/ac97_codec.h1
-rw-r--r--include/sound/ak4114.h1
-rw-r--r--include/sound/ak4xxx-adda.h2
-rw-r--r--include/sound/asoundef.h8
-rw-r--r--include/sound/control.h7
-rw-r--r--include/sound/core.h10
-rw-r--r--include/sound/mpu401.h16
-rw-r--r--include/sound/version.h4
-rw-r--r--include/video/atmel_lcdc.h11
-rw-r--r--include/video/hecubafb.h51
-rw-r--r--include/video/metronomefb.h62
-rw-r--r--include/xen/balloon.h61
-rw-r--r--include/xen/events.h9
-rw-r--r--include/xen/grant_table.h7
-rw-r--r--include/xen/interface/callback.h102
-rw-r--r--include/xen/interface/grant_table.h11
-rw-r--r--include/xen/interface/io/fbif.h124
-rw-r--r--include/xen/interface/io/kbdif.h114
-rw-r--r--include/xen/interface/io/protocols.h21
-rw-r--r--include/xen/interface/memory.h12
-rw-r--r--include/xen/interface/vcpu.h5
-rw-r--r--include/xen/interface/xen.h22
-rw-r--r--include/xen/interface/xencomm.h41
-rw-r--r--include/xen/page.h181
-rw-r--r--include/xen/xen-ops.h8
-rw-r--r--include/xen/xenbus.h1
-rw-r--r--include/xen/xencomm.h77
1246 files changed, 30375 insertions, 25033 deletions
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index 422f29c06c77..28fe8bae1037 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,7 @@
63 63
64/* Current ACPICA subsystem version in YYYYMMDD format */ 64/* Current ACPICA subsystem version in YYYYMMDD format */
65 65
66#define ACPI_CA_VERSION 0x20070126 66#define ACPI_CA_VERSION 0x20080321
67 67
68/* 68/*
69 * OS name, used for the _OS object. The _OS object is essentially obsolete, 69 * OS name, used for the _OS object. The _OS object is essentially obsolete,
@@ -150,6 +150,17 @@
150#define ACPI_OBJ_NUM_OPERANDS 8 150#define ACPI_OBJ_NUM_OPERANDS 8
151#define ACPI_OBJ_MAX_OPERAND 7 151#define ACPI_OBJ_MAX_OPERAND 7
152 152
153/* Number of elements in the Result Stack frame, can be an arbitrary value */
154
155#define ACPI_RESULTS_FRAME_OBJ_NUM 8
156
157/*
158 * Maximal number of elements the Result Stack can contain,
159 * it may be an arbitray value not exceeding the types of
160 * result_size and result_count (now u8).
161 */
162#define ACPI_RESULTS_OBJ_NUM_MAX 255
163
153/* Names within the namespace are 4 bytes long */ 164/* Names within the namespace are 4 bytes long */
154 165
155#define ACPI_NAME_SIZE 4 166#define ACPI_NAME_SIZE 4
diff --git a/include/acpi/acdebug.h b/include/acpi/acdebug.h
index d626bb1d2973..c5a1b50d8d94 100644
--- a/include/acpi/acdebug.h
+++ b/include/acpi/acdebug.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h
index 389d772c7d5b..788f88782012 100644
--- a/include/acpi/acdisasm.h
+++ b/include/acpi/acdisasm.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -97,19 +97,23 @@ typedef const struct acpi_dmtable_info {
97#define ACPI_DMT_CHKSUM 20 97#define ACPI_DMT_CHKSUM 20
98#define ACPI_DMT_SPACEID 21 98#define ACPI_DMT_SPACEID 21
99#define ACPI_DMT_GAS 22 99#define ACPI_DMT_GAS 22
100#define ACPI_DMT_DMAR 23 100#define ACPI_DMT_ASF 23
101#define ACPI_DMT_MADT 24 101#define ACPI_DMT_DMAR 24
102#define ACPI_DMT_SRAT 25 102#define ACPI_DMT_HEST 25
103#define ACPI_DMT_EXIT 26 103#define ACPI_DMT_HESTNTFY 26
104#define ACPI_DMT_SIG 27 104#define ACPI_DMT_HESTNTYP 27
105#define ACPI_DMT_MADT 28
106#define ACPI_DMT_SRAT 29
107#define ACPI_DMT_EXIT 30
108#define ACPI_DMT_SIG 31
105 109
106typedef 110typedef
107void (*ACPI_TABLE_HANDLER) (struct acpi_table_header * table); 111void (*acpi_dmtable_handler) (struct acpi_table_header * table);
108 112
109struct acpi_dmtable_data { 113struct acpi_dmtable_data {
110 char *signature; 114 char *signature;
111 struct acpi_dmtable_info *table_info; 115 struct acpi_dmtable_info *table_info;
112 ACPI_TABLE_HANDLER table_handler; 116 acpi_dmtable_handler table_handler;
113 char *name; 117 char *name;
114}; 118};
115 119
@@ -149,6 +153,7 @@ extern struct acpi_dmtable_info acpi_dm_table_info_asf3[];
149extern struct acpi_dmtable_info acpi_dm_table_info_asf4[]; 153extern struct acpi_dmtable_info acpi_dm_table_info_asf4[];
150extern struct acpi_dmtable_info acpi_dm_table_info_asf_hdr[]; 154extern struct acpi_dmtable_info acpi_dm_table_info_asf_hdr[];
151extern struct acpi_dmtable_info acpi_dm_table_info_boot[]; 155extern struct acpi_dmtable_info acpi_dm_table_info_boot[];
156extern struct acpi_dmtable_info acpi_dm_table_info_bert[];
152extern struct acpi_dmtable_info acpi_dm_table_info_cpep[]; 157extern struct acpi_dmtable_info acpi_dm_table_info_cpep[];
153extern struct acpi_dmtable_info acpi_dm_table_info_cpep0[]; 158extern struct acpi_dmtable_info acpi_dm_table_info_cpep0[];
154extern struct acpi_dmtable_info acpi_dm_table_info_dbgp[]; 159extern struct acpi_dmtable_info acpi_dm_table_info_dbgp[];
@@ -158,11 +163,17 @@ extern struct acpi_dmtable_info acpi_dm_table_info_dmar_scope[];
158extern struct acpi_dmtable_info acpi_dm_table_info_dmar0[]; 163extern struct acpi_dmtable_info acpi_dm_table_info_dmar0[];
159extern struct acpi_dmtable_info acpi_dm_table_info_dmar1[]; 164extern struct acpi_dmtable_info acpi_dm_table_info_dmar1[];
160extern struct acpi_dmtable_info acpi_dm_table_info_ecdt[]; 165extern struct acpi_dmtable_info acpi_dm_table_info_ecdt[];
166extern struct acpi_dmtable_info acpi_dm_table_info_einj[];
167extern struct acpi_dmtable_info acpi_dm_table_info_einj0[];
168extern struct acpi_dmtable_info acpi_dm_table_info_erst[];
161extern struct acpi_dmtable_info acpi_dm_table_info_facs[]; 169extern struct acpi_dmtable_info acpi_dm_table_info_facs[];
162extern struct acpi_dmtable_info acpi_dm_table_info_fadt1[]; 170extern struct acpi_dmtable_info acpi_dm_table_info_fadt1[];
163extern struct acpi_dmtable_info acpi_dm_table_info_fadt2[]; 171extern struct acpi_dmtable_info acpi_dm_table_info_fadt2[];
164extern struct acpi_dmtable_info acpi_dm_table_info_gas[]; 172extern struct acpi_dmtable_info acpi_dm_table_info_gas[];
165extern struct acpi_dmtable_info acpi_dm_table_info_header[]; 173extern struct acpi_dmtable_info acpi_dm_table_info_header[];
174extern struct acpi_dmtable_info acpi_dm_table_info_hest[];
175extern struct acpi_dmtable_info acpi_dm_table_info_hest9[];
176extern struct acpi_dmtable_info acpi_dm_table_info_hest_notify[];
166extern struct acpi_dmtable_info acpi_dm_table_info_hpet[]; 177extern struct acpi_dmtable_info acpi_dm_table_info_hpet[];
167extern struct acpi_dmtable_info acpi_dm_table_info_madt[]; 178extern struct acpi_dmtable_info acpi_dm_table_info_madt[];
168extern struct acpi_dmtable_info acpi_dm_table_info_madt0[]; 179extern struct acpi_dmtable_info acpi_dm_table_info_madt0[];
@@ -180,6 +191,7 @@ extern struct acpi_dmtable_info acpi_dm_table_info_mcfg0[];
180extern struct acpi_dmtable_info acpi_dm_table_info_rsdp1[]; 191extern struct acpi_dmtable_info acpi_dm_table_info_rsdp1[];
181extern struct acpi_dmtable_info acpi_dm_table_info_rsdp2[]; 192extern struct acpi_dmtable_info acpi_dm_table_info_rsdp2[];
182extern struct acpi_dmtable_info acpi_dm_table_info_sbst[]; 193extern struct acpi_dmtable_info acpi_dm_table_info_sbst[];
194extern struct acpi_dmtable_info acpi_dm_table_info_slic[];
183extern struct acpi_dmtable_info acpi_dm_table_info_slit[]; 195extern struct acpi_dmtable_info acpi_dm_table_info_slit[];
184extern struct acpi_dmtable_info acpi_dm_table_info_spcr[]; 196extern struct acpi_dmtable_info acpi_dm_table_info_spcr[];
185extern struct acpi_dmtable_info acpi_dm_table_info_spmi[]; 197extern struct acpi_dmtable_info acpi_dm_table_info_spmi[];
@@ -194,7 +206,7 @@ extern struct acpi_dmtable_info acpi_dm_table_info_wdrt[];
194 */ 206 */
195void acpi_dm_dump_data_table(struct acpi_table_header *table); 207void acpi_dm_dump_data_table(struct acpi_table_header *table);
196 208
197void 209acpi_status
198acpi_dm_dump_table(u32 table_length, 210acpi_dm_dump_table(u32 table_length,
199 u32 table_offset, 211 u32 table_offset,
200 void *table, 212 void *table,
@@ -213,9 +225,13 @@ void acpi_dm_dump_cpep(struct acpi_table_header *table);
213 225
214void acpi_dm_dump_dmar(struct acpi_table_header *table); 226void acpi_dm_dump_dmar(struct acpi_table_header *table);
215 227
228void acpi_dm_dump_einj(struct acpi_table_header *table);
229
230void acpi_dm_dump_erst(struct acpi_table_header *table);
231
216void acpi_dm_dump_fadt(struct acpi_table_header *table); 232void acpi_dm_dump_fadt(struct acpi_table_header *table);
217 233
218void acpi_dm_dump_srat(struct acpi_table_header *table); 234void acpi_dm_dump_hest(struct acpi_table_header *table);
219 235
220void acpi_dm_dump_mcfg(struct acpi_table_header *table); 236void acpi_dm_dump_mcfg(struct acpi_table_header *table);
221 237
@@ -227,6 +243,8 @@ void acpi_dm_dump_rsdt(struct acpi_table_header *table);
227 243
228void acpi_dm_dump_slit(struct acpi_table_header *table); 244void acpi_dm_dump_slit(struct acpi_table_header *table);
229 245
246void acpi_dm_dump_srat(struct acpi_table_header *table);
247
230void acpi_dm_dump_xsdt(struct acpi_table_header *table); 248void acpi_dm_dump_xsdt(struct acpi_table_header *table);
231 249
232/* 250/*
diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h
index 7f690bb0f02f..910f018d92c7 100644
--- a/include/acpi/acdispat.h
+++ b/include/acpi/acdispat.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -53,6 +53,9 @@
53acpi_status 53acpi_status
54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc); 54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc);
55 55
56acpi_status
57acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc);
58
56acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *rgn_desc); 59acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *rgn_desc);
57 60
58acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc); 61acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc);
@@ -68,10 +71,18 @@ acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
68 union acpi_parse_object *op); 71 union acpi_parse_object *op);
69 72
70acpi_status 73acpi_status
74acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
75 union acpi_parse_object *op);
76
77acpi_status
71acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, 78acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
72 union acpi_parse_object *op, 79 union acpi_parse_object *op,
73 union acpi_operand_object *obj_desc); 80 union acpi_operand_object *obj_desc);
74 81
82acpi_status
83acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
84 union acpi_parse_object *op);
85
75acpi_status acpi_ds_initialize_region(acpi_handle obj_handle); 86acpi_status acpi_ds_initialize_region(acpi_handle obj_handle);
76 87
77/* 88/*
@@ -269,6 +280,8 @@ acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state);
269 280
270void acpi_ds_clear_operands(struct acpi_walk_state *walk_state); 281void acpi_ds_clear_operands(struct acpi_walk_state *walk_state);
271 282
283acpi_status acpi_ds_evaluate_name_path(struct acpi_walk_state *walk_state);
284
272/* 285/*
273 * dswscope - Scope Stack manipulation 286 * dswscope - Scope Stack manipulation
274 */ 287 */
@@ -303,7 +316,7 @@ acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
303 u32 aml_length, 316 u32 aml_length,
304 struct acpi_evaluate_info *info, u8 pass_number); 317 struct acpi_evaluate_info *info, u8 pass_number);
305 318
306acpi_status 319void
307acpi_ds_obj_stack_pop_and_delete(u32 pop_count, 320acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
308 struct acpi_walk_state *walk_state); 321 struct acpi_walk_state *walk_state);
309 322
@@ -316,21 +329,11 @@ void
316acpi_ds_push_walk_state(struct acpi_walk_state *walk_state, 329acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
317 struct acpi_thread_state *thread); 330 struct acpi_thread_state *thread);
318 331
319acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state *walk_state);
320
321acpi_status acpi_ds_result_stack_push(struct acpi_walk_state *walk_state);
322
323acpi_status acpi_ds_result_stack_clear(struct acpi_walk_state *walk_state); 332acpi_status acpi_ds_result_stack_clear(struct acpi_walk_state *walk_state);
324 333
325struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state 334struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
326 *thread); 335 *thread);
327 336
328#ifdef ACPI_FUTURE_USAGE
329acpi_status
330acpi_ds_result_remove(union acpi_operand_object **object,
331 u32 index, struct acpi_walk_state *walk_state);
332#endif
333
334acpi_status 337acpi_status
335acpi_ds_result_pop(union acpi_operand_object **object, 338acpi_ds_result_pop(union acpi_operand_object **object,
336 struct acpi_walk_state *walk_state); 339 struct acpi_walk_state *walk_state);
@@ -339,8 +342,4 @@ acpi_status
339acpi_ds_result_push(union acpi_operand_object *object, 342acpi_ds_result_push(union acpi_operand_object *object,
340 struct acpi_walk_state *walk_state); 343 struct acpi_walk_state *walk_state);
341 344
342acpi_status
343acpi_ds_result_pop_from_bottom(union acpi_operand_object **object,
344 struct acpi_walk_state *walk_state);
345
346#endif /* _ACDISPAT_H_ */ 345#endif /* _ACDISPAT_H_ */
diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h
index d23cdf326808..d5d099bf349c 100644
--- a/include/acpi/acevents.h
+++ b/include/acpi/acevents.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index b73f18a48785..1f591171bf31 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h
index 47a1fd8f2d8a..74ad971241db 100644
--- a/include/acpi/acglobal.h
+++ b/include/acpi/acglobal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -170,10 +170,14 @@ ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
170ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX]; 170ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX];
171 171
172/* 172/*
173 * Global lock semaphore works in conjunction with the actual HW global lock 173 * Global lock mutex is an actual AML mutex object
174 * Global lock semaphore works in conjunction with the HW global lock
174 */ 175 */
175ACPI_EXTERN acpi_mutex acpi_gbl_global_lock_mutex; 176ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex;
176ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore; 177ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore;
178ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
179ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
180ACPI_EXTERN u8 acpi_gbl_global_lock_present;
177 181
178/* 182/*
179 * Spinlocks are used for interfaces that can be possibly called at 183 * Spinlocks are used for interfaces that can be possibly called at
@@ -213,27 +217,33 @@ ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify;
213ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify; 217ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
214ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; 218ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
215ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; 219ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
220ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler;
221ACPI_EXTERN void *acpi_gbl_table_handler_context;
216ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; 222ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
217 223
224/* Owner ID support */
225
226ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS];
227ACPI_EXTERN u8 acpi_gbl_last_owner_id_index;
228ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset;
229
218/* Misc */ 230/* Misc */
219 231
220ACPI_EXTERN u32 acpi_gbl_original_mode; 232ACPI_EXTERN u32 acpi_gbl_original_mode;
221ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; 233ACPI_EXTERN u32 acpi_gbl_rsdp_original_location;
222ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; 234ACPI_EXTERN u32 acpi_gbl_ns_lookup_count;
223ACPI_EXTERN u32 acpi_gbl_ps_find_count; 235ACPI_EXTERN u32 acpi_gbl_ps_find_count;
224ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS];
225ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; 236ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
226ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
227ACPI_EXTERN u8 acpi_gbl_last_owner_id_index;
228ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset;
229ACPI_EXTERN u8 acpi_gbl_debugger_configuration; 237ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
230ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
231ACPI_EXTERN u8 acpi_gbl_step_to_next_call; 238ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
232ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; 239ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
233ACPI_EXTERN u8 acpi_gbl_global_lock_present;
234ACPI_EXTERN u8 acpi_gbl_events_initialized; 240ACPI_EXTERN u8 acpi_gbl_events_initialized;
235ACPI_EXTERN u8 acpi_gbl_system_awake_and_running; 241ACPI_EXTERN u8 acpi_gbl_system_awake_and_running;
236 242
243#ifndef DEFINE_ACPI_GLOBALS
244
245/* Other miscellaneous */
246
237extern u8 acpi_gbl_shutdown; 247extern u8 acpi_gbl_shutdown;
238extern u32 acpi_gbl_startup_flags; 248extern u32 acpi_gbl_startup_flags;
239extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT]; 249extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
@@ -241,6 +251,8 @@ extern const char *acpi_gbl_highest_dstate_names[4];
241extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES]; 251extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
242extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; 252extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
243 253
254#endif
255
244/* Exception codes */ 256/* Exception codes */
245 257
246extern char const *acpi_gbl_exception_names_env[]; 258extern char const *acpi_gbl_exception_names_env[];
@@ -255,8 +267,6 @@ extern char const *acpi_gbl_exception_names_ctrl[];
255 * 267 *
256 ****************************************************************************/ 268 ****************************************************************************/
257 269
258#define NUM_NS_TYPES ACPI_TYPE_INVALID+1
259
260#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 270#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
261#define NUM_PREDEFINED_NAMES 10 271#define NUM_PREDEFINED_NAMES 10
262#else 272#else
@@ -267,7 +277,7 @@ ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct;
267ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node; 277ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node;
268ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device; 278ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device;
269 279
270extern const u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; 280extern const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES];
271extern const struct acpi_predefined_names 281extern const struct acpi_predefined_names
272 acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES]; 282 acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES];
273 283
@@ -275,8 +285,8 @@ extern const struct acpi_predefined_names
275ACPI_EXTERN u32 acpi_gbl_current_node_count; 285ACPI_EXTERN u32 acpi_gbl_current_node_count;
276ACPI_EXTERN u32 acpi_gbl_current_node_size; 286ACPI_EXTERN u32 acpi_gbl_current_node_size;
277ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count; 287ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count;
278ACPI_EXTERN acpi_size acpi_gbl_entry_stack_pointer; 288ACPI_EXTERN acpi_size *acpi_gbl_entry_stack_pointer;
279ACPI_EXTERN acpi_size acpi_gbl_lowest_stack_pointer; 289ACPI_EXTERN acpi_size *acpi_gbl_lowest_stack_pointer;
280ACPI_EXTERN u32 acpi_gbl_deepest_nesting; 290ACPI_EXTERN u32 acpi_gbl_deepest_nesting;
281#endif 291#endif
282 292
diff --git a/include/acpi/achware.h b/include/acpi/achware.h
index 4053df943453..d4fb9bbc903c 100644
--- a/include/acpi/achware.h
+++ b/include/acpi/achware.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h
index ce7c9d653910..e249ce5d3300 100644
--- a/include/acpi/acinterp.h
+++ b/include/acpi/acinterp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -215,8 +215,6 @@ acpi_ex_create_region(u8 * aml_start,
215 u32 aml_length, 215 u32 aml_length,
216 u8 region_space, struct acpi_walk_state *walk_state); 216 u8 region_space, struct acpi_walk_state *walk_state);
217 217
218acpi_status acpi_ex_create_table_region(struct acpi_walk_state *walk_state);
219
220acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state); 218acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state);
221 219
222acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state); 220acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state);
@@ -248,9 +246,16 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
248 struct acpi_walk_state *walk_state); 246 struct acpi_walk_state *walk_state);
249 247
250acpi_status 248acpi_status
249acpi_ex_acquire_mutex_object(u16 timeout,
250 union acpi_operand_object *obj_desc,
251 acpi_thread_id thread_id);
252
253acpi_status
251acpi_ex_release_mutex(union acpi_operand_object *obj_desc, 254acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
252 struct acpi_walk_state *walk_state); 255 struct acpi_walk_state *walk_state);
253 256
257acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc);
258
254void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread); 259void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread);
255 260
256void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc); 261void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc);
@@ -455,9 +460,9 @@ void acpi_ex_relinquish_interpreter(void);
455 460
456void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc); 461void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc);
457 462
458u8 acpi_ex_acquire_global_lock(u32 rule); 463void acpi_ex_acquire_global_lock(u32 rule);
459 464
460void acpi_ex_release_global_lock(u8 locked); 465void acpi_ex_release_global_lock(u32 rule);
461 466
462void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string); 467void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string);
463 468
diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h
index 202cd4242ba1..c5cdc32ac2f8 100644
--- a/include/acpi/aclocal.h
+++ b/include/acpi/aclocal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -522,9 +522,8 @@ struct acpi_thread_state {
522 * AML arguments 522 * AML arguments
523 */ 523 */
524struct acpi_result_values { 524struct acpi_result_values {
525 ACPI_STATE_COMMON u8 num_results; 525 ACPI_STATE_COMMON
526 u8 last_insert; 526 union acpi_operand_object *obj_desc[ACPI_RESULTS_FRAME_OBJ_NUM];
527 union acpi_operand_object *obj_desc[ACPI_OBJ_NUM_OPERANDS];
528}; 527};
529 528
530typedef 529typedef
@@ -604,6 +603,7 @@ union acpi_parse_value {
604 union acpi_parse_object *next; /* Next op */\ 603 union acpi_parse_object *next; /* Next op */\
605 struct acpi_namespace_node *node; /* For use by interpreter */\ 604 struct acpi_namespace_node *node; /* For use by interpreter */\
606 union acpi_parse_value value; /* Value or args associated with the opcode */\ 605 union acpi_parse_value value; /* Value or args associated with the opcode */\
606 u8 arg_list_length; /* Number of elements in the arg list */\
607 ACPI_DISASM_ONLY_MEMBERS (\ 607 ACPI_DISASM_ONLY_MEMBERS (\
608 u8 disasm_flags; /* Used during AML disassembly */\ 608 u8 disasm_flags; /* Used during AML disassembly */\
609 u8 disasm_opcode; /* Subtype used for disassembly */\ 609 u8 disasm_opcode; /* Subtype used for disassembly */\
@@ -696,6 +696,8 @@ struct acpi_parse_state {
696#define ACPI_PARSEOP_NAMED 0x02 696#define ACPI_PARSEOP_NAMED 0x02
697#define ACPI_PARSEOP_DEFERRED 0x04 697#define ACPI_PARSEOP_DEFERRED 0x04
698#define ACPI_PARSEOP_BYTELIST 0x08 698#define ACPI_PARSEOP_BYTELIST 0x08
699#define ACPI_PARSEOP_IN_STACK 0x10
700#define ACPI_PARSEOP_TARGET 0x20
699#define ACPI_PARSEOP_IN_CACHE 0x80 701#define ACPI_PARSEOP_IN_CACHE 0x80
700 702
701/* Parse object disasm_flags */ 703/* Parse object disasm_flags */
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 99d171c87c84..fb41a3b802fc 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -61,30 +61,6 @@
61 61
62#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) 62#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
63 63
64#ifdef ACPI_NO_INTEGER64_SUPPORT
65/*
66 * acpi_integer is 32-bits, no 64-bit support on this platform
67 */
68#define ACPI_LODWORD(l) ((u32)(l))
69#define ACPI_HIDWORD(l) ((u32)(0))
70
71#else
72
73/*
74 * Full 64-bit address/integer on both 32-bit and 64-bit platforms
75 */
76#define ACPI_LODWORD(l) ((u32)(u64)(l))
77#define ACPI_HIDWORD(l) ((u32)(((*(struct uint64_struct *)(void *)(&l))).hi))
78#endif
79
80/*
81 * printf() format helpers
82 */
83
84/* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */
85
86#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i)
87
88/* 64/*
89 * Extract data using a pointer. Any more than a byte and we 65 * Extract data using a pointer. Any more than a byte and we
90 * get into potential aligment issues -- see the STORE macros below. 66 * get into potential aligment issues -- see the STORE macros below.
@@ -122,6 +98,31 @@
122#endif 98#endif
123 99
124/* 100/*
101 * Full 64-bit integer must be available on both 32-bit and 64-bit platforms
102 */
103struct acpi_integer_overlay {
104 u32 lo_dword;
105 u32 hi_dword;
106};
107
108#define ACPI_LODWORD(integer) (ACPI_CAST_PTR (struct acpi_integer_overlay, &integer)->lo_dword)
109#define ACPI_HIDWORD(integer) (ACPI_CAST_PTR (struct acpi_integer_overlay, &integer)->hi_dword)
110
111/*
112 * printf() format helpers
113 */
114
115/* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */
116
117#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i)
118
119#if ACPI_MACHINE_WIDTH == 64
120#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i)
121#else
122#define ACPI_FORMAT_NATIVE_UINT(i) 0, (i)
123#endif
124
125/*
125 * Macros for moving data around to/from buffers that are possibly unaligned. 126 * Macros for moving data around to/from buffers that are possibly unaligned.
126 * If the hardware supports the transfer of unaligned data, just do the store. 127 * If the hardware supports the transfer of unaligned data, just do the store.
127 * Otherwise, we have to move one byte at a time. 128 * Otherwise, we have to move one byte at a time.
@@ -137,29 +138,29 @@
137 138
138/* These macros reverse the bytes during the move, converting little-endian to big endian */ 139/* These macros reverse the bytes during the move, converting little-endian to big endian */
139 140
140 /* Big Endian <== Little Endian */ 141 /* Big Endian <== Little Endian */
141 /* Hi...Lo Lo...Hi */ 142 /* Hi...Lo Lo...Hi */
142/* 16-bit source, 16/32/64 destination */ 143/* 16-bit source, 16/32/64 destination */
143 144
144#define ACPI_MOVE_16_TO_16(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\ 145#define ACPI_MOVE_16_TO_16(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\
145 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];} 146 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];}
146 147
147#define ACPI_MOVE_16_TO_32(d,s) {(*(u32 *)(void *)(d))=0;\ 148#define ACPI_MOVE_16_TO_32(d,s) {(*(u32 *)(void *)(d))=0;\
148 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ 149 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
149 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} 150 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
150 151
151#define ACPI_MOVE_16_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\ 152#define ACPI_MOVE_16_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\
152 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\ 153 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
153 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];} 154 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
154 155
155/* 32-bit source, 16/32/64 destination */ 156/* 32-bit source, 16/32/64 destination */
156 157
157#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 158#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */
158 159
159#define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ 160#define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\
160 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ 161 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\
161 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ 162 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
162 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} 163 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
163 164
164#define ACPI_MOVE_32_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\ 165#define ACPI_MOVE_32_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\
165 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\ 166 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index 34bfae8a05f3..c1343a9265fa 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h
index 5ef38a6c8a61..713b30903fe5 100644
--- a/include/acpi/acnamesp.h
+++ b/include/acpi/acnamesp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -113,7 +113,8 @@ acpi_ns_parse_table(acpi_native_uint table_index,
113 113
114acpi_status 114acpi_status
115acpi_ns_one_complete_parse(acpi_native_uint pass_number, 115acpi_ns_one_complete_parse(acpi_native_uint pass_number,
116 acpi_native_uint table_index); 116 acpi_native_uint table_index,
117 struct acpi_namespace_node *start_node);
117 118
118/* 119/*
119 * nsaccess - Top-level namespace access 120 * nsaccess - Top-level namespace access
diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h
index 7e1211a8b8fa..e9657dac69b7 100644
--- a/include/acpi/acobject.h
+++ b/include/acpi/acobject.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2007, R. Byron Moore 9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -155,8 +155,9 @@ struct acpi_object_event {
155struct acpi_object_mutex { 155struct acpi_object_mutex {
156 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */ 156 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */
157 u16 acquisition_depth; /* Allow multiple Acquires, same thread */ 157 u16 acquisition_depth; /* Allow multiple Acquires, same thread */
158 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */
159 acpi_mutex os_mutex; /* Actual OS synchronization object */ 158 acpi_mutex os_mutex; /* Actual OS synchronization object */
159 acpi_thread_id thread_id; /* Current owner of the mutex */
160 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */
160 union acpi_operand_object *prev; /* Link for list of acquired mutexes */ 161 union acpi_operand_object *prev; /* Link for list of acquired mutexes */
161 union acpi_operand_object *next; /* Link for list of acquired mutexes */ 162 union acpi_operand_object *next; /* Link for list of acquired mutexes */
162 struct acpi_namespace_node *node; /* Containing namespace node */ 163 struct acpi_namespace_node *node; /* Containing namespace node */
diff --git a/include/acpi/acopcode.h b/include/acpi/acopcode.h
index e6f76a280a94..dfdf63327885 100644
--- a/include/acpi/acopcode.h
+++ b/include/acpi/acopcode.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -233,7 +233,7 @@
233#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) 233#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
234#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING) 234#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING)
235#define ARGI_DEBUG_OP ARG_NONE 235#define ARGI_DEBUG_OP ARG_NONE
236#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) 236#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_TARGETREF)
237#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING) 237#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING)
238#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE 238#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE
239#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF) 239#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF)
@@ -246,7 +246,7 @@
246#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) 246#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
247#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) 247#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
248#define ARGI_IF_OP ARGI_INVALID_OPCODE 248#define ARGI_IF_OP ARGI_INVALID_OPCODE
249#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) 249#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_TARGETREF)
250#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE 250#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE
251#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF) 251#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF)
252#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) 252#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index c090a8b0bc99..e17873defcec 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acparser.h b/include/acpi/acparser.h
index 85c358e21014..23ee0fbf5619 100644
--- a/include/acpi/acparser.h
+++ b/include/acpi/acparser.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -109,6 +109,8 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
109 109
110char *acpi_ps_get_opcode_name(u16 opcode); 110char *acpi_ps_get_opcode_name(u16 opcode);
111 111
112u8 acpi_ps_get_argument_count(u32 op_type);
113
112/* 114/*
113 * psparse - top level parsing routines 115 * psparse - top level parsing routines
114 */ 116 */
diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index 2e5f00d3ea0d..c515ef6cc89e 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 4839f2af94c3..d4a560d2deb6 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -8,7 +8,7 @@
8 *****************************************************************************/ 8 *****************************************************************************/
9 9
10/* 10/*
11 * Copyright (C) 2000 - 2007, R. Byron Moore 11 * Copyright (C) 2000 - 2008, Intel Corp.
12 * All rights reserved. 12 * All rights reserved.
13 * 13 *
14 * Redistribution and use in source and binary forms, with or without 14 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index d970f7f99549..2c3806e6546f 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2007, R. Byron Moore 9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -119,6 +119,11 @@ acpi_status
119acpi_get_table_by_index(acpi_native_uint table_index, 119acpi_get_table_by_index(acpi_native_uint table_index,
120 struct acpi_table_header **out_table); 120 struct acpi_table_header **out_table);
121 121
122acpi_status
123acpi_install_table_handler(acpi_tbl_handler handler, void *context);
124
125acpi_status acpi_remove_table_handler(acpi_tbl_handler handler);
126
122/* 127/*
123 * Namespace and name interfaces 128 * Namespace and name interfaces
124 */ 129 */
diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h
index 9486ab266a5e..eef5bd7a59fa 100644
--- a/include/acpi/acresrc.h
+++ b/include/acpi/acresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -94,6 +94,7 @@ typedef const struct acpi_rsconvert_info {
94#define ACPI_RSC_BITMASK16 18 94#define ACPI_RSC_BITMASK16 18
95#define ACPI_RSC_EXIT_NE 19 95#define ACPI_RSC_EXIT_NE 19
96#define ACPI_RSC_EXIT_LE 20 96#define ACPI_RSC_EXIT_LE 20
97#define ACPI_RSC_EXIT_EQ 21
97 98
98/* Resource Conversion sub-opcodes */ 99/* Resource Conversion sub-opcodes */
99 100
diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h
index 88482655407f..a907c67d651e 100644
--- a/include/acpi/acstruct.h
+++ b/include/acpi/acstruct.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -80,12 +80,15 @@ struct acpi_walk_state {
80 u16 opcode; /* Current AML opcode */ 80 u16 opcode; /* Current AML opcode */
81 u8 next_op_info; /* Info about next_op */ 81 u8 next_op_info; /* Info about next_op */
82 u8 num_operands; /* Stack pointer for Operands[] array */ 82 u8 num_operands; /* Stack pointer for Operands[] array */
83 u8 operand_index; /* Index into operand stack, to be used by acpi_ds_obj_stack_push */
83 acpi_owner_id owner_id; /* Owner of objects created during the walk */ 84 acpi_owner_id owner_id; /* Owner of objects created during the walk */
84 u8 last_predicate; /* Result of last predicate */ 85 u8 last_predicate; /* Result of last predicate */
85 u8 current_result; 86 u8 current_result;
86 u8 return_used; 87 u8 return_used;
87 u8 scope_depth; 88 u8 scope_depth;
88 u8 pass_number; /* Parse pass during table load */ 89 u8 pass_number; /* Parse pass during table load */
90 u8 result_size; /* Total elements for the result stack */
91 u8 result_count; /* Current number of occupied elements of result stack */
89 u32 aml_offset; 92 u32 aml_offset;
90 u32 arg_types; 93 u32 arg_types;
91 u32 method_breakpoint; /* For single stepping */ 94 u32 method_breakpoint; /* For single stepping */
diff --git a/include/acpi/actables.h b/include/acpi/actables.h
index 2b9f46f9da4d..4b36a55b0b3b 100644
--- a/include/acpi/actables.h
+++ b/include/acpi/actables.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 955adfb8d64c..1ebbe883f786 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index a1b1b2ee3e51..9af239bd1153 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -58,20 +58,28 @@
58 * it more difficult to inadvertently type in the wrong signature. 58 * it more difficult to inadvertently type in the wrong signature.
59 */ 59 */
60#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ 60#define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */
61#define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */
61#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */ 62#define ACPI_SIG_BOOT "BOOT" /* Simple Boot Flag Table */
62#define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling table */ 63#define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling table */
63#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ 64#define ACPI_SIG_DBGP "DBGP" /* Debug Port table */
64#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ 65#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */
65#define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */ 66#define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */
67#define ACPI_SIG_EINJ "EINJ" /* Error Injection table */
68#define ACPI_SIG_ERST "ERST" /* Error Record Serialization Table */
69#define ACPI_SIG_HEST "HEST" /* Hardware Error Source Table */
66#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */ 70#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */
71#define ACPI_SIG_IBFT "IBFT" /* i_sCSI Boot Firmware Table */
67#define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */ 72#define ACPI_SIG_MADT "APIC" /* Multiple APIC Description Table */
68#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ 73#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */
69#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ 74#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */
75#define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */
70#define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ 76#define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */
71#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ 77#define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */
72#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ 78#define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */
73#define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */ 79#define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */
74#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ 80#define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */
81#define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */
82#define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */
75#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */ 83#define ACPI_SIG_WDRT "WDRT" /* Watchdog Resource Table */
76 84
77/* 85/*
@@ -86,13 +94,25 @@
86 * portable, so do not use any other bitfield types. 94 * portable, so do not use any other bitfield types.
87 */ 95 */
88 96
89/* Common Sub-table header (used in MADT, SRAT, etc.) */ 97/* Common Subtable header (used in MADT, SRAT, etc.) */
90 98
91struct acpi_subtable_header { 99struct acpi_subtable_header {
92 u8 type; 100 u8 type;
93 u8 length; 101 u8 length;
94}; 102};
95 103
104/* Common Subtable header for WHEA tables (EINJ, ERST, WDAT) */
105
106struct acpi_whea_header {
107 u8 action;
108 u8 instruction;
109 u8 flags;
110 u8 reserved;
111 struct acpi_generic_address register_region;
112 u64 value; /* Value used with Read/Write register */
113 u64 mask; /* Bitmask required for this register instruction */
114};
115
96/******************************************************************************* 116/*******************************************************************************
97 * 117 *
98 * ASF - Alert Standard Format table (Signature "ASF!") 118 * ASF - Alert Standard Format table (Signature "ASF!")
@@ -204,6 +224,35 @@ struct acpi_asf_address {
204 224
205/******************************************************************************* 225/*******************************************************************************
206 * 226 *
227 * BERT - Boot Error Record Table
228 *
229 ******************************************************************************/
230
231struct acpi_table_bert {
232 struct acpi_table_header header; /* Common ACPI table header */
233 u32 region_length; /* Length of the boot error region */
234 u64 address; /* Physical addresss of the error region */
235};
236
237/* Boot Error Region */
238
239struct acpi_bert_region {
240 u32 block_status;
241 u32 raw_data_offset;
242 u32 raw_data_length;
243 u32 data_length;
244 u32 error_severity;
245};
246
247/* block_status Flags */
248
249#define ACPI_BERT_UNCORRECTABLE (1)
250#define ACPI_BERT_CORRECTABLE (2)
251#define ACPI_BERT_MULTIPLE_UNCORRECTABLE (4)
252#define ACPI_BERT_MULTIPLE_CORRECTABLE (8)
253
254/*******************************************************************************
255 *
207 * BOOT - Simple Boot Flag Table 256 * BOOT - Simple Boot Flag Table
208 * 257 *
209 ******************************************************************************/ 258 ******************************************************************************/
@@ -350,6 +399,352 @@ struct acpi_table_ecdt {
350 399
351/******************************************************************************* 400/*******************************************************************************
352 * 401 *
402 * EINJ - Error Injection Table
403 *
404 ******************************************************************************/
405
406struct acpi_table_einj {
407 struct acpi_table_header header; /* Common ACPI table header */
408 u32 header_length;
409 u32 reserved;
410 u32 entries;
411};
412
413/* EINJ Injection Instruction Entries (actions) */
414
415struct acpi_einj_entry {
416 struct acpi_whea_header whea_header; /* Common header for WHEA tables */
417};
418
419/* Values for Action field above */
420
421enum acpi_einj_actions {
422 ACPI_EINJ_BEGIN_OPERATION = 0,
423 ACPI_EINJ_GET_TRIGGER_TABLE = 1,
424 ACPI_EINJ_SET_ERROR_TYPE = 2,
425 ACPI_EINJ_GET_ERROR_TYPE = 3,
426 ACPI_EINJ_END_OPERATION = 4,
427 ACPI_EINJ_EXECUTE_OPERATION = 5,
428 ACPI_EINJ_CHECK_BUSY_STATUS = 6,
429 ACPI_EINJ_GET_COMMAND_STATUS = 7,
430 ACPI_EINJ_ACTION_RESERVED = 8, /* 8 and greater are reserved */
431 ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */
432};
433
434/* Values for Instruction field above */
435
436enum acpi_einj_instructions {
437 ACPI_EINJ_READ_REGISTER = 0,
438 ACPI_EINJ_READ_REGISTER_VALUE = 1,
439 ACPI_EINJ_WRITE_REGISTER = 2,
440 ACPI_EINJ_WRITE_REGISTER_VALUE = 3,
441 ACPI_EINJ_NOOP = 4,
442 ACPI_EINJ_INSTRUCTION_RESERVED = 5 /* 5 and greater are reserved */
443};
444
445/* EINJ Trigger Error Action Table */
446
447struct acpi_einj_trigger {
448 u32 header_size;
449 u32 revision;
450 u32 table_size;
451 u32 entry_count;
452};
453
454/*******************************************************************************
455 *
456 * ERST - Error Record Serialization Table
457 *
458 ******************************************************************************/
459
460struct acpi_table_erst {
461 struct acpi_table_header header; /* Common ACPI table header */
462 u32 header_length;
463 u32 reserved;
464 u32 entries;
465};
466
467/* ERST Serialization Entries (actions) */
468
469struct acpi_erst_entry {
470 struct acpi_whea_header whea_header; /* Common header for WHEA tables */
471};
472
473/* Values for Action field above */
474
475enum acpi_erst_actions {
476 ACPI_ERST_BEGIN_WRITE_OPERATION = 0,
477 ACPI_ERST_BEGIN_READ_OPERATION = 1,
478 ACPI_ERST_BETGIN_CLEAR_OPERATION = 2,
479 ACPI_ERST_END_OPERATION = 3,
480 ACPI_ERST_SET_RECORD_OFFSET = 4,
481 ACPI_ERST_EXECUTE_OPERATION = 5,
482 ACPI_ERST_CHECK_BUSY_STATUS = 6,
483 ACPI_ERST_GET_COMMAND_STATUS = 7,
484 ACPI_ERST_GET_RECORD_IDENTIFIER = 8,
485 ACPI_ERST_SET_RECORD_IDENTIFIER = 9,
486 ACPI_ERST_GET_RECORD_COUNT = 10,
487 ACPI_ERST_BEGIN_DUMMY_WRIITE = 11,
488 ACPI_ERST_NOT_USED = 12,
489 ACPI_ERST_GET_ERROR_RANGE = 13,
490 ACPI_ERST_GET_ERROR_LENGTH = 14,
491 ACPI_ERST_GET_ERROR_ATTRIBUTES = 15,
492 ACPI_ERST_ACTION_RESERVED = 16 /* 16 and greater are reserved */
493};
494
495/* Values for Instruction field above */
496
497enum acpi_erst_instructions {
498 ACPI_ERST_READ_REGISTER = 0,
499 ACPI_ERST_READ_REGISTER_VALUE = 1,
500 ACPI_ERST_WRITE_REGISTER = 2,
501 ACPI_ERST_WRITE_REGISTER_VALUE = 3,
502 ACPI_ERST_NOOP = 4,
503 ACPI_ERST_LOAD_VAR1 = 5,
504 ACPI_ERST_LOAD_VAR2 = 6,
505 ACPI_ERST_STORE_VAR1 = 7,
506 ACPI_ERST_ADD = 8,
507 ACPI_ERST_SUBTRACT = 9,
508 ACPI_ERST_ADD_VALUE = 10,
509 ACPI_ERST_SUBTRACT_VALUE = 11,
510 ACPI_ERST_STALL = 12,
511 ACPI_ERST_STALL_WHILE_TRUE = 13,
512 ACPI_ERST_SKIP_NEXT_IF_TRUE = 14,
513 ACPI_ERST_GOTO = 15,
514 ACPI_ERST_SET_SRC_ADDRESS_BASE = 16,
515 ACPI_ERST_SET_DST_ADDRESS_BASE = 17,
516 ACPI_ERST_MOVE_DATA = 18,
517 ACPI_ERST_INSTRUCTION_RESERVED = 19 /* 19 and greater are reserved */
518};
519
520/*******************************************************************************
521 *
522 * HEST - Hardware Error Source Table
523 *
524 ******************************************************************************/
525
526struct acpi_table_hest {
527 struct acpi_table_header header; /* Common ACPI table header */
528 u32 error_source_count;
529};
530
531/* HEST subtable header */
532
533struct acpi_hest_header {
534 u16 type;
535};
536
537/* Values for Type field above for subtables */
538
539enum acpi_hest_types {
540 ACPI_HEST_TYPE_XPF_MACHINE_CHECK = 0,
541 ACPI_HEST_TYPE_XPF_CORRECTED_MACHINE_CHECK = 1,
542 ACPI_HEST_TYPE_XPF_UNUSED = 2,
543 ACPI_HEST_TYPE_XPF_NON_MASKABLE_INTERRUPT = 3,
544 ACPI_HEST_TYPE_IPF_CORRECTED_MACHINE_CHECK = 4,
545 ACPI_HEST_TYPE_IPF_CORRECTED_PLATFORM_ERROR = 5,
546 ACPI_HEST_TYPE_AER_ROOT_PORT = 6,
547 ACPI_HEST_TYPE_AER_ENDPOINT = 7,
548 ACPI_HEST_TYPE_AER_BRIDGE = 8,
549 ACPI_HEST_TYPE_GENERIC_HARDWARE_ERROR_SOURCE = 9,
550 ACPI_HEST_TYPE_RESERVED = 10 /* 10 and greater are reserved */
551};
552
553/*
554 * HEST Sub-subtables
555 */
556
557/* XPF Machine Check Error Bank */
558
559struct acpi_hest_xpf_error_bank {
560 u8 bank_number;
561 u8 clear_status_on_init;
562 u8 status_format;
563 u8 config_write_enable;
564 u32 control_register;
565 u64 control_init_data;
566 u32 status_register;
567 u32 address_register;
568 u32 misc_register;
569};
570
571/* Generic Error Status */
572
573struct acpi_hest_generic_status {
574 u32 block_status;
575 u32 raw_data_offset;
576 u32 raw_data_length;
577 u32 data_length;
578 u32 error_severity;
579};
580
581/* Generic Error Data */
582
583struct acpi_hest_generic_data {
584 u8 section_type[16];
585 u32 error_severity;
586 u16 revision;
587 u8 validation_bits;
588 u8 flags;
589 u32 error_data_length;
590 u8 fru_id[16];
591 u8 fru_text[20];
592};
593
594/* Common HEST structure for PCI/AER types below (6,7,8) */
595
596struct acpi_hest_aer_common {
597 u16 source_id;
598 u16 config_write_enable;
599 u8 flags;
600 u8 enabled;
601 u32 records_to_pre_allocate;
602 u32 max_sections_per_record;
603 u32 bus;
604 u16 device;
605 u16 function;
606 u16 device_control;
607 u16 reserved;
608 u32 uncorrectable_error_mask;
609 u32 uncorrectable_error_severity;
610 u32 correctable_error_mask;
611 u32 advanced_error_cababilities;
612};
613
614/* Hardware Error Notification */
615
616struct acpi_hest_notify {
617 u8 type;
618 u8 length;
619 u16 config_write_enable;
620 u32 poll_interval;
621 u32 vector;
622 u32 polling_threshold_value;
623 u32 polling_threshold_window;
624 u32 error_threshold_value;
625 u32 error_threshold_window;
626};
627
628/* Values for Notify Type field above */
629
630enum acpi_hest_notify_types {
631 ACPI_HEST_NOTIFY_POLLED = 0,
632 ACPI_HEST_NOTIFY_EXTERNAL = 1,
633 ACPI_HEST_NOTIFY_LOCAL = 2,
634 ACPI_HEST_NOTIFY_SCI = 3,
635 ACPI_HEST_NOTIFY_NMI = 4,
636 ACPI_HEST_NOTIFY_RESERVED = 5 /* 5 and greater are reserved */
637};
638
639/*
640 * HEST subtables
641 *
642 * From WHEA Design Document, 16 May 2007.
643 * Note: There is no subtable type 2 in this version of the document,
644 * and there are two different subtable type 3s.
645 */
646
647 /* 0: XPF Machine Check Exception */
648
649struct acpi_hest_xpf_machine_check {
650 struct acpi_hest_header header;
651 u16 source_id;
652 u16 config_write_enable;
653 u8 flags;
654 u8 reserved1;
655 u32 records_to_pre_allocate;
656 u32 max_sections_per_record;
657 u64 global_capability_data;
658 u64 global_control_data;
659 u8 num_hardware_banks;
660 u8 reserved2[7];
661};
662
663/* 1: XPF Corrected Machine Check */
664
665struct acpi_table_hest_xpf_corrected {
666 struct acpi_hest_header header;
667 u16 source_id;
668 u16 config_write_enable;
669 u8 flags;
670 u8 enabled;
671 u32 records_to_pre_allocate;
672 u32 max_sections_per_record;
673 struct acpi_hest_notify notify;
674 u8 num_hardware_banks;
675 u8 reserved[3];
676};
677
678/* 3: XPF Non-Maskable Interrupt */
679
680struct acpi_hest_xpf_nmi {
681 struct acpi_hest_header header;
682 u16 source_id;
683 u32 reserved;
684 u32 records_to_pre_allocate;
685 u32 max_sections_per_record;
686 u32 max_raw_data_length;
687};
688
689/* 4: IPF Corrected Machine Check */
690
691struct acpi_hest_ipf_corrected {
692 struct acpi_hest_header header;
693 u8 enabled;
694 u8 reserved;
695};
696
697/* 5: IPF Corrected Platform Error */
698
699struct acpi_hest_ipf_corrected_platform {
700 struct acpi_hest_header header;
701 u8 enabled;
702 u8 reserved;
703};
704
705/* 6: PCI Express Root Port AER */
706
707struct acpi_hest_aer_root {
708 struct acpi_hest_header header;
709 struct acpi_hest_aer_common aer;
710 u32 root_error_command;
711};
712
713/* 7: PCI Express AER (AER Endpoint) */
714
715struct acpi_hest_aer {
716 struct acpi_hest_header header;
717 struct acpi_hest_aer_common aer;
718};
719
720/* 8: PCI Express/PCI-X Bridge AER */
721
722struct acpi_hest_aer_bridge {
723 struct acpi_hest_header header;
724 struct acpi_hest_aer_common aer;
725 u32 secondary_uncorrectable_error_mask;
726 u32 secondary_uncorrectable_error_severity;
727 u32 secondary_advanced_capabilities;
728};
729
730/* 9: Generic Hardware Error Source */
731
732struct acpi_hest_generic {
733 struct acpi_hest_header header;
734 u16 source_id;
735 u16 related_source_id;
736 u8 config_write_enable;
737 u8 enabled;
738 u32 records_to_pre_allocate;
739 u32 max_sections_per_record;
740 u32 max_raw_data_length;
741 struct acpi_generic_address error_status_address;
742 struct acpi_hest_notify notify;
743 u32 error_status_block_length;
744};
745
746/*******************************************************************************
747 *
353 * HPET - High Precision Event Timer table 748 * HPET - High Precision Event Timer table
354 * 749 *
355 ******************************************************************************/ 750 ******************************************************************************/
@@ -373,6 +768,96 @@ struct acpi_table_hpet {
373 768
374/******************************************************************************* 769/*******************************************************************************
375 * 770 *
771 * IBFT - Boot Firmware Table
772 *
773 ******************************************************************************/
774
775struct acpi_table_ibft {
776 struct acpi_table_header header; /* Common ACPI table header */
777 u8 reserved[12];
778};
779
780/* IBFT common subtable header */
781
782struct acpi_ibft_header {
783 u8 type;
784 u8 version;
785 u16 length;
786 u8 index;
787 u8 flags;
788};
789
790/* Values for Type field above */
791
792enum acpi_ibft_type {
793 ACPI_IBFT_TYPE_NOT_USED = 0,
794 ACPI_IBFT_TYPE_CONTROL = 1,
795 ACPI_IBFT_TYPE_INITIATOR = 2,
796 ACPI_IBFT_TYPE_NIC = 3,
797 ACPI_IBFT_TYPE_TARGET = 4,
798 ACPI_IBFT_TYPE_EXTENSIONS = 5,
799 ACPI_IBFT_TYPE_RESERVED = 6 /* 6 and greater are reserved */
800};
801
802/* IBFT subtables */
803
804struct acpi_ibft_control {
805 struct acpi_ibft_header header;
806 u16 extensions;
807 u16 initiator_offset;
808 u16 nic0_offset;
809 u16 target0_offset;
810 u16 nic1_offset;
811 u16 target1_offset;
812};
813
814struct acpi_ibft_initiator {
815 struct acpi_ibft_header header;
816 u8 sns_server[16];
817 u8 slp_server[16];
818 u8 primary_server[16];
819 u8 secondary_server[16];
820 u16 name_length;
821 u16 name_offset;
822};
823
824struct acpi_ibft_nic {
825 struct acpi_ibft_header header;
826 u8 ip_address[16];
827 u8 subnet_mask_prefix;
828 u8 origin;
829 u8 gateway[16];
830 u8 primary_dns[16];
831 u8 secondary_dns[16];
832 u8 dhcp[16];
833 u16 vlan;
834 u8 mac_address[6];
835 u16 pci_address;
836 u16 name_length;
837 u16 name_offset;
838};
839
840struct acpi_ibft_target {
841 struct acpi_ibft_header header;
842 u8 target_ip_address[16];
843 u16 target_ip_socket;
844 u8 target_boot_lun[8];
845 u8 chap_type;
846 u8 nic_association;
847 u16 target_name_length;
848 u16 target_name_offset;
849 u16 chap_name_length;
850 u16 chap_name_offset;
851 u16 chap_secret_length;
852 u16 chap_secret_offset;
853 u16 reverse_chap_name_length;
854 u16 reverse_chap_name_offset;
855 u16 reverse_chap_secret_length;
856 u16 reverse_chap_secret_offset;
857};
858
859/*******************************************************************************
860 *
376 * MADT - Multiple APIC Description Table 861 * MADT - Multiple APIC Description Table
377 * 862 *
378 ******************************************************************************/ 863 ******************************************************************************/
@@ -697,6 +1182,78 @@ struct acpi_table_tcpa {
697 1182
698/******************************************************************************* 1183/*******************************************************************************
699 * 1184 *
1185 * UEFI - UEFI Boot optimization Table
1186 *
1187 ******************************************************************************/
1188
1189struct acpi_table_uefi {
1190 struct acpi_table_header header; /* Common ACPI table header */
1191 u8 identifier[16]; /* UUID identifier */
1192 u16 data_offset; /* Offset of remaining data in table */
1193 u8 data;
1194};
1195
1196/*******************************************************************************
1197 *
1198 * WDAT - Watchdog Action Table
1199 *
1200 ******************************************************************************/
1201
1202struct acpi_table_wdat {
1203 struct acpi_table_header header; /* Common ACPI table header */
1204 u32 header_length; /* Watchdog Header Length */
1205 u16 pci_segment; /* PCI Segment number */
1206 u8 pci_bus; /* PCI Bus number */
1207 u8 pci_device; /* PCI Device number */
1208 u8 pci_function; /* PCI Function number */
1209 u8 reserved[3];
1210 u32 timer_period; /* Period of one timer count (msec) */
1211 u32 max_count; /* Maximum counter value supported */
1212 u32 min_count; /* Minimum counter value */
1213 u8 flags;
1214 u8 reserved2[3];
1215 u32 entries; /* Number of watchdog entries that follow */
1216};
1217
1218/* WDAT Instruction Entries (actions) */
1219
1220struct acpi_wdat_entry {
1221 struct acpi_whea_header whea_header; /* Common header for WHEA tables */
1222};
1223
1224/* Values for Action field above */
1225
1226enum acpi_wdat_actions {
1227 ACPI_WDAT_RESET = 1,
1228 ACPI_WDAT_GET_CURRENT_COUNTDOWN = 4,
1229 ACPI_WDAT_GET_COUNTDOWN = 5,
1230 ACPI_WDAT_SET_COUNTDOWN = 6,
1231 ACPI_WDAT_GET_RUNNING_STATE = 8,
1232 ACPI_WDAT_SET_RUNNING_STATE = 9,
1233 ACPI_WDAT_GET_STOPPED_STATE = 10,
1234 ACPI_WDAT_SET_STOPPED_STATE = 11,
1235 ACPI_WDAT_GET_REBOOT = 16,
1236 ACPI_WDAT_SET_REBOOT = 17,
1237 ACPI_WDAT_GET_SHUTDOWN = 18,
1238 ACPI_WDAT_SET_SHUTDOWN = 19,
1239 ACPI_WDAT_GET_STATUS = 32,
1240 ACPI_WDAT_SET_STATUS = 33,
1241 ACPI_WDAT_ACTION_RESERVED = 34 /* 34 and greater are reserved */
1242};
1243
1244/* Values for Instruction field above */
1245
1246enum acpi_wdat_instructions {
1247 ACPI_WDAT_READ_VALUE = 0,
1248 ACPI_WDAT_READ_COUNTDOWN = 1,
1249 ACPI_WDAT_WRITE_VALUE = 2,
1250 ACPI_WDAT_WRITE_COUNTDOWN = 3,
1251 ACPI_WDAT_INSTRUCTION_RESERVED = 4, /* 4 and greater are reserved */
1252 ACPI_WDAT_PRESERVE_REGISTER = 0x80 /* Except for this value */
1253};
1254
1255/*******************************************************************************
1256 *
700 * WDRT - Watchdog Resource Table 1257 * WDRT - Watchdog Resource Table
701 * 1258 *
702 ******************************************************************************/ 1259 ******************************************************************************/
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index e73a38939120..dfea2d440488 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -323,27 +323,11 @@ struct uint32_struct {
323#define acpi_semaphore void * 323#define acpi_semaphore void *
324 324
325/* 325/*
326 * Acpi integer width. In ACPI version 1, integers are 326 * Acpi integer width. In ACPI version 1, integers are 32 bits. In ACPI
327 * 32 bits. In ACPI version 2, integers are 64 bits. 327 * version 2, integers are 64 bits. Note that this pertains to the ACPI integer
328 * Note that this pertains to the ACPI integer type only, not 328 * type only, not other integers used in the implementation of the ACPI CA
329 * other integers used in the implementation of the ACPI CA
330 * subsystem. 329 * subsystem.
331 */ 330 */
332#ifdef ACPI_NO_INTEGER64_SUPPORT
333
334/* 32-bit integers only, no 64-bit support */
335
336typedef u32 acpi_integer;
337#define ACPI_INTEGER_MAX ACPI_UINT32_MAX
338#define ACPI_INTEGER_BIT_SIZE 32
339#define ACPI_MAX_DECIMAL_DIGITS 10 /* 2^32 = 4,294,967,296 */
340
341#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */
342
343#else
344
345/* 64-bit integers */
346
347typedef unsigned long long acpi_integer; 331typedef unsigned long long acpi_integer;
348#define ACPI_INTEGER_MAX ACPI_UINT64_MAX 332#define ACPI_INTEGER_MAX ACPI_UINT64_MAX
349#define ACPI_INTEGER_BIT_SIZE 64 333#define ACPI_INTEGER_BIT_SIZE 64
@@ -352,7 +336,6 @@ typedef unsigned long long acpi_integer;
352#if ACPI_MACHINE_WIDTH == 64 336#if ACPI_MACHINE_WIDTH == 64
353#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ 337#define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */
354#endif 338#endif
355#endif
356 339
357#define ACPI_MAX64_DECIMAL_DIGITS 20 340#define ACPI_MAX64_DECIMAL_DIGITS 20
358#define ACPI_MAX32_DECIMAL_DIGITS 10 341#define ACPI_MAX32_DECIMAL_DIGITS 10
@@ -419,14 +402,20 @@ typedef unsigned long long acpi_integer;
419/* 402/*
420 * Standard notify values 403 * Standard notify values
421 */ 404 */
422#define ACPI_NOTIFY_BUS_CHECK (u8) 0 405#define ACPI_NOTIFY_BUS_CHECK (u8) 0x00
423#define ACPI_NOTIFY_DEVICE_CHECK (u8) 1 406#define ACPI_NOTIFY_DEVICE_CHECK (u8) 0x01
424#define ACPI_NOTIFY_DEVICE_WAKE (u8) 2 407#define ACPI_NOTIFY_DEVICE_WAKE (u8) 0x02
425#define ACPI_NOTIFY_EJECT_REQUEST (u8) 3 408#define ACPI_NOTIFY_EJECT_REQUEST (u8) 0x03
426#define ACPI_NOTIFY_DEVICE_CHECK_LIGHT (u8) 4 409#define ACPI_NOTIFY_DEVICE_CHECK_LIGHT (u8) 0x04
427#define ACPI_NOTIFY_FREQUENCY_MISMATCH (u8) 5 410#define ACPI_NOTIFY_FREQUENCY_MISMATCH (u8) 0x05
428#define ACPI_NOTIFY_BUS_MODE_MISMATCH (u8) 6 411#define ACPI_NOTIFY_BUS_MODE_MISMATCH (u8) 0x06
429#define ACPI_NOTIFY_POWER_FAULT (u8) 7 412#define ACPI_NOTIFY_POWER_FAULT (u8) 0x07
413#define ACPI_NOTIFY_CAPABILITIES_CHECK (u8) 0x08
414#define ACPI_NOTIFY_DEVICE_PLD_CHECK (u8) 0x09
415#define ACPI_NOTIFY_RESERVED (u8) 0x0A
416#define ACPI_NOTIFY_LOCALITY_UPDATE (u8) 0x0B
417
418#define ACPI_NOTIFY_MAX 0x0B
430 419
431/* 420/*
432 * Types associated with ACPI names and objects. The first group of 421 * Types associated with ACPI names and objects. The first group of
@@ -494,6 +483,8 @@ typedef u32 acpi_object_type;
494#define ACPI_TYPE_INVALID 0x1E 483#define ACPI_TYPE_INVALID 0x1E
495#define ACPI_TYPE_NOT_FOUND 0xFF 484#define ACPI_TYPE_NOT_FOUND 0xFF
496 485
486#define ACPI_NUM_NS_TYPES (ACPI_TYPE_INVALID + 1)
487
497/* 488/*
498 * All I/O 489 * All I/O
499 */ 490 */
@@ -599,7 +590,7 @@ typedef u32 acpi_event_status;
599 590
600#define ACPI_SYSTEM_NOTIFY 0x1 591#define ACPI_SYSTEM_NOTIFY 0x1
601#define ACPI_DEVICE_NOTIFY 0x2 592#define ACPI_DEVICE_NOTIFY 0x2
602#define ACPI_ALL_NOTIFY 0x3 593#define ACPI_ALL_NOTIFY (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY)
603#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3 594#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3
604 595
605#define ACPI_MAX_SYS_NOTIFY 0x7f 596#define ACPI_MAX_SYS_NOTIFY 0x7f
@@ -654,46 +645,51 @@ typedef u8 acpi_adr_space_type;
654/* 645/*
655 * External ACPI object definition 646 * External ACPI object definition
656 */ 647 */
648
649/*
650 * Note: Type == ACPI_TYPE_ANY (0) is used to indicate a NULL package element
651 * or an unresolved named reference.
652 */
657union acpi_object { 653union acpi_object {
658 acpi_object_type type; /* See definition of acpi_ns_type for values */ 654 acpi_object_type type; /* See definition of acpi_ns_type for values */
659 struct { 655 struct {
660 acpi_object_type type; 656 acpi_object_type type; /* ACPI_TYPE_INTEGER */
661 acpi_integer value; /* The actual number */ 657 acpi_integer value; /* The actual number */
662 } integer; 658 } integer;
663 659
664 struct { 660 struct {
665 acpi_object_type type; 661 acpi_object_type type; /* ACPI_TYPE_STRING */
666 u32 length; /* # of bytes in string, excluding trailing null */ 662 u32 length; /* # of bytes in string, excluding trailing null */
667 char *pointer; /* points to the string value */ 663 char *pointer; /* points to the string value */
668 } string; 664 } string;
669 665
670 struct { 666 struct {
671 acpi_object_type type; 667 acpi_object_type type; /* ACPI_TYPE_BUFFER */
672 u32 length; /* # of bytes in buffer */ 668 u32 length; /* # of bytes in buffer */
673 u8 *pointer; /* points to the buffer */ 669 u8 *pointer; /* points to the buffer */
674 } buffer; 670 } buffer;
675 671
676 struct { 672 struct {
677 acpi_object_type type; 673 acpi_object_type type; /* ACPI_TYPE_PACKAGE */
678 u32 fill1;
679 acpi_handle handle; /* object reference */
680 } reference;
681
682 struct {
683 acpi_object_type type;
684 u32 count; /* # of elements in package */ 674 u32 count; /* # of elements in package */
685 union acpi_object *elements; /* Pointer to an array of ACPI_OBJECTs */ 675 union acpi_object *elements; /* Pointer to an array of ACPI_OBJECTs */
686 } package; 676 } package;
687 677
688 struct { 678 struct {
689 acpi_object_type type; 679 acpi_object_type type; /* ACPI_TYPE_LOCAL_REFERENCE */
680 acpi_object_type actual_type; /* Type associated with the Handle */
681 acpi_handle handle; /* object reference */
682 } reference;
683
684 struct {
685 acpi_object_type type; /* ACPI_TYPE_PROCESSOR */
690 u32 proc_id; 686 u32 proc_id;
691 acpi_io_address pblk_address; 687 acpi_io_address pblk_address;
692 u32 pblk_length; 688 u32 pblk_length;
693 } processor; 689 } processor;
694 690
695 struct { 691 struct {
696 acpi_object_type type; 692 acpi_object_type type; /* ACPI_TYPE_POWER */
697 u32 system_level; 693 u32 system_level;
698 u32 resource_order; 694 u32 resource_order;
699 } power_resource; 695 } power_resource;
@@ -747,6 +743,12 @@ struct acpi_system_info {
747 u32 debug_layer; 743 u32 debug_layer;
748}; 744};
749 745
746/* Table Event Types */
747
748#define ACPI_TABLE_EVENT_LOAD 0x0
749#define ACPI_TABLE_EVENT_UNLOAD 0x1
750#define ACPI_NUM_TABLE_EVENTS 2
751
750/* 752/*
751 * Types specific to the OS service interfaces 753 * Types specific to the OS service interfaces
752 */ 754 */
@@ -776,6 +778,11 @@ acpi_status(*acpi_exception_handler) (acpi_status aml_status,
776 u16 opcode, 778 u16 opcode,
777 u32 aml_offset, void *context); 779 u32 aml_offset, void *context);
778 780
781/* Table Event handler (Load, load_table etc) and types */
782
783typedef
784acpi_status(*acpi_tbl_handler) (u32 event, void *table, void *context);
785
779/* Address Spaces (For Operation Regions) */ 786/* Address Spaces (For Operation Regions) */
780 787
781typedef 788typedef
@@ -990,6 +997,7 @@ struct acpi_vendor_uuid {
990 * Structures used to describe device resources 997 * Structures used to describe device resources
991 */ 998 */
992struct acpi_resource_irq { 999struct acpi_resource_irq {
1000 u8 descriptor_length;
993 u8 triggering; 1001 u8 triggering;
994 u8 polarity; 1002 u8 polarity;
995 u8 sharable; 1003 u8 sharable;
@@ -1006,6 +1014,7 @@ struct acpi_resource_dma {
1006}; 1014};
1007 1015
1008struct acpi_resource_start_dependent { 1016struct acpi_resource_start_dependent {
1017 u8 descriptor_length;
1009 u8 compatibility_priority; 1018 u8 compatibility_priority;
1010 u8 performance_robustness; 1019 u8 performance_robustness;
1011}; 1020};
diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h
index a2918547c73f..b42cadf07302 100644
--- a/include/acpi/acutils.h
+++ b/include/acpi/acutils.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -116,6 +116,8 @@ void acpi_ut_init_globals(void);
116 116
117char *acpi_ut_get_mutex_name(u32 mutex_id); 117char *acpi_ut_get_mutex_name(u32 mutex_id);
118 118
119const char *acpi_ut_get_notify_name(u32 notify_value);
120
119#endif 121#endif
120 122
121char *acpi_ut_get_type_name(acpi_object_type type); 123char *acpi_ut_get_type_name(acpi_object_type type);
diff --git a/include/acpi/amlcode.h b/include/acpi/amlcode.h
index da53a4ef287a..ff851c5df698 100644
--- a/include/acpi/amlcode.h
+++ b/include/acpi/amlcode.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2007, R. Byron Moore 10 * Copyright (C) 2000 - 2008, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h
index f7d541239da4..7b070e42b7c5 100644
--- a/include/acpi/amlresrc.h
+++ b/include/acpi/amlresrc.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2007, R. Byron Moore 9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index c785485e62a6..fcd2572e428c 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h
index 3bb50494a38a..8996dba90cd9 100644
--- a/include/acpi/platform/acgcc.h
+++ b/include/acpi/platform/acgcc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 6ed15a0978eb..9af464598682 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2007, R. Byron Moore 8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/asm-alpha/bitops.h b/include/asm-alpha/bitops.h
index 9e19a704d484..15f3ae25c511 100644
--- a/include/asm-alpha/bitops.h
+++ b/include/asm-alpha/bitops.h
@@ -388,6 +388,11 @@ static inline int fls64(unsigned long x)
388} 388}
389#endif 389#endif
390 390
391static inline unsigned long __fls(unsigned long x)
392{
393 return fls64(x) - 1;
394}
395
391static inline int fls(int x) 396static inline int fls(int x)
392{ 397{
393 return fls64((unsigned int) x); 398 return fls64((unsigned int) x);
diff --git a/include/asm-alpha/bug.h b/include/asm-alpha/bug.h
index 39a3e2a5017d..695a5ee4b5d3 100644
--- a/include/asm-alpha/bug.h
+++ b/include/asm-alpha/bug.h
@@ -1,14 +1,24 @@
1#ifndef _ALPHA_BUG_H 1#ifndef _ALPHA_BUG_H
2#define _ALPHA_BUG_H 2#define _ALPHA_BUG_H
3 3
4#include <linux/linkage.h>
5
4#ifdef CONFIG_BUG 6#ifdef CONFIG_BUG
5#include <asm/pal.h> 7#include <asm/pal.h>
6 8
7/* ??? Would be nice to use .gprel32 here, but we can't be sure that the 9/* ??? Would be nice to use .gprel32 here, but we can't be sure that the
8 function loaded the GP, so this could fail in modules. */ 10 function loaded the GP, so this could fail in modules. */
9#define BUG() \ 11static inline void ATTRIB_NORET __BUG(const char *file, int line)
10 __asm__ __volatile__("call_pal %0 # bugchk\n\t"".long %1\n\t.8byte %2" \ 12{
11 : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__)) 13 __asm__ __volatile__(
14 "call_pal %0 # bugchk\n\t"
15 ".long %1\n\t.8byte %2"
16 : : "i" (PAL_bugchk), "i"(line), "i"(file));
17 for ( ; ; )
18 ;
19}
20
21#define BUG() __BUG(__FILE__, __LINE__)
12 22
13#define HAVE_ARCH_BUG 23#define HAVE_ARCH_BUG
14#endif 24#endif
diff --git a/include/asm-alpha/byteorder.h b/include/asm-alpha/byteorder.h
index 7af2b8d25486..58e958fc7f1b 100644
--- a/include/asm-alpha/byteorder.h
+++ b/include/asm-alpha/byteorder.h
@@ -7,7 +7,7 @@
7 7
8#ifdef __GNUC__ 8#ifdef __GNUC__
9 9
10static __inline __attribute_const__ __u32 __arch__swab32(__u32 x) 10static inline __attribute_const__ __u32 __arch__swab32(__u32 x)
11{ 11{
12 /* 12 /*
13 * Unfortunately, we can't use the 6 instruction sequence 13 * Unfortunately, we can't use the 6 instruction sequence
diff --git a/include/asm-alpha/ide.h b/include/asm-alpha/ide.h
index b7bf68d0407b..f44129abc02c 100644
--- a/include/asm-alpha/ide.h
+++ b/include/asm-alpha/ide.h
@@ -13,9 +13,6 @@
13 13
14#ifdef __KERNEL__ 14#ifdef __KERNEL__
15 15
16
17#define IDE_ARCH_OBSOLETE_DEFAULTS
18
19static inline int ide_default_irq(unsigned long base) 16static inline int ide_default_irq(unsigned long base)
20{ 17{
21 switch (base) { 18 switch (base) {
@@ -40,14 +37,6 @@ static inline unsigned long ide_default_io_base(int index)
40 } 37 }
41} 38}
42 39
43#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
44
45#ifdef CONFIG_PCI
46#define ide_init_default_irq(base) (0)
47#else
48#define ide_init_default_irq(base) ide_default_irq(base)
49#endif
50
51#include <asm-generic/ide_iops.h> 40#include <asm-generic/ide_iops.h>
52 41
53#endif /* __KERNEL__ */ 42#endif /* __KERNEL__ */
diff --git a/include/asm-alpha/pgtable.h b/include/asm-alpha/pgtable.h
index 99037b032357..05ce5fba43e3 100644
--- a/include/asm-alpha/pgtable.h
+++ b/include/asm-alpha/pgtable.h
@@ -268,6 +268,7 @@ extern inline int pte_write(pte_t pte) { return !(pte_val(pte) & _PAGE_FOW); }
268extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 268extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
269extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 269extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
270extern inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 270extern inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
271extern inline int pte_special(pte_t pte) { return 0; }
271 272
272extern inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOW; return pte; } 273extern inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOW; return pte; }
273extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~(__DIRTY_BITS); return pte; } 274extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~(__DIRTY_BITS); return pte; }
@@ -275,6 +276,7 @@ extern inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~(__ACCESS_BITS); ret
275extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) &= ~_PAGE_FOW; return pte; } 276extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) &= ~_PAGE_FOW; return pte; }
276extern inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= __DIRTY_BITS; return pte; } 277extern inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= __DIRTY_BITS; return pte; }
277extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= __ACCESS_BITS; return pte; } 278extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= __ACCESS_BITS; return pte; }
279extern inline pte_t pte_mkspecial(pte_t pte) { return pte; }
278 280
279#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address)) 281#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
280 282
diff --git a/include/asm-alpha/semaphore.h b/include/asm-alpha/semaphore.h
index f1e9278a9fe2..d9b2034ed1d2 100644
--- a/include/asm-alpha/semaphore.h
+++ b/include/asm-alpha/semaphore.h
@@ -1,149 +1 @@
1#ifndef _ALPHA_SEMAPHORE_H #include <linux/semaphore.h>
2#define _ALPHA_SEMAPHORE_H
3
4/*
5 * SMP- and interrupt-safe semaphores..
6 *
7 * (C) Copyright 1996 Linus Torvalds
8 * (C) Copyright 1996, 2000 Richard Henderson
9 */
10
11#include <asm/current.h>
12#include <asm/system.h>
13#include <asm/atomic.h>
14#include <linux/compiler.h>
15#include <linux/wait.h>
16#include <linux/rwsem.h>
17
18struct semaphore {
19 atomic_t count;
20 wait_queue_head_t wait;
21};
22
23#define __SEMAPHORE_INITIALIZER(name, n) \
24{ \
25 .count = ATOMIC_INIT(n), \
26 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \
27}
28
29#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
30 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
31
32#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
33
34static inline void sema_init(struct semaphore *sem, int val)
35{
36 /*
37 * Logically,
38 * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
39 * except that gcc produces better initializing by parts yet.
40 */
41
42 atomic_set(&sem->count, val);
43 init_waitqueue_head(&sem->wait);
44}
45
46static inline void init_MUTEX (struct semaphore *sem)
47{
48 sema_init(sem, 1);
49}
50
51static inline void init_MUTEX_LOCKED (struct semaphore *sem)
52{
53 sema_init(sem, 0);
54}
55
56extern void down(struct semaphore *);
57extern void __down_failed(struct semaphore *);
58extern int down_interruptible(struct semaphore *);
59extern int __down_failed_interruptible(struct semaphore *);
60extern int down_trylock(struct semaphore *);
61extern void up(struct semaphore *);
62extern void __up_wakeup(struct semaphore *);
63
64/*
65 * Hidden out of line code is fun, but extremely messy. Rely on newer
66 * compilers to do a respectable job with this. The contention cases
67 * are handled out of line in arch/alpha/kernel/semaphore.c.
68 */
69
70static inline void __down(struct semaphore *sem)
71{
72 long count;
73 might_sleep();
74 count = atomic_dec_return(&sem->count);
75 if (unlikely(count < 0))
76 __down_failed(sem);
77}
78
79static inline int __down_interruptible(struct semaphore *sem)
80{
81 long count;
82 might_sleep();
83 count = atomic_dec_return(&sem->count);
84 if (unlikely(count < 0))
85 return __down_failed_interruptible(sem);
86 return 0;
87}
88
89/*
90 * down_trylock returns 0 on success, 1 if we failed to get the lock.
91 */
92
93static inline int __down_trylock(struct semaphore *sem)
94{
95 long ret;
96
97 /* "Equivalent" C:
98
99 do {
100 ret = ldl_l;
101 --ret;
102 if (ret < 0)
103 break;
104 ret = stl_c = ret;
105 } while (ret == 0);
106 */
107 __asm__ __volatile__(
108 "1: ldl_l %0,%1\n"
109 " subl %0,1,%0\n"
110 " blt %0,2f\n"
111 " stl_c %0,%1\n"
112 " beq %0,3f\n"
113 " mb\n"
114 "2:\n"
115 ".subsection 2\n"
116 "3: br 1b\n"
117 ".previous"
118 : "=&r" (ret), "=m" (sem->count)
119 : "m" (sem->count));
120
121 return ret < 0;
122}
123
124static inline void __up(struct semaphore *sem)
125{
126 if (unlikely(atomic_inc_return(&sem->count) <= 0))
127 __up_wakeup(sem);
128}
129
130#if !defined(CONFIG_DEBUG_SEMAPHORE)
131extern inline void down(struct semaphore *sem)
132{
133 __down(sem);
134}
135extern inline int down_interruptible(struct semaphore *sem)
136{
137 return __down_interruptible(sem);
138}
139extern inline int down_trylock(struct semaphore *sem)
140{
141 return __down_trylock(sem);
142}
143extern inline void up(struct semaphore *sem)
144{
145 __up(sem);
146}
147#endif
148
149#endif
diff --git a/include/asm-alpha/topology.h b/include/asm-alpha/topology.h
index 420ccde6b916..149532e162c4 100644
--- a/include/asm-alpha/topology.h
+++ b/include/asm-alpha/topology.h
@@ -41,8 +41,7 @@ static inline cpumask_t node_to_cpumask(int node)
41 41
42#define pcibus_to_cpumask(bus) (cpu_online_map) 42#define pcibus_to_cpumask(bus) (cpu_online_map)
43 43
44#else /* CONFIG_NUMA */
45# include <asm-generic/topology.h>
46#endif /* !CONFIG_NUMA */ 44#endif /* !CONFIG_NUMA */
45# include <asm-generic/topology.h>
47 46
48#endif /* _ASM_ALPHA_TOPOLOGY_H */ 47#endif /* _ASM_ALPHA_TOPOLOGY_H */
diff --git a/include/asm-alpha/unaligned.h b/include/asm-alpha/unaligned.h
index a1d72846f61c..3787c60aed3f 100644
--- a/include/asm-alpha/unaligned.h
+++ b/include/asm-alpha/unaligned.h
@@ -1,6 +1,11 @@
1#ifndef __ALPHA_UNALIGNED_H 1#ifndef _ASM_ALPHA_UNALIGNED_H
2#define __ALPHA_UNALIGNED_H 2#define _ASM_ALPHA_UNALIGNED_H
3 3
4#include <asm-generic/unaligned.h> 4#include <linux/unaligned/le_struct.h>
5#include <linux/unaligned/be_byteshift.h>
6#include <linux/unaligned/generic.h>
5 7
6#endif 8#define get_unaligned __get_unaligned_le
9#define put_unaligned __put_unaligned_le
10
11#endif /* _ASM_ALPHA_UNALIGNED_H */
diff --git a/include/asm-arm/arch-at91/at91_ecc.h b/include/asm-arm/arch-at91/at91_ecc.h
index ff93df516d6d..1e5a8caca2d1 100644
--- a/include/asm-arm/arch-at91/at91_ecc.h
+++ b/include/asm-arm/arch-at91/at91_ecc.h
@@ -13,26 +13,26 @@
13#ifndef AT91_ECC_H 13#ifndef AT91_ECC_H
14#define AT91_ECC_H 14#define AT91_ECC_H
15 15
16#define AT91_ECC_CR (AT91_ECC + 0x00) /* Control register */ 16#define AT91_ECC_CR 0x00 /* Control register */
17#define AT91_ECC_RST (1 << 0) /* Reset parity */ 17#define AT91_ECC_RST (1 << 0) /* Reset parity */
18 18
19#define AT91_ECC_MR (AT91_ECC + 0x04) /* Mode register */ 19#define AT91_ECC_MR 0x04 /* Mode register */
20#define AT91_ECC_PAGESIZE (3 << 0) /* Page Size */ 20#define AT91_ECC_PAGESIZE (3 << 0) /* Page Size */
21#define AT91_ECC_PAGESIZE_528 (0) 21#define AT91_ECC_PAGESIZE_528 (0)
22#define AT91_ECC_PAGESIZE_1056 (1) 22#define AT91_ECC_PAGESIZE_1056 (1)
23#define AT91_ECC_PAGESIZE_2112 (2) 23#define AT91_ECC_PAGESIZE_2112 (2)
24#define AT91_ECC_PAGESIZE_4224 (3) 24#define AT91_ECC_PAGESIZE_4224 (3)
25 25
26#define AT91_ECC_SR (AT91_ECC + 0x08) /* Status register */ 26#define AT91_ECC_SR 0x08 /* Status register */
27#define AT91_ECC_RECERR (1 << 0) /* Recoverable Error */ 27#define AT91_ECC_RECERR (1 << 0) /* Recoverable Error */
28#define AT91_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */ 28#define AT91_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
29#define AT91_ECC_MULERR (1 << 2) /* Multiple Errors */ 29#define AT91_ECC_MULERR (1 << 2) /* Multiple Errors */
30 30
31#define AT91_ECC_PR (AT91_ECC + 0x0c) /* Parity register */ 31#define AT91_ECC_PR 0x0c /* Parity register */
32#define AT91_ECC_BITADDR (0xf << 0) /* Bit Error Address */ 32#define AT91_ECC_BITADDR (0xf << 0) /* Bit Error Address */
33#define AT91_ECC_WORDADDR (0xfff << 4) /* Word Error Address */ 33#define AT91_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
34 34
35#define AT91_ECC_NPR (AT91_ECC + 0x10) /* NParity register */ 35#define AT91_ECC_NPR 0x10 /* NParity register */
36#define AT91_ECC_NPARITY (0xffff << 0) /* NParity */ 36#define AT91_ECC_NPARITY (0xffff << 0) /* NParity */
37 37
38#endif 38#endif
diff --git a/include/asm-arm/arch-at91/at91_pmc.h b/include/asm-arm/arch-at91/at91_pmc.h
index 52cd8e5dabc9..c2b13c280155 100644
--- a/include/asm-arm/arch-at91/at91_pmc.h
+++ b/include/asm-arm/arch-at91/at91_pmc.h
@@ -76,10 +76,17 @@
76#define AT91_PMC_PRES_32 (5 << 2) 76#define AT91_PMC_PRES_32 (5 << 2)
77#define AT91_PMC_PRES_64 (6 << 2) 77#define AT91_PMC_PRES_64 (6 << 2)
78#define AT91_PMC_MDIV (3 << 8) /* Master Clock Division */ 78#define AT91_PMC_MDIV (3 << 8) /* Master Clock Division */
79#define AT91_PMC_MDIV_1 (0 << 8) 79#define AT91RM9200_PMC_MDIV_1 (0 << 8) /* [AT91RM9200 only] */
80#define AT91_PMC_MDIV_2 (1 << 8) 80#define AT91RM9200_PMC_MDIV_2 (1 << 8)
81#define AT91_PMC_MDIV_3 (2 << 8) 81#define AT91RM9200_PMC_MDIV_3 (2 << 8)
82#define AT91_PMC_MDIV_4 (3 << 8) 82#define AT91RM9200_PMC_MDIV_4 (3 << 8)
83#define AT91SAM9_PMC_MDIV_1 (0 << 8) /* [SAM9,CAP9 only] */
84#define AT91SAM9_PMC_MDIV_2 (1 << 8)
85#define AT91SAM9_PMC_MDIV_4 (2 << 8)
86#define AT91SAM9_PMC_MDIV_6 (3 << 8)
87#define AT91_PMC_PDIV (1 << 12) /* Processor Clock Division [some SAM9 only] */
88#define AT91_PMC_PDIV_1 (0 << 12)
89#define AT91_PMC_PDIV_2 (1 << 12)
83 90
84#define AT91_PMC_PCKR(n) (AT91_PMC + 0x40 + ((n) * 4)) /* Programmable Clock 0-3 Registers */ 91#define AT91_PMC_PCKR(n) (AT91_PMC + 0x40 + ((n) * 4)) /* Programmable Clock 0-3 Registers */
85 92
diff --git a/include/asm-arm/arch-at91/at91_shdwc.h b/include/asm-arm/arch-at91/at91_shdwc.h
index 01b433de2272..581fa41d90e8 100644
--- a/include/asm-arm/arch-at91/at91_shdwc.h
+++ b/include/asm-arm/arch-at91/at91_shdwc.h
@@ -24,10 +24,12 @@
24#define AT91_SHDW_WKMODE0_LOW 2 24#define AT91_SHDW_WKMODE0_LOW 2
25#define AT91_SHDW_WKMODE0_ANYLEVEL 3 25#define AT91_SHDW_WKMODE0_ANYLEVEL 3
26#define AT91_SHDW_CPTWK0 (0xf << 4) /* Counter On Wake Up 0 */ 26#define AT91_SHDW_CPTWK0 (0xf << 4) /* Counter On Wake Up 0 */
27#define AT91_SHDW_CPTWK0_(x) ((x) << 4)
27#define AT91_SHDW_RTTWKEN (1 << 16) /* Real Time Timer Wake-up Enable */ 28#define AT91_SHDW_RTTWKEN (1 << 16) /* Real Time Timer Wake-up Enable */
28 29
29#define AT91_SHDW_SR (AT91_SHDWC + 0x08) /* Shut Down Status Register */ 30#define AT91_SHDW_SR (AT91_SHDWC + 0x08) /* Shut Down Status Register */
30#define AT91_SHDW_WAKEUP0 (1 << 0) /* Wake-up 0 Status */ 31#define AT91_SHDW_WAKEUP0 (1 << 0) /* Wake-up 0 Status */
31#define AT91_SHDW_RTTWK (1 << 16) /* Real-time Timer Wake-up */ 32#define AT91_SHDW_RTTWK (1 << 16) /* Real-time Timer Wake-up */
33#define AT91_SHDW_RTCWK (1 << 17) /* Real-time Clock Wake-up [SAM9RL] */
32 34
33#endif 35#endif
diff --git a/include/asm-arm/arch-at91/at91cap9_ddrsdr.h b/include/asm-arm/arch-at91/at91cap9_ddrsdr.h
new file mode 100644
index 000000000000..efdb23af1ee4
--- /dev/null
+++ b/include/asm-arm/arch-at91/at91cap9_ddrsdr.h
@@ -0,0 +1,100 @@
1/*
2 * include/asm-arm/arch-at91/at91cap9_ddrsdr.h
3 *
4 * DDR/SDR Controller (DDRSDRC) - System peripherals registers.
5 * Based on AT91CAP9 datasheet revision B.
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 AT91CAP9_DDRSDR_H
14#define AT91CAP9_DDRSDR_H
15
16#define AT91_DDRSDRC_MR (AT91_DDRSDRC + 0x00) /* Mode Register */
17#define AT91_DDRSDRC_MODE (0xf << 0) /* Command Mode */
18#define AT91_DDRSDRC_MODE_NORMAL 0
19#define AT91_DDRSDRC_MODE_NOP 1
20#define AT91_DDRSDRC_MODE_PRECHARGE 2
21#define AT91_DDRSDRC_MODE_LMR 3
22#define AT91_DDRSDRC_MODE_REFRESH 4
23#define AT91_DDRSDRC_MODE_EXT_LMR 5
24#define AT91_DDRSDRC_MODE_DEEP 6
25
26#define AT91_DDRSDRC_RTR (AT91_DDRSDRC + 0x04) /* Refresh Timer Register */
27#define AT91_DDRSDRC_COUNT (0xfff << 0) /* Refresh Timer Counter */
28
29#define AT91_DDRSDRC_CR (AT91_DDRSDRC + 0x08) /* Configuration Register */
30#define AT91_DDRSDRC_NC (3 << 0) /* Number of Column Bits */
31#define AT91_DDRSDRC_NC_SDR8 (0 << 0)
32#define AT91_DDRSDRC_NC_SDR9 (1 << 0)
33#define AT91_DDRSDRC_NC_SDR10 (2 << 0)
34#define AT91_DDRSDRC_NC_SDR11 (3 << 0)
35#define AT91_DDRSDRC_NC_DDR9 (0 << 0)
36#define AT91_DDRSDRC_NC_DDR10 (1 << 0)
37#define AT91_DDRSDRC_NC_DDR11 (2 << 0)
38#define AT91_DDRSDRC_NC_DDR12 (3 << 0)
39#define AT91_DDRSDRC_NR (3 << 2) /* Number of Row Bits */
40#define AT91_DDRSDRC_NR_11 (0 << 2)
41#define AT91_DDRSDRC_NR_12 (1 << 2)
42#define AT91_DDRSDRC_NR_13 (2 << 2)
43#define AT91_DDRSDRC_CAS (7 << 4) /* CAS Latency */
44#define AT91_DDRSDRC_CAS_2 (2 << 4)
45#define AT91_DDRSDRC_CAS_3 (3 << 4)
46#define AT91_DDRSDRC_CAS_25 (6 << 4)
47#define AT91_DDRSDRC_DLL (1 << 7) /* Reset DLL */
48#define AT91_DDRSDRC_DICDS (1 << 8) /* Output impedance control */
49
50#define AT91_DDRSDRC_T0PR (AT91_DDRSDRC + 0x0C) /* Timing 0 Register */
51#define AT91_DDRSDRC_TRAS (0xf << 0) /* Active to Precharge delay */
52#define AT91_DDRSDRC_TRCD (0xf << 4) /* Row to Column delay */
53#define AT91_DDRSDRC_TWR (0xf << 8) /* Write recovery delay */
54#define AT91_DDRSDRC_TRC (0xf << 12) /* Row cycle delay */
55#define AT91_DDRSDRC_TRP (0xf << 16) /* Row precharge delay */
56#define AT91_DDRSDRC_TRRD (0xf << 20) /* Active BankA to BankB */
57#define AT91_DDRSDRC_TWTR (1 << 24) /* Internal Write to Read delay */
58#define AT91_DDRSDRC_TMRD (0xf << 28) /* Load mode to active/refresh delay */
59
60#define AT91_DDRSDRC_T1PR (AT91_DDRSDRC + 0x10) /* Timing 1 Register */
61#define AT91_DDRSDRC_TRFC (0x1f << 0) /* Row Cycle Delay */
62#define AT91_DDRSDRC_TXSNR (0xff << 8) /* Exit self-refresh to non-read */
63#define AT91_DDRSDRC_TXSRD (0xff << 16) /* Exit self-refresh to read */
64#define AT91_DDRSDRC_TXP (0xf << 24) /* Exit power-down delay */
65
66#define AT91_DDRSDRC_LPR (AT91_DDRSDRC + 0x18) /* Low Power Register */
67#define AT91_DDRSDRC_LPCB (3 << 0) /* Low-power Configurations */
68#define AT91_DDRSDRC_LPCB_DISABLE 0
69#define AT91_DDRSDRC_LPCB_SELF_REFRESH 1
70#define AT91_DDRSDRC_LPCB_POWER_DOWN 2
71#define AT91_DDRSDRC_LPCB_DEEP_POWER_DOWN 3
72#define AT91_DDRSDRC_CLKFR (1 << 2) /* Clock Frozen */
73#define AT91_DDRSDRC_PASR (7 << 4) /* Partial Array Self Refresh */
74#define AT91_DDRSDRC_TCSR (3 << 8) /* Temperature Compensated Self Refresh */
75#define AT91_DDRSDRC_DS (3 << 10) /* Drive Strength */
76#define AT91_DDRSDRC_TIMEOUT (3 << 12) /* Time to define when Low Power Mode is enabled */
77#define AT91_DDRSDRC_TIMEOUT_0_CLK_CYCLES (0 << 12)
78#define AT91_DDRSDRC_TIMEOUT_64_CLK_CYCLES (1 << 12)
79#define AT91_DDRSDRC_TIMEOUT_128_CLK_CYCLES (2 << 12)
80
81#define AT91_DDRSDRC_MDR (AT91_DDRSDRC + 0x1C) /* Memory Device Register */
82#define AT91_DDRSDRC_MD (3 << 0) /* Memory Device Type */
83#define AT91_DDRSDRC_MD_SDR 0
84#define AT91_DDRSDRC_MD_LOW_POWER_SDR 1
85#define AT91_DDRSDRC_MD_DDR 2
86#define AT91_DDRSDRC_MD_LOW_POWER_DDR 3
87
88#define AT91_DDRSDRC_DLLR (AT91_DDRSDRC + 0x20) /* DLL Information Register */
89#define AT91_DDRSDRC_MDINC (1 << 0) /* Master Delay increment */
90#define AT91_DDRSDRC_MDDEC (1 << 1) /* Master Delay decrement */
91#define AT91_DDRSDRC_MDOVF (1 << 2) /* Master Delay Overflow */
92#define AT91_DDRSDRC_SDCOVF (1 << 3) /* Slave Delay Correction Overflow */
93#define AT91_DDRSDRC_SDCUDF (1 << 4) /* Slave Delay Correction Underflow */
94#define AT91_DDRSDRC_SDERF (1 << 5) /* Slave Delay Correction error */
95#define AT91_DDRSDRC_MDVAL (0xff << 8) /* Master Delay value */
96#define AT91_DDRSDRC_SDVAL (0xff << 16) /* Slave Delay value */
97#define AT91_DDRSDRC_SDCVAL (0xff << 24) /* Slave Delay Correction value */
98
99
100#endif
diff --git a/include/asm-arm/arch-at91/at91sam926x_mc.h b/include/asm-arm/arch-at91/at91sam9_sdramc.h
index d82631c251f1..d3b8b3da6b4d 100644
--- a/include/asm-arm/arch-at91/at91sam926x_mc.h
+++ b/include/asm-arm/arch-at91/at91sam9_sdramc.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/asm-arm/arch-at91/at91sam926x_mc.h 2 * include/asm-arm/arch-at91/at91sam9_sdramc.h
3 * 3 *
4 * Memory Controllers (SMC, SDRAMC) - System peripherals registers. 4 * SDRAM Controllers (SDRAMC) - System peripherals registers.
5 * Based on AT91SAM9261 datasheet revision D. 5 * Based on AT91SAM9261 datasheet revision D.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -10,8 +10,8 @@
10 * (at your option) any later version. 10 * (at your option) any later version.
11 */ 11 */
12 12
13#ifndef AT91SAM926x_MC_H 13#ifndef AT91SAM9_SDRAMC_H
14#define AT91SAM926x_MC_H 14#define AT91SAM9_SDRAMC_H
15 15
16/* SDRAM Controller (SDRAMC) registers */ 16/* SDRAM Controller (SDRAMC) registers */
17#define AT91_SDRAMC_MR (AT91_SDRAMC + 0x00) /* SDRAM Controller Mode Register */ 17#define AT91_SDRAMC_MR (AT91_SDRAMC + 0x00) /* SDRAM Controller Mode Register */
@@ -62,7 +62,7 @@
62#define AT91_SDRAMC_LPCB_DEEP_POWER_DOWN 3 62#define AT91_SDRAMC_LPCB_DEEP_POWER_DOWN 3
63#define AT91_SDRAMC_PASR (7 << 4) /* Partial Array Self Refresh */ 63#define AT91_SDRAMC_PASR (7 << 4) /* Partial Array Self Refresh */
64#define AT91_SDRAMC_TCSR (3 << 8) /* Temperature Compensated Self Refresh */ 64#define AT91_SDRAMC_TCSR (3 << 8) /* Temperature Compensated Self Refresh */
65#define AT91_SDRAMC_DS (3 << 10) /* Drive Strenght */ 65#define AT91_SDRAMC_DS (3 << 10) /* Drive Strength */
66#define AT91_SDRAMC_TIMEOUT (3 << 12) /* Time to define when Low Power Mode is enabled */ 66#define AT91_SDRAMC_TIMEOUT (3 << 12) /* Time to define when Low Power Mode is enabled */
67#define AT91_SDRAMC_TIMEOUT_0_CLK_CYCLES (0 << 12) 67#define AT91_SDRAMC_TIMEOUT_0_CLK_CYCLES (0 << 12)
68#define AT91_SDRAMC_TIMEOUT_64_CLK_CYCLES (1 << 12) 68#define AT91_SDRAMC_TIMEOUT_64_CLK_CYCLES (1 << 12)
@@ -80,62 +80,4 @@
80#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1 80#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1
81 81
82 82
83/* Static Memory Controller (SMC) registers */
84#define AT91_SMC_SETUP(n) (AT91_SMC + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
85#define AT91_SMC_NWESETUP (0x3f << 0) /* NWE Setup Length */
86#define AT91_SMC_NWESETUP_(x) ((x) << 0)
87#define AT91_SMC_NCS_WRSETUP (0x3f << 8) /* NCS Setup Length in Write Access */
88#define AT91_SMC_NCS_WRSETUP_(x) ((x) << 8)
89#define AT91_SMC_NRDSETUP (0x3f << 16) /* NRD Setup Length */
90#define AT91_SMC_NRDSETUP_(x) ((x) << 16)
91#define AT91_SMC_NCS_RDSETUP (0x3f << 24) /* NCS Setup Length in Read Access */
92#define AT91_SMC_NCS_RDSETUP_(x) ((x) << 24)
93
94#define AT91_SMC_PULSE(n) (AT91_SMC + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
95#define AT91_SMC_NWEPULSE (0x7f << 0) /* NWE Pulse Length */
96#define AT91_SMC_NWEPULSE_(x) ((x) << 0)
97#define AT91_SMC_NCS_WRPULSE (0x7f << 8) /* NCS Pulse Length in Write Access */
98#define AT91_SMC_NCS_WRPULSE_(x)((x) << 8)
99#define AT91_SMC_NRDPULSE (0x7f << 16) /* NRD Pulse Length */
100#define AT91_SMC_NRDPULSE_(x) ((x) << 16)
101#define AT91_SMC_NCS_RDPULSE (0x7f << 24) /* NCS Pulse Length in Read Access */
102#define AT91_SMC_NCS_RDPULSE_(x)((x) << 24)
103
104#define AT91_SMC_CYCLE(n) (AT91_SMC + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
105#define AT91_SMC_NWECYCLE (0x1ff << 0 ) /* Total Write Cycle Length */
106#define AT91_SMC_NWECYCLE_(x) ((x) << 0)
107#define AT91_SMC_NRDCYCLE (0x1ff << 16) /* Total Read Cycle Length */
108#define AT91_SMC_NRDCYCLE_(x) ((x) << 16)
109
110#define AT91_SMC_MODE(n) (AT91_SMC + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
111#define AT91_SMC_READMODE (1 << 0) /* Read Mode */
112#define AT91_SMC_WRITEMODE (1 << 1) /* Write Mode */
113#define AT91_SMC_EXNWMODE (3 << 4) /* NWAIT Mode */
114#define AT91_SMC_EXNWMODE_DISABLE (0 << 4)
115#define AT91_SMC_EXNWMODE_FROZEN (2 << 4)
116#define AT91_SMC_EXNWMODE_READY (3 << 4)
117#define AT91_SMC_BAT (1 << 8) /* Byte Access Type */
118#define AT91_SMC_BAT_SELECT (0 << 8)
119#define AT91_SMC_BAT_WRITE (1 << 8)
120#define AT91_SMC_DBW (3 << 12) /* Data Bus Width */
121#define AT91_SMC_DBW_8 (0 << 12)
122#define AT91_SMC_DBW_16 (1 << 12)
123#define AT91_SMC_DBW_32 (2 << 12)
124#define AT91_SMC_TDF (0xf << 16) /* Data Float Time. */
125#define AT91_SMC_TDF_(x) ((x) << 16)
126#define AT91_SMC_TDFMODE (1 << 20) /* TDF Optimization - Enabled */
127#define AT91_SMC_PMEN (1 << 24) /* Page Mode Enabled */
128#define AT91_SMC_PS (3 << 28) /* Page Size */
129#define AT91_SMC_PS_4 (0 << 28)
130#define AT91_SMC_PS_8 (1 << 28)
131#define AT91_SMC_PS_16 (2 << 28)
132#define AT91_SMC_PS_32 (3 << 28)
133
134#if defined(AT91_SMC1) /* The AT91SAM9263 has 2 Static Memory contollers */
135#define AT91_SMC1_SETUP(n) (AT91_SMC1 + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
136#define AT91_SMC1_PULSE(n) (AT91_SMC1 + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
137#define AT91_SMC1_CYCLE(n) (AT91_SMC1 + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
138#define AT91_SMC1_MODE(n) (AT91_SMC1 + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
139#endif
140
141#endif 83#endif
diff --git a/include/asm-arm/arch-at91/at91sam9_smc.h b/include/asm-arm/arch-at91/at91sam9_smc.h
new file mode 100644
index 000000000000..9e49eed31e50
--- /dev/null
+++ b/include/asm-arm/arch-at91/at91sam9_smc.h
@@ -0,0 +1,73 @@
1/*
2 * include/asm-arm/arch-at91/at91sam9_smc.h
3 *
4 * Static Memory Controllers (SMC) - System peripherals registers.
5 * Based on AT91SAM9261 datasheet revision D.
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 AT91SAM9_SMC_H
14#define AT91SAM9_SMC_H
15
16#define AT91_SMC_SETUP(n) (AT91_SMC + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
17#define AT91_SMC_NWESETUP (0x3f << 0) /* NWE Setup Length */
18#define AT91_SMC_NWESETUP_(x) ((x) << 0)
19#define AT91_SMC_NCS_WRSETUP (0x3f << 8) /* NCS Setup Length in Write Access */
20#define AT91_SMC_NCS_WRSETUP_(x) ((x) << 8)
21#define AT91_SMC_NRDSETUP (0x3f << 16) /* NRD Setup Length */
22#define AT91_SMC_NRDSETUP_(x) ((x) << 16)
23#define AT91_SMC_NCS_RDSETUP (0x3f << 24) /* NCS Setup Length in Read Access */
24#define AT91_SMC_NCS_RDSETUP_(x) ((x) << 24)
25
26#define AT91_SMC_PULSE(n) (AT91_SMC + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
27#define AT91_SMC_NWEPULSE (0x7f << 0) /* NWE Pulse Length */
28#define AT91_SMC_NWEPULSE_(x) ((x) << 0)
29#define AT91_SMC_NCS_WRPULSE (0x7f << 8) /* NCS Pulse Length in Write Access */
30#define AT91_SMC_NCS_WRPULSE_(x)((x) << 8)
31#define AT91_SMC_NRDPULSE (0x7f << 16) /* NRD Pulse Length */
32#define AT91_SMC_NRDPULSE_(x) ((x) << 16)
33#define AT91_SMC_NCS_RDPULSE (0x7f << 24) /* NCS Pulse Length in Read Access */
34#define AT91_SMC_NCS_RDPULSE_(x)((x) << 24)
35
36#define AT91_SMC_CYCLE(n) (AT91_SMC + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
37#define AT91_SMC_NWECYCLE (0x1ff << 0 ) /* Total Write Cycle Length */
38#define AT91_SMC_NWECYCLE_(x) ((x) << 0)
39#define AT91_SMC_NRDCYCLE (0x1ff << 16) /* Total Read Cycle Length */
40#define AT91_SMC_NRDCYCLE_(x) ((x) << 16)
41
42#define AT91_SMC_MODE(n) (AT91_SMC + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
43#define AT91_SMC_READMODE (1 << 0) /* Read Mode */
44#define AT91_SMC_WRITEMODE (1 << 1) /* Write Mode */
45#define AT91_SMC_EXNWMODE (3 << 4) /* NWAIT Mode */
46#define AT91_SMC_EXNWMODE_DISABLE (0 << 4)
47#define AT91_SMC_EXNWMODE_FROZEN (2 << 4)
48#define AT91_SMC_EXNWMODE_READY (3 << 4)
49#define AT91_SMC_BAT (1 << 8) /* Byte Access Type */
50#define AT91_SMC_BAT_SELECT (0 << 8)
51#define AT91_SMC_BAT_WRITE (1 << 8)
52#define AT91_SMC_DBW (3 << 12) /* Data Bus Width */
53#define AT91_SMC_DBW_8 (0 << 12)
54#define AT91_SMC_DBW_16 (1 << 12)
55#define AT91_SMC_DBW_32 (2 << 12)
56#define AT91_SMC_TDF (0xf << 16) /* Data Float Time. */
57#define AT91_SMC_TDF_(x) ((x) << 16)
58#define AT91_SMC_TDFMODE (1 << 20) /* TDF Optimization - Enabled */
59#define AT91_SMC_PMEN (1 << 24) /* Page Mode Enabled */
60#define AT91_SMC_PS (3 << 28) /* Page Size */
61#define AT91_SMC_PS_4 (0 << 28)
62#define AT91_SMC_PS_8 (1 << 28)
63#define AT91_SMC_PS_16 (2 << 28)
64#define AT91_SMC_PS_32 (3 << 28)
65
66#if defined(AT91_SMC1) /* The AT91SAM9263 has 2 Static Memory contollers */
67#define AT91_SMC1_SETUP(n) (AT91_SMC1 + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
68#define AT91_SMC1_PULSE(n) (AT91_SMC1 + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
69#define AT91_SMC1_CYCLE(n) (AT91_SMC1 + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
70#define AT91_SMC1_MODE(n) (AT91_SMC1 + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
71#endif
72
73#endif
diff --git a/include/asm-arm/arch-ep93xx/gpio.h b/include/asm-arm/arch-ep93xx/gpio.h
index 9b1864bbd9a8..186e7c715f8a 100644
--- a/include/asm-arm/arch-ep93xx/gpio.h
+++ b/include/asm-arm/arch-ep93xx/gpio.h
@@ -101,30 +101,17 @@
101 101
102/* new generic GPIO API - see Documentation/gpio.txt */ 102/* new generic GPIO API - see Documentation/gpio.txt */
103 103
104static inline int gpio_request(unsigned gpio, const char *label) 104#include <asm-generic/gpio.h>
105{
106 if (gpio > EP93XX_GPIO_LINE_MAX)
107 return -EINVAL;
108 return 0;
109}
110 105
111static inline void gpio_free(unsigned gpio) 106#define gpio_get_value __gpio_get_value
112{ 107#define gpio_set_value __gpio_set_value
113} 108#define gpio_cansleep __gpio_cansleep
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 109
122/* 110/*
123 * Map GPIO A0..A7 (0..7) to irq 64..71, 111 * Map GPIO A0..A7 (0..7) to irq 64..71,
124 * B0..B7 (7..15) to irq 72..79, and 112 * B0..B7 (7..15) to irq 72..79, and
125 * F0..F7 (16..24) to irq 80..87. 113 * F0..F7 (16..24) to irq 80..87.
126 */ 114 */
127
128static inline int gpio_to_irq(unsigned gpio) 115static inline int gpio_to_irq(unsigned gpio)
129{ 116{
130 if (gpio <= EP93XX_GPIO_LINE_MAX_IRQ) 117 if (gpio <= EP93XX_GPIO_LINE_MAX_IRQ)
diff --git a/include/asm-arm/arch-iop13xx/adma.h b/include/asm-arm/arch-iop13xx/adma.h
index efd9a5eb1008..90d14ee564f5 100644
--- a/include/asm-arm/arch-iop13xx/adma.h
+++ b/include/asm-arm/arch-iop13xx/adma.h
@@ -454,11 +454,6 @@ static inline void iop_chan_append(struct iop_adma_chan *chan)
454 __raw_writel(adma_accr, ADMA_ACCR(chan)); 454 __raw_writel(adma_accr, ADMA_ACCR(chan));
455} 455}
456 456
457static inline void iop_chan_idle(int busy, struct iop_adma_chan *chan)
458{
459 do { } while (0);
460}
461
462static inline u32 iop_chan_get_status(struct iop_adma_chan *chan) 457static inline u32 iop_chan_get_status(struct iop_adma_chan *chan)
463{ 458{
464 return __raw_readl(ADMA_ACSR(chan)); 459 return __raw_readl(ADMA_ACSR(chan));
diff --git a/include/asm-arm/arch-ks8695/devices.h b/include/asm-arm/arch-ks8695/devices.h
index b0364dce463f..7ad2c656e162 100644
--- a/include/asm-arm/arch-ks8695/devices.h
+++ b/include/asm-arm/arch-ks8695/devices.h
@@ -18,6 +18,11 @@ extern void __init ks8695_add_device_wan(void);
18extern void __init ks8695_add_device_lan(void); 18extern void __init ks8695_add_device_lan(void);
19extern void __init ks8695_add_device_hpna(void); 19extern void __init ks8695_add_device_hpna(void);
20 20
21 /* LEDs */
22extern short ks8695_leds_cpu;
23extern short ks8695_leds_timer;
24extern void __init ks8695_init_leds(u8 cpu_led, u8 timer_led);
25
21 /* PCI */ 26 /* PCI */
22#define KS8695_MODE_PCI 0 27#define KS8695_MODE_PCI 0
23#define KS8695_MODE_MINIPCI 1 28#define KS8695_MODE_MINIPCI 1
diff --git a/include/asm-arm/arch-mxc/board-mx31ads.h b/include/asm-arm/arch-mxc/board-mx31ads.h
index be29b83ad4ae..8590127760a8 100644
--- a/include/asm-arm/arch-mxc/board-mx31ads.h
+++ b/include/asm-arm/arch-mxc/board-mx31ads.h
@@ -11,107 +11,77 @@
11#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__ 11#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__
12#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__ 12#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__
13 13
14/*! 14/* Base address of PBC controller */
15 * @name PBC Controller parameters
16 */
17/*! @{ */
18/*!
19 * Base address of PBC controller
20 */
21#define PBC_BASE_ADDRESS IO_ADDRESS(CS4_BASE_ADDR) 15#define PBC_BASE_ADDRESS IO_ADDRESS(CS4_BASE_ADDR)
22/* Offsets for the PBC Controller register */ 16/* Offsets for the PBC Controller register */
23/*! 17
24 * PBC Board status register offset 18/* PBC Board status register offset */
25 */
26#define PBC_BSTAT 0x000002 19#define PBC_BSTAT 0x000002
27/*! 20
28 * PBC Board control register 1 set address. 21/* PBC Board control register 1 set address */
29 */
30#define PBC_BCTRL1_SET 0x000004 22#define PBC_BCTRL1_SET 0x000004
31/*! 23
32 * PBC Board control register 1 clear address. 24/* PBC Board control register 1 clear address */
33 */
34#define PBC_BCTRL1_CLEAR 0x000006 25#define PBC_BCTRL1_CLEAR 0x000006
35/*! 26
36 * PBC Board control register 2 set address. 27/* PBC Board control register 2 set address */
37 */
38#define PBC_BCTRL2_SET 0x000008 28#define PBC_BCTRL2_SET 0x000008
39/*! 29
40 * PBC Board control register 2 clear address. 30/* PBC Board control register 2 clear address */
41 */
42#define PBC_BCTRL2_CLEAR 0x00000A 31#define PBC_BCTRL2_CLEAR 0x00000A
43/*! 32
44 * PBC Board control register 3 set address. 33/* PBC Board control register 3 set address */
45 */
46#define PBC_BCTRL3_SET 0x00000C 34#define PBC_BCTRL3_SET 0x00000C
47/*! 35
48 * PBC Board control register 3 clear address. 36/* PBC Board control register 3 clear address */
49 */
50#define PBC_BCTRL3_CLEAR 0x00000E 37#define PBC_BCTRL3_CLEAR 0x00000E
51/*! 38
52 * PBC Board control register 4 set address. 39/* PBC Board control register 4 set address */
53 */
54#define PBC_BCTRL4_SET 0x000010 40#define PBC_BCTRL4_SET 0x000010
55/*! 41
56 * PBC Board control register 4 clear address. 42/* PBC Board control register 4 clear address */
57 */
58#define PBC_BCTRL4_CLEAR 0x000012 43#define PBC_BCTRL4_CLEAR 0x000012
59/*! 44
60 * PBC Board status register 1. 45/* PBC Board status register 1 */
61 */
62#define PBC_BSTAT1 0x000014 46#define PBC_BSTAT1 0x000014
63/*! 47
64 * PBC Board interrupt status register. 48/* PBC Board interrupt status register */
65 */
66#define PBC_INTSTATUS 0x000016 49#define PBC_INTSTATUS 0x000016
67/*! 50
68 * PBC Board interrupt current status register. 51/* PBC Board interrupt current status register */
69 */
70#define PBC_INTCURR_STATUS 0x000018 52#define PBC_INTCURR_STATUS 0x000018
71/*! 53
72 * PBC Interrupt mask register set address. 54/* PBC Interrupt mask register set address */
73 */
74#define PBC_INTMASK_SET 0x00001A 55#define PBC_INTMASK_SET 0x00001A
75/*! 56
76 * PBC Interrupt mask register clear address. 57/* PBC Interrupt mask register clear address */
77 */
78#define PBC_INTMASK_CLEAR 0x00001C 58#define PBC_INTMASK_CLEAR 0x00001C
79 59
80/*! 60/* External UART A */
81 * External UART A.
82 */
83#define PBC_SC16C652_UARTA 0x010000 61#define PBC_SC16C652_UARTA 0x010000
84/*! 62
85 * External UART B. 63/* External UART B */
86 */
87#define PBC_SC16C652_UARTB 0x010010 64#define PBC_SC16C652_UARTB 0x010010
88/*! 65
89 * Ethernet Controller IO base address. 66/* Ethernet Controller IO base address */
90 */
91#define PBC_CS8900A_IOBASE 0x020000 67#define PBC_CS8900A_IOBASE 0x020000
92/*! 68
93 * Ethernet Controller Memory base address. 69/* Ethernet Controller Memory base address */
94 */
95#define PBC_CS8900A_MEMBASE 0x021000 70#define PBC_CS8900A_MEMBASE 0x021000
96/*! 71
97 * Ethernet Controller DMA base address. 72/* Ethernet Controller DMA base address */
98 */
99#define PBC_CS8900A_DMABASE 0x022000 73#define PBC_CS8900A_DMABASE 0x022000
100/*! 74
101 * External chip select 0. 75/* External chip select 0 */
102 */
103#define PBC_XCS0 0x040000 76#define PBC_XCS0 0x040000
104/*! 77
105 * LCD Display enable. 78/* LCD Display enable */
106 */
107#define PBC_LCD_EN_B 0x060000 79#define PBC_LCD_EN_B 0x060000
108/*! 80
109 * Code test debug enable. 81/* Code test debug enable */
110 */
111#define PBC_CODE_B 0x070000 82#define PBC_CODE_B 0x070000
112/*! 83
113 * PSRAM memory select. 84/* PSRAM memory select */
114 */
115#define PBC_PSRAM_B 0x5000000 85#define PBC_PSRAM_B 0x5000000
116 86
117#define PBC_INTSTATUS_REG (PBC_INTSTATUS + PBC_BASE_ADDRESS) 87#define PBC_INTSTATUS_REG (PBC_INTSTATUS + PBC_BASE_ADDRESS)
@@ -139,4 +109,4 @@
139 109
140#define MXC_MAX_EXP_IO_LINES 16 110#define MXC_MAX_EXP_IO_LINES 16
141 111
142#endif /* __ASM_ARCH_MXC_BOARD_MX31ADS_H__ */ 112#endif /* __ASM_ARCH_MXC_BOARD_MX31ADS_H__ */
diff --git a/include/asm-arm/arch-mxc/dma.h b/include/asm-arm/arch-mxc/dma.h
index 65e639d51d2b..c822d569a05e 100644
--- a/include/asm-arm/arch-mxc/dma.h
+++ b/include/asm-arm/arch-mxc/dma.h
@@ -11,11 +11,4 @@
11#ifndef __ASM_ARCH_MXC_DMA_H__ 11#ifndef __ASM_ARCH_MXC_DMA_H__
12#define __ASM_ARCH_MXC_DMA_H__ 12#define __ASM_ARCH_MXC_DMA_H__
13 13
14/*!
15 * @file dma.h
16 * @brief This file contains Unified DMA API for all MXC platforms.
17 * The API is platform independent.
18 *
19 * @ingroup SDMA
20 */
21#endif 14#endif
diff --git a/include/asm-arm/arch-mxc/hardware.h b/include/asm-arm/arch-mxc/hardware.h
index 3c09b92fef0d..e87ff0679d5e 100644
--- a/include/asm-arm/arch-mxc/hardware.h
+++ b/include/asm-arm/arch-mxc/hardware.h
@@ -8,45 +8,24 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11/*!
12 * @file hardware.h
13 * @brief This file contains the hardware definitions of the board.
14 *
15 * @ingroup System
16 */
17#ifndef __ASM_ARCH_MXC_HARDWARE_H__ 11#ifndef __ASM_ARCH_MXC_HARDWARE_H__
18#define __ASM_ARCH_MXC_HARDWARE_H__ 12#define __ASM_ARCH_MXC_HARDWARE_H__
19 13
20#include <asm/sizes.h> 14#include <asm/sizes.h>
21 15
22#include <asm/arch/mx31.h> 16#ifdef CONFIG_ARCH_MX3
17# include <asm/arch/mx31.h>
18#endif
23 19
24#include <asm/arch/mxc.h> 20#include <asm/arch/mxc.h>
25 21
26#define MXC_MAX_GPIO_LINES (GPIO_NUM_PIN * GPIO_PORT_NUM)
27
28/* 22/*
29 * --------------------------------------------------------------------------- 23 * ---------------------------------------------------------------------------
30 * Board specific defines 24 * Board specific defines
31 * --------------------------------------------------------------------------- 25 * ---------------------------------------------------------------------------
32 */ 26 */
33#define MXC_EXP_IO_BASE (MXC_GPIO_INT_BASE + MXC_MAX_GPIO_LINES) 27#ifdef CONFIG_MACH_MX31ADS
34 28# include <asm/arch/board-mx31ads.h>
35#include <asm/arch/board-mx31ads.h>
36
37#ifndef MXC_MAX_EXP_IO_LINES
38#define MXC_MAX_EXP_IO_LINES 0
39#endif 29#endif
40 30
41#define MXC_MAX_VIRTUAL_INTS 16 31#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */
42#define MXC_VIRTUAL_INTS_BASE (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES)
43#define MXC_SDIO1_CARD_IRQ MXC_VIRTUAL_INTS_BASE
44#define MXC_SDIO2_CARD_IRQ (MXC_VIRTUAL_INTS_BASE + 1)
45#define MXC_SDIO3_CARD_IRQ (MXC_VIRTUAL_INTS_BASE + 2)
46
47#define MXC_MAX_INTS (MXC_MAX_INT_LINES + \
48 MXC_MAX_GPIO_LINES + \
49 MXC_MAX_EXP_IO_LINES + \
50 MXC_MAX_VIRTUAL_INTS)
51
52#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */
diff --git a/include/asm-arm/arch-mxc/io.h b/include/asm-arm/arch-mxc/io.h
index cf6c83a4b9f7..65b6810124c1 100644
--- a/include/asm-arm/arch-mxc/io.h
+++ b/include/asm-arm/arch-mxc/io.h
@@ -8,24 +8,13 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11/*!
12 * @file io.h
13 * @brief This file contains some memory mapping macros.
14 * @note There is no real ISA or PCI buses. But have to define these macros
15 * for some drivers to compile.
16 *
17 * @ingroup System
18 */
19
20#ifndef __ASM_ARCH_MXC_IO_H__ 11#ifndef __ASM_ARCH_MXC_IO_H__
21#define __ASM_ARCH_MXC_IO_H__ 12#define __ASM_ARCH_MXC_IO_H__
22 13
23/*! Allow IO space to be anywhere in the memory */ 14/* Allow IO space to be anywhere in the memory */
24#define IO_SPACE_LIMIT 0xffffffff 15#define IO_SPACE_LIMIT 0xffffffff
25 16
26/*! 17/* io address mapping macro */
27 * io address mapping macro
28 */
29#define __io(a) ((void __iomem *)(a)) 18#define __io(a) ((void __iomem *)(a))
30 19
31#define __mem_pci(a) (a) 20#define __mem_pci(a) (a)
diff --git a/include/asm-arm/arch-mxc/irqs.h b/include/asm-arm/arch-mxc/irqs.h
index e4686c6bc4bf..b2c5205e1962 100644
--- a/include/asm-arm/arch-mxc/irqs.h
+++ b/include/asm-arm/arch-mxc/irqs.h
@@ -13,26 +13,17 @@
13 13
14#include <asm/hardware.h> 14#include <asm/hardware.h>
15 15
16/*!
17 * @file irqs.h
18 * @brief This file defines the number of normal interrupts and fast interrupts
19 *
20 * @ingroup Interrupt
21 */
22
23#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE) 16#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE)
24 17
25#define MXC_IRQ_TO_GPIO(irq) ((irq) - MXC_GPIO_INT_BASE) 18#define MXC_IRQ_TO_GPIO(irq) ((irq) - MXC_GPIO_INT_BASE)
26#define MXC_GPIO_TO_IRQ(x) (MXC_GPIO_INT_BASE + x) 19#define MXC_GPIO_TO_IRQ(x) (MXC_GPIO_INT_BASE + x)
27 20
28/*! 21/* Number of normal interrupts */
29 * Number of normal interrupts 22#define NR_IRQS (MXC_MAX_INT_LINES + \
30 */ 23 MXC_MAX_GPIO_LINES + \
31#define NR_IRQS MXC_MAX_INTS 24 MXC_MAX_VIRTUAL_INTS)
32 25
33/*! 26/* Number of fast interrupts */
34 * Number of fast interrupts
35 */
36#define NR_FIQS MXC_MAX_INTS 27#define NR_FIQS MXC_MAX_INTS
37 28
38#endif /* __ASM_ARCH_MXC_IRQS_H__ */ 29#endif /* __ASM_ARCH_MXC_IRQS_H__ */
diff --git a/include/asm-arm/arch-mxc/memory.h b/include/asm-arm/arch-mxc/memory.h
index c89aac83a407..059f83023a10 100644
--- a/include/asm-arm/arch-mxc/memory.h
+++ b/include/asm-arm/arch-mxc/memory.h
@@ -13,24 +13,17 @@
13 13
14#include <asm/hardware.h> 14#include <asm/hardware.h>
15 15
16/*! 16/*
17 * @file memory.h
18 * @brief This file contains macros needed by the Linux kernel and drivers.
19 *
20 * @ingroup Memory
21 */
22
23/*!
24 * Virtual view <-> DMA view memory address translations 17 * Virtual view <-> DMA view memory address translations
25 * This macro is used to translate the virtual address to an address 18 * This macro is used to translate the virtual address to an address
26 * suitable to be passed to set_dma_addr() 19 * suitable to be passed to set_dma_addr()
27 */ 20 */
28#define __virt_to_bus(a) __virt_to_phys(a) 21#define __virt_to_bus(a) __virt_to_phys(a)
29 22
30/*! 23/*
31 * Used to convert an address for DMA operations to an address that the 24 * Used to convert an address for DMA operations to an address that the
32 * kernel can use. 25 * kernel can use.
33 */ 26 */
34#define __bus_to_virt(a) __phys_to_virt(a) 27#define __bus_to_virt(a) __phys_to_virt(a)
35 28
36#endif /* __ASM_ARCH_MXC_MEMORY_H__ */ 29#endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/include/asm-arm/arch-mxc/mx31.h b/include/asm-arm/arch-mxc/mx31.h
index 85c49c9e5d15..36a1af495bb3 100644
--- a/include/asm-arm/arch-mxc/mx31.h
+++ b/include/asm-arm/arch-mxc/mx31.h
@@ -317,6 +317,8 @@
317#define MXC_MAX_INT_LINES 64 317#define MXC_MAX_INT_LINES 64
318 318
319#define MXC_GPIO_INT_BASE MXC_MAX_INT_LINES 319#define MXC_GPIO_INT_BASE MXC_MAX_INT_LINES
320#define MXC_MAX_GPIO_LINES (GPIO_NUM_PIN * GPIO_PORT_NUM)
321#define MXC_MAX_VIRTUAL_INTS 16
320 322
321/*! 323/*!
322 * Number of GPIO port as defined in the IC Spec 324 * Number of GPIO port as defined in the IC Spec
@@ -329,7 +331,33 @@
329 331
330#define PROD_SIGNATURE 0x1 /* For MX31 */ 332#define PROD_SIGNATURE 0x1 /* For MX31 */
331 333
334/* silicon revisions specific to i.MX31 */
335#define CHIP_REV_1_0 0x10
336#define CHIP_REV_1_1 0x11
337#define CHIP_REV_1_2 0x12
338#define CHIP_REV_1_3 0x13
339#define CHIP_REV_2_0 0x20
340#define CHIP_REV_2_1 0x21
341#define CHIP_REV_2_2 0x22
342#define CHIP_REV_2_3 0x23
343#define CHIP_REV_3_0 0x30
344#define CHIP_REV_3_1 0x31
345#define CHIP_REV_3_2 0x32
346
332#define SYSTEM_REV_MIN CHIP_REV_1_0 347#define SYSTEM_REV_MIN CHIP_REV_1_0
333#define SYSTEM_REV_NUM 3 348#define SYSTEM_REV_NUM 3
334 349
335#endif /* __ASM_ARCH_MXC_MX31_H__ */ 350#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS)
351
352/* this is a i.MX31 CPU */
353#define cpu_is_mx31() (1)
354
355extern unsigned int system_rev;
356
357static inline int mx31_revision(void)
358{
359 return system_rev;
360}
361#endif
362
363#endif /* __ASM_ARCH_MXC_MX31_H__ */
diff --git a/include/asm-arm/arch-mxc/mxc.h b/include/asm-arm/arch-mxc/mxc.h
index 0837f1f9ca31..146d3f60951a 100644
--- a/include/asm-arm/arch-mxc/mxc.h
+++ b/include/asm-arm/arch-mxc/mxc.h
@@ -15,6 +15,11 @@
15#error "Do not include directly." 15#error "Do not include directly."
16#endif 16#endif
17 17
18/* clean up all things that are not used */
19#ifndef CONFIG_ARCH_MX3
20# define cpu_is_mx31() (0)
21#endif
22
18/* 23/*
19 ***************************************** 24 *****************************************
20 * GPT Register definitions * 25 * GPT Register definitions *
@@ -31,9 +36,7 @@
31#define MXC_GPT_GPTICR2 IO_ADDRESS(GPT1_BASE_ADDR + 0x20) 36#define MXC_GPT_GPTICR2 IO_ADDRESS(GPT1_BASE_ADDR + 0x20)
32#define MXC_GPT_GPTCNT IO_ADDRESS(GPT1_BASE_ADDR + 0x24) 37#define MXC_GPT_GPTCNT IO_ADDRESS(GPT1_BASE_ADDR + 0x24)
33 38
34/*! 39/* GPT Control register bit definitions */
35 * GPT Control register bit definitions
36 */
37#define GPTCR_FO3 (1 << 31) 40#define GPTCR_FO3 (1 << 31)
38#define GPTCR_FO2 (1 << 30) 41#define GPTCR_FO2 (1 << 30)
39#define GPTCR_FO1 (1 << 29) 42#define GPTCR_FO1 (1 << 29)
@@ -146,4 +149,4 @@
146#define IIM_PROD_REV_SH 3 149#define IIM_PROD_REV_SH 3
147#define IIM_PROD_REV_LEN 5 150#define IIM_PROD_REV_LEN 5
148 151
149#endif /* __ASM_ARCH_MXC_H__ */ 152#endif /* __ASM_ARCH_MXC_H__ */
diff --git a/include/asm-arm/arch-mxc/system.h b/include/asm-arm/arch-mxc/system.h
index 109956b41aca..bbfc37465fc5 100644
--- a/include/asm-arm/arch-mxc/system.h
+++ b/include/asm-arm/arch-mxc/system.h
@@ -21,30 +21,14 @@
21#ifndef __ASM_ARCH_MXC_SYSTEM_H__ 21#ifndef __ASM_ARCH_MXC_SYSTEM_H__
22#define __ASM_ARCH_MXC_SYSTEM_H__ 22#define __ASM_ARCH_MXC_SYSTEM_H__
23 23
24/*!
25 * @file system.h
26 * @brief This file contains idle and reset functions.
27 *
28 * @ingroup System
29 */
30
31/*!
32 * This function puts the CPU into idle mode. It is called by default_idle()
33 * in process.c file.
34 */
35static inline void arch_idle(void) 24static inline void arch_idle(void)
36{ 25{
37 cpu_do_idle(); 26 cpu_do_idle();
38} 27}
39 28
40/*
41 * This function resets the system. It is called by machine_restart().
42 *
43 * @param mode indicates different kinds of resets
44 */
45static inline void arch_reset(char mode) 29static inline void arch_reset(char mode)
46{ 30{
47 cpu_reset(0); 31 cpu_reset(0);
48} 32}
49 33
50#endif /* __ASM_ARCH_MXC_SYSTEM_H__ */ 34#endif /* __ASM_ARCH_MXC_SYSTEM_H__ */
diff --git a/include/asm-arm/arch-mxc/vmalloc.h b/include/asm-arm/arch-mxc/vmalloc.h
index 83a73da895eb..62d97623412f 100644
--- a/include/asm-arm/arch-mxc/vmalloc.h
+++ b/include/asm-arm/arch-mxc/vmalloc.h
@@ -20,17 +20,7 @@
20#ifndef __ASM_ARCH_MXC_VMALLOC_H__ 20#ifndef __ASM_ARCH_MXC_VMALLOC_H__
21#define __ASM_ARCH_MXC_VMALLOC_H__ 21#define __ASM_ARCH_MXC_VMALLOC_H__
22 22
23/*! 23/* vmalloc ending address */
24 * @file vmalloc.h
25 *
26 * @brief This file contains platform specific macros for vmalloc.
27 *
28 * @ingroup System
29 */
30
31/*!
32 * vmalloc ending address
33 */
34#define VMALLOC_END 0xF4000000 24#define VMALLOC_END 0xF4000000
35 25
36#endif /* __ASM_ARCH_MXC_VMALLOC_H__ */ 26#endif /* __ASM_ARCH_MXC_VMALLOC_H__ */
diff --git a/include/asm-arm/arch-ns9xxx/board.h b/include/asm-arm/arch-ns9xxx/board.h
index 716f34fdb716..e57443bdbbd9 100644
--- a/include/asm-arm/arch-ns9xxx/board.h
+++ b/include/asm-arm/arch-ns9xxx/board.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/asm-arm/arch-ns9xxx/board.h 2 * include/asm-arm/arch-ns9xxx/board.h
3 * 3 *
4 * Copyright (C) 2006 by Digi International Inc. 4 * Copyright (C) 2006,2007 by Digi International Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
@@ -13,8 +13,30 @@
13 13
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
15 15
16#define board_is_a9m9750dev() (machine_is_cc9p9360dev()) 16#define board_is_a9m9750dev() (0 \
17 || machine_is_cc9p9360dev() \
18 || machine_is_cc9p9750dev() \
19 )
17 20
18#define board_is_jscc9p9360() (machine_is_cc9p9360js()) 21#define board_is_a9mvali() (0 \
22 || machine_is_cc9p9360val() \
23 || machine_is_cc9p9750val() \
24 )
25
26#define board_is_jscc9p9210() (0 \
27 || machine_is_cc9p9210js() \
28 )
29
30#define board_is_jscc9p9215() (0 \
31 || machine_is_cc9p9215js() \
32 )
33
34#define board_is_jscc9p9360() (0 \
35 || machine_is_cc9p9360js() \
36 )
37
38#define board_is_uncbas() (0 \
39 || machine_is_cc7ucamry() \
40 )
19 41
20#endif /* ifndef __ASM_ARCH_BOARD_H */ 42#endif /* ifndef __ASM_ARCH_BOARD_H */
diff --git a/include/asm-arm/arch-ns9xxx/clock.h b/include/asm-arm/arch-ns9xxx/clock.h
deleted file mode 100644
index b943d3a92a1d..000000000000
--- a/include/asm-arm/arch-ns9xxx/clock.h
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * include/asm-arm/arch-ns9xxx/clock.h
3 *
4 * Copyright (C) 2007 by Digi International Inc.
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11#ifndef __ASM_ARCH_CLOCK_H
12#define __ASM_ARCH_CLOCK_H
13
14#include <asm/arch-ns9xxx/regs-sys.h>
15
16#define CRYSTAL 29491200 /* Hz */
17
18/* The HRM calls this value f_vco */
19static inline u32 ns9xxx_systemclock(void) __attribute__((const));
20static inline u32 ns9xxx_systemclock(void)
21{
22 u32 pll = __raw_readl(SYS_PLL);
23
24 /*
25 * The system clock should be a multiple of HZ * TIMERCLOCKSELECT (in
26 * time.c).
27 *
28 * The following values are given:
29 * - TIMERCLOCKSELECT == 2^i for an i in {0 .. 6}
30 * - CRYSTAL == 29491200 == 2^17 * 3^2 * 5^2
31 * - ND in {0 .. 31}
32 * - FS in {0 .. 3}
33 *
34 * Assuming the worst, we consider:
35 * - TIMERCLOCKSELECT == 64
36 * - ND == 0
37 * - FS == 3
38 *
39 * So HZ should be a divisor of:
40 * (CRYSTAL * (ND + 1) >> FS) / TIMERCLOCKSELECT
41 * == (2^17 * 3^2 * 5^2 * 1 >> 3) / 64
42 * == 2^8 * 3^2 * 5^2
43 * == 57600
44 *
45 * Currently HZ is defined to be 100 for this platform.
46 *
47 * Fine.
48 */
49 return CRYSTAL * (REGGETIM(pll, SYS_PLL, ND) + 1)
50 >> REGGETIM(pll, SYS_PLL, FS);
51}
52
53static inline u32 ns9xxx_cpuclock(void) __attribute__((const));
54static inline u32 ns9xxx_cpuclock(void)
55{
56 return ns9xxx_systemclock() / 2;
57}
58
59static inline u32 ns9xxx_ahbclock(void) __attribute__((const));
60static inline u32 ns9xxx_ahbclock(void)
61{
62 return ns9xxx_systemclock() / 4;
63}
64
65static inline u32 ns9xxx_bbusclock(void) __attribute__((const));
66static inline u32 ns9xxx_bbusclock(void)
67{
68 return ns9xxx_systemclock() / 8;
69}
70
71#endif /* ifndef __ASM_ARCH_CLOCK_H */
diff --git a/include/asm-arm/arch-ns9xxx/entry-macro.S b/include/asm-arm/arch-ns9xxx/entry-macro.S
index 86aec87303e4..89a21c530468 100644
--- a/include/asm-arm/arch-ns9xxx/entry-macro.S
+++ b/include/asm-arm/arch-ns9xxx/entry-macro.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/asm-arm/arch-ns9xxx/entry-macro.S 2 * include/asm-arm/arch-ns9xxx/entry-macro.S
3 * 3 *
4 * Copyright (C) 2006 by Digi International Inc. 4 * Copyright (C) 2006,2007 by Digi International Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
@@ -9,16 +9,16 @@
9 * the Free Software Foundation. 9 * the Free Software Foundation.
10 */ 10 */
11#include <asm/hardware.h> 11#include <asm/hardware.h>
12#include <asm/arch-ns9xxx/regs-sys.h> 12#include <asm/arch-ns9xxx/regs-sys-common.h>
13 13
14 .macro get_irqnr_preamble, base, tmp 14 .macro get_irqnr_preamble, base, tmp
15 ldr \base, =SYS_ISRADDR
15 .endm 16 .endm
16 17
17 .macro arch_ret_to_user, tmp1, tmp2 18 .macro arch_ret_to_user, tmp1, tmp2
18 .endm 19 .endm
19 20
20 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 21 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
21 ldr \base, =SYS_ISRADDR
22 ldr \irqstat, [\base, #(SYS_ISA - SYS_ISRADDR)] 22 ldr \irqstat, [\base, #(SYS_ISA - SYS_ISRADDR)]
23 cmp \irqstat, #0 23 cmp \irqstat, #0
24 ldrne \irqnr, [\base] 24 ldrne \irqnr, [\base]
diff --git a/include/asm-arm/arch-ns9xxx/irqs.h b/include/asm-arm/arch-ns9xxx/irqs.h
index 25d8d28b27f3..e83d48ec42c9 100644
--- a/include/asm-arm/arch-ns9xxx/irqs.h
+++ b/include/asm-arm/arch-ns9xxx/irqs.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/asm-arm/arch-ns9xxx/irqs.h 2 * include/asm-arm/arch-ns9xxx/irqs.h
3 * 3 *
4 * Copyright (C) 2006 by Digi International Inc. 4 * Copyright (C) 2006,2007 by Digi International Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
@@ -11,38 +11,39 @@
11#ifndef __ASM_ARCH_IRQS_H 11#ifndef __ASM_ARCH_IRQS_H
12#define __ASM_ARCH_IRQS_H 12#define __ASM_ARCH_IRQS_H
13 13
14#define IRQ_WATCHDOG 0 14/* NetSilicon 9360 */
15#define IRQ_AHBBUSERR 1 15#define IRQ_NS9XXX_WATCHDOG 0
16#define IRQ_BBUSAGG 2 16#define IRQ_NS9XXX_AHBBUSERR 1
17#define IRQ_NS9360_BBUSAGG 2
17/* irq 3 is reserved for NS9360 */ 18/* irq 3 is reserved for NS9360 */
18#define IRQ_ETHRX 4 19#define IRQ_NS9XXX_ETHRX 4
19#define IRQ_ETHTX 5 20#define IRQ_NS9XXX_ETHTX 5
20#define IRQ_ETHPHY 6 21#define IRQ_NS9XXX_ETHPHY 6
21#define IRQ_LCD 7 22#define IRQ_NS9360_LCD 7
22#define IRQ_SERBRX 8 23#define IRQ_NS9360_SERBRX 8
23#define IRQ_SERBTX 9 24#define IRQ_NS9360_SERBTX 9
24#define IRQ_SERARX 10 25#define IRQ_NS9360_SERARX 10
25#define IRQ_SERATX 11 26#define IRQ_NS9360_SERATX 11
26#define IRQ_SERCRX 12 27#define IRQ_NS9360_SERCRX 12
27#define IRQ_SERCTX 13 28#define IRQ_NS9360_SERCTX 13
28#define IRQ_I2C 14 29#define IRQ_NS9360_I2C 14
29#define IRQ_BBUSDMA 15 30#define IRQ_NS9360_BBUSDMA 15
30#define IRQ_TIMER0 16 31#define IRQ_NS9360_TIMER0 16
31#define IRQ_TIMER1 17 32#define IRQ_NS9360_TIMER1 17
32#define IRQ_TIMER2 18 33#define IRQ_NS9360_TIMER2 18
33#define IRQ_TIMER3 19 34#define IRQ_NS9360_TIMER3 19
34#define IRQ_TIMER4 20 35#define IRQ_NS9360_TIMER4 20
35#define IRQ_TIMER5 21 36#define IRQ_NS9360_TIMER5 21
36#define IRQ_TIMER6 22 37#define IRQ_NS9360_TIMER6 22
37#define IRQ_TIMER7 23 38#define IRQ_NS9360_TIMER7 23
38#define IRQ_RTC 24 39#define IRQ_NS9360_RTC 24
39#define IRQ_USBHOST 25 40#define IRQ_NS9360_USBHOST 25
40#define IRQ_USBDEVICE 26 41#define IRQ_NS9360_USBDEVICE 26
41#define IRQ_IEEE1284 27 42#define IRQ_NS9360_IEEE1284 27
42#define IRQ_EXT0 28 43#define IRQ_NS9XXX_EXT0 28
43#define IRQ_EXT1 29 44#define IRQ_NS9XXX_EXT1 29
44#define IRQ_EXT2 30 45#define IRQ_NS9XXX_EXT2 30
45#define IRQ_EXT3 31 46#define IRQ_NS9XXX_EXT3 31
46 47
47#define BBUS_IRQ(irq) (32 + irq) 48#define BBUS_IRQ(irq) (32 + irq)
48 49
@@ -67,7 +68,7 @@
67/* 68/*
68 * these Interrupts are specific for the a9m9750dev board. 69 * these Interrupts are specific for the a9m9750dev board.
69 * They are generated by an FPGA that interrupts the CPU on 70 * They are generated by an FPGA that interrupts the CPU on
70 * IRQ_EXT2 71 * IRQ_NS9360_EXT2
71 */ 72 */
72#define FPGA_IRQ(irq) (64 + irq) 73#define FPGA_IRQ(irq) (64 + irq)
73 74
diff --git a/include/asm-arm/arch-ns9xxx/module.h b/include/asm-arm/arch-ns9xxx/module.h
new file mode 100644
index 000000000000..ac08a31111e4
--- /dev/null
+++ b/include/asm-arm/arch-ns9xxx/module.h
@@ -0,0 +1,60 @@
1/*
2 * include/asm-arm/arch-ns9xxx/module.h
3 *
4 * Copyright (C) 2007 by Digi International Inc.
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11#ifndef __ASM_ARCH_MODULE_H
12#define __ASM_ARCH_MODULE_H
13
14#include <asm/mach-types.h>
15
16#define module_is_cc7ucamry() (0 \
17 || machine_is_cc7ucamry() \
18 )
19
20#define module_is_cc9c() (0 \
21 || machine_is_cc9c() \
22 )
23
24#define module_is_cc9p9210() (0 \
25 || machine_is_cc9p9210() \
26 || machine_is_cc9p9210js() \
27 )
28
29#define module_is_cc9p9215() (0 \
30 || machine_is_cc9p9215() \
31 || machine_is_cc9p9215js() \
32 )
33
34#define module_is_cc9p9360() (0 \
35 || machine_is_a9m9360() \
36 || machine_is_cc9p9360dev() \
37 || machine_is_cc9p9360js() \
38 || machine_is_cc9p9360val() \
39 )
40
41#define module_is_cc9p9750() (0 \
42 || machine_is_a9m9750() \
43 || machine_is_cc9p9750dev() \
44 || machine_is_cc9p9750js() \
45 || machine_is_cc9p9750val() \
46 )
47
48#define module_is_ccw9c() (0 \
49 || machine_is_ccw9c() \
50 )
51
52#define module_is_inc20otter() (0 \
53 || machine_is_inc20otter() \
54 )
55
56#define module_is_otter() (0 \
57 || machine_is_otter() \
58 )
59
60#endif /* ifndef __ASM_ARCH_MODULE_H */
diff --git a/include/asm-arm/arch-ns9xxx/processor-ns9360.h b/include/asm-arm/arch-ns9xxx/processor-ns9360.h
new file mode 100644
index 000000000000..f3aa6c50dbe5
--- /dev/null
+++ b/include/asm-arm/arch-ns9xxx/processor-ns9360.h
@@ -0,0 +1,32 @@
1/*
2 * include/asm-arm/arch-ns9xxx/processor-ns9360.h
3 *
4 * Copyright (C) 2007 by Digi International Inc.
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11#ifndef __ASM_ARCH_PROCESSORNS9360_H
12#define __ASM_ARCH_PROCESSORNS9360_H
13
14#include <linux/init.h>
15
16void ns9360_reset(char mode);
17
18unsigned long ns9360_systemclock(void) __attribute__((const));
19
20static inline unsigned long ns9360_cpuclock(void) __attribute__((const));
21static inline unsigned long ns9360_cpuclock(void)
22{
23 return ns9360_systemclock() / 2;
24}
25
26void __init ns9360_map_io(void);
27
28extern struct sys_timer ns9360_timer;
29
30int ns9360_gpio_configure(unsigned gpio, int inv, int func);
31
32#endif /* ifndef __ASM_ARCH_PROCESSORNS9360_H */
diff --git a/include/asm-arm/arch-ns9xxx/processor.h b/include/asm-arm/arch-ns9xxx/processor.h
index 223e51b8e104..f7b53b65de81 100644
--- a/include/asm-arm/arch-ns9xxx/processor.h
+++ b/include/asm-arm/arch-ns9xxx/processor.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/asm-arm/arch-ns9xxx/processor.h 2 * include/asm-arm/arch-ns9xxx/processor.h
3 * 3 *
4 * Copyright (C) 2006 by Digi International Inc. 4 * Copyright (C) 2006,2007 by Digi International Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
@@ -11,9 +11,32 @@
11#ifndef __ASM_ARCH_PROCESSOR_H 11#ifndef __ASM_ARCH_PROCESSOR_H
12#define __ASM_ARCH_PROCESSOR_H 12#define __ASM_ARCH_PROCESSOR_H
13 13
14#include <asm/mach-types.h> 14#include <asm/arch-ns9xxx/module.h>
15 15
16#define processor_is_ns9360() (machine_is_cc9p9360dev() \ 16#define processor_is_ns9210() (0 \
17 || machine_is_cc9p9360js()) 17 || module_is_cc7ucamry() \
18 || module_is_cc9p9210() \
19 || module_is_inc20otter() \
20 || module_is_otter() \
21 )
22
23#define processor_is_ns9215() (0 \
24 || module_is_cc9p9215() \
25 )
26
27#define processor_is_ns9360() (0 \
28 || module_is_cc9p9360() \
29 || module_is_cc9c() \
30 || module_is_ccw9c() \
31 )
32
33#define processor_is_ns9750() (0 \
34 || module_is_cc9p9750() \
35 )
36
37#define processor_is_ns921x() (0 \
38 || processor_is_ns9210() \
39 || processor_is_ns9215() \
40 )
18 41
19#endif /* ifndef __ASM_ARCH_PROCESSOR_H */ 42#endif /* ifndef __ASM_ARCH_PROCESSOR_H */
diff --git a/include/asm-arm/arch-ns9xxx/regs-sys-common.h b/include/asm-arm/arch-ns9xxx/regs-sys-common.h
new file mode 100644
index 000000000000..956c57cb781f
--- /dev/null
+++ b/include/asm-arm/arch-ns9xxx/regs-sys-common.h
@@ -0,0 +1,31 @@
1/*
2 * include/asm-arm/arch-ns9xxx/regs-sys-common.h
3 *
4 * Copyright (C) 2007 by Digi International Inc.
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11
12#ifndef __ASM_ARCH_REGSSYSCOMMON_H
13#define __ASM_ARCH_REGSSYSCOMMON_H
14#include <asm/hardware.h>
15
16/* Interrupt Vector Address Register Level x */
17#define SYS_IVA(x) __REG2(0xa09000c4, (x))
18
19/* Interrupt Configuration registers */
20#define SYS_IC(x) __REG2(0xa0900144, (x))
21
22/* ISRADDR */
23#define SYS_ISRADDR __REG(0xa0900164)
24
25/* Interrupt Status Active */
26#define SYS_ISA __REG(0xa0900168)
27
28/* Interrupt Status Raw */
29#define SYS_ISR __REG(0xa090016c)
30
31#endif /* ifndef __ASM_ARCH_REGSSYSCOMMON_H */
diff --git a/include/asm-arm/arch-ns9xxx/regs-sys.h b/include/asm-arm/arch-ns9xxx/regs-sys-ns9360.h
index 749262f86204..318b6945afb6 100644
--- a/include/asm-arm/arch-ns9xxx/regs-sys.h
+++ b/include/asm-arm/arch-ns9xxx/regs-sys-ns9360.h
@@ -1,15 +1,15 @@
1/* 1/*
2 * include/asm-arm/arch-ns9xxx/regs-sys.h 2 * include/asm-arm/arch-ns9xxx/regs-sys-ns9360.h
3 * 3 *
4 * Copyright (C) 2006 by Digi International Inc. 4 * Copyright (C) 2006,2007 by Digi International Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by 8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation. 9 * the Free Software Foundation.
10 */ 10 */
11#ifndef __ASM_ARCH_REGSSYS_H 11#ifndef __ASM_ARCH_REGSSYSNS9360_H
12#define __ASM_ARCH_REGSSYS_H 12#define __ASM_ARCH_REGSSYSNS9360_H
13 13
14#include <asm/hardware.h> 14#include <asm/hardware.h>
15 15
@@ -27,21 +27,6 @@
27/* Timer x Read register */ 27/* Timer x Read register */
28#define SYS_TR(x) __REG2(0xa0900084, (x)) 28#define SYS_TR(x) __REG2(0xa0900084, (x))
29 29
30/* Interrupt Vector Address Register Level x */
31#define SYS_IVA(x) __REG2(0xa09000c4, (x))
32
33/* Interrupt Configuration registers */
34#define SYS_IC(x) __REG2(0xa0900144, (x))
35
36/* ISRADDR */
37#define SYS_ISRADDR __REG(0xa0900164)
38
39/* Interrupt Status Active */
40#define SYS_ISA __REG(0xa0900168)
41
42/* Interrupt Status Raw */
43#define SYS_ISR __REG(0xa090016c)
44
45/* Timer Interrupt Status register */ 30/* Timer Interrupt Status register */
46#define SYS_TIS __REG(0xa0900170) 31#define SYS_TIS __REG(0xa0900170)
47 32
@@ -160,4 +145,4 @@
160#define SYS_EIC_LVEDG_LEVEL __REGVAL(SYS_EIC_LVEDG, 0) 145#define SYS_EIC_LVEDG_LEVEL __REGVAL(SYS_EIC_LVEDG, 0)
161#define SYS_EIC_LVEDG_EDGE __REGVAL(SYS_EIC_LVEDG, 1) 146#define SYS_EIC_LVEDG_EDGE __REGVAL(SYS_EIC_LVEDG, 1)
162 147
163#endif /* ifndef __ASM_ARCH_REGSSYS_H */ 148#endif /* ifndef __ASM_ARCH_REGSSYSNS9360_H */
diff --git a/include/asm-arm/arch-ns9xxx/system.h b/include/asm-arm/arch-ns9xxx/system.h
index c1082bd8977c..1348073afe48 100644
--- a/include/asm-arm/arch-ns9xxx/system.h
+++ b/include/asm-arm/arch-ns9xxx/system.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/asm-arm/arch-ns9xxx/system.h 2 * include/asm-arm/arch-ns9xxx/system.h
3 * 3 *
4 * Copyright (C) 2006 by Digi International Inc. 4 * Copyright (C) 2006,2007 by Digi International Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
@@ -12,8 +12,8 @@
12#define __ASM_ARCH_SYSTEM_H 12#define __ASM_ARCH_SYSTEM_H
13 13
14#include <asm/proc-fns.h> 14#include <asm/proc-fns.h>
15#include <asm/arch-ns9xxx/regs-sys.h> 15#include <asm/arch-ns9xxx/processor.h>
16#include <asm/mach-types.h> 16#include <asm/arch-ns9xxx/processor-ns9360.h>
17 17
18static inline void arch_idle(void) 18static inline void arch_idle(void)
19{ 19{
@@ -22,11 +22,12 @@ static inline void arch_idle(void)
22 22
23static inline void arch_reset(char mode) 23static inline void arch_reset(char mode)
24{ 24{
25 u32 reg; 25#ifdef CONFIG_PROCESSOR_NS9360
26 26 if (processor_is_ns9360())
27 reg = __raw_readl(SYS_PLL) >> 16; 27 ns9360_reset(mode);
28 REGSET(reg, SYS_PLL, SWC, YES); 28 else
29 __raw_writel(reg, SYS_PLL); 29#endif
30 BUG();
30 31
31 BUG(); 32 BUG();
32} 33}
diff --git a/include/asm-arm/arch-ns9xxx/uncompress.h b/include/asm-arm/arch-ns9xxx/uncompress.h
index 961ca7dc9954..71066baceab7 100644
--- a/include/asm-arm/arch-ns9xxx/uncompress.h
+++ b/include/asm-arm/arch-ns9xxx/uncompress.h
@@ -11,20 +11,149 @@
11#ifndef __ASM_ARCH_UNCOMPRESS_H 11#ifndef __ASM_ARCH_UNCOMPRESS_H
12#define __ASM_ARCH_UNCOMPRESS_H 12#define __ASM_ARCH_UNCOMPRESS_H
13 13
14static void putc(char c) 14#include <asm/io.h>
15
16#define __REG(x) ((void __iomem __force *)(x))
17
18static void putc_dummy(char c, void __iomem *base)
15{ 19{
16 volatile u8 *base = (volatile u8 *)0x40000000; 20 /* nothing */
17 int t = 0x10000; 21}
18 22
23static void putc_ns9360(char c, void __iomem *base)
24{
25 static int t = 0x10000;
26 do {
27 if (t)
28 --t;
29
30 if (__raw_readl(base + 8) & (1 << 3)) {
31 __raw_writeb(c, base + 16);
32 t = 0x10000;
33 break;
34 }
35 } while (t);
36}
37
38static void putc_a9m9750dev(char c, void __iomem *base)
39{
40 static int t = 0x10000;
41 do {
42 if (t)
43 --t;
44
45 if (__raw_readb(base + 5) & (1 << 5)) {
46 __raw_writeb(c, base);
47 t = 0x10000;
48 break;
49 }
50 } while (t);
51
52}
53
54static void putc_ns921x(char c, void __iomem *base)
55{
56 static int t = 0x10000;
19 do { 57 do {
20 if (base[5] & 0x20) { 58 if (t)
21 base[0] = c; 59 --t;
60
61 if (!(__raw_readl(base) & (1 << 11))) {
62 __raw_writeb(c, base + 0x0028);
63 t = 0x10000;
22 break; 64 break;
23 } 65 }
24 } while (--t); 66 } while (t);
25} 67}
26 68
27#define arch_decomp_setup() 69#define MSCS __REG(0xA0900184)
70
71#define NS9360_UARTA __REG(0x90200040)
72#define NS9360_UARTB __REG(0x90200000)
73#define NS9360_UARTC __REG(0x90300000)
74#define NS9360_UARTD __REG(0x90300040)
75
76#define NS9360_UART_ENABLED(base) \
77 (__raw_readl(NS9360_UARTA) & (1 << 31))
78
79#define A9M9750DEV_UARTA __REG(0x40000000)
80
81#define NS921XSYS_CLOCK __REG(0xa090017c)
82#define NS921X_UARTA __REG(0x90010000)
83#define NS921X_UARTB __REG(0x90018000)
84#define NS921X_UARTC __REG(0x90020000)
85#define NS921X_UARTD __REG(0x90028000)
86
87#define NS921X_UART_ENABLED(base) \
88 (__raw_readl((base) + 0x1000) & (1 << 29))
89
90static void autodetect(void (**putc)(char, void __iomem *), void __iomem **base)
91{
92 if (((__raw_readl(MSCS) >> 16) & 0xfe) == 0x00) {
93 /* ns9360 or ns9750 */
94 if (NS9360_UART_ENABLED(NS9360_UARTA)) {
95 *putc = putc_ns9360;
96 *base = NS9360_UARTA;
97 return;
98 } else if (NS9360_UART_ENABLED(NS9360_UARTB)) {
99 *putc = putc_ns9360;
100 *base = NS9360_UARTB;
101 return;
102 } else if (NS9360_UART_ENABLED(NS9360_UARTC)) {
103 *putc = putc_ns9360;
104 *base = NS9360_UARTC;
105 return;
106 } else if (NS9360_UART_ENABLED(NS9360_UARTD)) {
107 *putc = putc_ns9360;
108 *base = NS9360_UARTD;
109 return;
110 } else if (__raw_readl(__REG(0xa09001f4)) == 0xfffff001) {
111 *putc = putc_a9m9750dev;
112 *base = A9M9750DEV_UARTA;
113 return;
114 }
115 } else if (((__raw_readl(MSCS) >> 16) & 0xfe) == 0x02) {
116 /* ns921x */
117 u32 clock = __raw_readl(NS921XSYS_CLOCK);
118
119 if ((clock & (1 << 1)) &&
120 NS921X_UART_ENABLED(NS921X_UARTA)) {
121 *putc = putc_ns921x;
122 *base = NS921X_UARTA;
123 return;
124 } else if ((clock & (1 << 2)) &&
125 NS921X_UART_ENABLED(NS921X_UARTB)) {
126 *putc = putc_ns921x;
127 *base = NS921X_UARTB;
128 return;
129 } else if ((clock & (1 << 3)) &&
130 NS921X_UART_ENABLED(NS921X_UARTC)) {
131 *putc = putc_ns921x;
132 *base = NS921X_UARTC;
133 return;
134 } else if ((clock & (1 << 4)) &&
135 NS921X_UART_ENABLED(NS921X_UARTD)) {
136 *putc = putc_ns921x;
137 *base = NS921X_UARTD;
138 return;
139 }
140 }
141
142 *putc = putc_dummy;
143}
144
145void (*myputc)(char, void __iomem *);
146void __iomem *base;
147
148static void putc(char c)
149{
150 myputc(c, base);
151}
152
153static void arch_decomp_setup(void)
154{
155 autodetect(&myputc, &base);
156}
28#define arch_decomp_wdog() 157#define arch_decomp_wdog()
29 158
30static void flush(void) 159static void flush(void)
diff --git a/include/asm-arm/arch-omap/board-osk.h b/include/asm-arm/arch-omap/board-osk.h
index 2b1a8a4fe44e..94926090e475 100644
--- a/include/asm-arm/arch-omap/board-osk.h
+++ b/include/asm-arm/arch-omap/board-osk.h
@@ -32,5 +32,16 @@
32/* At OMAP5912 OSK the Ethernet is directly connected to CS1 */ 32/* At OMAP5912 OSK the Ethernet is directly connected to CS1 */
33#define OMAP_OSK_ETHR_START 0x04800300 33#define OMAP_OSK_ETHR_START 0x04800300
34 34
35/* TPS65010 has four GPIOs. nPG and LED2 can be treated like GPIOs with
36 * alternate pin configurations for hardware-controlled blinking.
37 */
38#define OSK_TPS_GPIO_BASE (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)
39# define OSK_TPS_GPIO_USB_PWR_EN (OSK_TPS_GPIO_BASE + 0)
40# define OSK_TPS_GPIO_LED_D3 (OSK_TPS_GPIO_BASE + 1)
41# define OSK_TPS_GPIO_LAN_RESET (OSK_TPS_GPIO_BASE + 2)
42# define OSK_TPS_GPIO_DSP_PWR_EN (OSK_TPS_GPIO_BASE + 3)
43# define OSK_TPS_GPIO_LED_D9 (OSK_TPS_GPIO_BASE + 4)
44# define OSK_TPS_GPIO_LED_D2 (OSK_TPS_GPIO_BASE + 5)
45
35#endif /* __ASM_ARCH_OMAP_OSK_H */ 46#endif /* __ASM_ARCH_OMAP_OSK_H */
36 47
diff --git a/include/asm-arm/arch-omap/clock.h b/include/asm-arm/arch-omap/clock.h
index fa6881049903..57523bdb642b 100644
--- a/include/asm-arm/arch-omap/clock.h
+++ b/include/asm-arm/arch-omap/clock.h
@@ -14,6 +14,35 @@
14#define __ARCH_ARM_OMAP_CLOCK_H 14#define __ARCH_ARM_OMAP_CLOCK_H
15 15
16struct module; 16struct module;
17struct clk;
18
19#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
20
21struct clksel_rate {
22 u8 div;
23 u32 val;
24 u8 flags;
25};
26
27struct clksel {
28 struct clk *parent;
29 const struct clksel_rate *rates;
30};
31
32struct dpll_data {
33 void __iomem *mult_div1_reg;
34 u32 mult_mask;
35 u32 div1_mask;
36# if defined(CONFIG_ARCH_OMAP3)
37 void __iomem *control_reg;
38 u32 enable_mask;
39 u8 auto_recal_bit;
40 u8 recal_en_bit;
41 u8 recal_st_bit;
42# endif
43};
44
45#endif
17 46
18struct clk { 47struct clk {
19 struct list_head node; 48 struct list_head node;
@@ -25,8 +54,6 @@ struct clk {
25 __u32 flags; 54 __u32 flags;
26 void __iomem *enable_reg; 55 void __iomem *enable_reg;
27 __u8 enable_bit; 56 __u8 enable_bit;
28 __u8 rate_offset;
29 __u8 src_offset;
30 __s8 usecount; 57 __s8 usecount;
31 void (*recalc)(struct clk *); 58 void (*recalc)(struct clk *);
32 int (*set_rate)(struct clk *, unsigned long); 59 int (*set_rate)(struct clk *, unsigned long);
@@ -34,6 +61,16 @@ struct clk {
34 void (*init)(struct clk *); 61 void (*init)(struct clk *);
35 int (*enable)(struct clk *); 62 int (*enable)(struct clk *);
36 void (*disable)(struct clk *); 63 void (*disable)(struct clk *);
64#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
65 u8 fixed_div;
66 void __iomem *clksel_reg;
67 u32 clksel_mask;
68 const struct clksel *clksel;
69 const struct dpll_data *dpll_data;
70#else
71 __u8 rate_offset;
72 __u8 src_offset;
73#endif
37}; 74};
38 75
39struct clk_functions { 76struct clk_functions {
@@ -54,10 +91,12 @@ extern int clk_init(struct clk_functions * custom_clocks);
54extern int clk_register(struct clk *clk); 91extern int clk_register(struct clk *clk);
55extern void clk_unregister(struct clk *clk); 92extern void clk_unregister(struct clk *clk);
56extern void propagate_rate(struct clk *clk); 93extern void propagate_rate(struct clk *clk);
94extern void recalculate_root_clocks(void);
57extern void followparent_recalc(struct clk * clk); 95extern void followparent_recalc(struct clk * clk);
58extern void clk_allow_idle(struct clk *clk); 96extern void clk_allow_idle(struct clk *clk);
59extern void clk_deny_idle(struct clk *clk); 97extern void clk_deny_idle(struct clk *clk);
60extern int clk_get_usecount(struct clk *clk); 98extern int clk_get_usecount(struct clk *clk);
99extern void clk_enable_init_clocks(void);
61 100
62/* Clock flags */ 101/* Clock flags */
63#define RATE_CKCTL (1 << 0) /* Main fixed ratio clocks */ 102#define RATE_CKCTL (1 << 0) /* Main fixed ratio clocks */
@@ -71,21 +110,33 @@ extern int clk_get_usecount(struct clk *clk);
71#define CLOCK_NO_IDLE_PARENT (1 << 8) 110#define CLOCK_NO_IDLE_PARENT (1 << 8)
72#define DELAYED_APP (1 << 9) /* Delay application of clock */ 111#define DELAYED_APP (1 << 9) /* Delay application of clock */
73#define CONFIG_PARTICIPANT (1 << 10) /* Fundamental clock */ 112#define CONFIG_PARTICIPANT (1 << 10) /* Fundamental clock */
74#define CM_MPU_SEL1 (1 << 11) /* Domain divider/source */ 113#define ENABLE_ON_INIT (1 << 11) /* Enable upon framework init */
75#define CM_DSP_SEL1 (1 << 12) 114#define INVERT_ENABLE (1 << 12) /* 0 enables, 1 disables */
76#define CM_GFX_SEL1 (1 << 13) 115/* bits 13-20 are currently free */
77#define CM_MODEM_SEL1 (1 << 14)
78#define CM_CORE_SEL1 (1 << 15) /* Sets divider for many */
79#define CM_CORE_SEL2 (1 << 16) /* sets parent for GPT */
80#define CM_WKUP_SEL1 (1 << 17)
81#define CM_PLL_SEL1 (1 << 18)
82#define CM_PLL_SEL2 (1 << 19)
83#define CM_SYSCLKOUT_SEL1 (1 << 20)
84#define CLOCK_IN_OMAP310 (1 << 21) 116#define CLOCK_IN_OMAP310 (1 << 21)
85#define CLOCK_IN_OMAP730 (1 << 22) 117#define CLOCK_IN_OMAP730 (1 << 22)
86#define CLOCK_IN_OMAP1510 (1 << 23) 118#define CLOCK_IN_OMAP1510 (1 << 23)
87#define CLOCK_IN_OMAP16XX (1 << 24) 119#define CLOCK_IN_OMAP16XX (1 << 24)
88#define CLOCK_IN_OMAP242X (1 << 25) 120#define CLOCK_IN_OMAP242X (1 << 25)
89#define CLOCK_IN_OMAP243X (1 << 26) 121#define CLOCK_IN_OMAP243X (1 << 26)
122#define CLOCK_IN_OMAP343X (1 << 27) /* clocks common to all 343X */
123#define PARENT_CONTROLS_CLOCK (1 << 28)
124#define CLOCK_IN_OMAP3430ES1 (1 << 29) /* 3430ES1 clocks only */
125#define CLOCK_IN_OMAP3430ES2 (1 << 30) /* 3430ES2 clocks only */
126
127/* Clksel_rate flags */
128#define DEFAULT_RATE (1 << 0)
129#define RATE_IN_242X (1 << 1)
130#define RATE_IN_243X (1 << 2)
131#define RATE_IN_343X (1 << 3) /* rates common to all 343X */
132#define RATE_IN_3430ES2 (1 << 4) /* 3430ES2 rates only */
133
134#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)
135
136
137/* CM_CLKSEL2_PLL.CORE_CLK_SRC options (24XX) */
138#define CORE_CLK_SRC_32K 0
139#define CORE_CLK_SRC_DPLL 1
140#define CORE_CLK_SRC_DPLL_X2 2
90 141
91#endif 142#endif
diff --git a/include/asm-arm/arch-omap/control.h b/include/asm-arm/arch-omap/control.h
new file mode 100644
index 000000000000..9944bb5d5330
--- /dev/null
+++ b/include/asm-arm/arch-omap/control.h
@@ -0,0 +1,191 @@
1#ifndef __ASM_ARCH_CONTROL_H
2#define __ASM_ARCH_CONTROL_H
3
4/*
5 * include/asm-arm/arch-omap/control.h
6 *
7 * OMAP2/3 System Control Module definitions
8 *
9 * Copyright (C) 2007 Texas Instruments, Inc.
10 * Copyright (C) 2007 Nokia Corporation
11 *
12 * Written by Paul Walmsley
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.
17 */
18
19#include <asm/arch/io.h>
20
21#define OMAP242X_CTRL_REGADDR(reg) \
22 (void __iomem *)IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
23#define OMAP243X_CTRL_REGADDR(reg) \
24 (void __iomem *)IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
25#define OMAP343X_CTRL_REGADDR(reg) \
26 (void __iomem *)IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
27
28/*
29 * As elsewhere, the "OMAP2_" prefix indicates that the macro is valid for
30 * OMAP24XX and OMAP34XX.
31 */
32
33/* Control submodule offsets */
34
35#define OMAP2_CONTROL_INTERFACE 0x000
36#define OMAP2_CONTROL_PADCONFS 0x030
37#define OMAP2_CONTROL_GENERAL 0x270
38#define OMAP343X_CONTROL_MEM_WKUP 0x600
39#define OMAP343X_CONTROL_PADCONFS_WKUP 0xa00
40#define OMAP343X_CONTROL_GENERAL_WKUP 0xa60
41
42/* Control register offsets - read/write with omap_ctrl_{read,write}{bwl}() */
43
44#define OMAP2_CONTROL_SYSCONFIG (OMAP2_CONTROL_INTERFACE + 0x10)
45
46/* CONTROL_GENERAL register offsets common to OMAP2 & 3 */
47#define OMAP2_CONTROL_DEVCONF0 (OMAP2_CONTROL_GENERAL + 0x0004)
48#define OMAP2_CONTROL_MSUSPENDMUX_0 (OMAP2_CONTROL_GENERAL + 0x0020)
49#define OMAP2_CONTROL_MSUSPENDMUX_1 (OMAP2_CONTROL_GENERAL + 0x0024)
50#define OMAP2_CONTROL_MSUSPENDMUX_2 (OMAP2_CONTROL_GENERAL + 0x0028)
51#define OMAP2_CONTROL_MSUSPENDMUX_3 (OMAP2_CONTROL_GENERAL + 0x002c)
52#define OMAP2_CONTROL_MSUSPENDMUX_4 (OMAP2_CONTROL_GENERAL + 0x0030)
53#define OMAP2_CONTROL_MSUSPENDMUX_5 (OMAP2_CONTROL_GENERAL + 0x0034)
54#define OMAP2_CONTROL_SEC_CTRL (OMAP2_CONTROL_GENERAL + 0x0040)
55#define OMAP2_CONTROL_RPUB_KEY_H_0 (OMAP2_CONTROL_GENERAL + 0x0090)
56#define OMAP2_CONTROL_RPUB_KEY_H_1 (OMAP2_CONTROL_GENERAL + 0x0094)
57#define OMAP2_CONTROL_RPUB_KEY_H_2 (OMAP2_CONTROL_GENERAL + 0x0098)
58#define OMAP2_CONTROL_RPUB_KEY_H_3 (OMAP2_CONTROL_GENERAL + 0x009c)
59
60/* 242x-only CONTROL_GENERAL register offsets */
61#define OMAP242X_CONTROL_DEVCONF OMAP2_CONTROL_DEVCONF0 /* match TRM */
62#define OMAP242X_CONTROL_OCM_RAM_PERM (OMAP2_CONTROL_GENERAL + 0x0068)
63
64/* 243x-only CONTROL_GENERAL register offsets */
65/* CONTROL_IVA2_BOOT{ADDR,MOD} are at the same place on 343x - noted below */
66#define OMAP243X_CONTROL_DEVCONF1 (OMAP2_CONTROL_GENERAL + 0x0078)
67#define OMAP243X_CONTROL_CSIRXFE (OMAP2_CONTROL_GENERAL + 0x007c)
68#define OMAP243X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190)
69#define OMAP243X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194)
70#define OMAP243X_CONTROL_IVA2_GEMCFG (OMAP2_CONTROL_GENERAL + 0x0198)
71
72/* 24xx-only CONTROL_GENERAL register offsets */
73#define OMAP24XX_CONTROL_DEBOBS (OMAP2_CONTROL_GENERAL + 0x0000)
74#define OMAP24XX_CONTROL_EMU_SUPPORT (OMAP2_CONTROL_GENERAL + 0x0008)
75#define OMAP24XX_CONTROL_SEC_TEST (OMAP2_CONTROL_GENERAL + 0x0044)
76#define OMAP24XX_CONTROL_PSA_CTRL (OMAP2_CONTROL_GENERAL + 0x0048)
77#define OMAP24XX_CONTROL_PSA_CMD (OMAP2_CONTROL_GENERAL + 0x004c)
78#define OMAP24XX_CONTROL_PSA_VALUE (OMAP2_CONTROL_GENERAL + 0x0050)
79#define OMAP24XX_CONTROL_SEC_EMU (OMAP2_CONTROL_GENERAL + 0x0060)
80#define OMAP24XX_CONTROL_SEC_TAP (OMAP2_CONTROL_GENERAL + 0x0064)
81#define OMAP24XX_CONTROL_OCM_PUB_RAM_ADD (OMAP2_CONTROL_GENERAL + 0x006c)
82#define OMAP24XX_CONTROL_EXT_SEC_RAM_START_ADD (OMAP2_CONTROL_GENERAL + 0x0070)
83#define OMAP24XX_CONTROL_EXT_SEC_RAM_STOP_ADD (OMAP2_CONTROL_GENERAL + 0x0074
84#define OMAP24XX_CONTROL_SEC_STATUS (OMAP2_CONTROL_GENERAL + 0x0080)
85#define OMAP24XX_CONTROL_SEC_ERR_STATUS (OMAP2_CONTROL_GENERAL + 0x0084)
86#define OMAP24XX_CONTROL_STATUS (OMAP2_CONTROL_GENERAL + 0x0088)
87#define OMAP24XX_CONTROL_GENERAL_PURPOSE_STATUS (OMAP2_CONTROL_GENERAL + 0x008c)
88#define OMAP24XX_CONTROL_RAND_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00a0)
89#define OMAP24XX_CONTROL_RAND_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00a4)
90#define OMAP24XX_CONTROL_RAND_KEY_2 (OMAP2_CONTROL_GENERAL + 0x00a8)
91#define OMAP24XX_CONTROL_RAND_KEY_3 (OMAP2_CONTROL_GENERAL + 0x00ac)
92#define OMAP24XX_CONTROL_CUST_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00b0)
93#define OMAP24XX_CONTROL_CUST_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00b4)
94#define OMAP24XX_CONTROL_TEST_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00c0)
95#define OMAP24XX_CONTROL_TEST_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00c4)
96#define OMAP24XX_CONTROL_TEST_KEY_2 (OMAP2_CONTROL_GENERAL + 0x00c8)
97#define OMAP24XX_CONTROL_TEST_KEY_3 (OMAP2_CONTROL_GENERAL + 0x00cc)
98#define OMAP24XX_CONTROL_TEST_KEY_4 (OMAP2_CONTROL_GENERAL + 0x00d0)
99#define OMAP24XX_CONTROL_TEST_KEY_5 (OMAP2_CONTROL_GENERAL + 0x00d4)
100#define OMAP24XX_CONTROL_TEST_KEY_6 (OMAP2_CONTROL_GENERAL + 0x00d8)
101#define OMAP24XX_CONTROL_TEST_KEY_7 (OMAP2_CONTROL_GENERAL + 0x00dc)
102#define OMAP24XX_CONTROL_TEST_KEY_8 (OMAP2_CONTROL_GENERAL + 0x00e0)
103#define OMAP24XX_CONTROL_TEST_KEY_9 (OMAP2_CONTROL_GENERAL + 0x00e4)
104
105/* 34xx-only CONTROL_GENERAL register offsets */
106#define OMAP343X_CONTROL_PADCONF_OFF (OMAP2_CONTROL_GENERAL + 0x0000)
107#define OMAP343X_CONTROL_MEM_DFTRW0 (OMAP2_CONTROL_GENERAL + 0x0008)
108#define OMAP343X_CONTROL_MEM_DFTRW1 (OMAP2_CONTROL_GENERAL + 0x000c)
109#define OMAP343X_CONTROL_DEVCONF1 (OMAP2_CONTROL_GENERAL + 0x0068)
110#define OMAP343X_CONTROL_CSIRXFE (OMAP2_CONTROL_GENERAL + 0x006c)
111#define OMAP343X_CONTROL_SEC_STATUS (OMAP2_CONTROL_GENERAL + 0x0070)
112#define OMAP343X_CONTROL_SEC_ERR_STATUS (OMAP2_CONTROL_GENERAL + 0x0074)
113#define OMAP343X_CONTROL_SEC_ERR_STATUS_DEBUG (OMAP2_CONTROL_GENERAL + 0x0078)
114#define OMAP343X_CONTROL_STATUS (OMAP2_CONTROL_GENERAL + 0x0080)
115#define OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS (OMAP2_CONTROL_GENERAL + 0x0084)
116#define OMAP343X_CONTROL_RPUB_KEY_H_4 (OMAP2_CONTROL_GENERAL + 0x00a0)
117#define OMAP343X_CONTROL_RAND_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00a8)
118#define OMAP343X_CONTROL_RAND_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00ac)
119#define OMAP343X_CONTROL_RAND_KEY_2 (OMAP2_CONTROL_GENERAL + 0x00b0)
120#define OMAP343X_CONTROL_RAND_KEY_3 (OMAP2_CONTROL_GENERAL + 0x00b4)
121#define OMAP343X_CONTROL_TEST_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00c8)
122#define OMAP343X_CONTROL_TEST_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00cc)
123#define OMAP343X_CONTROL_TEST_KEY_2 (OMAP2_CONTROL_GENERAL + 0x00d0)
124#define OMAP343X_CONTROL_TEST_KEY_3 (OMAP2_CONTROL_GENERAL + 0x00d4)
125#define OMAP343X_CONTROL_TEST_KEY_4 (OMAP2_CONTROL_GENERAL + 0x00d8)
126#define OMAP343X_CONTROL_TEST_KEY_5 (OMAP2_CONTROL_GENERAL + 0x00dc)
127#define OMAP343X_CONTROL_TEST_KEY_6 (OMAP2_CONTROL_GENERAL + 0x00e0)
128#define OMAP343X_CONTROL_TEST_KEY_7 (OMAP2_CONTROL_GENERAL + 0x00e4)
129#define OMAP343X_CONTROL_TEST_KEY_8 (OMAP2_CONTROL_GENERAL + 0x00e8)
130#define OMAP343X_CONTROL_TEST_KEY_9 (OMAP2_CONTROL_GENERAL + 0x00ec)
131#define OMAP343X_CONTROL_TEST_KEY_10 (OMAP2_CONTROL_GENERAL + 0x00f0)
132#define OMAP343X_CONTROL_TEST_KEY_11 (OMAP2_CONTROL_GENERAL + 0x00f4)
133#define OMAP343X_CONTROL_TEST_KEY_12 (OMAP2_CONTROL_GENERAL + 0x00f8)
134#define OMAP343X_CONTROL_TEST_KEY_13 (OMAP2_CONTROL_GENERAL + 0x00fc)
135#define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190)
136#define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194)
137
138/*
139 * REVISIT: This list of registers is not comprehensive - there are more
140 * that should be added.
141 */
142
143/*
144 * Control module register bit defines - these should eventually go into
145 * their own regbits file. Some of these will be complicated, depending
146 * on the device type (general-purpose, emulator, test, secure, bad, other)
147 * and the security mode (secure, non-secure, don't care)
148 */
149/* CONTROL_DEVCONF0 bits */
150#define OMAP24XX_USBSTANDBYCTRL (1 << 15)
151#define OMAP2_MCBSP2_CLKS_MASK (1 << 6)
152#define OMAP2_MCBSP1_CLKS_MASK (1 << 2)
153
154/* CONTROL_DEVCONF1 bits */
155#define OMAP2_MCBSP5_CLKS_MASK (1 << 4) /* > 242x */
156#define OMAP2_MCBSP4_CLKS_MASK (1 << 2) /* > 242x */
157#define OMAP2_MCBSP3_CLKS_MASK (1 << 0) /* > 242x */
158
159/* CONTROL_STATUS bits */
160#define OMAP2_DEVICETYPE_MASK (0x7 << 8)
161#define OMAP2_SYSBOOT_5_MASK (1 << 5)
162#define OMAP2_SYSBOOT_4_MASK (1 << 4)
163#define OMAP2_SYSBOOT_3_MASK (1 << 3)
164#define OMAP2_SYSBOOT_2_MASK (1 << 2)
165#define OMAP2_SYSBOOT_1_MASK (1 << 1)
166#define OMAP2_SYSBOOT_0_MASK (1 << 0)
167
168#ifndef __ASSEMBLY__
169#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
170extern void omap_ctrl_base_set(u32 base);
171extern u32 omap_ctrl_base_get(void);
172extern u8 omap_ctrl_readb(u16 offset);
173extern u16 omap_ctrl_readw(u16 offset);
174extern u32 omap_ctrl_readl(u16 offset);
175extern void omap_ctrl_writeb(u8 val, u16 offset);
176extern void omap_ctrl_writew(u16 val, u16 offset);
177extern void omap_ctrl_writel(u32 val, u16 offset);
178#else
179#define omap_ctrl_base_set(x) WARN_ON(1)
180#define omap_ctrl_base_get() 0
181#define omap_ctrl_readb(x) 0
182#define omap_ctrl_readw(x) 0
183#define omap_ctrl_readl(x) 0
184#define omap_ctrl_writeb(x, y) WARN_ON(1)
185#define omap_ctrl_writew(x, y) WARN_ON(1)
186#define omap_ctrl_writel(x, y) WARN_ON(1)
187#endif
188#endif /* __ASSEMBLY__ */
189
190#endif /* __ASM_ARCH_CONTROL_H */
191
diff --git a/include/asm-arm/arch-omap/entry-macro.S b/include/asm-arm/arch-omap/entry-macro.S
index f6967c8df323..74cd57221c8e 100644
--- a/include/asm-arm/arch-omap/entry-macro.S
+++ b/include/asm-arm/arch-omap/entry-macro.S
@@ -68,7 +68,7 @@
68 .endm 68 .endm
69 69
70 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 70 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
71 ldr \base, =VA_IC_BASE 71 ldr \base, =OMAP2_VA_IC_BASE
72 ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */ 72 ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
73 cmp \irqnr, #0x0 73 cmp \irqnr, #0x0
74 bne 2222f 74 bne 2222f
diff --git a/include/asm-arm/arch-omap/gpio.h b/include/asm-arm/arch-omap/gpio.h
index 164da09be095..86621a04cd8f 100644
--- a/include/asm-arm/arch-omap/gpio.h
+++ b/include/asm-arm/arch-omap/gpio.h
@@ -82,62 +82,35 @@ extern void omap_set_gpio_debounce_time(int gpio, int enable);
82 82
83/*-------------------------------------------------------------------------*/ 83/*-------------------------------------------------------------------------*/
84 84
85/* wrappers for "new style" GPIO calls. the old OMAP-specfic ones should 85/* Wrappers for "new style" GPIO calls, using the new infrastructure
86 * eventually be removed (along with this errno.h inclusion), and maybe 86 * which lets us plug in FPGA, I2C, and other implementations.
87 * gpios should put MPUIOs last too. 87 * *
88 * The original OMAP-specfic calls should eventually be removed.
88 */ 89 */
89 90
90#include <asm/errno.h> 91#include <linux/errno.h>
91 92#include <asm-generic/gpio.h>
92static inline int gpio_request(unsigned gpio, const char *label)
93{
94 return omap_request_gpio(gpio);
95}
96
97static inline void gpio_free(unsigned gpio)
98{
99 omap_free_gpio(gpio);
100}
101
102static inline int __gpio_set_direction(unsigned gpio, int is_input)
103{
104 if (cpu_class_is_omap2()) {
105 if (gpio > OMAP_MAX_GPIO_LINES)
106 return -EINVAL;
107 } else {
108 if (gpio > (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */))
109 return -EINVAL;
110 }
111 omap_set_gpio_direction(gpio, is_input);
112 return 0;
113}
114
115static inline int gpio_direction_input(unsigned gpio)
116{
117 return __gpio_set_direction(gpio, 1);
118}
119
120static inline int gpio_direction_output(unsigned gpio, int value)
121{
122 omap_set_gpio_dataout(gpio, value);
123 return __gpio_set_direction(gpio, 0);
124}
125 93
126static inline int gpio_get_value(unsigned gpio) 94static inline int gpio_get_value(unsigned gpio)
127{ 95{
128 return omap_get_gpio_datain(gpio); 96 return __gpio_get_value(gpio);
129} 97}
130 98
131static inline void gpio_set_value(unsigned gpio, int value) 99static inline void gpio_set_value(unsigned gpio, int value)
132{ 100{
133 omap_set_gpio_dataout(gpio, value); 101 __gpio_set_value(gpio, value);
134} 102}
135 103
136#include <asm-generic/gpio.h> /* cansleep wrappers */ 104static inline int gpio_cansleep(unsigned gpio)
105{
106 return __gpio_cansleep(gpio);
107}
137 108
138static inline int gpio_to_irq(unsigned gpio) 109static inline int gpio_to_irq(unsigned gpio)
139{ 110{
140 return OMAP_GPIO_IRQ(gpio); 111 if (gpio < (OMAP_MAX_GPIO_LINES + 16))
112 return OMAP_GPIO_IRQ(gpio);
113 return -EINVAL;
141} 114}
142 115
143static inline int irq_to_gpio(unsigned irq) 116static inline int irq_to_gpio(unsigned irq)
diff --git a/include/asm-arm/arch-omap/io.h b/include/asm-arm/arch-omap/io.h
index 289082d07f14..160578e1f557 100644
--- a/include/asm-arm/arch-omap/io.h
+++ b/include/asm-arm/arch-omap/io.h
@@ -80,6 +80,13 @@
80#define OMAP243X_GPMC_PHYS OMAP243X_GPMC_BASE /* 0x49000000 */ 80#define OMAP243X_GPMC_PHYS OMAP243X_GPMC_BASE /* 0x49000000 */
81#define OMAP243X_GPMC_VIRT 0xFE000000 81#define OMAP243X_GPMC_VIRT 0xFE000000
82#define OMAP243X_GPMC_SIZE SZ_1M 82#define OMAP243X_GPMC_SIZE SZ_1M
83#define OMAP243X_SDRC_PHYS OMAP243X_SDRC_BASE
84#define OMAP243X_SDRC_VIRT 0xFD000000
85#define OMAP243X_SDRC_SIZE SZ_1M
86#define OMAP243X_SMS_PHYS OMAP243X_SMS_BASE
87#define OMAP243X_SMS_VIRT 0xFC000000
88#define OMAP243X_SMS_SIZE SZ_1M
89
83#endif 90#endif
84 91
85#define IO_OFFSET 0x90000000 92#define IO_OFFSET 0x90000000
@@ -88,16 +95,73 @@
88#define io_v2p(va) ((va) - IO_OFFSET) /* Works for L3 and L4 */ 95#define io_v2p(va) ((va) - IO_OFFSET) /* Works for L3 and L4 */
89 96
90/* DSP */ 97/* DSP */
91#define DSP_MEM_24XX_PHYS OMAP24XX_DSP_MEM_BASE /* 0x58000000 */ 98#define DSP_MEM_24XX_PHYS OMAP2420_DSP_MEM_BASE /* 0x58000000 */
92#define DSP_MEM_24XX_VIRT 0xe0000000 99#define DSP_MEM_24XX_VIRT 0xe0000000
93#define DSP_MEM_24XX_SIZE 0x28000 100#define DSP_MEM_24XX_SIZE 0x28000
94#define DSP_IPI_24XX_PHYS OMAP24XX_DSP_IPI_BASE /* 0x59000000 */ 101#define DSP_IPI_24XX_PHYS OMAP2420_DSP_IPI_BASE /* 0x59000000 */
95#define DSP_IPI_24XX_VIRT 0xe1000000 102#define DSP_IPI_24XX_VIRT 0xe1000000
96#define DSP_IPI_24XX_SIZE SZ_4K 103#define DSP_IPI_24XX_SIZE SZ_4K
97#define DSP_MMU_24XX_PHYS OMAP24XX_DSP_MMU_BASE /* 0x5a000000 */ 104#define DSP_MMU_24XX_PHYS OMAP2420_DSP_MMU_BASE /* 0x5a000000 */
98#define DSP_MMU_24XX_VIRT 0xe2000000 105#define DSP_MMU_24XX_VIRT 0xe2000000
99#define DSP_MMU_24XX_SIZE SZ_4K 106#define DSP_MMU_24XX_SIZE SZ_4K
100 107
108#elif defined(CONFIG_ARCH_OMAP3)
109
110/* We map both L3 and L4 on OMAP3 */
111#define L3_34XX_PHYS L3_34XX_BASE /* 0x68000000 */
112#define L3_34XX_VIRT 0xf8000000
113#define L3_34XX_SIZE SZ_1M /* 44kB of 128MB used, want 1MB sect */
114
115#define L4_34XX_PHYS L4_34XX_BASE /* 0x48000000 */
116#define L4_34XX_VIRT 0xd8000000
117#define L4_34XX_SIZE SZ_4M /* 1MB of 128MB used, want 1MB sect */
118
119/*
120 * Need to look at the Size 4M for L4.
121 * VPOM3430 was not working for Int controller
122 */
123
124#define L4_WK_34XX_PHYS L4_WK_34XX_BASE /* 0x48300000 */
125#define L4_WK_34XX_VIRT 0xd8300000
126#define L4_WK_34XX_SIZE SZ_1M
127
128#define L4_PER_34XX_PHYS L4_PER_34XX_BASE /* 0x49000000 */
129#define L4_PER_34XX_VIRT 0xd9000000
130#define L4_PER_34XX_SIZE SZ_1M
131
132#define L4_EMU_34XX_PHYS L4_EMU_34XX_BASE /* 0x54000000 */
133#define L4_EMU_34XX_VIRT 0xe4000000
134#define L4_EMU_34XX_SIZE SZ_64M
135
136#define OMAP34XX_GPMC_PHYS OMAP34XX_GPMC_BASE /* 0x6E000000 */
137#define OMAP34XX_GPMC_VIRT 0xFE000000
138#define OMAP34XX_GPMC_SIZE SZ_1M
139
140#define OMAP343X_SMS_PHYS OMAP343X_SMS_BASE /* 0x6C000000 */
141#define OMAP343X_SMS_VIRT 0xFC000000
142#define OMAP343X_SMS_SIZE SZ_1M
143
144#define OMAP343X_SDRC_PHYS OMAP343X_SDRC_BASE /* 0x6D000000 */
145#define OMAP343X_SDRC_VIRT 0xFD000000
146#define OMAP343X_SDRC_SIZE SZ_1M
147
148
149#define IO_OFFSET 0x90000000
150#define IO_ADDRESS(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */
151#define io_p2v(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */
152#define io_v2p(va) ((va) - IO_OFFSET)/* Works for L3 and L4 */
153
154/* DSP */
155#define DSP_MEM_34XX_PHYS OMAP34XX_DSP_MEM_BASE /* 0x58000000 */
156#define DSP_MEM_34XX_VIRT 0xe0000000
157#define DSP_MEM_34XX_SIZE 0x28000
158#define DSP_IPI_34XX_PHYS OMAP34XX_DSP_IPI_BASE /* 0x59000000 */
159#define DSP_IPI_34XX_VIRT 0xe1000000
160#define DSP_IPI_34XX_SIZE SZ_4K
161#define DSP_MMU_34XX_PHYS OMAP34XX_DSP_MMU_BASE /* 0x5a000000 */
162#define DSP_MMU_34XX_VIRT 0xe2000000
163#define DSP_MMU_34XX_SIZE SZ_4K
164
101#endif 165#endif
102 166
103#ifndef __ASSEMBLER__ 167#ifndef __ASSEMBLER__
diff --git a/include/asm-arm/arch-omap/mmc.h b/include/asm-arm/arch-omap/mmc.h
index b70e37b61242..c9588f49eb52 100644
--- a/include/asm-arm/arch-omap/mmc.h
+++ b/include/asm-arm/arch-omap/mmc.h
@@ -18,6 +18,8 @@
18#define OMAP_MMC_MAX_SLOTS 2 18#define OMAP_MMC_MAX_SLOTS 2
19 19
20struct omap_mmc_platform_data { 20struct omap_mmc_platform_data {
21 struct omap_mmc_conf conf;
22
21 unsigned enabled:1; 23 unsigned enabled:1;
22 /* number of slots on board */ 24 /* number of slots on board */
23 unsigned nr_slots:2; 25 unsigned nr_slots:2;
diff --git a/include/asm-arm/arch-omap/mux.h b/include/asm-arm/arch-omap/mux.h
index b8fff50e6a87..ff9a5b5575fd 100644
--- a/include/asm-arm/arch-omap/mux.h
+++ b/include/asm-arm/arch-omap/mux.h
@@ -4,9 +4,10 @@
4 * Table of the Omap register configurations for the FUNC_MUX and 4 * Table of the Omap register configurations for the FUNC_MUX and
5 * PULL_DWN combinations. 5 * PULL_DWN combinations.
6 * 6 *
7 * Copyright (C) 2003 - 2005 Nokia Corporation 7 * Copyright (C) 2004 - 2008 Texas Instruments Inc.
8 * Copyright (C) 2003 - 2008 Nokia Corporation
8 * 9 *
9 * Written by Tony Lindgren <tony.lindgren@nokia.com> 10 * Written by Tony Lindgren
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify 12 * 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 * it under the terms of the GNU General Public License as published by
@@ -27,14 +28,6 @@
27 * - W8 = ball 28 * - W8 = ball
28 * - 1610 = 1510 or 1610, none if common for both 1510 and 1610 29 * - 1610 = 1510 or 1610, none if common for both 1510 and 1610
29 * - MMC2_DAT0 = function 30 * - MMC2_DAT0 = function
30 *
31 * Change log:
32 * Added entry for the I2C interface. (02Feb 2004)
33 * Copyright (C) 2004 Texas Instruments
34 *
35 * Added entry for the keypad and uwire CS1. (09Mar 2004)
36 * Copyright (C) 2004 Texas Instruments
37 *
38 */ 31 */
39 32
40#ifndef __ASM_ARCH_MUX_H 33#ifndef __ASM_ARCH_MUX_H
@@ -469,7 +462,12 @@ enum omap24xx_index {
469 AA8_242X_GPIO58, 462 AA8_242X_GPIO58,
470 Y20_24XX_GPIO60, 463 Y20_24XX_GPIO60,
471 W4__24XX_GPIO74, 464 W4__24XX_GPIO74,
465 N15_24XX_GPIO85,
472 M15_24XX_GPIO92, 466 M15_24XX_GPIO92,
467 P20_24XX_GPIO93,
468 P18_24XX_GPIO95,
469 M18_24XX_GPIO96,
470 L14_24XX_GPIO97,
473 J15_24XX_GPIO99, 471 J15_24XX_GPIO99,
474 V14_24XX_GPIO117, 472 V14_24XX_GPIO117,
475 P14_24XX_GPIO125, 473 P14_24XX_GPIO125,
@@ -494,8 +492,6 @@ enum omap24xx_index {
494 D3_242X_DMAREQ4, 492 D3_242X_DMAREQ4,
495 E3_242X_DMAREQ5, 493 E3_242X_DMAREQ5,
496 494
497 P20_24XX_TSC_IRQ,
498
499 /* UART3 */ 495 /* UART3 */
500 K15_24XX_UART3_TX, 496 K15_24XX_UART3_TX,
501 K14_24XX_UART3_RX, 497 K14_24XX_UART3_RX,
@@ -557,13 +553,57 @@ enum omap24xx_index {
557 B3__24XX_KBR5, 553 B3__24XX_KBR5,
558 AA4_24XX_KBC2, 554 AA4_24XX_KBC2,
559 B13_24XX_KBC6, 555 B13_24XX_KBC6,
556
557 /* 2430 USB */
558 AD9_2430_USB0_PUEN,
559 Y11_2430_USB0_VP,
560 AD7_2430_USB0_VM,
561 AE7_2430_USB0_RCV,
562 AD4_2430_USB0_TXEN,
563 AF9_2430_USB0_SE0,
564 AE6_2430_USB0_DAT,
565 AD24_2430_USB1_SE0,
566 AB24_2430_USB1_RCV,
567 Y25_2430_USB1_TXEN,
568 AA26_2430_USB1_DAT,
569
570 /* 2430 HS-USB */
571 AD9_2430_USB0HS_DATA3,
572 Y11_2430_USB0HS_DATA4,
573 AD7_2430_USB0HS_DATA5,
574 AE7_2430_USB0HS_DATA6,
575 AD4_2430_USB0HS_DATA2,
576 AF9_2430_USB0HS_DATA0,
577 AE6_2430_USB0HS_DATA1,
578 AE8_2430_USB0HS_CLK,
579 AD8_2430_USB0HS_DIR,
580 AE5_2430_USB0HS_STP,
581 AE9_2430_USB0HS_NXT,
582 AC7_2430_USB0HS_DATA7,
583
584 /* 2430 McBSP */
585 AC10_2430_MCBSP2_FSX,
586 AD16_2430_MCBSP2_CLX,
587 AE13_2430_MCBSP2_DX,
588 AD13_2430_MCBSP2_DR,
589 AC10_2430_MCBSP2_FSX_OFF,
590 AD16_2430_MCBSP2_CLX_OFF,
591 AE13_2430_MCBSP2_DX_OFF,
592 AD13_2430_MCBSP2_DR_OFF,
593
594};
595
596struct omap_mux_cfg {
597 struct pin_config *pins;
598 unsigned long size;
599 int (*cfg_reg)(const struct pin_config *cfg);
560}; 600};
561 601
562#ifdef CONFIG_OMAP_MUX 602#ifdef CONFIG_OMAP_MUX
563/* setup pin muxing in Linux */ 603/* setup pin muxing in Linux */
564extern int omap1_mux_init(void); 604extern int omap1_mux_init(void);
565extern int omap2_mux_init(void); 605extern int omap2_mux_init(void);
566extern int omap_mux_register(struct pin_config * pins, unsigned long size); 606extern int omap_mux_register(struct omap_mux_cfg *);
567extern int omap_cfg_reg(unsigned long reg_cfg); 607extern int omap_cfg_reg(unsigned long reg_cfg);
568#else 608#else
569/* boot loader does it all (no warnings from CONFIG_OMAP_MUX_WARNINGS) */ 609/* boot loader does it all (no warnings from CONFIG_OMAP_MUX_WARNINGS) */
diff --git a/include/asm-arm/arch-omap/omap24xx.h b/include/asm-arm/arch-omap/omap24xx.h
index 14c0f9496579..b9fcaae287c8 100644
--- a/include/asm-arm/arch-omap/omap24xx.h
+++ b/include/asm-arm/arch-omap/omap24xx.h
@@ -1,3 +1,28 @@
1/*
2 * include/asm-arm/arch-omap/omap24xx.h
3 *
4 * This file contains the processor specific definitions
5 * of the TI OMAP24XX.
6 *
7 * Copyright (C) 2007 Texas Instruments.
8 * Copyright (C) 2007 Nokia Corporation.
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
1#ifndef __ASM_ARCH_OMAP24XX_H 26#ifndef __ASM_ARCH_OMAP24XX_H
2#define __ASM_ARCH_OMAP24XX_H 27#define __ASM_ARCH_OMAP24XX_H
3 28
@@ -13,33 +38,70 @@
13 38
14/* interrupt controller */ 39/* interrupt controller */
15#define OMAP24XX_IC_BASE (L4_24XX_BASE + 0xfe000) 40#define OMAP24XX_IC_BASE (L4_24XX_BASE + 0xfe000)
16#define VA_IC_BASE IO_ADDRESS(OMAP24XX_IC_BASE)
17#define OMAP24XX_IVA_INTC_BASE 0x40000000 41#define OMAP24XX_IVA_INTC_BASE 0x40000000
18#define IRQ_SIR_IRQ 0x0040 42#define IRQ_SIR_IRQ 0x0040
19 43
20#ifdef CONFIG_ARCH_OMAP2420 44#define OMAP2420_CTRL_BASE L4_24XX_BASE
21#define OMAP24XX_32KSYNCT_BASE (L4_24XX_BASE + 0x4000) 45#define OMAP2420_32KSYNCT_BASE (L4_24XX_BASE + 0x4000)
22#define OMAP24XX_PRCM_BASE (L4_24XX_BASE + 0x8000) 46#define OMAP2420_PRCM_BASE (L4_24XX_BASE + 0x8000)
23#define OMAP24XX_SDRC_BASE (L3_24XX_BASE + 0x9000) 47#define OMAP2420_CM_BASE (L4_24XX_BASE + 0x8000)
24#define OMAP242X_CONTROL_STATUS (L4_24XX_BASE + 0x2f8) 48#define OMAP2420_PRM_BASE OMAP2420_CM_BASE
25#endif 49#define OMAP2420_SDRC_BASE (L3_24XX_BASE + 0x9000)
50#define OMAP2420_SMS_BASE 0x68008000
26 51
27#ifdef CONFIG_ARCH_OMAP2430 52#define OMAP2430_32KSYNCT_BASE (L4_WK_243X_BASE + 0x20000)
28#define OMAP24XX_32KSYNCT_BASE (L4_WK_243X_BASE + 0x20000) 53#define OMAP2430_PRCM_BASE (L4_WK_243X_BASE + 0x6000)
29#define OMAP24XX_PRCM_BASE (L4_WK_243X_BASE + 0x6000) 54#define OMAP2430_CM_BASE (L4_WK_243X_BASE + 0x6000)
30#define OMAP24XX_SDRC_BASE (0x6D000000) 55#define OMAP2430_PRM_BASE OMAP2430_CM_BASE
31#define OMAP242X_CONTROL_STATUS (L4_24XX_BASE + 0x2f8) 56
57#define OMAP243X_SMS_BASE 0x6C000000
58#define OMAP243X_SDRC_BASE 0x6D000000
32#define OMAP243X_GPMC_BASE 0x6E000000 59#define OMAP243X_GPMC_BASE 0x6E000000
33#endif 60#define OMAP243X_SCM_BASE (L4_WK_243X_BASE + 0x2000)
61#define OMAP243X_CTRL_BASE OMAP243X_SCM_BASE
62#define OMAP243X_HS_BASE (L4_24XX_BASE + 0x000ac000)
34 63
35/* DSP SS */ 64/* DSP SS */
36#define OMAP24XX_DSP_BASE 0x58000000 65#define OMAP2420_DSP_BASE 0x58000000
37#define OMAP24XX_DSP_MEM_BASE (OMAP24XX_DSP_BASE + 0x0) 66#define OMAP2420_DSP_MEM_BASE (OMAP2420_DSP_BASE + 0x0)
38#define OMAP24XX_DSP_IPI_BASE (OMAP24XX_DSP_BASE + 0x1000000) 67#define OMAP2420_DSP_IPI_BASE (OMAP2420_DSP_BASE + 0x1000000)
39#define OMAP24XX_DSP_MMU_BASE (OMAP24XX_DSP_BASE + 0x2000000) 68#define OMAP2420_DSP_MMU_BASE (OMAP2420_DSP_BASE + 0x2000000)
69
70#define OMAP243X_DSP_BASE 0x5C000000
71#define OMAP243X_DSP_MEM_BASE (OMAP243X_DSP_BASE + 0x0)
72#define OMAP243X_DSP_MMU_BASE (OMAP243X_DSP_BASE + 0x1000000)
40 73
41/* Mailbox */ 74/* Mailbox */
42#define OMAP24XX_MAILBOX_BASE (L4_24XX_BASE + 0x94000) 75#define OMAP24XX_MAILBOX_BASE (L4_24XX_BASE + 0x94000)
43 76
77/* Camera */
78#define OMAP24XX_CAMERA_BASE (L4_24XX_BASE + 0x52000)
79
80/* Security */
81#define OMAP24XX_SEC_BASE (L4_24XX_BASE + 0xA0000)
82#define OMAP24XX_SEC_RNG_BASE (OMAP24XX_SEC_BASE + 0x0000)
83#define OMAP24XX_SEC_DES_BASE (OMAP24XX_SEC_BASE + 0x2000)
84#define OMAP24XX_SEC_SHA1MD5_BASE (OMAP24XX_SEC_BASE + 0x4000)
85#define OMAP24XX_SEC_AES_BASE (OMAP24XX_SEC_BASE + 0x6000)
86#define OMAP24XX_SEC_PKA_BASE (OMAP24XX_SEC_BASE + 0x8000)
87
88#if defined(CONFIG_ARCH_OMAP2420)
89
90#define OMAP2_32KSYNCT_BASE OMAP2420_32KSYNCT_BASE
91#define OMAP2_PRCM_BASE OMAP2420_PRCM_BASE
92#define OMAP2_CM_BASE OMAP2420_CM_BASE
93#define OMAP2_PRM_BASE OMAP2420_PRM_BASE
94#define OMAP2_VA_IC_BASE IO_ADDRESS(OMAP24XX_IC_BASE)
95
96#elif defined(CONFIG_ARCH_OMAP2430)
97
98#define OMAP2_32KSYNCT_BASE OMAP2430_32KSYNCT_BASE
99#define OMAP2_PRCM_BASE OMAP2430_PRCM_BASE
100#define OMAP2_CM_BASE OMAP2430_CM_BASE
101#define OMAP2_PRM_BASE OMAP2430_PRM_BASE
102#define OMAP2_VA_IC_BASE IO_ADDRESS(OMAP24XX_IC_BASE)
103
104#endif
105
44#endif /* __ASM_ARCH_OMAP24XX_H */ 106#endif /* __ASM_ARCH_OMAP24XX_H */
45 107
diff --git a/include/asm-arm/arch-omap/sdrc.h b/include/asm-arm/arch-omap/sdrc.h
new file mode 100644
index 000000000000..673b3965befc
--- /dev/null
+++ b/include/asm-arm/arch-omap/sdrc.h
@@ -0,0 +1,75 @@
1#ifndef ____ASM_ARCH_SDRC_H
2#define ____ASM_ARCH_SDRC_H
3
4/*
5 * OMAP2/3 SDRC/SMS register definitions
6 *
7 * Copyright (C) 2007 Texas Instruments, Inc.
8 * Copyright (C) 2007 Nokia Corporation
9 *
10 * Written by Paul Walmsley
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <asm/arch/io.h>
18
19/* SDRC register offsets - read/write with sdrc_{read,write}_reg() */
20
21#define SDRC_SYSCONFIG 0x010
22#define SDRC_DLLA_CTRL 0x060
23#define SDRC_DLLA_STATUS 0x064
24#define SDRC_DLLB_CTRL 0x068
25#define SDRC_DLLB_STATUS 0x06C
26#define SDRC_POWER 0x070
27#define SDRC_MR_0 0x084
28#define SDRC_RFR_CTRL_0 0x0a4
29
30/*
31 * These values represent the number of memory clock cycles between
32 * autorefresh initiation. They assume 1 refresh per 64 ms (JEDEC), 8192
33 * rows per device, and include a subtraction of a 50 cycle window in the
34 * event that the autorefresh command is delayed due to other SDRC activity.
35 * The '| 1' sets the ARE field to send one autorefresh when the autorefresh
36 * counter reaches 0.
37 *
38 * These represent optimal values for common parts, it won't work for all.
39 * As long as you scale down, most parameters are still work, they just
40 * become sub-optimal. The RFR value goes in the opposite direction. If you
41 * don't adjust it down as your clock period increases the refresh interval
42 * will not be met. Setting all parameters for complete worst case may work,
43 * but may cut memory performance by 2x. Due to errata the DLLs need to be
44 * unlocked and their value needs run time calibration. A dynamic call is
45 * need for that as no single right value exists acorss production samples.
46 *
47 * Only the FULL speed values are given. Current code is such that rate
48 * changes must be made at DPLLoutx2. The actual value adjustment for low
49 * frequency operation will be handled by omap_set_performance()
50 *
51 * By having the boot loader boot up in the fastest L4 speed available likely
52 * will result in something which you can switch between.
53 */
54#define SDRC_RFR_CTRL_165MHz (0x00044c00 | 1)
55#define SDRC_RFR_CTRL_133MHz (0x0003de00 | 1)
56#define SDRC_RFR_CTRL_100MHz (0x0002da01 | 1)
57#define SDRC_RFR_CTRL_110MHz (0x0002da01 | 1) /* Need to calc */
58#define SDRC_RFR_CTRL_BYPASS (0x00005000 | 1) /* Need to calc */
59
60
61/*
62 * SMS register access
63 */
64
65
66#define OMAP242X_SMS_REGADDR(reg) (void __iomem *)IO_ADDRESS(OMAP2420_SMS_BASE + reg)
67#define OMAP243X_SMS_REGADDR(reg) (void __iomem *)IO_ADDRESS(OMAP243X_SMS_BASE + reg)
68#define OMAP343X_SMS_REGADDR(reg) (void __iomem *)IO_ADDRESS(OMAP343X_SMS_BASE + reg)
69
70/* SMS register offsets - read/write with sms_{read,write}_reg() */
71
72#define SMS_SYSCONFIG 0x010
73/* REVISIT: fill in other SMS registers here */
74
75#endif
diff --git a/include/asm-arm/arch-omap/usb.h b/include/asm-arm/arch-omap/usb.h
index 99ae9eabaf71..2147d18aaeae 100644
--- a/include/asm-arm/arch-omap/usb.h
+++ b/include/asm-arm/arch-omap/usb.h
@@ -132,14 +132,11 @@
132# define CONF_USB_PWRDN_DP_R (1 << 1) 132# define CONF_USB_PWRDN_DP_R (1 << 1)
133 133
134/* OMAP2 */ 134/* OMAP2 */
135#define CONTROL_DEVCONF_REG __REG32(L4_24XX_BASE + 0x0274)
136# define USB_UNIDIR 0x0 135# define USB_UNIDIR 0x0
137# define USB_UNIDIR_TLL 0x1 136# define USB_UNIDIR_TLL 0x1
138# define USB_BIDIR 0x2 137# define USB_BIDIR 0x2
139# define USB_BIDIR_TLL 0x3 138# define USB_BIDIR_TLL 0x3
140# define USBT0WRMODEI(x) ((x) << 22) 139# define USBTXWRMODEI(port, x) ((x) << (22 - (port * 2)))
141# define USBT1WRMODEI(x) ((x) << 20)
142# define USBT2WRMODEI(x) ((x) << 18)
143# define USBT2TLL5PI (1 << 17) 140# define USBT2TLL5PI (1 << 17)
144# define USB0PUENACTLOI (1 << 16) 141# define USB0PUENACTLOI (1 << 16)
145# define USBSTANDBYCTRL (1 << 15) 142# define USBSTANDBYCTRL (1 << 15)
diff --git a/include/asm-arm/arch-orion/io.h b/include/asm-arm/arch-orion/io.h
deleted file mode 100644
index e0b8c39b9167..000000000000
--- a/include/asm-arm/arch-orion/io.h
+++ /dev/null
@@ -1,27 +0,0 @@
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
deleted file mode 100644
index eea65ca6076a..000000000000
--- a/include/asm-arm/arch-orion/irqs.h
+++ /dev/null
@@ -1,61 +0,0 @@
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/orion.h b/include/asm-arm/arch-orion/orion.h
deleted file mode 100644
index 673a418a7419..000000000000
--- a/include/asm-arm/arch-orion/orion.h
+++ /dev/null
@@ -1,165 +0,0 @@
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 *
20 * virt phys size
21 * fdd00000 f1000000 1M on-chip peripheral registers
22 * fde00000 f2000000 1M PCIe I/O space
23 * fdf00000 f2100000 1M PCI I/O space
24 * fe000000 f0000000 16M PCIe WA space (Orion-NAS only)
25 ****************************************************************************/
26#define ORION_REGS_PHYS_BASE 0xf1000000
27#define ORION_REGS_VIRT_BASE 0xfdd00000
28#define ORION_REGS_SIZE SZ_1M
29
30#define ORION_PCIE_IO_PHYS_BASE 0xf2000000
31#define ORION_PCIE_IO_VIRT_BASE 0xfde00000
32#define ORION_PCIE_IO_BUS_BASE 0x00000000
33#define ORION_PCIE_IO_SIZE SZ_1M
34
35#define ORION_PCI_IO_PHYS_BASE 0xf2100000
36#define ORION_PCI_IO_VIRT_BASE 0xfdf00000
37#define ORION_PCI_IO_BUS_BASE 0x00100000
38#define ORION_PCI_IO_SIZE SZ_1M
39
40/* Relevant only for Orion-NAS */
41#define ORION_PCIE_WA_PHYS_BASE 0xf0000000
42#define ORION_PCIE_WA_VIRT_BASE 0xfe000000
43#define ORION_PCIE_WA_SIZE SZ_16M
44
45#define ORION_PCIE_MEM_PHYS_BASE 0xe0000000
46#define ORION_PCIE_MEM_SIZE SZ_128M
47
48#define ORION_PCI_MEM_PHYS_BASE 0xe8000000
49#define ORION_PCI_MEM_SIZE SZ_128M
50
51/*******************************************************************************
52 * Supported Devices & Revisions
53 ******************************************************************************/
54/* Orion-1 (88F5181) */
55#define MV88F5181_DEV_ID 0x5181
56#define MV88F5181_REV_B1 3
57/* Orion-NAS (88F5182) */
58#define MV88F5182_DEV_ID 0x5182
59#define MV88F5182_REV_A2 2
60/* Orion-2 (88F5281) */
61#define MV88F5281_DEV_ID 0x5281
62#define MV88F5281_REV_D1 5
63#define MV88F5281_REV_D2 6
64
65/*******************************************************************************
66 * Orion Registers Map
67 ******************************************************************************/
68#define ORION_DDR_VIRT_BASE (ORION_REGS_VIRT_BASE | 0x00000)
69#define ORION_DDR_REG(x) (ORION_DDR_VIRT_BASE | (x))
70
71#define ORION_DEV_BUS_PHYS_BASE (ORION_REGS_PHYS_BASE | 0x10000)
72#define ORION_DEV_BUS_VIRT_BASE (ORION_REGS_VIRT_BASE | 0x10000)
73#define ORION_DEV_BUS_REG(x) (ORION_DEV_BUS_VIRT_BASE | (x))
74#define I2C_PHYS_BASE (ORION_DEV_BUS_PHYS_BASE | 0x1000)
75#define UART0_PHYS_BASE (ORION_DEV_BUS_PHYS_BASE | 0x2000)
76#define UART0_VIRT_BASE (ORION_DEV_BUS_VIRT_BASE | 0x2000)
77#define UART1_PHYS_BASE (ORION_DEV_BUS_PHYS_BASE | 0x2100)
78#define UART1_VIRT_BASE (ORION_DEV_BUS_VIRT_BASE | 0x2100)
79
80#define ORION_BRIDGE_VIRT_BASE (ORION_REGS_VIRT_BASE | 0x20000)
81#define ORION_BRIDGE_REG(x) (ORION_BRIDGE_VIRT_BASE | (x))
82
83#define ORION_PCI_VIRT_BASE (ORION_REGS_VIRT_BASE | 0x30000)
84#define ORION_PCI_REG(x) (ORION_PCI_VIRT_BASE | (x))
85
86#define ORION_PCIE_VIRT_BASE (ORION_REGS_VIRT_BASE | 0x40000)
87#define ORION_PCIE_REG(x) (ORION_PCIE_VIRT_BASE | (x))
88
89#define ORION_USB0_PHYS_BASE (ORION_REGS_PHYS_BASE | 0x50000)
90#define ORION_USB0_VIRT_BASE (ORION_REGS_VIRT_BASE | 0x50000)
91#define ORION_USB0_REG(x) (ORION_USB0_VIRT_BASE | (x))
92
93#define ORION_ETH_PHYS_BASE (ORION_REGS_PHYS_BASE | 0x70000)
94#define ORION_ETH_VIRT_BASE (ORION_REGS_VIRT_BASE | 0x70000)
95#define ORION_ETH_REG(x) (ORION_ETH_VIRT_BASE | (x))
96
97#define ORION_SATA_PHYS_BASE (ORION_REGS_PHYS_BASE | 0x80000)
98#define ORION_SATA_VIRT_BASE (ORION_REGS_VIRT_BASE | 0x80000)
99#define ORION_SATA_REG(x) (ORION_SATA_VIRT_BASE | (x))
100
101#define ORION_USB1_PHYS_BASE (ORION_REGS_PHYS_BASE | 0xa0000)
102#define ORION_USB1_VIRT_BASE (ORION_REGS_VIRT_BASE | 0xa0000)
103#define ORION_USB1_REG(x) (ORION_USB1_VIRT_BASE | (x))
104
105/*******************************************************************************
106 * Device Bus Registers
107 ******************************************************************************/
108#define MPP_0_7_CTRL ORION_DEV_BUS_REG(0x000)
109#define MPP_8_15_CTRL ORION_DEV_BUS_REG(0x004)
110#define MPP_16_19_CTRL ORION_DEV_BUS_REG(0x050)
111#define MPP_DEV_CTRL ORION_DEV_BUS_REG(0x008)
112#define MPP_RESET_SAMPLE ORION_DEV_BUS_REG(0x010)
113#define GPIO_OUT ORION_DEV_BUS_REG(0x100)
114#define GPIO_IO_CONF ORION_DEV_BUS_REG(0x104)
115#define GPIO_BLINK_EN ORION_DEV_BUS_REG(0x108)
116#define GPIO_IN_POL ORION_DEV_BUS_REG(0x10c)
117#define GPIO_DATA_IN ORION_DEV_BUS_REG(0x110)
118#define GPIO_EDGE_CAUSE ORION_DEV_BUS_REG(0x114)
119#define GPIO_EDGE_MASK ORION_DEV_BUS_REG(0x118)
120#define GPIO_LEVEL_MASK ORION_DEV_BUS_REG(0x11c)
121#define DEV_BANK_0_PARAM ORION_DEV_BUS_REG(0x45c)
122#define DEV_BANK_1_PARAM ORION_DEV_BUS_REG(0x460)
123#define DEV_BANK_2_PARAM ORION_DEV_BUS_REG(0x464)
124#define DEV_BANK_BOOT_PARAM ORION_DEV_BUS_REG(0x46c)
125#define DEV_BUS_CTRL ORION_DEV_BUS_REG(0x4c0)
126#define DEV_BUS_INT_CAUSE ORION_DEV_BUS_REG(0x4d0)
127#define DEV_BUS_INT_MASK ORION_DEV_BUS_REG(0x4d4)
128#define GPIO_MAX 32
129
130/***************************************************************************
131 * Orion CPU Bridge Registers
132 **************************************************************************/
133#define CPU_CONF ORION_BRIDGE_REG(0x100)
134#define CPU_CTRL ORION_BRIDGE_REG(0x104)
135#define CPU_RESET_MASK ORION_BRIDGE_REG(0x108)
136#define CPU_SOFT_RESET ORION_BRIDGE_REG(0x10c)
137#define POWER_MNG_CTRL_REG ORION_BRIDGE_REG(0x11C)
138#define BRIDGE_CAUSE ORION_BRIDGE_REG(0x110)
139#define BRIDGE_MASK ORION_BRIDGE_REG(0x114)
140#define MAIN_IRQ_CAUSE ORION_BRIDGE_REG(0x200)
141#define MAIN_IRQ_MASK ORION_BRIDGE_REG(0x204)
142#define TIMER_CTRL ORION_BRIDGE_REG(0x300)
143#define TIMER_VAL(x) ORION_BRIDGE_REG(0x314 + ((x) * 8))
144#define TIMER_VAL_RELOAD(x) ORION_BRIDGE_REG(0x310 + ((x) * 8))
145
146#ifndef __ASSEMBLY__
147
148/*******************************************************************************
149 * Helpers to access Orion registers
150 ******************************************************************************/
151#include <asm/types.h>
152#include <asm/io.h>
153
154#define orion_read(r) __raw_readl(r)
155#define orion_write(r, val) __raw_writel(val, r)
156
157/*
158 * These are not preempt safe. Locks, if needed, must be taken care by caller.
159 */
160#define orion_setbits(r, mask) orion_write((r), orion_read(r) | (mask))
161#define orion_clrbits(r, mask) orion_write((r), orion_read(r) & ~(mask))
162
163#endif /* __ASSEMBLY__ */
164
165#endif /* __ASM_ARCH_ORION_H__ */
diff --git a/include/asm-arm/arch-orion/timex.h b/include/asm-arm/arch-orion/timex.h
deleted file mode 100644
index 26c2c91eecf0..000000000000
--- a/include/asm-arm/arch-orion/timex.h
+++ /dev/null
@@ -1,12 +0,0 @@
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/debug-macro.S b/include/asm-arm/arch-orion5x/debug-macro.S
index 2746220f5d85..4f98f3ba2929 100644
--- a/include/asm-arm/arch-orion/debug-macro.S
+++ b/include/asm-arm/arch-orion5x/debug-macro.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/include/asm-arm/arch-orion/debug-macro.S 2 * include/asm-arm/arch-orion5x/debug-macro.S
3 * 3 *
4 * Debugging macro include header 4 * Debugging macro include header
5 * 5 *
@@ -8,13 +8,13 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9*/ 9*/
10 10
11#include <asm/arch/orion.h> 11#include <asm/arch/orion5x.h>
12 12
13 .macro addruart,rx 13 .macro addruart,rx
14 mrc p15, 0, \rx, c1, c0 14 mrc p15, 0, \rx, c1, c0
15 tst \rx, #1 @ MMU enabled? 15 tst \rx, #1 @ MMU enabled?
16 ldreq \rx, =ORION_REGS_PHYS_BASE 16 ldreq \rx, =ORION5X_REGS_PHYS_BASE
17 ldrne \rx, =ORION_REGS_VIRT_BASE 17 ldrne \rx, =ORION5X_REGS_VIRT_BASE
18 orr \rx, \rx, #0x00012000 18 orr \rx, \rx, #0x00012000
19 .endm 19 .endm
20 20
diff --git a/include/asm-arm/arch-orion/dma.h b/include/asm-arm/arch-orion5x/dma.h
index 40a8c178f10d..40a8c178f10d 100644
--- a/include/asm-arm/arch-orion/dma.h
+++ b/include/asm-arm/arch-orion5x/dma.h
diff --git a/include/asm-arm/arch-orion/entry-macro.S b/include/asm-arm/arch-orion5x/entry-macro.S
index cda096b2acfd..d8ef54c0ee9a 100644
--- a/include/asm-arm/arch-orion/entry-macro.S
+++ b/include/asm-arm/arch-orion5x/entry-macro.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-arm/arch-orion/entry-macro.S 2 * include/asm-arm/arch-orion5x/entry-macro.S
3 * 3 *
4 * Low-level IRQ helper macros for Orion platforms 4 * Low-level IRQ helper macros for Orion platforms
5 * 5 *
@@ -8,7 +8,7 @@
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 10
11#include <asm/arch/orion.h> 11#include <asm/arch/orion5x.h>
12 12
13 .macro disable_fiq 13 .macro disable_fiq
14 .endm 14 .endm
diff --git a/include/asm-arm/arch-orion/gpio.h b/include/asm-arm/arch-orion5x/gpio.h
index d66284f9a14c..c85e498388b6 100644
--- a/include/asm-arm/arch-orion/gpio.h
+++ b/include/asm-arm/arch-orion5x/gpio.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-arm/arch-orion/gpio.h 2 * include/asm-arm/arch-orion5x/gpio.h
3 * 3 *
4 * This file is licensed under the terms of the GNU General Public 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 5 * License version 2. This program is licensed "as is" without any
@@ -12,17 +12,17 @@ extern int gpio_direction_input(unsigned pin);
12extern int gpio_direction_output(unsigned pin, int value); 12extern int gpio_direction_output(unsigned pin, int value);
13extern int gpio_get_value(unsigned pin); 13extern int gpio_get_value(unsigned pin);
14extern void gpio_set_value(unsigned pin, int value); 14extern void gpio_set_value(unsigned pin, int value);
15extern void orion_gpio_set_blink(unsigned pin, int blink); 15extern void orion5x_gpio_set_blink(unsigned pin, int blink);
16extern void gpio_display(void); /* debug */ 16extern void gpio_display(void); /* debug */
17 17
18static inline int gpio_to_irq(int pin) 18static inline int gpio_to_irq(int pin)
19{ 19{
20 return pin + IRQ_ORION_GPIO_START; 20 return pin + IRQ_ORION5X_GPIO_START;
21} 21}
22 22
23static inline int irq_to_gpio(int irq) 23static inline int irq_to_gpio(int irq)
24{ 24{
25 return irq - IRQ_ORION_GPIO_START; 25 return irq - IRQ_ORION5X_GPIO_START;
26} 26}
27 27
28#include <asm-generic/gpio.h> /* cansleep wrappers */ 28#include <asm-generic/gpio.h> /* cansleep wrappers */
diff --git a/include/asm-arm/arch-orion/hardware.h b/include/asm-arm/arch-orion5x/hardware.h
index 65da374de735..5d2d8e0b5630 100644
--- a/include/asm-arm/arch-orion/hardware.h
+++ b/include/asm-arm/arch-orion5x/hardware.h
@@ -1,21 +1,21 @@
1/* 1/*
2 * include/asm-arm/arch-orion/hardware.h 2 * include/asm-arm/arch-orion5x/hardware.h
3 * 3 *
4 * 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
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8 8
9#ifndef __ASM_ARCH_HARDWARE_H__ 9#ifndef __ASM_ARCH_HARDWARE_H
10#define __ASM_ARCH_HARDWARE_H__ 10#define __ASM_ARCH_HARDWARE_H
11 11
12#include "orion.h" 12#include "orion5x.h"
13 13
14#define pcibios_assign_all_busses() 1 14#define pcibios_assign_all_busses() 1
15 15
16#define PCIBIOS_MIN_IO 0x00001000 16#define PCIBIOS_MIN_IO 0x00001000
17#define PCIBIOS_MIN_MEM 0x01000000 17#define PCIBIOS_MIN_MEM 0x01000000
18#define PCIMEM_BASE ORION_PCIE_MEM_PHYS_BASE 18#define PCIMEM_BASE ORION5X_PCIE_MEM_PHYS_BASE
19 19
20 20
21#endif 21#endif
diff --git a/include/asm-arm/arch-orion5x/io.h b/include/asm-arm/arch-orion5x/io.h
new file mode 100644
index 000000000000..50f8c8802206
--- /dev/null
+++ b/include/asm-arm/arch-orion5x/io.h
@@ -0,0 +1,67 @@
1/*
2 * include/asm-arm/arch-orion5x/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_ARCH_IO_H
12#define __ASM_ARCH_IO_H
13
14#include "orion5x.h"
15
16#define IO_SPACE_LIMIT 0xffffffff
17#define IO_SPACE_REMAP ORION5X_PCI_SYS_IO_BASE
18
19static inline void __iomem *
20__arch_ioremap(unsigned long paddr, size_t size, unsigned int mtype)
21{
22 void __iomem *retval;
23 unsigned long offs = paddr - ORION5X_REGS_PHYS_BASE;
24 if (mtype == MT_DEVICE && size && offs < ORION5X_REGS_SIZE &&
25 size <= ORION5X_REGS_SIZE && offs + size <= ORION5X_REGS_SIZE) {
26 retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + offs;
27 } else {
28 retval = __arm_ioremap(paddr, size, mtype);
29 }
30
31 return retval;
32}
33
34static inline void
35__arch_iounmap(void __iomem *addr)
36{
37 if (addr < (void __iomem *)ORION5X_REGS_VIRT_BASE ||
38 addr >= (void __iomem *)(ORION5X_REGS_VIRT_BASE + ORION5X_REGS_SIZE))
39 __iounmap(addr);
40}
41
42static inline void __iomem *__io(unsigned long addr)
43{
44 return (void __iomem *)addr;
45}
46
47#define __arch_ioremap(p, s, m) __arch_ioremap(p, s, m)
48#define __arch_iounmap(a) __arch_iounmap(a)
49#define __io(a) __io(a)
50#define __mem_pci(a) (a)
51
52
53/*****************************************************************************
54 * Helpers to access Orion registers
55 ****************************************************************************/
56#define orion5x_read(r) __raw_readl(r)
57#define orion5x_write(r, val) __raw_writel(val, r)
58
59/*
60 * These are not preempt-safe. Locks, if needed, must be taken
61 * care of by the caller.
62 */
63#define orion5x_setbits(r, mask) orion5x_write((r), orion5x_read(r) | (mask))
64#define orion5x_clrbits(r, mask) orion5x_write((r), orion5x_read(r) & ~(mask))
65
66
67#endif
diff --git a/include/asm-arm/arch-orion5x/irqs.h b/include/asm-arm/arch-orion5x/irqs.h
new file mode 100644
index 000000000000..abdd61a4833a
--- /dev/null
+++ b/include/asm-arm/arch-orion5x/irqs.h
@@ -0,0 +1,62 @@
1/*
2 * include/asm-arm/arch-orion5x/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 "orion5x.h" /* need GPIO_MAX */
17
18/*
19 * Orion Main Interrupt Controller
20 */
21#define IRQ_ORION5X_BRIDGE 0
22#define IRQ_ORION5X_DOORBELL_H2C 1
23#define IRQ_ORION5X_DOORBELL_C2H 2
24#define IRQ_ORION5X_UART0 3
25#define IRQ_ORION5X_UART1 4
26#define IRQ_ORION5X_I2C 5
27#define IRQ_ORION5X_GPIO_0_7 6
28#define IRQ_ORION5X_GPIO_8_15 7
29#define IRQ_ORION5X_GPIO_16_23 8
30#define IRQ_ORION5X_GPIO_24_31 9
31#define IRQ_ORION5X_PCIE0_ERR 10
32#define IRQ_ORION5X_PCIE0_INT 11
33#define IRQ_ORION5X_USB1_CTRL 12
34#define IRQ_ORION5X_DEV_BUS_ERR 14
35#define IRQ_ORION5X_PCI_ERR 15
36#define IRQ_ORION5X_USB_BR_ERR 16
37#define IRQ_ORION5X_USB0_CTRL 17
38#define IRQ_ORION5X_ETH_RX 18
39#define IRQ_ORION5X_ETH_TX 19
40#define IRQ_ORION5X_ETH_MISC 20
41#define IRQ_ORION5X_ETH_SUM 21
42#define IRQ_ORION5X_ETH_ERR 22
43#define IRQ_ORION5X_IDMA_ERR 23
44#define IRQ_ORION5X_IDMA_0 24
45#define IRQ_ORION5X_IDMA_1 25
46#define IRQ_ORION5X_IDMA_2 26
47#define IRQ_ORION5X_IDMA_3 27
48#define IRQ_ORION5X_CESA 28
49#define IRQ_ORION5X_SATA 29
50#define IRQ_ORION5X_XOR0 30
51#define IRQ_ORION5X_XOR1 31
52
53/*
54 * Orion General Purpose Pins
55 */
56#define IRQ_ORION5X_GPIO_START 32
57#define NR_GPIO_IRQS GPIO_MAX
58
59#define NR_IRQS (IRQ_ORION5X_GPIO_START + NR_GPIO_IRQS)
60
61
62#endif
diff --git a/include/asm-arm/arch-orion/memory.h b/include/asm-arm/arch-orion5x/memory.h
index d954dba87ced..80053a7afc7a 100644
--- a/include/asm-arm/arch-orion/memory.h
+++ b/include/asm-arm/arch-orion5x/memory.h
@@ -1,15 +1,16 @@
1/* 1/*
2 * include/asm-arm/arch-orion/memory.h 2 * include/asm-arm/arch-orion5x/memory.h
3 * 3 *
4 * Marvell Orion memory definitions 4 * Marvell Orion memory definitions
5 */ 5 */
6 6
7#ifndef __ASM_ARCH_MMU_H 7#ifndef __ASM_ARCH_MEMORY_H
8#define __ASM_ARCH_MMU_H 8#define __ASM_ARCH_MEMORY_H
9 9
10#define PHYS_OFFSET UL(0x00000000) 10#define PHYS_OFFSET UL(0x00000000)
11 11
12#define __virt_to_bus(x) __virt_to_phys(x) 12#define __virt_to_bus(x) __virt_to_phys(x)
13#define __bus_to_virt(x) __phys_to_virt(x) 13#define __bus_to_virt(x) __phys_to_virt(x)
14 14
15
15#endif 16#endif
diff --git a/include/asm-arm/arch-orion5x/orion5x.h b/include/asm-arm/arch-orion5x/orion5x.h
new file mode 100644
index 000000000000..206ddd71e193
--- /dev/null
+++ b/include/asm-arm/arch-orion5x/orion5x.h
@@ -0,0 +1,159 @@
1/*
2 * include/asm-arm/arch-orion5x/orion5x.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_ORION5X_H
15#define __ASM_ARCH_ORION5X_H
16
17/*****************************************************************************
18 * Orion Address Maps
19 *
20 * phys
21 * e0000000 PCIe MEM space
22 * e8000000 PCI MEM space
23 * f0000000 PCIe WA space (Orion-1/Orion-NAS only)
24 * f1000000 on-chip peripheral registers
25 * f2000000 PCIe I/O space
26 * f2100000 PCI I/O space
27 * f4000000 device bus mappings (boot)
28 * fa000000 device bus mappings (cs0)
29 * fa800000 device bus mappings (cs2)
30 * fc000000 device bus mappings (cs0/cs1)
31 *
32 * virt phys size
33 * fdd00000 f1000000 1M on-chip peripheral registers
34 * fde00000 f2000000 1M PCIe I/O space
35 * fdf00000 f2100000 1M PCI I/O space
36 * fe000000 f0000000 16M PCIe WA space (Orion-1/Orion-NAS only)
37 ****************************************************************************/
38#define ORION5X_REGS_PHYS_BASE 0xf1000000
39#define ORION5X_REGS_VIRT_BASE 0xfdd00000
40#define ORION5X_REGS_SIZE SZ_1M
41
42#define ORION5X_PCIE_IO_PHYS_BASE 0xf2000000
43#define ORION5X_PCIE_IO_VIRT_BASE 0xfde00000
44#define ORION5X_PCIE_IO_BUS_BASE 0x00000000
45#define ORION5X_PCIE_IO_SIZE SZ_1M
46
47#define ORION5X_PCI_IO_PHYS_BASE 0xf2100000
48#define ORION5X_PCI_IO_VIRT_BASE 0xfdf00000
49#define ORION5X_PCI_IO_BUS_BASE 0x00100000
50#define ORION5X_PCI_IO_SIZE SZ_1M
51
52/* Relevant only for Orion-1/Orion-NAS */
53#define ORION5X_PCIE_WA_PHYS_BASE 0xf0000000
54#define ORION5X_PCIE_WA_VIRT_BASE 0xfe000000
55#define ORION5X_PCIE_WA_SIZE SZ_16M
56
57#define ORION5X_PCIE_MEM_PHYS_BASE 0xe0000000
58#define ORION5X_PCIE_MEM_SIZE SZ_128M
59
60#define ORION5X_PCI_MEM_PHYS_BASE 0xe8000000
61#define ORION5X_PCI_MEM_SIZE SZ_128M
62
63/*******************************************************************************
64 * Supported Devices & Revisions
65 ******************************************************************************/
66/* Orion-1 (88F5181) */
67#define MV88F5181_DEV_ID 0x5181
68#define MV88F5181_REV_B1 3
69/* Orion-NAS (88F5182) */
70#define MV88F5182_DEV_ID 0x5182
71#define MV88F5182_REV_A2 2
72/* Orion-2 (88F5281) */
73#define MV88F5281_DEV_ID 0x5281
74#define MV88F5281_REV_D1 5
75#define MV88F5281_REV_D2 6
76
77/*******************************************************************************
78 * Orion Registers Map
79 ******************************************************************************/
80#define ORION5X_DDR_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x00000)
81#define ORION5X_DDR_REG(x) (ORION5X_DDR_VIRT_BASE | (x))
82
83#define ORION5X_DEV_BUS_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0x10000)
84#define ORION5X_DEV_BUS_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x10000)
85#define ORION5X_DEV_BUS_REG(x) (ORION5X_DEV_BUS_VIRT_BASE | (x))
86#define I2C_PHYS_BASE (ORION5X_DEV_BUS_PHYS_BASE | 0x1000)
87#define UART0_PHYS_BASE (ORION5X_DEV_BUS_PHYS_BASE | 0x2000)
88#define UART0_VIRT_BASE (ORION5X_DEV_BUS_VIRT_BASE | 0x2000)
89#define UART1_PHYS_BASE (ORION5X_DEV_BUS_PHYS_BASE | 0x2100)
90#define UART1_VIRT_BASE (ORION5X_DEV_BUS_VIRT_BASE | 0x2100)
91
92#define ORION5X_BRIDGE_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x20000)
93#define ORION5X_BRIDGE_REG(x) (ORION5X_BRIDGE_VIRT_BASE | (x))
94#define TIMER_VIRT_BASE (ORION5X_BRIDGE_VIRT_BASE | 0x300)
95
96#define ORION5X_PCI_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x30000)
97#define ORION5X_PCI_REG(x) (ORION5X_PCI_VIRT_BASE | (x))
98
99#define ORION5X_PCIE_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x40000)
100#define ORION5X_PCIE_REG(x) (ORION5X_PCIE_VIRT_BASE | (x))
101
102#define ORION5X_USB0_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0x50000)
103#define ORION5X_USB0_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x50000)
104#define ORION5X_USB0_REG(x) (ORION5X_USB0_VIRT_BASE | (x))
105
106#define ORION5X_ETH_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0x70000)
107#define ORION5X_ETH_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x70000)
108#define ORION5X_ETH_REG(x) (ORION5X_ETH_VIRT_BASE | (x))
109
110#define ORION5X_SATA_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0x80000)
111#define ORION5X_SATA_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x80000)
112#define ORION5X_SATA_REG(x) (ORION5X_SATA_VIRT_BASE | (x))
113
114#define ORION5X_USB1_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0xa0000)
115#define ORION5X_USB1_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0xa0000)
116#define ORION5X_USB1_REG(x) (ORION5X_USB1_VIRT_BASE | (x))
117
118/*******************************************************************************
119 * Device Bus Registers
120 ******************************************************************************/
121#define MPP_0_7_CTRL ORION5X_DEV_BUS_REG(0x000)
122#define MPP_8_15_CTRL ORION5X_DEV_BUS_REG(0x004)
123#define MPP_16_19_CTRL ORION5X_DEV_BUS_REG(0x050)
124#define MPP_DEV_CTRL ORION5X_DEV_BUS_REG(0x008)
125#define MPP_RESET_SAMPLE ORION5X_DEV_BUS_REG(0x010)
126#define GPIO_OUT ORION5X_DEV_BUS_REG(0x100)
127#define GPIO_IO_CONF ORION5X_DEV_BUS_REG(0x104)
128#define GPIO_BLINK_EN ORION5X_DEV_BUS_REG(0x108)
129#define GPIO_IN_POL ORION5X_DEV_BUS_REG(0x10c)
130#define GPIO_DATA_IN ORION5X_DEV_BUS_REG(0x110)
131#define GPIO_EDGE_CAUSE ORION5X_DEV_BUS_REG(0x114)
132#define GPIO_EDGE_MASK ORION5X_DEV_BUS_REG(0x118)
133#define GPIO_LEVEL_MASK ORION5X_DEV_BUS_REG(0x11c)
134#define DEV_BANK_0_PARAM ORION5X_DEV_BUS_REG(0x45c)
135#define DEV_BANK_1_PARAM ORION5X_DEV_BUS_REG(0x460)
136#define DEV_BANK_2_PARAM ORION5X_DEV_BUS_REG(0x464)
137#define DEV_BANK_BOOT_PARAM ORION5X_DEV_BUS_REG(0x46c)
138#define DEV_BUS_CTRL ORION5X_DEV_BUS_REG(0x4c0)
139#define DEV_BUS_INT_CAUSE ORION5X_DEV_BUS_REG(0x4d0)
140#define DEV_BUS_INT_MASK ORION5X_DEV_BUS_REG(0x4d4)
141#define GPIO_MAX 32
142
143/***************************************************************************
144 * Orion CPU Bridge Registers
145 **************************************************************************/
146#define CPU_CONF ORION5X_BRIDGE_REG(0x100)
147#define CPU_CTRL ORION5X_BRIDGE_REG(0x104)
148#define CPU_RESET_MASK ORION5X_BRIDGE_REG(0x108)
149#define CPU_SOFT_RESET ORION5X_BRIDGE_REG(0x10c)
150#define POWER_MNG_CTRL_REG ORION5X_BRIDGE_REG(0x11C)
151#define BRIDGE_CAUSE ORION5X_BRIDGE_REG(0x110)
152#define BRIDGE_MASK ORION5X_BRIDGE_REG(0x114)
153#define BRIDGE_INT_TIMER0 0x0002
154#define BRIDGE_INT_TIMER1 0x0004
155#define MAIN_IRQ_CAUSE ORION5X_BRIDGE_REG(0x200)
156#define MAIN_IRQ_MASK ORION5X_BRIDGE_REG(0x204)
157
158
159#endif
diff --git a/include/asm-arm/arch-orion/system.h b/include/asm-arm/arch-orion5x/system.h
index 17704c68f90e..3f1d1e2d38f8 100644
--- a/include/asm-arm/arch-orion/system.h
+++ b/include/asm-arm/arch-orion5x/system.h
@@ -1,10 +1,10 @@
1/* 1/*
2 * include/asm-arm/arch-orion/system.h 2 * include/asm-arm/arch-orion5x/system.h
3 * 3 *
4 * Tzachi Perelstein <tzachi@marvell.com> 4 * Tzachi Perelstein <tzachi@marvell.com>
5 * 5 *
6 * This file is licensed under the terms of the GNU General Public 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 7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 10
@@ -12,7 +12,7 @@
12#define __ASM_ARCH_SYSTEM_H 12#define __ASM_ARCH_SYSTEM_H
13 13
14#include <asm/arch/hardware.h> 14#include <asm/arch/hardware.h>
15#include <asm/arch/orion.h> 15#include <asm/arch/orion5x.h>
16 16
17static inline void arch_idle(void) 17static inline void arch_idle(void)
18{ 18{
@@ -24,8 +24,9 @@ static inline void arch_reset(char mode)
24 /* 24 /*
25 * Enable and issue soft reset 25 * Enable and issue soft reset
26 */ 26 */
27 orion_setbits(CPU_RESET_MASK, (1 << 2)); 27 orion5x_setbits(CPU_RESET_MASK, (1 << 2));
28 orion_setbits(CPU_SOFT_RESET, 1); 28 orion5x_setbits(CPU_SOFT_RESET, 1);
29} 29}
30 30
31
31#endif 32#endif
diff --git a/include/asm-arm/arch-orion5x/timex.h b/include/asm-arm/arch-orion5x/timex.h
new file mode 100644
index 000000000000..31c568e28cc3
--- /dev/null
+++ b/include/asm-arm/arch-orion5x/timex.h
@@ -0,0 +1,13 @@
1/*
2 * include/asm-arm/arch-orion5x/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 CLOCK_TICK_RATE (100 * HZ)
12
13#define ORION5X_TCLK 166666667
diff --git a/include/asm-arm/arch-orion/uncompress.h b/include/asm-arm/arch-orion5x/uncompress.h
index 59f44039909a..5c13d4fafb4e 100644
--- a/include/asm-arm/arch-orion/uncompress.h
+++ b/include/asm-arm/arch-orion5x/uncompress.h
@@ -1,14 +1,14 @@
1/* 1/*
2 * include/asm-arm/arch-orion/uncompress.h 2 * include/asm-arm/arch-orion5x/uncompress.h
3 * 3 *
4 * Tzachi Perelstein <tzachi@marvell.com> 4 * Tzachi Perelstein <tzachi@marvell.com>
5 * 5 *
6 * This file is licensed under the terms of the GNU General Public 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 7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 10
11#include <asm/arch/orion.h> 11#include <asm/arch/orion5x.h>
12 12
13#define MV_UART_THR ((volatile unsigned char *)(UART0_PHYS_BASE + 0x0)) 13#define MV_UART_THR ((volatile unsigned char *)(UART0_PHYS_BASE + 0x0))
14#define MV_UART_LSR ((volatile unsigned char *)(UART0_PHYS_BASE + 0x14)) 14#define MV_UART_LSR ((volatile unsigned char *)(UART0_PHYS_BASE + 0x14))
diff --git a/include/asm-arm/arch-orion/vmalloc.h b/include/asm-arm/arch-orion5x/vmalloc.h
index 9d580278d2bc..2b3061e90dc1 100644
--- a/include/asm-arm/arch-orion/vmalloc.h
+++ b/include/asm-arm/arch-orion5x/vmalloc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * include/asm-arm/arch-orion/vmalloc.h 2 * include/asm-arm/arch-orion5x/vmalloc.h
3 */ 3 */
4 4
5#define VMALLOC_END 0xfd800000 5#define VMALLOC_END 0xfd800000
diff --git a/include/asm-arm/arch-pxa/camera.h b/include/asm-arm/arch-pxa/camera.h
new file mode 100644
index 000000000000..39516ced8b1f
--- /dev/null
+++ b/include/asm-arm/arch-pxa/camera.h
@@ -0,0 +1,48 @@
1/*
2 camera.h - PXA camera driver header file
3
4 Copyright (C) 2003, Intel Corporation
5 Copyright (C) 2008, Guennadi Liakhovetski <kernel@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., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef __ASM_ARCH_CAMERA_H_
23#define __ASM_ARCH_CAMERA_H_
24
25#define PXA_CAMERA_MASTER 1
26#define PXA_CAMERA_DATAWIDTH_4 2
27#define PXA_CAMERA_DATAWIDTH_5 4
28#define PXA_CAMERA_DATAWIDTH_8 8
29#define PXA_CAMERA_DATAWIDTH_9 0x10
30#define PXA_CAMERA_DATAWIDTH_10 0x20
31#define PXA_CAMERA_PCLK_EN 0x40
32#define PXA_CAMERA_MCLK_EN 0x80
33#define PXA_CAMERA_PCP 0x100
34#define PXA_CAMERA_HSP 0x200
35#define PXA_CAMERA_VSP 0x400
36
37struct pxacamera_platform_data {
38 int (*init)(struct device *);
39 int (*power)(struct device *, int);
40 int (*reset)(struct device *, int);
41
42 unsigned long flags;
43 unsigned long mclk_10khz;
44};
45
46extern void pxa_set_camera_info(struct pxacamera_platform_data *);
47
48#endif /* __ASM_ARCH_CAMERA_H_ */
diff --git a/include/asm-arm/arch-pxa/gumstix.h b/include/asm-arm/arch-pxa/gumstix.h
new file mode 100644
index 000000000000..6fa85c4f94f8
--- /dev/null
+++ b/include/asm-arm/arch-pxa/gumstix.h
@@ -0,0 +1,96 @@
1/*
2 * linux/include/asm-arm/arch-pxa/gumstix.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/* BTRESET - Reset line to Bluetooth module, active low signal. */
11#define GPIO_GUMSTIX_BTRESET 7
12#define GPIO_GUMSTIX_BTRESET_MD (GPIO_GUMSTIX_BTRESET | GPIO_OUT)
13
14
15/*
16GPIOn - Input from MAX823 (or equiv), normalizing USB +5V into a clean
17interrupt signal for determining cable presence. On the original gumstix,
18this is GPIO81, and GPIO83 needs to be defined as well. On the gumstix F,
19this moves to GPIO17 and GPIO37. */
20
21/* GPIOx - Connects to USB D+ and used as a pull-up after GPIOn
22has detected a cable insertion; driven low otherwise. */
23
24#ifdef CONFIG_ARCH_GUMSTIX_ORIG
25
26#define GPIO_GUMSTIX_USB_GPIOn 81
27#define GPIO_GUMSTIX_USB_GPIOx 83
28
29#else
30
31#define GPIO_GUMSTIX_USB_GPIOn 35
32#define GPIO_GUMSTIX_USB_GPIOx 41
33
34#endif
35
36/* usb state change */
37#define GUMSTIX_USB_INTR_IRQ IRQ_GPIO(GPIO_GUMSTIX_USB_GPIOn)
38
39#define GPIO_GUMSTIX_USB_GPIOn_MD (GPIO_GUMSTIX_USB_GPIOn | GPIO_IN)
40#define GPIO_GUMSTIX_USB_GPIOx_CON_MD (GPIO_GUMSTIX_USB_GPIOx | GPIO_OUT)
41#define GPIO_GUMSTIX_USB_GPIOx_DIS_MD (GPIO_GUMSTIX_USB_GPIOx | GPIO_IN)
42
43/*
44 * SD/MMC definitions
45 */
46#define GUMSTIX_GPIO_nSD_WP 22 /* SD Write Protect */
47#define GUMSTIX_GPIO_nSD_DETECT 11 /* MMC/SD Card Detect */
48#define GUMSTIX_IRQ_GPIO_nSD_DETECT IRQ_GPIO(GUMSTIX_GPIO_nSD_DETECT)
49
50/*
51 * SMC Ethernet definitions
52 * ETH_RST provides a hardware reset line to the ethernet chip
53 * ETH is the IRQ line in from the ethernet chip to the PXA
54 */
55#define GPIO_GUMSTIX_ETH0_RST 80
56#define GPIO_GUMSTIX_ETH0_RST_MD (GPIO_GUMSTIX_ETH0_RST | GPIO_OUT)
57#define GPIO_GUMSTIX_ETH1_RST 52
58#define GPIO_GUMSTIX_ETH1_RST_MD (GPIO_GUMSTIX_ETH1_RST | GPIO_OUT)
59
60#define GPIO_GUMSTIX_ETH0 36
61#define GPIO_GUMSTIX_ETH0_MD (GPIO_GUMSTIX_ETH0 | GPIO_IN)
62#define GUMSTIX_ETH0_IRQ IRQ_GPIO(GPIO_GUMSTIX_ETH0)
63#define GPIO_GUMSTIX_ETH1 27
64#define GPIO_GUMSTIX_ETH1_MD (GPIO_GUMSTIX_ETH1 | GPIO_IN)
65#define GUMSTIX_ETH1_IRQ IRQ_GPIO(GPIO_GUMSTIX_ETH1)
66
67
68/* CF reset line */
69#define GPIO8_RESET 8
70
71/* CF slot 0 */
72#define GPIO4_nBVD1 4
73#define GPIO4_nSTSCHG GPIO4_nBVD1
74#define GPIO11_nCD 11
75#define GPIO26_PRDY_nBSY 26
76#define GUMSTIX_S0_nSTSCHG_IRQ IRQ_GPIO(GPIO4_nSTSCHG)
77#define GUMSTIX_S0_nCD_IRQ IRQ_GPIO(GPIO11_nCD)
78#define GUMSTIX_S0_PRDY_nBSY_IRQ IRQ_GPIO(GPIO26_PRDY_nBSY)
79
80/* CF slot 1 */
81#define GPIO18_nBVD1 18
82#define GPIO18_nSTSCHG GPIO18_nBVD1
83#define GPIO36_nCD 36
84#define GPIO27_PRDY_nBSY 27
85#define GUMSTIX_S1_nSTSCHG_IRQ IRQ_GPIO(GPIO18_nSTSCHG)
86#define GUMSTIX_S1_nCD_IRQ IRQ_GPIO(GPIO36_nCD)
87#define GUMSTIX_S1_PRDY_nBSY_IRQ IRQ_GPIO(GPIO27_PRDY_nBSY)
88
89/* CF GPIO line modes */
90#define GPIO4_nSTSCHG_MD (GPIO4_nSTSCHG | GPIO_IN)
91#define GPIO8_RESET_MD (GPIO8_RESET | GPIO_OUT)
92#define GPIO11_nCD_MD (GPIO11_nCD | GPIO_IN)
93#define GPIO18_nSTSCHG_MD (GPIO18_nSTSCHG | GPIO_IN)
94#define GPIO26_PRDY_nBSY_MD (GPIO26_PRDY_nBSY | GPIO_IN)
95#define GPIO27_PRDY_nBSY_MD (GPIO27_PRDY_nBSY | GPIO_IN)
96#define GPIO36_nCD_MD (GPIO36_nCD | GPIO_IN)
diff --git a/include/asm-arm/arch-pxa/irda.h b/include/asm-arm/arch-pxa/irda.h
index 748406f384c2..99f4f423a8e1 100644
--- a/include/asm-arm/arch-pxa/irda.h
+++ b/include/asm-arm/arch-pxa/irda.h
@@ -10,6 +10,8 @@
10struct pxaficp_platform_data { 10struct pxaficp_platform_data {
11 int transceiver_cap; 11 int transceiver_cap;
12 void (*transceiver_mode)(struct device *dev, int mode); 12 void (*transceiver_mode)(struct device *dev, int mode);
13 int (*startup)(struct device *dev);
14 void (*shutdown)(struct device *dev);
13}; 15};
14 16
15extern void pxa_set_ficp_info(struct pxaficp_platform_data *info); 17extern void pxa_set_ficp_info(struct pxaficp_platform_data *info);
diff --git a/include/asm-arm/arch-pxa/irqs.h b/include/asm-arm/arch-pxa/irqs.h
index c562b972a4a6..b6c8fe377683 100644
--- a/include/asm-arm/arch-pxa/irqs.h
+++ b/include/asm-arm/arch-pxa/irqs.h
@@ -181,7 +181,8 @@
181#elif defined(CONFIG_ARCH_LUBBOCK) || \ 181#elif defined(CONFIG_ARCH_LUBBOCK) || \
182 defined(CONFIG_MACH_LOGICPD_PXA270) || \ 182 defined(CONFIG_MACH_LOGICPD_PXA270) || \
183 defined(CONFIG_MACH_MAINSTONE) || \ 183 defined(CONFIG_MACH_MAINSTONE) || \
184 defined(CONFIG_MACH_PCM027) 184 defined(CONFIG_MACH_PCM027) || \
185 defined(CONFIG_MACH_MAGICIAN)
185#define NR_IRQS (IRQ_BOARD_END) 186#define NR_IRQS (IRQ_BOARD_END)
186#else 187#else
187#define NR_IRQS (IRQ_BOARD_START) 188#define NR_IRQS (IRQ_BOARD_START)
@@ -238,7 +239,7 @@
238/* ITE8152 irqs */ 239/* ITE8152 irqs */
239/* add IT8152 IRQs beyond BOARD_END */ 240/* add IT8152 IRQs beyond BOARD_END */
240#ifdef CONFIG_PCI_HOST_ITE8152 241#ifdef CONFIG_PCI_HOST_ITE8152
241#define IT8152_IRQ(x) (IRQ_GPIO(IRQ_BOARD_END) + 1 + (x)) 242#define IT8152_IRQ(x) (IRQ_BOARD_END + (x))
242 243
243/* IRQ-sources in 3 groups - local devices, LPC (serial), and external PCI */ 244/* IRQ-sources in 3 groups - local devices, LPC (serial), and external PCI */
244#define IT8152_LD_IRQ_COUNT 9 245#define IT8152_LD_IRQ_COUNT 9
@@ -252,6 +253,9 @@
252 253
253#define IT8152_LAST_IRQ IT8152_LD_IRQ(IT8152_LD_IRQ_COUNT - 1) 254#define IT8152_LAST_IRQ IT8152_LD_IRQ(IT8152_LD_IRQ_COUNT - 1)
254 255
256#if NR_IRQS < (IT8152_LAST_IRQ+1)
255#undef NR_IRQS 257#undef NR_IRQS
256#define NR_IRQS (IT8152_LAST_IRQ+1) 258#define NR_IRQS (IT8152_LAST_IRQ+1)
257#endif 259#endif
260
261#endif /* CONFIG_PCI_HOST_ITE8152 */
diff --git a/include/asm-arm/arch-pxa/magician.h b/include/asm-arm/arch-pxa/magician.h
index 337f51f06b3a..169b374f9921 100644
--- a/include/asm-arm/arch-pxa/magician.h
+++ b/include/asm-arm/arch-pxa/magician.h
@@ -12,7 +12,7 @@
12#ifndef _MAGICIAN_H_ 12#ifndef _MAGICIAN_H_
13#define _MAGICIAN_H_ 13#define _MAGICIAN_H_
14 14
15#include <asm/arch/pxa-regs.h> 15#include <asm/arch/irqs.h>
16 16
17/* 17/*
18 * PXA GPIOs 18 * PXA GPIOs
@@ -34,6 +34,7 @@
34#define GPIO48_MAGICIAN_UNKNOWN 48 34#define GPIO48_MAGICIAN_UNKNOWN 48
35#define GPIO56_MAGICIAN_UNKNOWN 56 35#define GPIO56_MAGICIAN_UNKNOWN 56
36#define GPIO57_MAGICIAN_CAM_RESET 57 36#define GPIO57_MAGICIAN_CAM_RESET 57
37#define GPIO75_MAGICIAN_SAMSUNG_POWER 75
37#define GPIO83_MAGICIAN_nIR_EN 83 38#define GPIO83_MAGICIAN_nIR_EN 83
38#define GPIO86_MAGICIAN_GSM_RESET 86 39#define GPIO86_MAGICIAN_GSM_RESET 86
39#define GPIO87_MAGICIAN_GSM_SELECT 87 40#define GPIO87_MAGICIAN_GSM_SELECT 87
@@ -62,50 +63,55 @@
62#define GPIO120_MAGICIAN_UNKNOWN 120 63#define GPIO120_MAGICIAN_UNKNOWN 120
63 64
64/* 65/*
65 * PXA GPIO alternate function mode & direction 66 * CPLD IRQs
66 */ 67 */
67 68
68#define GPIO0_MAGICIAN_KEY_POWER_MD (0 | GPIO_IN) 69#define IRQ_MAGICIAN_SD (IRQ_BOARD_START + 0)
69#define GPIO9_MAGICIAN_UNKNOWN_MD (9 | GPIO_IN) 70#define IRQ_MAGICIAN_EP (IRQ_BOARD_START + 1)
70#define GPIO10_MAGICIAN_GSM_IRQ_MD (10 | GPIO_IN) 71#define IRQ_MAGICIAN_BT (IRQ_BOARD_START + 2)
71#define GPIO11_MAGICIAN_GSM_OUT1_MD (11 | GPIO_OUT) 72#define IRQ_MAGICIAN_AC (IRQ_BOARD_START + 3)
72#define GPIO13_MAGICIAN_CPLD_IRQ_MD (13 | GPIO_IN) 73
73#define GPIO18_MAGICIAN_UNKNOWN_MD (18 | GPIO_OUT) 74/*
74#define GPIO22_MAGICIAN_VIBRA_EN_MD (22 | GPIO_OUT) 75 * CPLD EGPIOs
75#define GPIO26_MAGICIAN_GSM_POWER_MD (26 | GPIO_OUT) 76 */
76#define GPIO27_MAGICIAN_USBC_PUEN_MD (27 | GPIO_OUT) 77
77#define GPIO30_MAGICIAN_nCHARGE_EN_MD (30 | GPIO_OUT) 78#define MAGICIAN_EGPIO_BASE 0x80 /* GPIO_BOARD_START */
78#define GPIO37_MAGICIAN_KEY_HANGUP_MD (37 | GPIO_OUT) 79#define MAGICIAN_EGPIO(reg,bit) \
79#define GPIO38_MAGICIAN_KEY_CONTACTS_MD (38 | GPIO_OUT) 80 (MAGICIAN_EGPIO_BASE + 8*reg + bit)
80#define GPIO40_MAGICIAN_GSM_OUT2_MD (40 | GPIO_OUT) 81
81#define GPIO48_MAGICIAN_UNKNOWN_MD (48 | GPIO_OUT) 82/* output */
82#define GPIO56_MAGICIAN_UNKNOWN_MD (56 | GPIO_OUT) 83
83#define GPIO57_MAGICIAN_CAM_RESET_MD (57 | GPIO_OUT) 84#define EGPIO_MAGICIAN_TOPPOLY_POWER MAGICIAN_EGPIO(0, 2)
84#define GPIO83_MAGICIAN_nIR_EN_MD (83 | GPIO_OUT) 85#define EGPIO_MAGICIAN_LED_POWER MAGICIAN_EGPIO(0, 5)
85#define GPIO86_MAGICIAN_GSM_RESET_MD (86 | GPIO_OUT) 86#define EGPIO_MAGICIAN_GSM_RESET MAGICIAN_EGPIO(0, 6)
86#define GPIO87_MAGICIAN_GSM_SELECT_MD (87 | GPIO_OUT) 87#define EGPIO_MAGICIAN_LCD_POWER MAGICIAN_EGPIO(0, 7)
87#define GPIO90_MAGICIAN_KEY_CALENDAR_MD (90 | GPIO_OUT) 88#define EGPIO_MAGICIAN_SPK_POWER MAGICIAN_EGPIO(1, 0)
88#define GPIO91_MAGICIAN_KEY_CAMERA_MD (91 | GPIO_OUT) 89#define EGPIO_MAGICIAN_EP_POWER MAGICIAN_EGPIO(1, 1)
89#define GPIO93_MAGICIAN_KEY_UP_MD (93 | GPIO_IN) 90#define EGPIO_MAGICIAN_IN_SEL0 MAGICIAN_EGPIO(1, 2)
90#define GPIO94_MAGICIAN_KEY_DOWN_MD (94 | GPIO_IN) 91#define EGPIO_MAGICIAN_IN_SEL1 MAGICIAN_EGPIO(1, 3)
91#define GPIO95_MAGICIAN_KEY_LEFT_MD (95 | GPIO_IN) 92#define EGPIO_MAGICIAN_MIC_POWER MAGICIAN_EGPIO(1, 4)
92#define GPIO96_MAGICIAN_KEY_RIGHT_MD (96 | GPIO_IN) 93#define EGPIO_MAGICIAN_CODEC_RESET MAGICIAN_EGPIO(1, 5)
93#define GPIO97_MAGICIAN_KEY_ENTER_MD (97 | GPIO_IN) 94#define EGPIO_MAGICIAN_CODEC_POWER MAGICIAN_EGPIO(1, 6)
94#define GPIO98_MAGICIAN_KEY_RECORD_MD (98 | GPIO_IN) 95#define EGPIO_MAGICIAN_BL_POWER MAGICIAN_EGPIO(1, 7)
95#define GPIO99_MAGICIAN_HEADPHONE_IN_MD (99 | GPIO_IN) 96#define EGPIO_MAGICIAN_SD_POWER MAGICIAN_EGPIO(2, 0)
96#define GPIO100_MAGICIAN_KEY_VOL_UP_MD (100 | GPIO_IN) 97#define EGPIO_MAGICIAN_CARKIT_MIC MAGICIAN_EGPIO(2, 1)
97#define GPIO101_MAGICIAN_KEY_VOL_DOWN_MD (101 | GPIO_IN) 98#define EGPIO_MAGICIAN_UNKNOWN_WAVEDEV_DLL MAGICIAN_EGPIO(2, 2)
98#define GPIO102_MAGICIAN_KEY_PHONE_MD (102 | GPIO_IN) 99#define EGPIO_MAGICIAN_FLASH_VPP MAGICIAN_EGPIO(2, 3)
99#define GPIO103_MAGICIAN_LED_KP_MD (103 | GPIO_OUT) 100#define EGPIO_MAGICIAN_BL_POWER2 MAGICIAN_EGPIO(2, 4)
100#define GPIO104_MAGICIAN_LCD_POWER_1_MD (104 | GPIO_OUT) 101#define EGPIO_MAGICIAN_CHARGE_EN MAGICIAN_EGPIO(2, 5)
101#define GPIO105_MAGICIAN_LCD_POWER_2_MD (105 | GPIO_OUT) 102#define EGPIO_MAGICIAN_GSM_POWER MAGICIAN_EGPIO(2, 7)
102#define GPIO106_MAGICIAN_LCD_POWER_3_MD (106 | GPIO_OUT) 103
103#define GPIO107_MAGICIAN_DS1WM_IRQ_MD (107 | GPIO_IN) 104/* input */
104#define GPIO108_MAGICIAN_GSM_READY_MD (108 | GPIO_IN) 105
105#define GPIO114_MAGICIAN_UNKNOWN_MD (114 | GPIO_OUT) 106#define EGPIO_MAGICIAN_CABLE_STATE_AC MAGICIAN_EGPIO(4, 0)
106#define GPIO115_MAGICIAN_nPEN_IRQ_MD (115 | GPIO_IN) 107#define EGPIO_MAGICIAN_CABLE_STATE_USB MAGICIAN_EGPIO(4, 1)
107#define GPIO116_MAGICIAN_nCAM_EN_MD (116 | GPIO_OUT) 108
108#define GPIO119_MAGICIAN_UNKNOWN_MD (119 | GPIO_OUT) 109#define EGPIO_MAGICIAN_BOARD_ID0 MAGICIAN_EGPIO(5, 0)
109#define GPIO120_MAGICIAN_UNKNOWN_MD (120 | GPIO_OUT) 110#define EGPIO_MAGICIAN_BOARD_ID1 MAGICIAN_EGPIO(5, 1)
111#define EGPIO_MAGICIAN_BOARD_ID2 MAGICIAN_EGPIO(5, 2)
112#define EGPIO_MAGICIAN_LCD_SELECT MAGICIAN_EGPIO(5, 3)
113#define EGPIO_MAGICIAN_nSD_READONLY MAGICIAN_EGPIO(5, 4)
114
115#define EGPIO_MAGICIAN_EP_INSERT MAGICIAN_EGPIO(6, 1)
110 116
111#endif /* _MAGICIAN_H_ */ 117#endif /* _MAGICIAN_H_ */
diff --git a/include/asm-arm/arch-pxa/mfp-pxa25x.h b/include/asm-arm/arch-pxa/mfp-pxa25x.h
new file mode 100644
index 000000000000..0499323010ba
--- /dev/null
+++ b/include/asm-arm/arch-pxa/mfp-pxa25x.h
@@ -0,0 +1,161 @@
1#ifndef __ASM_ARCH_MFP_PXA25X_H
2#define __ASM_ARCH_MFP_PXA25X_H
3
4#include <asm/arch/mfp.h>
5#include <asm/arch/mfp-pxa2xx.h>
6
7/* GPIO */
8#define GPIO2_GPIO MFP_CFG_IN(GPIO2, AF0)
9#define GPIO3_GPIO MFP_CFG_IN(GPIO3, AF0)
10#define GPIO4_GPIO MFP_CFG_IN(GPIO4, AF0)
11#define GPIO5_GPIO MFP_CFG_IN(GPIO5, AF0)
12#define GPIO6_GPIO MFP_CFG_IN(GPIO6, AF0)
13#define GPIO7_GPIO MFP_CFG_IN(GPIO7, AF0)
14#define GPIO8_GPIO MFP_CFG_IN(GPIO8, AF0)
15
16#define GPIO1_RST MFP_CFG_IN(GPIO1, AF1)
17
18/* Crystal and Clock Signals */
19#define GPIO10_RTCCLK MFP_CFG_OUT(GPIO10, AF1, DRIVE_LOW)
20#define GPIO70_RTC_CLK MFP_CFG_OUT(GPIO70, AF1, DRIVE_LOW)
21#define GPIO7_48MHz MFP_CFG_OUT(GPIO7, AF1, DRIVE_LOW)
22#define GPIO11_3_6MHz MFP_CFG_OUT(GPIO11, AF1, DRIVE_LOW)
23#define GPIO71_3_6MHz MFP_CFG_OUT(GPIO71, AF1, DRIVE_LOW)
24#define GPIO12_32KHz MFP_CFG_OUT(GPIO12, AF1, DRIVE_LOW)
25#define GPIO72_32kHz MFP_CFG_OUT(GPIO72, AF1, DRIVE_LOW)
26
27/* SDRAM and Static Memory I/O Signals */
28#define GPIO15_nCS_1 MFP_CFG_OUT(GPIO15, AF2, DRIVE_HIGH)
29#define GPIO78_nCS_2 MFP_CFG_OUT(GPIO78, AF2, DRIVE_HIGH)
30#define GPIO79_nCS_3 MFP_CFG_OUT(GPIO79, AF2, DRIVE_HIGH)
31#define GPIO80_nCS_4 MFP_CFG_OUT(GPIO80, AF2, DRIVE_HIGH)
32#define GPIO33_nCS_5 MFP_CFG_OUT(GPIO33, AF2, DRIVE_HIGH)
33
34/* Miscellaneous I/O and DMA Signals */
35#define GPIO18_RDY MFP_CFG_IN(GPIO18, AF1)
36#define GPIO20_DREQ_0 MFP_CFG_IN(GPIO20, AF1)
37#define GPIO19_DREQ_1 MFP_CFG_IN(GPIO19, AF1)
38
39/* Alternate Bus Master Mode I/O Signals */
40#define GPIO13_MBGNT MFP_CFG_OUT(GPIO13, AF2, DRIVE_LOW)
41#define GPIO73_MBGNT MFP_CFG_OUT(GPIO73, AF1, DRIVE_LOW)
42#define GPIO14_MBREQ MFP_CFG_IN(GPIO14, AF1)
43#define GPIO66_MBREQ MFP_CFG_IN(GPIO66, AF1)
44
45/* PC CARD */
46#define GPIO52_nPCE_1 MFP_CFG_OUT(GPIO52, AF2, DRIVE_HIGH)
47#define GPIO53_nPCE_2 MFP_CFG_OUT(GPIO53, AF2, DRIVE_HIGH)
48#define GPIO55_nPREG MFP_CFG_OUT(GPIO55, AF2, DRIVE_HIGH)
49#define GPIO50_nPIOR MFP_CFG_OUT(GPIO50, AF2, DRIVE_HIGH)
50#define GPIO51_nPIOW MFP_CFG_OUT(GPIO51, AF2, DRIVE_HIGH)
51#define GPIO49_nPWE MFP_CFG_OUT(GPIO49, AF2, DRIVE_HIGH)
52#define GPIO48_nPOE MFP_CFG_OUT(GPIO48, AF2, DRIVE_HIGH)
53#define GPIO57_nIOIS16 MFP_CFG_IN(GPIO57, AF1)
54#define GPIO56_nPWAIT MFP_CFG_IN(GPIO56, AF1)
55#define GPIO54_nPSKTSEL MFP_CFG_OUT(GPIO54, AF2, DRIVE_HIGH)
56
57/* FFUART */
58#define GPIO34_FFUART_RXD MFP_CFG_IN(GPIO34, AF1)
59#define GPIO35_FFUART_CTS MFP_CFG_IN(GPIO35, AF1)
60#define GPIO36_FFUART_DCD MFP_CFG_IN(GPIO36, AF1)
61#define GPIO37_FFUART_DSR MFP_CFG_IN(GPIO37, AF1)
62#define GPIO38_FFUART_RI MFP_CFG_IN(GPIO38, AF1)
63#define GPIO39_FFUART_TXD MFP_CFG_OUT(GPIO39, AF2, DRIVE_HIGH)
64#define GPIO40_FFUART_DTR MFP_CFG_OUT(GPIO40, AF2, DRIVE_HIGH)
65#define GPIO41_FFUART_RTS MFP_CFG_OUT(GPIO41, AF2, DRIVE_HIGH)
66
67/* BTUART */
68#define GPIO42_BTUART_RXD MFP_CFG_IN(GPIO42, AF1)
69#define GPIO43_BTUART_TXD MFP_CFG_OUT(GPIO43, AF2, DRIVE_HIGH)
70#define GPIO44_BTUART_CTS MFP_CFG_IN(GPIO44, AF1)
71#define GPIO45_BTUART_RTS MFP_CFG_OUT(GPIO45, AF2, DRIVE_HIGH)
72
73/* STUART */
74#define GPIO46_STUART_RXD MFP_CFG_IN(GPIO46, AF2)
75#define GPIO47_STUART_TXD MFP_CFG_OUT(GPIO47, AF1, DRIVE_HIGH)
76
77/* HWUART */
78#define GPIO42_HWUART_RXD MFP_CFG_IN(GPIO42, AF3)
79#define GPIO43_HWUART_TXD MFP_CFG_OUT(GPIO43, AF3, DRIVE_HIGH)
80#define GPIO44_HWUART_CTS MFP_CFG_IN(GPIO44, AF3)
81#define GPIO45_HWUART_RTS MFP_CFG_OUT(GPIO45, AF3, DRIVE_HIGH)
82#define GPIO48_HWUART_TXD MFP_CFG_OUT(GPIO48, AF1, DRIVE_HIGH)
83#define GPIO49_HWUART_RXD MFP_CFG_IN(GPIO49, AF1)
84#define GPIO50_HWUART_CTS MFP_CFG_IN(GPIO50, AF1)
85#define GPIO51_HWUART_RTS MFP_CFG_OUT(GPIO51, AF1, DRIVE_HIGH)
86
87/* FICP */
88#define GPIO46_FICP_RXD MFP_CFG_IN(GPIO46, AF1)
89#define GPIO47_FICP_TXD MFP_CFG_OUT(GPIO47, AF2, DRIVE_HIGH)
90
91/* PWM 0/1 */
92#define GPIO16_PWM0_OUT MFP_CFG_OUT(GPIO16, AF2, DRIVE_LOW)
93#define GPIO17_PWM1_OUT MFP_CFG_OUT(GPIO17, AF2, DRIVE_LOW)
94
95/* AC97 */
96#define GPIO28_AC97_BITCLK MFP_CFG_IN(GPIO28, AF1)
97#define GPIO29_AC97_SDATA_IN_0 MFP_CFG_IN(GPIO29, AF1)
98#define GPIO30_AC97_SDATA_OUT MFP_CFG_OUT(GPIO30, AF2, DRIVE_LOW)
99#define GPIO31_AC97_SYNC MFP_CFG_OUT(GPIO31, AF2, DRIVE_LOW)
100#define GPIO32_AC97_SDATA_IN_1 MFP_CFG_IN(GPIO32, AF1)
101
102/* I2S */
103#define GPIO28_I2S_BITCLK_IN MFP_CFG_IN(GPIO28, AF2)
104#define GPIO28_I2S_BITCLK_OUT MFP_CFG_OUT(GPIO28, AF1, DRIVE_LOW)
105#define GPIO29_I2S_SDATA_IN MFP_CFG_IN(GPIO29, AF2)
106#define GPIO30_I2S_SDATA_OUT MFP_CFG_OUT(GPIO30, AF1, DRIVE_LOW)
107#define GPIO31_I2S_SYNC MFP_CFG_OUT(GPIO31, AF1, DRIVE_LOW)
108#define GPIO32_I2S_SYSCLK MFP_CFG_OUT(GPIO32, AF1, DRIVE_LOW)
109
110/* SSP 1 */
111#define GPIO23_SSP1_SCLK MFP_CFG_OUT(GPIO23, AF2, DRIVE_LOW)
112#define GPIO24_SSP1_SFRM MFP_CFG_OUT(GPIO24, AF2, DRIVE_LOW)
113#define GPIO25_SSP1_TXD MFP_CFG_OUT(GPIO25, AF2, DRIVE_LOW)
114#define GPIO26_SSP1_RXD MFP_CFG_IN(GPIO26, AF1)
115#define GPIO27_SSP1_EXTCLK MFP_CFG_IN(GPIO27, AF1)
116
117/* SSP 2 - NSSP */
118#define GPIO81_SSP2_CLK_OUT MFP_CFG_OUT(GPIO81, AF1, DRIVE_LOW)
119#define GPIO81_SSP2_CLK_IN MFP_CFG_IN(GPIO81, AF1)
120#define GPIO82_SSP2_FRM_OUT MFP_CFG_OUT(GPIO82, AF1, DRIVE_LOW)
121#define GPIO82_SSP2_FRM_IN MFP_CFG_IN(GPIO82, AF1)
122#define GPIO83_SSP2_TXD MFP_CFG_OUT(GPIO83, AF1, DRIVE_LOW)
123#define GPIO83_SSP2_RXD MFP_CFG_IN(GPIO83, AF2)
124#define GPIO84_SSP2_TXD MFP_CFG_OUT(GPIO84, AF1, DRIVE_LOW)
125#define GPIO84_SSP2_RXD MFP_CFG_IN(GPIO84, AF2)
126
127/* MMC */
128#define GPIO6_MMC_CLK MFP_CFG_OUT(GPIO6, AF1, DRIVE_LOW)
129#define GPIO8_MMC_CS0 MFP_CFG_OUT(GPIO8, AF1, DRIVE_LOW)
130#define GPIO9_MMC_CS1 MFP_CFG_OUT(GPIO9, AF1, DRIVE_LOW)
131#define GPIO34_MMC_CS0 MFP_CFG_OUT(GPIO34, AF2, DRIVE_LOW)
132#define GPIO39_MMC_CS1 MFP_CFG_OUT(GPIO39, AF1, DRIVE_LOW)
133#define GPIO53_MMC_CLK MFP_CFG_OUT(GPIO53, AF1, DRIVE_LOW)
134#define GPIO54_MMC_CLK MFP_CFG_OUT(GPIO54, AF1, DRIVE_LOW)
135#define GPIO69_MMC_CLK MFP_CFG_OUT(GPIO69, AF1, DRIVE_LOW)
136#define GPIO67_MMC_CS0 MFP_CFG_OUT(GPIO67, AF1, DRIVE_LOW)
137#define GPIO68_MMC_CS1 MFP_CFG_OUT(GPIO68, AF1, DRIVE_LOW)
138
139/* LCD */
140#define GPIO58_LCD_LDD_0 MFP_CFG_OUT(GPIO58, AF2, DRIVE_LOW)
141#define GPIO59_LCD_LDD_1 MFP_CFG_OUT(GPIO59, AF2, DRIVE_LOW)
142#define GPIO60_LCD_LDD_2 MFP_CFG_OUT(GPIO60, AF2, DRIVE_LOW)
143#define GPIO61_LCD_LDD_3 MFP_CFG_OUT(GPIO61, AF2, DRIVE_LOW)
144#define GPIO62_LCD_LDD_4 MFP_CFG_OUT(GPIO62, AF2, DRIVE_LOW)
145#define GPIO63_LCD_LDD_5 MFP_CFG_OUT(GPIO63, AF2, DRIVE_LOW)
146#define GPIO64_LCD_LDD_6 MFP_CFG_OUT(GPIO64, AF2, DRIVE_LOW)
147#define GPIO65_LCD_LDD_7 MFP_CFG_OUT(GPIO65, AF2, DRIVE_LOW)
148#define GPIO66_LCD_LDD_8 MFP_CFG_OUT(GPIO66, AF2, DRIVE_LOW)
149#define GPIO67_LCD_LDD_9 MFP_CFG_OUT(GPIO67, AF2, DRIVE_LOW)
150#define GPIO68_LCD_LDD_10 MFP_CFG_OUT(GPIO68, AF2, DRIVE_LOW)
151#define GPIO69_LCD_LDD_11 MFP_CFG_OUT(GPIO69, AF2, DRIVE_LOW)
152#define GPIO70_LCD_LDD_12 MFP_CFG_OUT(GPIO70, AF2, DRIVE_LOW)
153#define GPIO71_LCD_LDD_13 MFP_CFG_OUT(GPIO71, AF2, DRIVE_LOW)
154#define GPIO72_LCD_LDD_14 MFP_CFG_OUT(GPIO72, AF2, DRIVE_LOW)
155#define GPIO73_LCD_LDD_15 MFP_CFG_OUT(GPIO73, AF2, DRIVE_LOW)
156#define GPIO74_LCD_FCLK MFP_CFG_OUT(GPIO74, AF2, DRIVE_LOW)
157#define GPIO75_LCD_LCLK MFP_CFG_OUT(GPIO75, AF2, DRIVE_LOW)
158#define GPIO76_LCD_PCLK MFP_CFG_OUT(GPIO76, AF2, DRIVE_LOW)
159#define GPIO77_LCD_ACBIAS MFP_CFG_OUT(GPIO77, AF2, DRIVE_LOW)
160
161#endif /* __ASM_ARCH_MFP_PXA25X_H */
diff --git a/include/asm-arm/arch-pxa/mfp-pxa27x.h b/include/asm-arm/arch-pxa/mfp-pxa27x.h
new file mode 100644
index 000000000000..eb6eaa174f8d
--- /dev/null
+++ b/include/asm-arm/arch-pxa/mfp-pxa27x.h
@@ -0,0 +1,432 @@
1#ifndef __ASM_ARCH_MFP_PXA27X_H
2#define __ASM_ARCH_MFP_PXA27X_H
3
4/*
5 * NOTE: for those special-function bidirectional GPIOs, as described
6 * in the "PXA27x Developer's Manual" Section 24.4.2.1, only its input
7 * alternative is preserved, the direction is actually selected by the
8 * specific controller, and this should work in most cases.
9 */
10
11#include <asm/arch/mfp.h>
12#include <asm/arch/mfp-pxa2xx.h>
13
14/* GPIO */
15#define GPIO85_GPIO MFP_CFG_IN(GPIO85, AF0)
16#define GPIO86_GPIO MFP_CFG_IN(GPIO86, AF0)
17#define GPIO87_GPIO MFP_CFG_IN(GPIO87, AF0)
18#define GPIO88_GPIO MFP_CFG_IN(GPIO88, AF0)
19#define GPIO89_GPIO MFP_CFG_IN(GPIO89, AF0)
20#define GPIO90_GPIO MFP_CFG_IN(GPIO90, AF0)
21#define GPIO91_GPIO MFP_CFG_IN(GPIO91, AF0)
22#define GPIO92_GPIO MFP_CFG_IN(GPIO92, AF0)
23#define GPIO93_GPIO MFP_CFG_IN(GPIO93, AF0)
24#define GPIO94_GPIO MFP_CFG_IN(GPIO94, AF0)
25#define GPIO95_GPIO MFP_CFG_IN(GPIO95, AF0)
26#define GPIO96_GPIO MFP_CFG_IN(GPIO96, AF0)
27#define GPIO97_GPIO MFP_CFG_IN(GPIO97, AF0)
28#define GPIO98_GPIO MFP_CFG_IN(GPIO98, AF0)
29#define GPIO99_GPIO MFP_CFG_IN(GPIO99, AF0)
30#define GPIO100_GPIO MFP_CFG_IN(GPIO100, AF0)
31#define GPIO101_GPIO MFP_CFG_IN(GPIO101, AF0)
32#define GPIO102_GPIO MFP_CFG_IN(GPIO102, AF0)
33#define GPIO103_GPIO MFP_CFG_IN(GPIO103, AF0)
34#define GPIO104_GPIO MFP_CFG_IN(GPIO104, AF0)
35#define GPIO105_GPIO MFP_CFG_IN(GPIO105, AF0)
36#define GPIO106_GPIO MFP_CFG_IN(GPIO106, AF0)
37#define GPIO107_GPIO MFP_CFG_IN(GPIO107, AF0)
38#define GPIO108_GPIO MFP_CFG_IN(GPIO108, AF0)
39#define GPIO109_GPIO MFP_CFG_IN(GPIO109, AF0)
40#define GPIO110_GPIO MFP_CFG_IN(GPIO110, AF0)
41#define GPIO111_GPIO MFP_CFG_IN(GPIO111, AF0)
42#define GPIO112_GPIO MFP_CFG_IN(GPIO112, AF0)
43#define GPIO113_GPIO MFP_CFG_IN(GPIO113, AF0)
44#define GPIO114_GPIO MFP_CFG_IN(GPIO114, AF0)
45#define GPIO115_GPIO MFP_CFG_IN(GPIO115, AF0)
46#define GPIO116_GPIO MFP_CFG_IN(GPIO116, AF0)
47#define GPIO117_GPIO MFP_CFG_IN(GPIO117, AF0)
48#define GPIO118_GPIO MFP_CFG_IN(GPIO118, AF0)
49#define GPIO119_GPIO MFP_CFG_IN(GPIO119, AF0)
50#define GPIO120_GPIO MFP_CFG_IN(GPIO120, AF0)
51
52/* Crystal and Clock Signals */
53#define GPIO9_HZ_CLK MFP_CFG_OUT(GPIO9, AF1, DRIVE_LOW)
54#define GPIO10_HZ_CLK MFP_CFG_OUT(GPIO10, AF1, DRIVE_LOW)
55#define GPIO11_48_MHz MFP_CFG_OUT(GPIO11, AF3, DRIVE_LOW)
56#define GPIO12_48_MHz MFP_CFG_OUT(GPIO12, AF3, DRIVE_LOW)
57#define GPIO13_CLK_EXT MFP_CFG_IN(GPIO13, AF1)
58
59/* OS Timer Signals */
60#define GPIO11_EXT_SYNC_0 MFP_CFG_IN(GPIO11, AF1)
61#define GPIO12_EXT_SYNC_1 MFP_CFG_IN(GPIO12, AF1)
62#define GPIO9_CHOUT_0 MFP_CFG_OUT(GPIO9, AF3, DRIVE_LOW)
63#define GPIO10_CHOUT_1 MFP_CFG_OUT(GPIO10, AF3, DRIVE_LOW)
64#define GPIO11_CHOUT_0 MFP_CFG_OUT(GPIO11, AF1, DRIVE_LOW)
65#define GPIO12_CHOUT_1 MFP_CFG_OUT(GPIO12, AF1, DRIVE_LOW)
66
67/* SDRAM and Static Memory I/O Signals */
68#define GPIO20_nSDCS_2 MFP_CFG_OUT(GPIO20, AF1, DRIVE_HIGH)
69#define GPIO21_nSDCS_3 MFP_CFG_OUT(GPIO21, AF1, DRIVE_HIGH)
70#define GPIO15_nCS_1 MFP_CFG_OUT(GPIO15, AF2, DRIVE_HIGH)
71#define GPIO78_nCS_2 MFP_CFG_OUT(GPIO78, AF2, DRIVE_HIGH)
72#define GPIO79_nCS_3 MFP_CFG_OUT(GPIO79, AF2, DRIVE_HIGH)
73#define GPIO80_nCS_4 MFP_CFG_OUT(GPIO80, AF2, DRIVE_HIGH)
74#define GPIO33_nCS_5 MFP_CFG_OUT(GPIO33, AF2, DRIVE_HIGH)
75
76/* Miscellaneous I/O and DMA Signals */
77#define GPIO21_DVAL_0 MFP_CFG_OUT(GPIO21, AF2, DRIVE_HIGH)
78#define GPIO116_DVAL_0 MFP_CFG_OUT(GPIO116, AF1, DRIVE_HIGH)
79#define GPIO33_DVAL_1 MFP_CFG_OUT(GPIO33, AF1, DRIVE_HIGH)
80#define GPIO96_DVAL_1 MFP_CFG_OUT(GPIO96, AF2, DRIVE_HIGH)
81#define GPIO18_RDY MFP_CFG_IN(GPIO18, AF1)
82#define GPIO20_DREQ_0 MFP_CFG_IN(GPIO20, AF1)
83#define GPIO115_DREQ_0 MFP_CFG_IN(GPIO115, AF1)
84#define GPIO80_DREQ_1 MFP_CFG_IN(GPIO80, AF1)
85#define GPIO97_DREQ_1 MFP_CFG_IN(GPIO97, AF2)
86#define GPIO85_DREQ_2 MFP_CFG_IN(GPIO85, AF2)
87#define GPIO100_DREQ_2 MFP_CFG_IN(GPIO100, AF2)
88
89/* Alternate Bus Master Mode I/O Signals */
90#define GPIO20_MBREQ MFP_CFG_IN(GPIO20, AF2)
91#define GPIO80_MBREQ MFP_CFG_IN(GPIO80, AF2)
92#define GPIO96_MBREQ MFP_CFG_IN(GPIO96, AF2)
93#define GPIO115_MBREQ MFP_CFG_IN(GPIO115, AF3)
94#define GPIO21_MBGNT MFP_CFG_OUT(GPIO21, AF3, DRIVE_LOW)
95#define GPIO33_MBGNT MFP_CFG_OUT(GPIO33, AF3, DRIVE_LOW)
96#define GPIO97_MBGNT MFP_CFG_OUT(GPIO97, AF2, DRIVE_LOW)
97#define GPIO116_MBGNT MFP_CFG_OUT(GPIO116, AF3, DRIVE_LOW)
98
99/* PC CARD */
100#define GPIO15_nPCE_1 MFP_CFG_OUT(GPIO15, AF1, DRIVE_HIGH)
101#define GPIO85_nPCE_1 MFP_CFG_OUT(GPIO85, AF1, DRIVE_HIGH)
102#define GPIO86_nPCE_1 MFP_CFG_OUT(GPIO86, AF1, DRIVE_HIGH)
103#define GPIO102_nPCE_1 MFP_CFG_OUT(GPIO102, AF1, DRIVE_HIGH)
104#define GPIO54_nPCE_2 MFP_CFG_OUT(GPIO54, AF2, DRIVE_HIGH)
105#define GPIO78_nPCE_2 MFP_CFG_OUT(GPIO78, AF1, DRIVE_HIGH)
106#define GPIO87_nPCE_2 MFP_CFG_IN(GPIO87, AF1)
107#define GPIO55_nPREG MFP_CFG_OUT(GPIO55, AF2, DRIVE_HIGH)
108#define GPIO50_nPIOR MFP_CFG_OUT(GPIO50, AF2, DRIVE_HIGH)
109#define GPIO51_nPIOW MFP_CFG_OUT(GPIO51, AF2, DRIVE_HIGH)
110#define GPIO49_nPWE MFP_CFG_OUT(GPIO49, AF2, DRIVE_HIGH)
111#define GPIO48_nPOE MFP_CFG_OUT(GPIO48, AF2, DRIVE_HIGH)
112#define GPIO57_nIOIS16 MFP_CFG_IN(GPIO57, AF1)
113#define GPIO56_nPWAIT MFP_CFG_IN(GPIO56, AF1)
114#define GPIO79_PSKTSEL MFP_CFG_OUT(GPIO79, AF1, DRIVE_HIGH)
115
116/* I2C */
117#define GPIO117_I2C_SCL MFP_CFG_IN(GPIO117, AF1)
118#define GPIO118_I2C_SDA MFP_CFG_IN(GPIO118, AF1)
119
120/* FFUART */
121#define GPIO9_FFUART_CTS MFP_CFG_IN(GPIO9, AF3)
122#define GPIO26_FFUART_CTS MFP_CFG_IN(GPIO26, AF3)
123#define GPIO35_FFUART_CTS MFP_CFG_IN(GPIO35, AF1)
124#define GPIO100_FFUART_CTS MFP_CFG_IN(GPIO100, AF3)
125#define GPIO10_FFUART_DCD MFP_CFG_IN(GPIO10, AF1)
126#define GPIO36_FFUART_DCD MFP_CFG_IN(GPIO36, AF1)
127#define GPIO33_FFUART_DSR MFP_CFG_IN(GPIO33, AF2)
128#define GPIO37_FFUART_DSR MFP_CFG_IN(GPIO37, AF1)
129#define GPIO38_FFUART_RI MFP_CFG_IN(GPIO38, AF1)
130#define GPIO89_FFUART_RI MFP_CFG_IN(GPIO89, AF3)
131#define GPIO19_FFUART_RXD MFP_CFG_IN(GPIO19, AF3)
132#define GPIO33_FFUART_RXD MFP_CFG_IN(GPIO33, AF1)
133#define GPIO34_FFUART_RXD MFP_CFG_IN(GPIO34, AF1)
134#define GPIO41_FFUART_RXD MFP_CFG_IN(GPIO41, AF1)
135#define GPIO53_FFUART_RXD MFP_CFG_IN(GPIO53, AF1)
136#define GPIO85_FFUART_RXD MFP_CFG_IN(GPIO85, AF1)
137#define GPIO96_FFUART_RXD MFP_CFG_IN(GPIO96, AF3)
138#define GPIO102_FFUART_RXD MFP_CFG_IN(GPIO102, AF3)
139#define GPIO16_FFUART_TXD MFP_CFG_OUT(GPIO16, AF3, DRIVE_HIGH)
140#define GPIO37_FFUART_TXD MFP_CFG_OUT(GPIO37, AF3, DRIVE_HIGH)
141#define GPIO39_FFUART_TXD MFP_CFG_OUT(GPIO39, AF2, DRIVE_HIGH)
142#define GPIO83_FFUART_TXD MFP_CFG_OUT(GPIO83, AF2, DRIVE_HIGH)
143#define GPIO99_FFUART_TXD MFP_CFG_OUT(GPIO99, AF3, DRIVE_HIGH)
144#define GPIO27_FFUART_RTS MFP_CFG_OUT(GPIO27, AF3, DRIVE_HIGH)
145#define GPIO41_FFUART_RTS MFP_CFG_OUT(GPIO41, AF2, DRIVE_HIGH)
146#define GPIO83_FFUART_RTS MFP_CFG_OUT(GPIO83, AF3, DRIVE_HIGH)
147#define GPIO98_FFUART_RTS MFP_CFG_OUT(GPIO98, AF3, DRIVE_HIGH)
148#define GPIO40_FFUART_DTR MFP_CFG_OUT(GPIO40, AF2, DRIVE_HIGH)
149#define GPIO82_FFUART_DTR MFP_CFG_OUT(GPIO82, AF3, DRIVE_HIGH)
150
151/* BTUART */
152#define GPIO44_BTUART_CTS MFP_CFG_IN(GPIO44, AF1)
153#define GPIO42_BTUART_RXD MFP_CFG_IN(GPIO42, AF1)
154#define GPIO45_BTUART_RTS MFP_CFG_OUT(GPIO45, AF2, DRIVE_HIGH)
155#define GPIO43_BTUART_TXD MFP_CFG_OUT(GPIO43, AF2, DRIVE_HIGH)
156
157/* STUART */
158#define GPIO46_STUART_RXD MFP_CFG_IN(GPIO46, AF2)
159#define GPIO47_STUART_TXD MFP_CFG_OUT(GPIO47, AF1, DRIVE_HIGH)
160
161/* FICP */
162#define GPIO42_FICP_RXD MFP_CFG_IN(GPIO42, AF2)
163#define GPIO46_FICP_RXD MFP_CFG_IN(GPIO46, AF1)
164#define GPIO43_FICP_TXD MFP_CFG_OUT(GPIO43, AF1, DRIVE_HIGH)
165#define GPIO47_FICP_TXD MFP_CFG_OUT(GPIO47, AF2, DRIVE_HIGH)
166
167/* PWM 0/1/2/3 */
168#define GPIO11_PWM2_OUT MFP_CFG_OUT(GPIO11, AF2, DRIVE_LOW)
169#define GPIO12_PWM3_OUT MFP_CFG_OUT(GPIO12, AF2, DRIVE_LOW)
170#define GPIO16_PWM0_OUT MFP_CFG_OUT(GPIO16, AF2, DRIVE_LOW)
171#define GPIO17_PWM1_OUT MFP_CFG_OUT(GPIO17, AF2, DRIVE_LOW)
172#define GPIO38_PWM1_OUT MFP_CFG_OUT(GPIO38, AF3, DRIVE_LOW)
173#define GPIO46_PWM2_OUT MFP_CFG_OUT(GPIO46, AF2, DRIVE_LOW)
174#define GPIO47_PWM3_OUT MFP_CFG_OUT(GPIO47, AF3, DRIVE_LOW)
175#define GPIO79_PWM2_OUT MFP_CFG_OUT(GPIO79, AF3, DRIVE_LOW)
176#define GPIO80_PWM3_OUT MFP_CFG_OUT(GPIO80, AF3, DRIVE_LOW)
177#define GPIO115_PWM1_OUT MFP_CFG_OUT(GPIO115, AF3, DRIVE_LOW)
178
179/* AC97 */
180#define GPIO31_AC97_SYNC MFP_CFG_OUT(GPIO31, AF2, DRIVE_LOW)
181#define GPIO94_AC97_SYNC MFP_CFG_OUT(GPIO94, AF1, DRIVE_LOW)
182#define GPIO30_AC97_SDATA_OUT MFP_CFG_OUT(GPIO30, AF2, DRIVE_LOW)
183#define GPIO93_AC97_SDATA_OUT MFP_CFG_OUT(GPIO93, AF1, DRIVE_LOW)
184#define GPIO45_AC97_SYSCLK MFP_CFG_OUT(GPIO45, AF1, DRIVE_LOW)
185#define GPIO89_AC97_SYSCLK MFP_CFG_OUT(GPIO89, AF1, DRIVE_LOW)
186#define GPIO98_AC97_SYSCLK MFP_CFG_OUT(GPIO98, AF1, DRIVE_LOW)
187#define GPIO95_AC97_nRESET MFP_CFG_OUT(GPIO95, AF1, DRIVE_LOW)
188#define GPIO113_AC97_nRESET MFP_CFG_OUT(GPIO113, AF2, DRIVE_LOW)
189#define GPIO28_AC97_BITCLK MFP_CFG_IN(GPIO28, AF1)
190#define GPIO29_AC97_SDATA_IN_0 MFP_CFG_IN(GPIO29, AF1)
191#define GPIO116_AC97_SDATA_IN_0 MFP_CFG_IN(GPIO116, AF2)
192#define GPIO99_AC97_SDATA_IN_1 MFP_CFG_IN(GPIO99, AF2)
193
194/* I2S */
195#define GPIO28_I2S_BITCLK_IN MFP_CFG_IN(GPIO28, AF2)
196#define GPIO28_I2S_BITCLK_OUT MFP_CFG_OUT(GPIO28, AF1, DRIVE_LOW)
197#define GPIO29_I2S_SDATA_IN MFP_CFG_IN(GPIO29, AF2)
198#define GPIO30_I2S_SDATA_OUT MFP_CFG_OUT(GPIO30, AF1, DRIVE_LOW)
199#define GPIO31_I2S_SYNC MFP_CFG_OUT(GPIO31, AF1, DRIVE_LOW)
200#define GPIO113_I2S_SYSCLK MFP_CFG_OUT(GPIO113, AF1, DRIVE_LOW)
201
202/* SSP 1 */
203#define GPIO23_SSP1_SCLK MFP_CFG_OUT(GPIO23, AF2, DRIVE_LOW)
204#define GPIO29_SSP1_SCLK MFP_CFG_IN(GPIO29, AF3)
205#define GPIO27_SSP1_SYSCLK MFP_CFG_OUT(GPIO27, AF1, DRIVE_LOW)
206#define GPIO53_SSP1_SYSCLK MFP_CFG_OUT(GPIO53, AF3, DRIVE_LOW)
207#define GPIO24_SSP1_SFRM MFP_CFG_IN(GPIO24, AF2)
208#define GPIO28_SSP1_SFRM MFP_CFG_IN(GPIO28, AF3)
209#define GPIO25_SSP1_TXD MFP_CFG_OUT(GPIO25, AF2, DRIVE_LOW)
210#define GPIO57_SSP1_TXD MFP_CFG_OUT(GPIO57, AF3, DRIVE_LOW)
211#define GPIO26_SSP1_RXD MFP_CFG_IN(GPIO26, AF1)
212#define GPIO27_SSP1_SCLKEN MFP_CFG_IN(GPIO27, AF2)
213
214/* SSP 2 */
215#define GPIO19_SSP2_SCLK MFP_CFG_IN(GPIO19, AF1)
216#define GPIO22_SSP2_SCLK MFP_CFG_IN(GPIO22, AF3)
217#define GPIO29_SSP2_SCLK MFP_CFG_OUT(GPIO29, AF3, DRIVE_LOW)
218#define GPIO36_SSP2_SCLK MFP_CFG_IN(GPIO36, AF2)
219#define GPIO50_SSP2_SCLK MFP_CFG_IN(GPIO50, AF3)
220#define GPIO22_SSP2_SYSCLK MFP_CFG_OUT(GPIO22, AF2, DRIVE_LOW)
221#define GPIO14_SSP2_SFRM MFP_CFG_IN(GPIO14, AF2)
222#define GPIO37_SSP2_SFRM MFP_CFG_IN(GPIO37, AF2)
223#define GPIO87_SSP2_SFRM MFP_CFG_OUT(GPIO87, AF3, DRIVE_LOW)
224#define GPIO88_SSP2_SFRM MFP_CFG_IN(GPIO88, AF3)
225#define GPIO13_SSP2_TXD MFP_CFG_OUT(GPIO13, AF1, DRIVE_LOW)
226#define GPIO38_SSP2_TXD MFP_CFG_OUT(GPIO38, AF2, DRIVE_LOW)
227#define GPIO87_SSP2_TXD MFP_CFG_OUT(GPIO87, AF1, DRIVE_LOW)
228#define GPIO89_SSP2_TXD MFP_CFG_OUT(GPIO89, AF3, DRIVE_LOW)
229#define GPIO11_SSP2_RXD MFP_CFG_IN(GPIO11, AF2)
230#define GPIO29_SSP2_RXD MFP_CFG_OUT(GPIO29, AF1, DRIVE_LOW)
231#define GPIO40_SSP2_RXD MFP_CFG_IN(GPIO40, AF1)
232#define GPIO86_SSP2_RXD MFP_CFG_IN(GPIO86, AF1)
233#define GPIO88_SSP2_RXD MFP_CFG_IN(GPIO88, AF2)
234#define GPIO22_SSP2_EXTCLK MFP_CFG_IN(GPIO22, AF1)
235#define GPIO27_SSP2_EXTCLK MFP_CFG_IN(GPIO27, AF1)
236#define GPIO22_SSP2_SCLKEN MFP_CFG_IN(GPIO22, AF2)
237#define GPIO23_SSP2_SCLKEN MFP_CFG_IN(GPIO23, AF2)
238
239/* SSP 3 */
240#define GPIO34_SSP3_SCLK MFP_CFG_IN(GPIO34, AF3)
241#define GPIO40_SSP3_SCLK MFP_CFG_OUT(GPIO40, AF3, DRIVE_LOW)
242#define GPIO52_SSP3_SCLK MFP_CFG_IN(GPIO52, AF2)
243#define GPIO84_SSP3_SCLK MFP_CFG_IN(GPIO84, AF1)
244#define GPIO45_SSP3_SYSCLK MFP_CFG_OUT(GPIO45, AF3, DRIVE_LOW)
245#define GPIO35_SSP3_SFRM MFP_CFG_IN(GPIO35, AF3)
246#define GPIO39_SSP3_SFRM MFP_CFG_IN(GPIO39, AF3)
247#define GPIO83_SSP3_SFRM MFP_CFG_IN(GPIO83, AF1)
248#define GPIO35_SSP3_TXD MFP_CFG_OUT(GPIO35, AF3, DRIVE_LOW)
249#define GPIO38_SSP3_TXD MFP_CFG_OUT(GPIO38, AF1, DRIVE_LOW)
250#define GPIO81_SSP3_TXD MFP_CFG_OUT(GPIO81, AF1, DRIVE_LOW)
251#define GPIO41_SSP3_RXD MFP_CFG_IN(GPIO41, AF3)
252#define GPIO82_SSP3_RXD MFP_CFG_IN(GPIO82, AF1)
253#define GPIO89_SSP3_RXD MFP_CFG_IN(GPIO89, AF1)
254
255/* MMC */
256#define GPIO32_MMC_CLK MFP_CFG_OUT(GPIO32, AF2, DRIVE_LOW)
257#define GPIO92_MMC_DAT_0 MFP_CFG_IN(GPIO92, AF1)
258#define GPIO109_MMC_DAT_1 MFP_CFG_IN(GPIO109, AF1)
259#define GPIO110_MMC_DAT_2 MFP_CFG_IN(GPIO110, AF1)
260#define GPIO111_MMC_DAT_3 MFP_CFG_IN(GPIO111, AF1)
261#define GPIO112_MMC_CMD MFP_CFG_IN(GPIO112, AF1)
262
263/* LCD */
264#define GPIO58_LCD_LDD_0 MFP_CFG_OUT(GPIO58, AF2, DRIVE_LOW)
265#define GPIO59_LCD_LDD_1 MFP_CFG_OUT(GPIO59, AF2, DRIVE_LOW)
266#define GPIO60_LCD_LDD_2 MFP_CFG_OUT(GPIO60, AF2, DRIVE_LOW)
267#define GPIO61_LCD_LDD_3 MFP_CFG_OUT(GPIO61, AF2, DRIVE_LOW)
268#define GPIO62_LCD_LDD_4 MFP_CFG_OUT(GPIO62, AF2, DRIVE_LOW)
269#define GPIO63_LCD_LDD_5 MFP_CFG_OUT(GPIO63, AF2, DRIVE_LOW)
270#define GPIO64_LCD_LDD_6 MFP_CFG_OUT(GPIO64, AF2, DRIVE_LOW)
271#define GPIO65_LCD_LDD_7 MFP_CFG_OUT(GPIO65, AF2, DRIVE_LOW)
272#define GPIO66_LCD_LDD_8 MFP_CFG_OUT(GPIO66, AF2, DRIVE_LOW)
273#define GPIO67_LCD_LDD_9 MFP_CFG_OUT(GPIO67, AF2, DRIVE_LOW)
274#define GPIO68_LCD_LDD_10 MFP_CFG_OUT(GPIO68, AF2, DRIVE_LOW)
275#define GPIO69_LCD_LDD_11 MFP_CFG_OUT(GPIO69, AF2, DRIVE_LOW)
276#define GPIO70_LCD_LDD_12 MFP_CFG_OUT(GPIO70, AF2, DRIVE_LOW)
277#define GPIO71_LCD_LDD_13 MFP_CFG_OUT(GPIO71, AF2, DRIVE_LOW)
278#define GPIO72_LCD_LDD_14 MFP_CFG_OUT(GPIO72, AF2, DRIVE_LOW)
279#define GPIO73_LCD_LDD_15 MFP_CFG_OUT(GPIO73, AF2, DRIVE_LOW)
280#define GPIO86_LCD_LDD_16 MFP_CFG_OUT(GPIO86, AF2, DRIVE_LOW)
281#define GPIO87_LCD_LDD_17 MFP_CFG_OUT(GPIO87, AF2, DRIVE_LOW)
282#define GPIO74_LCD_FCLK MFP_CFG_OUT(GPIO74, AF2, DRIVE_LOW)
283#define GPIO75_LCD_LCLK MFP_CFG_OUT(GPIO75, AF2, DRIVE_LOW)
284#define GPIO76_LCD_PCLK MFP_CFG_OUT(GPIO76, AF2, DRIVE_LOW)
285#define GPIO77_LCD_BIAS MFP_CFG_OUT(GPIO77, AF2, DRIVE_LOW)
286#define GPIO14_LCD_VSYNC MFP_CFG_IN(GPIO14, AF1)
287#define GPIO19_LCD_CS MFP_CFG_OUT(GPIO19, AF2, DRIVE_LOW)
288
289/* Keypad */
290#define GPIO93_KP_DKIN_0 MFP_CFG_IN(GPIO93, AF1)
291#define GPIO94_KP_DKIN_1 MFP_CFG_IN(GPIO94, AF1)
292#define GPIO95_KP_DKIN_2 MFP_CFG_IN(GPIO95, AF1)
293#define GPIO96_KP_DKIN_3 MFP_CFG_IN(GPIO96, AF1)
294#define GPIO97_KP_DKIN_4 MFP_CFG_IN(GPIO97, AF1)
295#define GPIO98_KP_DKIN_5 MFP_CFG_IN(GPIO98, AF1)
296#define GPIO99_KP_DKIN_6 MFP_CFG_IN(GPIO99, AF1)
297#define GPIO13_KP_KDIN_7 MFP_CFG_IN(GPIO13, AF2)
298#define GPIO100_KP_MKIN_0 MFP_CFG_IN(GPIO100, AF1)
299#define GPIO101_KP_MKIN_1 MFP_CFG_IN(GPIO101, AF1)
300#define GPIO102_KP_MKIN_2 MFP_CFG_IN(GPIO102, AF1)
301#define GPIO34_KP_MKIN_3 MFP_CFG_IN(GPIO34, AF2)
302#define GPIO37_KP_MKIN_3 MFP_CFG_IN(GPIO37, AF3)
303#define GPIO97_KP_MKIN_3 MFP_CFG_IN(GPIO97, AF3)
304#define GPIO98_KP_MKIN_4 MFP_CFG_IN(GPIO98, AF3)
305#define GPIO38_KP_MKIN_4 MFP_CFG_IN(GPIO38, AF2)
306#define GPIO39_KP_MKIN_4 MFP_CFG_IN(GPIO39, AF1)
307#define GPIO16_KP_MKIN_5 MFP_CFG_IN(GPIO16, AF1)
308#define GPIO90_KP_MKIN_5 MFP_CFG_IN(GPIO90, AF1)
309#define GPIO99_KP_MKIN_5 MFP_CFG_IN(GPIO99, AF3)
310#define GPIO17_KP_MKIN_6 MFP_CFG_IN(GPIO17, AF1)
311#define GPIO91_KP_MKIN_6 MFP_CFG_IN(GPIO91, AF1)
312#define GPIO95_KP_MKIN_6 MFP_CFG_IN(GPIO95, AF3)
313#define GPIO13_KP_MKIN_7 MFP_CFG_IN(GPIO13, AF3)
314#define GPIO36_KP_MKIN_7 MFP_CFG_IN(GPIO36, AF3)
315#define GPIO103_KP_MKOUT_0 MFP_CFG_OUT(GPIO103, AF2, DRIVE_HIGH)
316#define GPIO104_KP_MKOUT_1 MFP_CFG_OUT(GPIO104, AF2, DRIVE_HIGH)
317#define GPIO105_KP_MKOUT_2 MFP_CFG_OUT(GPIO105, AF2, DRIVE_HIGH)
318#define GPIO106_KP_MKOUT_3 MFP_CFG_OUT(GPIO106, AF2, DRIVE_HIGH)
319#define GPIO107_KP_MKOUT_4 MFP_CFG_OUT(GPIO107, AF2, DRIVE_HIGH)
320#define GPIO108_KP_MKOUT_5 MFP_CFG_OUT(GPIO108, AF2, DRIVE_HIGH)
321#define GPIO35_KP_MKOUT_6 MFP_CFG_OUT(GPIO35, AF2, DRIVE_HIGH)
322#define GPIO22_KP_MKOUT_7 MFP_CFG_OUT(GPIO22, AF1, DRIVE_HIGH)
323#define GPIO40_KP_MKOUT_6 MFP_CFG_OUT(GPIO40, AF1, DRIVE_HIGH)
324#define GPIO41_KP_MKOUT_7 MFP_CFG_OUT(GPIO41, AF1, DRIVE_HIGH)
325#define GPIO96_KP_MKOUT_6 MFP_CFG_OUT(GPIO96, AF3, DRIVE_HIGH)
326
327/* USB P3 */
328#define GPIO10_USB_P3_5 MFP_CFG_IN(GPIO10, AF3)
329#define GPIO11_USB_P3_1 MFP_CFG_IN(GPIO11, AF3)
330#define GPIO30_USB_P3_2 MFP_CFG_OUT(GPIO30, AF3, DRIVE_LOW)
331#define GPIO31_USB_P3_6 MFP_CFG_OUT(GPIO31, AF3, DRIVE_LOW)
332#define GPIO56_USB_P3_4 MFP_CFG_OUT(GPIO56, AF1, DRIVE_LOW)
333#define GPIO86_USB_P3_5 MFP_CFG_IN(GPIO86, AF3)
334#define GPIO87_USB_P3_1 MFP_CFG_IN(GPIO87, AF3)
335#define GPIO90_USB_P3_5 MFP_CFG_IN(GPIO90, AF2)
336#define GPIO91_USB_P3_1 MFP_CFG_IN(GPIO91, AF2)
337#define GPIO113_USB_P3_3 MFP_CFG_IN(GPIO113, AF3)
338
339/* USB P2 */
340#define GPIO34_USB_P2_2 MFP_CFG_OUT(GPIO34, AF1, DRIVE_LOW)
341#define GPIO35_USB_P2_1 MFP_CFG_IN(GPIO35, AF2)
342#define GPIO36_USB_P2_4 MFP_CFG_OUT(GPIO36, AF1, DRIVE_LOW)
343#define GPIO37_USB_P2_8 MFP_CFG_OUT(GPIO37, AF1, DRIVE_LOW)
344#define GPIO38_USB_P2_3 MFP_CFG_IN(GPIO38, AF3)
345#define GPIO39_USB_P2_6 MFP_CFG_OUT(GPIO39, AF1, DRIVE_LOW)
346#define GPIO40_USB_P2_5 MFP_CFG_IN(GPIO40, AF3)
347#define GPIO41_USB_P2_7 MFP_CFG_IN(GPIO41, AF2)
348#define GPIO53_USB_P2_3 MFP_CFG_IN(GPIO53, AF2)
349
350/* USB Host Port 1/2 */
351#define GPIO88_USBH1_PWR MFP_CFG_IN(GPIO88, AF1)
352#define GPIO89_USBH1_PEN MFP_CFG_OUT(GPIO89, AF2, DRIVE_LOW)
353#define GPIO119_USBH2_PWR MFP_CFG_IN(GPIO119, AF1)
354#define GPIO120_USBH2_PEN MFP_CFG_OUT(GPIO120, AF2, DRIVE_LOW)
355
356/* QCI - default to Master Mode: CIF_FV/CIF_LV Direction In */
357#define GPIO115_CIF_DD_3 MFP_CFG_IN(GPIO115, AF2)
358#define GPIO116_CIF_DD_2 MFP_CFG_IN(GPIO116, AF1)
359#define GPIO12_CIF_DD_7 MFP_CFG_IN(GPIO12, AF2)
360#define GPIO17_CIF_DD_6 MFP_CFG_IN(GPIO17, AF2)
361#define GPIO23_CIF_MCLK MFP_CFG_OUT(GPIO23, AF1, DRIVE_LOW)
362#define GPIO24_CIF_FV MFP_CFG_IN(GPIO24, AF1)
363#define GPIO25_CIF_LV MFP_CFG_IN(GPIO25, AF1)
364#define GPIO26_CIF_PCLK MFP_CFG_IN(GPIO26, AF2)
365#define GPIO27_CIF_DD_0 MFP_CFG_IN(GPIO27, AF3)
366#define GPIO42_CIF_MCLK MFP_CFG_OUT(GPIO42, AF3, DRIVE_LOW)
367#define GPIO43_CIF_FV MFP_CFG_IN(GPIO43, AF3)
368#define GPIO44_CIF_LV MFP_CFG_IN(GPIO44, AF3)
369#define GPIO45_CIF_PCLK MFP_CFG_IN(GPIO45, AF3)
370#define GPIO47_CIF_DD_0 MFP_CFG_IN(GPIO47, AF1)
371#define GPIO48_CIF_DD_5 MFP_CFG_IN(GPIO48, AF1)
372#define GPIO50_CIF_DD_3 MFP_CFG_IN(GPIO50, AF1)
373#define GPIO51_CIF_DD_2 MFP_CFG_IN(GPIO51, AF1)
374#define GPIO52_CIF_DD_4 MFP_CFG_IN(GPIO52, AF1)
375#define GPIO53_CIF_MCLK MFP_CFG_OUT(GPIO53, AF2, DRIVE_LOW)
376#define GPIO54_CIF_PCLK MFP_CFG_IN(GPIO54, AF3)
377#define GPIO55_CIF_DD_1 MFP_CFG_IN(GPIO55, AF1)
378#define GPIO81_CIF_DD_0 MFP_CFG_IN(GPIO81, AF2)
379#define GPIO82_CIF_DD_5 MFP_CFG_IN(GPIO82, AF3)
380#define GPIO83_CIF_DD_4 MFP_CFG_IN(GPIO83, AF3)
381#define GPIO84_CIF_FV MFP_CFG_IN(GPIO84, AF3)
382#define GPIO85_CIF_LV MFP_CFG_IN(GPIO85, AF3)
383#define GPIO90_CIF_DD_4 MFP_CFG_IN(GPIO90, AF3)
384#define GPIO91_CIF_DD_5 MFP_CFG_IN(GPIO91, AF3)
385#define GPIO93_CIF_DD_6 MFP_CFG_IN(GPIO93, AF2)
386#define GPIO94_CIF_DD_5 MFP_CFG_IN(GPIO94, AF2)
387#define GPIO95_CIF_DD_4 MFP_CFG_IN(GPIO95, AF2)
388#define GPIO98_CIF_DD_0 MFP_CFG_IN(GPIO98, AF2)
389#define GPIO103_CIF_DD_3 MFP_CFG_IN(GPIO103, AF1)
390#define GPIO104_CIF_DD_2 MFP_CFG_IN(GPIO104, AF1)
391#define GPIO105_CIF_DD_1 MFP_CFG_IN(GPIO105, AF1)
392#define GPIO106_CIF_DD_9 MFP_CFG_IN(GPIO106, AF1)
393#define GPIO107_CIF_DD_8 MFP_CFG_IN(GPIO107, AF1)
394#define GPIO108_CIF_DD_7 MFP_CFG_IN(GPIO108, AF1)
395#define GPIO114_CIF_DD_1 MFP_CFG_IN(GPIO114, AF1)
396
397/* Universal Subscriber ID Interface */
398#define GPIO114_UVS0 MFP_CFG_OUT(GPIO114, AF2, DRIVE_LOW)
399#define GPIO115_nUVS1 MFP_CFG_OUT(GPIO115, AF2, DRIVE_LOW)
400#define GPIO116_nUVS2 MFP_CFG_OUT(GPIO116, AF2, DRIVE_LOW)
401#define GPIO14_UCLK MFP_CFG_OUT(GPIO14, AF3, DRIVE_LOW)
402#define GPIO91_UCLK MFP_CFG_OUT(GPIO91, AF2, DRIVE_LOW)
403#define GPIO19_nURST MFP_CFG_OUT(GPIO19, AF3, DRIVE_LOW)
404#define GPIO90_nURST MFP_CFG_OUT(GPIO90, AF2, DRIVE_LOW)
405#define GPIO116_UDET MFP_CFG_IN(GPIO116, AF3)
406#define GPIO114_UEN MFP_CFG_OUT(GPIO114, AF1, DRIVE_LOW)
407#define GPIO115_UEN MFP_CFG_OUT(GPIO115, AF1, DRIVE_LOW)
408
409/* Mobile Scalable Link (MSL) Interface */
410#define GPIO81_BB_OB_DAT_0 MFP_CFG_OUT(GPIO81, AF2, DRIVE_LOW)
411#define GPIO48_BB_OB_DAT_1 MFP_CFG_OUT(GPIO48, AF1, DRIVE_LOW)
412#define GPIO50_BB_OB_DAT_2 MFP_CFG_OUT(GPIO50, AF1, DRIVE_LOW)
413#define GPIO51_BB_OB_DAT_3 MFP_CFG_OUT(GPIO51, AF1, DRIVE_LOW)
414#define GPIO52_BB_OB_CLK MFP_CFG_OUT(GPIO52, AF1, DRIVE_LOW)
415#define GPIO53_BB_OB_STB MFP_CFG_OUT(GPIO53, AF1, DRIVE_LOW)
416#define GPIO54_BB_OB_WAIT MFP_CFG_IN(GPIO54, AF2)
417#define GPIO82_BB_IB_DAT_0 MFP_CFG_IN(GPIO82, AF2)
418#define GPIO55_BB_IB_DAT_1 MFP_CFG_IN(GPIO55, AF2)
419#define GPIO56_BB_IB_DAT_2 MFP_CFG_IN(GPIO56, AF2)
420#define GPIO57_BB_IB_DAT_3 MFP_CFG_IN(GPIO57, AF2)
421#define GPIO83_BB_IB_CLK MFP_CFG_IN(GPIO83, AF2)
422#define GPIO84_BB_IB_STB MFP_CFG_IN(GPIO84, AF2)
423#define GPIO85_BB_IB_WAIT MFP_CFG_OUT(GPIO85, AF2, DRIVE_LOW)
424
425/* Memory Stick Host Controller */
426#define GPIO92_MSBS MFP_CFG_OUT(GPIO92, AF2, DRIVE_LOW)
427#define GPIO109_MSSDIO MFP_CFG_IN(GPIO109, AF2)
428#define GPIO112_nMSINS MFP_CFG_IN(GPIO112, AF2)
429#define GPIO32_MSSCLK MFP_CFG_OUT(GPIO32, AF1, DRIVE_LOW)
430
431extern int keypad_set_wake(unsigned int on);
432#endif /* __ASM_ARCH_MFP_PXA27X_H */
diff --git a/include/asm-arm/arch-pxa/mfp-pxa2xx.h b/include/asm-arm/arch-pxa/mfp-pxa2xx.h
new file mode 100644
index 000000000000..db8d890d237c
--- /dev/null
+++ b/include/asm-arm/arch-pxa/mfp-pxa2xx.h
@@ -0,0 +1,132 @@
1#ifndef __ASM_ARCH_MFP_PXA2XX_H
2#define __ASM_ARCH_MFP_PXA2XX_H
3
4#include <asm/arch/mfp.h>
5
6/*
7 * the following MFP_xxx bit definitions in mfp.h are re-used for pxa2xx:
8 *
9 * MFP_PIN(x)
10 * MFP_AFx
11 * MFP_LPM_DRIVE_{LOW, HIGH}
12 * MFP_LPM_EDGE_x
13 *
14 * other MFP_x bit definitions will be ignored
15 *
16 * and adds the below two bits specifically for pxa2xx:
17 *
18 * bit 23 - Input/Output (PXA2xx specific)
19 * bit 24 - Wakeup Enable(PXA2xx specific)
20 */
21
22#define MFP_DIR_IN (0x0 << 23)
23#define MFP_DIR_OUT (0x1 << 23)
24#define MFP_DIR_MASK (0x1 << 23)
25#define MFP_DIR(x) (((x) >> 23) & 0x1)
26
27#define MFP_LPM_CAN_WAKEUP (0x1 << 24)
28#define WAKEUP_ON_EDGE_RISE (MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_RISE)
29#define WAKEUP_ON_EDGE_FALL (MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_FALL)
30#define WAKEUP_ON_EDGE_BOTH (MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_BOTH)
31
32/* specifically for enabling wakeup on keypad GPIOs */
33#define WAKEUP_ON_LEVEL_HIGH (MFP_LPM_CAN_WAKEUP)
34
35#define MFP_CFG_IN(pin, af) \
36 ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DIR_MASK)) |\
37 (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_DIR_IN))
38
39/* NOTE: pins configured as output _must_ provide a low power state,
40 * and this state should help to minimize the power dissipation.
41 */
42#define MFP_CFG_OUT(pin, af, state) \
43 ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DIR_MASK | MFP_LPM_STATE_MASK)) |\
44 (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_DIR_OUT | MFP_LPM_##state))
45
46/* Common configurations for pxa25x and pxa27x
47 *
48 * Note: pins configured as GPIO are always initialized to input
49 * so not to cause any side effect
50 */
51#define GPIO0_GPIO MFP_CFG_IN(GPIO0, AF0)
52#define GPIO1_GPIO MFP_CFG_IN(GPIO1, AF0)
53#define GPIO9_GPIO MFP_CFG_IN(GPIO9, AF0)
54#define GPIO10_GPIO MFP_CFG_IN(GPIO10, AF0)
55#define GPIO11_GPIO MFP_CFG_IN(GPIO11, AF0)
56#define GPIO12_GPIO MFP_CFG_IN(GPIO12, AF0)
57#define GPIO13_GPIO MFP_CFG_IN(GPIO13, AF0)
58#define GPIO14_GPIO MFP_CFG_IN(GPIO14, AF0)
59#define GPIO15_GPIO MFP_CFG_IN(GPIO15, AF0)
60#define GPIO16_GPIO MFP_CFG_IN(GPIO16, AF0)
61#define GPIO17_GPIO MFP_CFG_IN(GPIO17, AF0)
62#define GPIO18_GPIO MFP_CFG_IN(GPIO18, AF0)
63#define GPIO19_GPIO MFP_CFG_IN(GPIO19, AF0)
64#define GPIO20_GPIO MFP_CFG_IN(GPIO20, AF0)
65#define GPIO21_GPIO MFP_CFG_IN(GPIO21, AF0)
66#define GPIO22_GPIO MFP_CFG_IN(GPIO22, AF0)
67#define GPIO23_GPIO MFP_CFG_IN(GPIO23, AF0)
68#define GPIO24_GPIO MFP_CFG_IN(GPIO24, AF0)
69#define GPIO25_GPIO MFP_CFG_IN(GPIO25, AF0)
70#define GPIO26_GPIO MFP_CFG_IN(GPIO26, AF0)
71#define GPIO27_GPIO MFP_CFG_IN(GPIO27, AF0)
72#define GPIO28_GPIO MFP_CFG_IN(GPIO28, AF0)
73#define GPIO29_GPIO MFP_CFG_IN(GPIO29, AF0)
74#define GPIO30_GPIO MFP_CFG_IN(GPIO30, AF0)
75#define GPIO31_GPIO MFP_CFG_IN(GPIO31, AF0)
76#define GPIO32_GPIO MFP_CFG_IN(GPIO32, AF0)
77#define GPIO33_GPIO MFP_CFG_IN(GPIO33, AF0)
78#define GPIO34_GPIO MFP_CFG_IN(GPIO34, AF0)
79#define GPIO35_GPIO MFP_CFG_IN(GPIO35, AF0)
80#define GPIO36_GPIO MFP_CFG_IN(GPIO36, AF0)
81#define GPIO37_GPIO MFP_CFG_IN(GPIO37, AF0)
82#define GPIO38_GPIO MFP_CFG_IN(GPIO38, AF0)
83#define GPIO39_GPIO MFP_CFG_IN(GPIO39, AF0)
84#define GPIO40_GPIO MFP_CFG_IN(GPIO40, AF0)
85#define GPIO41_GPIO MFP_CFG_IN(GPIO41, AF0)
86#define GPIO42_GPIO MFP_CFG_IN(GPIO42, AF0)
87#define GPIO43_GPIO MFP_CFG_IN(GPIO43, AF0)
88#define GPIO44_GPIO MFP_CFG_IN(GPIO44, AF0)
89#define GPIO45_GPIO MFP_CFG_IN(GPIO45, AF0)
90#define GPIO46_GPIO MFP_CFG_IN(GPIO46, AF0)
91#define GPIO47_GPIO MFP_CFG_IN(GPIO47, AF0)
92#define GPIO48_GPIO MFP_CFG_IN(GPIO48, AF0)
93#define GPIO49_GPIO MFP_CFG_IN(GPIO49, AF0)
94#define GPIO50_GPIO MFP_CFG_IN(GPIO50, AF0)
95#define GPIO51_GPIO MFP_CFG_IN(GPIO51, AF0)
96#define GPIO52_GPIO MFP_CFG_IN(GPIO52, AF0)
97#define GPIO53_GPIO MFP_CFG_IN(GPIO53, AF0)
98#define GPIO54_GPIO MFP_CFG_IN(GPIO54, AF0)
99#define GPIO55_GPIO MFP_CFG_IN(GPIO55, AF0)
100#define GPIO56_GPIO MFP_CFG_IN(GPIO56, AF0)
101#define GPIO57_GPIO MFP_CFG_IN(GPIO57, AF0)
102#define GPIO58_GPIO MFP_CFG_IN(GPIO58, AF0)
103#define GPIO59_GPIO MFP_CFG_IN(GPIO59, AF0)
104#define GPIO60_GPIO MFP_CFG_IN(GPIO60, AF0)
105#define GPIO61_GPIO MFP_CFG_IN(GPIO61, AF0)
106#define GPIO62_GPIO MFP_CFG_IN(GPIO62, AF0)
107#define GPIO63_GPIO MFP_CFG_IN(GPIO63, AF0)
108#define GPIO64_GPIO MFP_CFG_IN(GPIO64, AF0)
109#define GPIO65_GPIO MFP_CFG_IN(GPIO65, AF0)
110#define GPIO66_GPIO MFP_CFG_IN(GPIO66, AF0)
111#define GPIO67_GPIO MFP_CFG_IN(GPIO67, AF0)
112#define GPIO68_GPIO MFP_CFG_IN(GPIO68, AF0)
113#define GPIO69_GPIO MFP_CFG_IN(GPIO69, AF0)
114#define GPIO70_GPIO MFP_CFG_IN(GPIO70, AF0)
115#define GPIO71_GPIO MFP_CFG_IN(GPIO71, AF0)
116#define GPIO72_GPIO MFP_CFG_IN(GPIO72, AF0)
117#define GPIO73_GPIO MFP_CFG_IN(GPIO73, AF0)
118#define GPIO74_GPIO MFP_CFG_IN(GPIO74, AF0)
119#define GPIO75_GPIO MFP_CFG_IN(GPIO75, AF0)
120#define GPIO76_GPIO MFP_CFG_IN(GPIO76, AF0)
121#define GPIO77_GPIO MFP_CFG_IN(GPIO77, AF0)
122#define GPIO78_GPIO MFP_CFG_IN(GPIO78, AF0)
123#define GPIO79_GPIO MFP_CFG_IN(GPIO79, AF0)
124#define GPIO80_GPIO MFP_CFG_IN(GPIO80, AF0)
125#define GPIO81_GPIO MFP_CFG_IN(GPIO81, AF0)
126#define GPIO82_GPIO MFP_CFG_IN(GPIO82, AF0)
127#define GPIO83_GPIO MFP_CFG_IN(GPIO83, AF0)
128#define GPIO84_GPIO MFP_CFG_IN(GPIO84, AF0)
129
130extern void pxa2xx_mfp_config(unsigned long *mfp_cfgs, int num);
131extern int gpio_set_wake(unsigned int gpio, unsigned int on);
132#endif /* __ASM_ARCH_MFP_PXA2XX_H */
diff --git a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
index 2357a73340d4..4b2ea1e95c57 100644
--- a/include/asm-arm/arch-pxa/pxa-regs.h
+++ b/include/asm-arm/arch-pxa/pxa-regs.h
@@ -1129,6 +1129,11 @@
1129#define ICPR __REG(0x40D00010) /* Interrupt Controller Pending Register */ 1129#define ICPR __REG(0x40D00010) /* Interrupt Controller Pending Register */
1130#define ICCR __REG(0x40D00014) /* Interrupt Controller Control Register */ 1130#define ICCR __REG(0x40D00014) /* Interrupt Controller Control Register */
1131 1131
1132#define ICIP2 __REG(0x40D0009C) /* Interrupt Controller IRQ Pending Register 2 */
1133#define ICMR2 __REG(0x40D000A0) /* Interrupt Controller Mask Register 2 */
1134#define ICLR2 __REG(0x40D000A4) /* Interrupt Controller Level Register 2 */
1135#define ICFP2 __REG(0x40D000A8) /* Interrupt Controller FIQ Pending Register 2 */
1136#define ICPR2 __REG(0x40D000AC) /* Interrupt Controller Pending Register 2 */
1132 1137
1133/* 1138/*
1134 * General Purpose I/O 1139 * General Purpose I/O
@@ -1200,12 +1205,6 @@
1200 1205
1201/* Interrupt Controller */ 1206/* Interrupt Controller */
1202 1207
1203#define ICIP2 __REG(0x40D0009C) /* Interrupt Controller IRQ Pending Register 2 */
1204#define ICMR2 __REG(0x40D000A0) /* Interrupt Controller Mask Register 2 */
1205#define ICLR2 __REG(0x40D000A4) /* Interrupt Controller Level Register 2 */
1206#define ICFP2 __REG(0x40D000A8) /* Interrupt Controller FIQ Pending Register 2 */
1207#define ICPR2 __REG(0x40D000AC) /* Interrupt Controller Pending Register 2 */
1208
1209#define _GPLR(x) __REG2(0x40E00000, ((x) & 0x60) >> 3) 1208#define _GPLR(x) __REG2(0x40E00000, ((x) & 0x60) >> 3)
1210#define _GPDR(x) __REG2(0x40E0000C, ((x) & 0x60) >> 3) 1209#define _GPDR(x) __REG2(0x40E0000C, ((x) & 0x60) >> 3)
1211#define _GPSR(x) __REG2(0x40E00018, ((x) & 0x60) >> 3) 1210#define _GPSR(x) __REG2(0x40E00018, ((x) & 0x60) >> 3)
@@ -1237,267 +1236,6 @@
1237 1236
1238#endif 1237#endif
1239 1238
1240
1241/* GPIO alternate function assignments */
1242
1243#define GPIO1_RST 1 /* reset */
1244#define GPIO6_MMCCLK 6 /* MMC Clock */
1245#define GPIO7_48MHz 7 /* 48 MHz clock output */
1246#define GPIO8_MMCCS0 8 /* MMC Chip Select 0 */
1247#define GPIO9_MMCCS1 9 /* MMC Chip Select 1 */
1248#define GPIO10_RTCCLK 10 /* real time clock (1 Hz) */
1249#define GPIO11_3_6MHz 11 /* 3.6 MHz oscillator out */
1250#define GPIO12_32KHz 12 /* 32 kHz out */
1251#define GPIO13_MBGNT 13 /* memory controller grant */
1252#define GPIO14_MBREQ 14 /* alternate bus master request */
1253#define GPIO15_nCS_1 15 /* chip select 1 */
1254#define GPIO16_PWM0 16 /* PWM0 output */
1255#define GPIO17_PWM1 17 /* PWM1 output */
1256#define GPIO18_RDY 18 /* Ext. Bus Ready */
1257#define GPIO19_DREQ1 19 /* External DMA Request */
1258#define GPIO20_DREQ0 20 /* External DMA Request */
1259#define GPIO23_SCLK 23 /* SSP clock */
1260#define GPIO24_SFRM 24 /* SSP Frame */
1261#define GPIO25_STXD 25 /* SSP transmit */
1262#define GPIO26_SRXD 26 /* SSP receive */
1263#define GPIO27_SEXTCLK 27 /* SSP ext_clk */
1264#define GPIO28_BITCLK 28 /* AC97/I2S bit_clk */
1265#define GPIO29_SDATA_IN 29 /* AC97 Sdata_in0 / I2S Sdata_in */
1266#define GPIO30_SDATA_OUT 30 /* AC97/I2S Sdata_out */
1267#define GPIO31_SYNC 31 /* AC97/I2S sync */
1268#define GPIO32_SDATA_IN1 32 /* AC97 Sdata_in1 */
1269#define GPIO32_SYSCLK 32 /* I2S System Clock */
1270#define GPIO32_MMCCLK 32 /* MMC Clock (PXA270) */
1271#define GPIO33_nCS_5 33 /* chip select 5 */
1272#define GPIO34_FFRXD 34 /* FFUART receive */
1273#define GPIO34_MMCCS0 34 /* MMC Chip Select 0 */
1274#define GPIO35_FFCTS 35 /* FFUART Clear to send */
1275#define GPIO36_FFDCD 36 /* FFUART Data carrier detect */
1276#define GPIO37_FFDSR 37 /* FFUART data set ready */
1277#define GPIO38_FFRI 38 /* FFUART Ring Indicator */
1278#define GPIO39_MMCCS1 39 /* MMC Chip Select 1 */
1279#define GPIO39_FFTXD 39 /* FFUART transmit data */
1280#define GPIO40_FFDTR 40 /* FFUART data terminal Ready */
1281#define GPIO41_FFRTS 41 /* FFUART request to send */
1282#define GPIO42_BTRXD 42 /* BTUART receive data */
1283#define GPIO42_HWRXD 42 /* HWUART receive data */
1284#define GPIO43_BTTXD 43 /* BTUART transmit data */
1285#define GPIO43_HWTXD 43 /* HWUART transmit data */
1286#define GPIO44_BTCTS 44 /* BTUART clear to send */
1287#define GPIO44_HWCTS 44 /* HWUART clear to send */
1288#define GPIO45_BTRTS 45 /* BTUART request to send */
1289#define GPIO45_HWRTS 45 /* HWUART request to send */
1290#define GPIO45_AC97_SYSCLK 45 /* AC97 System Clock */
1291#define GPIO46_ICPRXD 46 /* ICP receive data */
1292#define GPIO46_STRXD 46 /* STD_UART receive data */
1293#define GPIO47_ICPTXD 47 /* ICP transmit data */
1294#define GPIO47_STTXD 47 /* STD_UART transmit data */
1295#define GPIO48_nPOE 48 /* Output Enable for Card Space */
1296#define GPIO49_nPWE 49 /* Write Enable for Card Space */
1297#define GPIO50_nPIOR 50 /* I/O Read for Card Space */
1298#define GPIO51_nPIOW 51 /* I/O Write for Card Space */
1299#define GPIO52_nPCE_1 52 /* Card Enable for Card Space */
1300#define GPIO53_nPCE_2 53 /* Card Enable for Card Space */
1301#define GPIO53_MMCCLK 53 /* MMC Clock */
1302#define GPIO54_MMCCLK 54 /* MMC Clock */
1303#define GPIO54_pSKTSEL 54 /* Socket Select for Card Space */
1304#define GPIO54_nPCE_2 54 /* Card Enable for Card Space (PXA27x) */
1305#define GPIO55_nPREG 55 /* Card Address bit 26 */
1306#define GPIO56_nPWAIT 56 /* Wait signal for Card Space */
1307#define GPIO57_nIOIS16 57 /* Bus Width select for I/O Card Space */
1308#define GPIO58_LDD_0 58 /* LCD data pin 0 */
1309#define GPIO59_LDD_1 59 /* LCD data pin 1 */
1310#define GPIO60_LDD_2 60 /* LCD data pin 2 */
1311#define GPIO61_LDD_3 61 /* LCD data pin 3 */
1312#define GPIO62_LDD_4 62 /* LCD data pin 4 */
1313#define GPIO63_LDD_5 63 /* LCD data pin 5 */
1314#define GPIO64_LDD_6 64 /* LCD data pin 6 */
1315#define GPIO65_LDD_7 65 /* LCD data pin 7 */
1316#define GPIO66_LDD_8 66 /* LCD data pin 8 */
1317#define GPIO66_MBREQ 66 /* alternate bus master req */
1318#define GPIO67_LDD_9 67 /* LCD data pin 9 */
1319#define GPIO67_MMCCS0 67 /* MMC Chip Select 0 */
1320#define GPIO68_LDD_10 68 /* LCD data pin 10 */
1321#define GPIO68_MMCCS1 68 /* MMC Chip Select 1 */
1322#define GPIO69_LDD_11 69 /* LCD data pin 11 */
1323#define GPIO69_MMCCLK 69 /* MMC_CLK */
1324#define GPIO70_LDD_12 70 /* LCD data pin 12 */
1325#define GPIO70_RTCCLK 70 /* Real Time clock (1 Hz) */
1326#define GPIO71_LDD_13 71 /* LCD data pin 13 */
1327#define GPIO71_3_6MHz 71 /* 3.6 MHz Oscillator clock */
1328#define GPIO72_LDD_14 72 /* LCD data pin 14 */
1329#define GPIO72_32kHz 72 /* 32 kHz clock */
1330#define GPIO73_LDD_15 73 /* LCD data pin 15 */
1331#define GPIO73_MBGNT 73 /* Memory controller grant */
1332#define GPIO74_LCD_FCLK 74 /* LCD Frame clock */
1333#define GPIO75_LCD_LCLK 75 /* LCD line clock */
1334#define GPIO76_LCD_PCLK 76 /* LCD Pixel clock */
1335#define GPIO77_LCD_ACBIAS 77 /* LCD AC Bias */
1336#define GPIO78_nCS_2 78 /* chip select 2 */
1337#define GPIO79_nCS_3 79 /* chip select 3 */
1338#define GPIO80_nCS_4 80 /* chip select 4 */
1339#define GPIO81_NSCLK 81 /* NSSP clock */
1340#define GPIO82_NSFRM 82 /* NSSP Frame */
1341#define GPIO83_NSTXD 83 /* NSSP transmit */
1342#define GPIO84_NSRXD 84 /* NSSP receive */
1343#define GPIO85_nPCE_1 85 /* Card Enable for Card Space (PXA27x) */
1344#define GPIO92_MMCDAT0 92 /* MMC DAT0 (PXA27x) */
1345#define GPIO102_nPCE_1 102 /* PCMCIA (PXA27x) */
1346#define GPIO109_MMCDAT1 109 /* MMC DAT1 (PXA27x) */
1347#define GPIO110_MMCDAT2 110 /* MMC DAT2 (PXA27x) */
1348#define GPIO110_MMCCS0 110 /* MMC Chip Select 0 (PXA27x) */
1349#define GPIO111_MMCDAT3 111 /* MMC DAT3 (PXA27x) */
1350#define GPIO111_MMCCS1 111 /* MMC Chip Select 1 (PXA27x) */
1351#define GPIO112_MMCCMD 112 /* MMC CMD (PXA27x) */
1352#define GPIO113_I2S_SYSCLK 113 /* I2S System Clock (PXA27x) */
1353#define GPIO113_AC97_RESET_N 113 /* AC97 NRESET on (PXA27x) */
1354
1355/* GPIO alternate function mode & direction */
1356
1357#define GPIO_IN 0x000
1358#define GPIO_OUT 0x080
1359#define GPIO_ALT_FN_1_IN 0x100
1360#define GPIO_ALT_FN_1_OUT 0x180
1361#define GPIO_ALT_FN_2_IN 0x200
1362#define GPIO_ALT_FN_2_OUT 0x280
1363#define GPIO_ALT_FN_3_IN 0x300
1364#define GPIO_ALT_FN_3_OUT 0x380
1365#define GPIO_MD_MASK_NR 0x07f
1366#define GPIO_MD_MASK_DIR 0x080
1367#define GPIO_MD_MASK_FN 0x300
1368#define GPIO_DFLT_LOW 0x400
1369#define GPIO_DFLT_HIGH 0x800
1370
1371#define GPIO1_RTS_MD ( 1 | GPIO_ALT_FN_1_IN)
1372#define GPIO6_MMCCLK_MD ( 6 | GPIO_ALT_FN_1_OUT)
1373#define GPIO7_48MHz_MD ( 7 | GPIO_ALT_FN_1_OUT)
1374#define GPIO8_MMCCS0_MD ( 8 | GPIO_ALT_FN_1_OUT)
1375#define GPIO9_MMCCS1_MD ( 9 | GPIO_ALT_FN_1_OUT)
1376#define GPIO10_RTCCLK_MD (10 | GPIO_ALT_FN_1_OUT)
1377#define GPIO11_3_6MHz_MD (11 | GPIO_ALT_FN_1_OUT)
1378#define GPIO12_32KHz_MD (12 | GPIO_ALT_FN_1_OUT)
1379#define GPIO13_MBGNT_MD (13 | GPIO_ALT_FN_2_OUT)
1380#define GPIO14_MBREQ_MD (14 | GPIO_ALT_FN_1_IN)
1381#define GPIO15_nCS_1_MD (15 | GPIO_ALT_FN_2_OUT)
1382#define GPIO16_PWM0_MD (16 | GPIO_ALT_FN_2_OUT)
1383#define GPIO17_PWM1_MD (17 | GPIO_ALT_FN_2_OUT)
1384#define GPIO18_RDY_MD (18 | GPIO_ALT_FN_1_IN)
1385#define GPIO19_DREQ1_MD (19 | GPIO_ALT_FN_1_IN)
1386#define GPIO20_DREQ0_MD (20 | GPIO_ALT_FN_1_IN)
1387#define GPIO23_SCLK_MD (23 | GPIO_ALT_FN_2_OUT)
1388#define GPIO24_SFRM_MD (24 | GPIO_ALT_FN_2_OUT)
1389#define GPIO25_STXD_MD (25 | GPIO_ALT_FN_2_OUT)
1390#define GPIO26_SRXD_MD (26 | GPIO_ALT_FN_1_IN)
1391#define GPIO27_SEXTCLK_MD (27 | GPIO_ALT_FN_1_IN)
1392#define GPIO28_BITCLK_AC97_MD (28 | GPIO_ALT_FN_1_IN)
1393#define GPIO28_BITCLK_IN_I2S_MD (28 | GPIO_ALT_FN_2_IN)
1394#define GPIO28_BITCLK_OUT_I2S_MD (28 | GPIO_ALT_FN_1_OUT)
1395#define GPIO29_SDATA_IN_AC97_MD (29 | GPIO_ALT_FN_1_IN)
1396#define GPIO29_SDATA_IN_I2S_MD (29 | GPIO_ALT_FN_2_IN)
1397#define GPIO30_SDATA_OUT_AC97_MD (30 | GPIO_ALT_FN_2_OUT)
1398#define GPIO30_SDATA_OUT_I2S_MD (30 | GPIO_ALT_FN_1_OUT)
1399#define GPIO31_SYNC_I2S_MD (31 | GPIO_ALT_FN_1_OUT)
1400#define GPIO31_SYNC_AC97_MD (31 | GPIO_ALT_FN_2_OUT)
1401#define GPIO32_SDATA_IN1_AC97_MD (32 | GPIO_ALT_FN_1_IN)
1402#define GPIO32_SYSCLK_I2S_MD (32 | GPIO_ALT_FN_1_OUT)
1403#define GPIO32_MMCCLK_MD ( 32 | GPIO_ALT_FN_2_OUT)
1404#define GPIO33_nCS_5_MD (33 | GPIO_ALT_FN_2_OUT)
1405#define GPIO34_FFRXD_MD (34 | GPIO_ALT_FN_1_IN)
1406#define GPIO34_MMCCS0_MD (34 | GPIO_ALT_FN_2_OUT)
1407#define GPIO35_FFCTS_MD (35 | GPIO_ALT_FN_1_IN)
1408#define GPIO36_FFDCD_MD (36 | GPIO_ALT_FN_1_IN)
1409#define GPIO37_FFDSR_MD (37 | GPIO_ALT_FN_1_IN)
1410#define GPIO38_FFRI_MD (38 | GPIO_ALT_FN_1_IN)
1411#define GPIO39_MMCCS1_MD (39 | GPIO_ALT_FN_1_OUT)
1412#define GPIO39_FFTXD_MD (39 | GPIO_ALT_FN_2_OUT)
1413#define GPIO40_FFDTR_MD (40 | GPIO_ALT_FN_2_OUT)
1414#define GPIO41_FFRTS_MD (41 | GPIO_ALT_FN_2_OUT)
1415#define GPIO42_BTRXD_MD (42 | GPIO_ALT_FN_1_IN)
1416#define GPIO42_HWRXD_MD (42 | GPIO_ALT_FN_3_IN)
1417#define GPIO43_BTTXD_MD (43 | GPIO_ALT_FN_2_OUT)
1418#define GPIO43_HWTXD_MD (43 | GPIO_ALT_FN_3_OUT)
1419#define GPIO44_BTCTS_MD (44 | GPIO_ALT_FN_1_IN)
1420#define GPIO44_HWCTS_MD (44 | GPIO_ALT_FN_3_IN)
1421#define GPIO45_BTRTS_MD (45 | GPIO_ALT_FN_2_OUT)
1422#define GPIO45_HWRTS_MD (45 | GPIO_ALT_FN_3_OUT)
1423#define GPIO45_SYSCLK_AC97_MD (45 | GPIO_ALT_FN_1_OUT)
1424#define GPIO46_ICPRXD_MD (46 | GPIO_ALT_FN_1_IN)
1425#define GPIO46_STRXD_MD (46 | GPIO_ALT_FN_2_IN)
1426#define GPIO47_ICPTXD_MD (47 | GPIO_ALT_FN_2_OUT)
1427#define GPIO47_STTXD_MD (47 | GPIO_ALT_FN_1_OUT)
1428#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT)
1429#define GPIO48_HWTXD_MD (48 | GPIO_ALT_FN_1_OUT)
1430#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT)
1431#define GPIO49_HWRXD_MD (49 | GPIO_ALT_FN_1_IN)
1432#define GPIO49_nPWE_MD (49 | GPIO_ALT_FN_2_OUT)
1433#define GPIO50_nPIOR_MD (50 | GPIO_ALT_FN_2_OUT)
1434#define GPIO50_HWCTS_MD (50 | GPIO_ALT_FN_1_IN)
1435#define GPIO51_HWRTS_MD (51 | GPIO_ALT_FN_1_OUT)
1436#define GPIO51_nPIOW_MD (51 | GPIO_ALT_FN_2_OUT)
1437#define GPIO52_nPCE_1_MD (52 | GPIO_ALT_FN_2_OUT)
1438#define GPIO53_nPCE_2_MD (53 | GPIO_ALT_FN_2_OUT)
1439#define GPIO53_MMCCLK_MD (53 | GPIO_ALT_FN_1_OUT)
1440#define GPIO54_MMCCLK_MD (54 | GPIO_ALT_FN_1_OUT)
1441#define GPIO54_nPCE_2_MD (54 | GPIO_ALT_FN_2_OUT)
1442#define GPIO54_pSKTSEL_MD (54 | GPIO_ALT_FN_2_OUT)
1443#define GPIO55_nPREG_MD (55 | GPIO_ALT_FN_2_OUT)
1444#define GPIO56_nPWAIT_MD (56 | GPIO_ALT_FN_1_IN)
1445#define GPIO57_nIOIS16_MD (57 | GPIO_ALT_FN_1_IN)
1446#define GPIO58_LDD_0_MD (58 | GPIO_ALT_FN_2_OUT)
1447#define GPIO59_LDD_1_MD (59 | GPIO_ALT_FN_2_OUT)
1448#define GPIO60_LDD_2_MD (60 | GPIO_ALT_FN_2_OUT)
1449#define GPIO61_LDD_3_MD (61 | GPIO_ALT_FN_2_OUT)
1450#define GPIO62_LDD_4_MD (62 | GPIO_ALT_FN_2_OUT)
1451#define GPIO63_LDD_5_MD (63 | GPIO_ALT_FN_2_OUT)
1452#define GPIO64_LDD_6_MD (64 | GPIO_ALT_FN_2_OUT)
1453#define GPIO65_LDD_7_MD (65 | GPIO_ALT_FN_2_OUT)
1454#define GPIO66_LDD_8_MD (66 | GPIO_ALT_FN_2_OUT)
1455#define GPIO66_MBREQ_MD (66 | GPIO_ALT_FN_1_IN)
1456#define GPIO67_LDD_9_MD (67 | GPIO_ALT_FN_2_OUT)
1457#define GPIO67_MMCCS0_MD (67 | GPIO_ALT_FN_1_OUT)
1458#define GPIO68_LDD_10_MD (68 | GPIO_ALT_FN_2_OUT)
1459#define GPIO68_MMCCS1_MD (68 | GPIO_ALT_FN_1_OUT)
1460#define GPIO69_LDD_11_MD (69 | GPIO_ALT_FN_2_OUT)
1461#define GPIO69_MMCCLK_MD (69 | GPIO_ALT_FN_1_OUT)
1462#define GPIO70_LDD_12_MD (70 | GPIO_ALT_FN_2_OUT)
1463#define GPIO70_RTCCLK_MD (70 | GPIO_ALT_FN_1_OUT)
1464#define GPIO71_LDD_13_MD (71 | GPIO_ALT_FN_2_OUT)
1465#define GPIO71_3_6MHz_MD (71 | GPIO_ALT_FN_1_OUT)
1466#define GPIO72_LDD_14_MD (72 | GPIO_ALT_FN_2_OUT)
1467#define GPIO72_32kHz_MD (72 | GPIO_ALT_FN_1_OUT)
1468#define GPIO73_LDD_15_MD (73 | GPIO_ALT_FN_2_OUT)
1469#define GPIO73_MBGNT_MD (73 | GPIO_ALT_FN_1_OUT)
1470#define GPIO74_LCD_FCLK_MD (74 | GPIO_ALT_FN_2_OUT)
1471#define GPIO75_LCD_LCLK_MD (75 | GPIO_ALT_FN_2_OUT)
1472#define GPIO76_LCD_PCLK_MD (76 | GPIO_ALT_FN_2_OUT)
1473#define GPIO77_LCD_ACBIAS_MD (77 | GPIO_ALT_FN_2_OUT)
1474#define GPIO78_nCS_2_MD (78 | GPIO_ALT_FN_2_OUT)
1475#define GPIO79_nCS_3_MD (79 | GPIO_ALT_FN_2_OUT)
1476#define GPIO79_pSKTSEL_MD (79 | GPIO_ALT_FN_1_OUT)
1477#define GPIO80_nCS_4_MD (80 | GPIO_ALT_FN_2_OUT)
1478#define GPIO81_NSSP_CLK_OUT (81 | GPIO_ALT_FN_1_OUT)
1479#define GPIO81_NSSP_CLK_IN (81 | GPIO_ALT_FN_1_IN)
1480#define GPIO82_NSSP_FRM_OUT (82 | GPIO_ALT_FN_1_OUT)
1481#define GPIO82_NSSP_FRM_IN (82 | GPIO_ALT_FN_1_IN)
1482#define GPIO83_NSSP_TX (83 | GPIO_ALT_FN_1_OUT)
1483#define GPIO83_NSSP_RX (83 | GPIO_ALT_FN_2_IN)
1484#define GPIO84_NSSP_TX (84 | GPIO_ALT_FN_1_OUT)
1485#define GPIO84_NSSP_RX (84 | GPIO_ALT_FN_2_IN)
1486#define GPIO85_nPCE_1_MD (85 | GPIO_ALT_FN_1_OUT)
1487#define GPIO92_MMCDAT0_MD (92 | GPIO_ALT_FN_1_OUT)
1488#define GPIO102_nPCE_1_MD (102 | GPIO_ALT_FN_1_OUT)
1489#define GPIO104_pSKTSEL_MD (104 | GPIO_ALT_FN_1_OUT)
1490#define GPIO109_MMCDAT1_MD (109 | GPIO_ALT_FN_1_OUT)
1491#define GPIO110_MMCDAT2_MD (110 | GPIO_ALT_FN_1_OUT)
1492#define GPIO110_MMCCS0_MD (110 | GPIO_ALT_FN_1_OUT)
1493#define GPIO111_MMCDAT3_MD (111 | GPIO_ALT_FN_1_OUT)
1494#define GPIO110_MMCCS1_MD (111 | GPIO_ALT_FN_1_OUT)
1495#define GPIO112_MMCCMD_MD (112 | GPIO_ALT_FN_1_OUT)
1496#define GPIO113_I2S_SYSCLK_MD (113 | GPIO_ALT_FN_1_OUT)
1497#define GPIO113_AC97_RESET_N_MD (113 | GPIO_ALT_FN_2_OUT)
1498#define GPIO117_I2CSCL_MD (117 | GPIO_ALT_FN_1_IN)
1499#define GPIO118_I2CSDA_MD (118 | GPIO_ALT_FN_1_IN)
1500
1501/* 1239/*
1502 * Power Manager 1240 * Power Manager
1503 */ 1241 */
@@ -1668,260 +1406,8 @@
1668#define OSCC_OON (1 << 1) /* 32.768kHz OON (write-once only bit) */ 1406#define OSCC_OON (1 << 1) /* 32.768kHz OON (write-once only bit) */
1669#define OSCC_OOK (1 << 0) /* 32.768kHz OOK (read-only bit) */ 1407#define OSCC_OOK (1 << 0) /* 32.768kHz OOK (read-only bit) */
1670 1408
1671
1672/*
1673 * LCD
1674 */
1675
1676#define LCCR0 __REG(0x44000000) /* LCD Controller Control Register 0 */
1677#define LCCR1 __REG(0x44000004) /* LCD Controller Control Register 1 */
1678#define LCCR2 __REG(0x44000008) /* LCD Controller Control Register 2 */
1679#define LCCR3 __REG(0x4400000C) /* LCD Controller Control Register 3 */
1680#define LCCR4 __REG(0x44000010) /* LCD Controller Control Register 3 */
1681#define DFBR0 __REG(0x44000020) /* DMA Channel 0 Frame Branch Register */
1682#define DFBR1 __REG(0x44000024) /* DMA Channel 1 Frame Branch Register */
1683#define LCSR __REG(0x44000038) /* LCD Controller Status Register */
1684#define LIIDR __REG(0x4400003C) /* LCD Controller Interrupt ID Register */
1685#define TMEDRGBR __REG(0x44000040) /* TMED RGB Seed Register */
1686#define TMEDCR __REG(0x44000044) /* TMED Control Register */
1687
1688#define LCCR3_1BPP (0 << 24)
1689#define LCCR3_2BPP (1 << 24)
1690#define LCCR3_4BPP (2 << 24)
1691#define LCCR3_8BPP (3 << 24)
1692#define LCCR3_16BPP (4 << 24)
1693
1694#define LCCR3_PDFOR_0 (0 << 30)
1695#define LCCR3_PDFOR_1 (1 << 30)
1696#define LCCR3_PDFOR_2 (2 << 30)
1697#define LCCR3_PDFOR_3 (3 << 30)
1698
1699#define LCCR4_PAL_FOR_0 (0 << 15)
1700#define LCCR4_PAL_FOR_1 (1 << 15)
1701#define LCCR4_PAL_FOR_2 (2 << 15)
1702#define LCCR4_PAL_FOR_MASK (3 << 15)
1703
1704#define FDADR0 __REG(0x44000200) /* DMA Channel 0 Frame Descriptor Address Register */
1705#define FSADR0 __REG(0x44000204) /* DMA Channel 0 Frame Source Address Register */
1706#define FIDR0 __REG(0x44000208) /* DMA Channel 0 Frame ID Register */
1707#define LDCMD0 __REG(0x4400020C) /* DMA Channel 0 Command Register */
1708#define FDADR1 __REG(0x44000210) /* DMA Channel 1 Frame Descriptor Address Register */
1709#define FSADR1 __REG(0x44000214) /* DMA Channel 1 Frame Source Address Register */
1710#define FIDR1 __REG(0x44000218) /* DMA Channel 1 Frame ID Register */
1711#define LDCMD1 __REG(0x4400021C) /* DMA Channel 1 Command Register */
1712
1713#define LCCR0_ENB (1 << 0) /* LCD Controller enable */
1714#define LCCR0_CMS (1 << 1) /* Color/Monochrome Display Select */
1715#define LCCR0_Color (LCCR0_CMS*0) /* Color display */
1716#define LCCR0_Mono (LCCR0_CMS*1) /* Monochrome display */
1717#define LCCR0_SDS (1 << 2) /* Single/Dual Panel Display */
1718 /* Select */
1719#define LCCR0_Sngl (LCCR0_SDS*0) /* Single panel display */
1720#define LCCR0_Dual (LCCR0_SDS*1) /* Dual panel display */
1721
1722#define LCCR0_LDM (1 << 3) /* LCD Disable Done Mask */
1723#define LCCR0_SFM (1 << 4) /* Start of frame mask */
1724#define LCCR0_IUM (1 << 5) /* Input FIFO underrun mask */
1725#define LCCR0_EFM (1 << 6) /* End of Frame mask */
1726#define LCCR0_PAS (1 << 7) /* Passive/Active display Select */
1727#define LCCR0_Pas (LCCR0_PAS*0) /* Passive display (STN) */
1728#define LCCR0_Act (LCCR0_PAS*1) /* Active display (TFT) */
1729#define LCCR0_DPD (1 << 9) /* Double Pixel Data (monochrome */
1730 /* display mode) */
1731#define LCCR0_4PixMono (LCCR0_DPD*0) /* 4-Pixel/clock Monochrome */
1732 /* display */
1733#define LCCR0_8PixMono (LCCR0_DPD*1) /* 8-Pixel/clock Monochrome */
1734 /* display */
1735#define LCCR0_DIS (1 << 10) /* LCD Disable */
1736#define LCCR0_QDM (1 << 11) /* LCD Quick Disable mask */
1737#define LCCR0_PDD (0xff << 12) /* Palette DMA request delay */
1738#define LCCR0_PDD_S 12
1739#define LCCR0_BM (1 << 20) /* Branch mask */
1740#define LCCR0_OUM (1 << 21) /* Output FIFO underrun mask */
1741#define LCCR0_LCDT (1 << 22) /* LCD panel type */
1742#define LCCR0_RDSTM (1 << 23) /* Read status interrupt mask */
1743#define LCCR0_CMDIM (1 << 24) /* Command interrupt mask */
1744#define LCCR0_OUC (1 << 25) /* Overlay Underlay control bit */
1745#define LCCR0_LDDALT (1 << 26) /* LDD alternate mapping control */
1746
1747#define LCCR1_PPL Fld (10, 0) /* Pixels Per Line - 1 */
1748#define LCCR1_DisWdth(Pixel) /* Display Width [1..800 pix.] */ \
1749 (((Pixel) - 1) << FShft (LCCR1_PPL))
1750
1751#define LCCR1_HSW Fld (6, 10) /* Horizontal Synchronization */
1752#define LCCR1_HorSnchWdth(Tpix) /* Horizontal Synchronization */ \
1753 /* pulse Width [1..64 Tpix] */ \
1754 (((Tpix) - 1) << FShft (LCCR1_HSW))
1755
1756#define LCCR1_ELW Fld (8, 16) /* End-of-Line pixel clock Wait */
1757 /* count - 1 [Tpix] */
1758#define LCCR1_EndLnDel(Tpix) /* End-of-Line Delay */ \
1759 /* [1..256 Tpix] */ \
1760 (((Tpix) - 1) << FShft (LCCR1_ELW))
1761
1762#define LCCR1_BLW Fld (8, 24) /* Beginning-of-Line pixel clock */
1763 /* Wait count - 1 [Tpix] */
1764#define LCCR1_BegLnDel(Tpix) /* Beginning-of-Line Delay */ \
1765 /* [1..256 Tpix] */ \
1766 (((Tpix) - 1) << FShft (LCCR1_BLW))
1767
1768
1769#define LCCR2_LPP Fld (10, 0) /* Line Per Panel - 1 */
1770#define LCCR2_DisHght(Line) /* Display Height [1..1024 lines] */ \
1771 (((Line) - 1) << FShft (LCCR2_LPP))
1772
1773#define LCCR2_VSW Fld (6, 10) /* Vertical Synchronization pulse */
1774 /* Width - 1 [Tln] (L_FCLK) */
1775#define LCCR2_VrtSnchWdth(Tln) /* Vertical Synchronization pulse */ \
1776 /* Width [1..64 Tln] */ \
1777 (((Tln) - 1) << FShft (LCCR2_VSW))
1778
1779#define LCCR2_EFW Fld (8, 16) /* End-of-Frame line clock Wait */
1780 /* count [Tln] */
1781#define LCCR2_EndFrmDel(Tln) /* End-of-Frame Delay */ \
1782 /* [0..255 Tln] */ \
1783 ((Tln) << FShft (LCCR2_EFW))
1784
1785#define LCCR2_BFW Fld (8, 24) /* Beginning-of-Frame line clock */
1786 /* Wait count [Tln] */
1787#define LCCR2_BegFrmDel(Tln) /* Beginning-of-Frame Delay */ \
1788 /* [0..255 Tln] */ \
1789 ((Tln) << FShft (LCCR2_BFW))
1790
1791#if 0
1792#define LCCR3_PCD (0xff) /* Pixel clock divisor */
1793#define LCCR3_ACB (0xff << 8) /* AC Bias pin frequency */
1794#define LCCR3_ACB_S 8
1795#endif
1796
1797#define LCCR3_API (0xf << 16) /* AC Bias pin trasitions per interrupt */
1798#define LCCR3_API_S 16
1799#define LCCR3_VSP (1 << 20) /* vertical sync polarity */
1800#define LCCR3_HSP (1 << 21) /* horizontal sync polarity */
1801#define LCCR3_PCP (1 << 22) /* Pixel Clock Polarity (L_PCLK) */
1802#define LCCR3_PixRsEdg (LCCR3_PCP*0) /* Pixel clock Rising-Edge */
1803#define LCCR3_PixFlEdg (LCCR3_PCP*1) /* Pixel clock Falling-Edge */
1804
1805#define LCCR3_OEP (1 << 23) /* Output Enable Polarity (L_BIAS, */
1806 /* active display mode) */
1807#define LCCR3_OutEnH (LCCR3_OEP*0) /* Output Enable active High */
1808#define LCCR3_OutEnL (LCCR3_OEP*1) /* Output Enable active Low */
1809
1810#if 0
1811#define LCCR3_BPP (7 << 24) /* bits per pixel */
1812#define LCCR3_BPP_S 24
1813#endif
1814#define LCCR3_DPC (1 << 27) /* double pixel clock mode */
1815
1816
1817#define LCCR3_PCD Fld (8, 0) /* Pixel Clock Divisor */
1818#define LCCR3_PixClkDiv(Div) /* Pixel Clock Divisor */ \
1819 (((Div) << FShft (LCCR3_PCD)))
1820
1821
1822#define LCCR3_BPP Fld (3, 24) /* Bit Per Pixel */
1823#define LCCR3_Bpp(Bpp) /* Bit Per Pixel */ \
1824 (((Bpp) << FShft (LCCR3_BPP)))
1825
1826#define LCCR3_ACB Fld (8, 8) /* AC Bias */
1827#define LCCR3_Acb(Acb) /* BAC Bias */ \
1828 (((Acb) << FShft (LCCR3_ACB)))
1829
1830#define LCCR3_HorSnchH (LCCR3_HSP*0) /* Horizontal Synchronization */
1831 /* pulse active High */
1832#define LCCR3_HorSnchL (LCCR3_HSP*1) /* Horizontal Synchronization */
1833
1834#define LCCR3_VrtSnchH (LCCR3_VSP*0) /* Vertical Synchronization pulse */
1835 /* active High */
1836#define LCCR3_VrtSnchL (LCCR3_VSP*1) /* Vertical Synchronization pulse */
1837 /* active Low */
1838
1839#define LCSR_LDD (1 << 0) /* LCD Disable Done */
1840#define LCSR_SOF (1 << 1) /* Start of frame */
1841#define LCSR_BER (1 << 2) /* Bus error */
1842#define LCSR_ABC (1 << 3) /* AC Bias count */
1843#define LCSR_IUL (1 << 4) /* input FIFO underrun Lower panel */
1844#define LCSR_IUU (1 << 5) /* input FIFO underrun Upper panel */
1845#define LCSR_OU (1 << 6) /* output FIFO underrun */
1846#define LCSR_QD (1 << 7) /* quick disable */
1847#define LCSR_EOF (1 << 8) /* end of frame */
1848#define LCSR_BS (1 << 9) /* branch status */
1849#define LCSR_SINT (1 << 10) /* subsequent interrupt */
1850
1851#define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */
1852
1853#define LCSR_LDD (1 << 0) /* LCD Disable Done */
1854#define LCSR_SOF (1 << 1) /* Start of frame */
1855#define LCSR_BER (1 << 2) /* Bus error */
1856#define LCSR_ABC (1 << 3) /* AC Bias count */
1857#define LCSR_IUL (1 << 4) /* input FIFO underrun Lower panel */
1858#define LCSR_IUU (1 << 5) /* input FIFO underrun Upper panel */
1859#define LCSR_OU (1 << 6) /* output FIFO underrun */
1860#define LCSR_QD (1 << 7) /* quick disable */
1861#define LCSR_EOF (1 << 8) /* end of frame */
1862#define LCSR_BS (1 << 9) /* branch status */
1863#define LCSR_SINT (1 << 10) /* subsequent interrupt */
1864
1865#define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */
1866
1867#ifdef CONFIG_PXA27x 1409#ifdef CONFIG_PXA27x
1868 1410
1869/*
1870 * Keypad
1871 */
1872#define KPC __REG(0x41500000) /* Keypad Interface Control register */
1873#define KPDK __REG(0x41500008) /* Keypad Interface Direct Key register */
1874#define KPREC __REG(0x41500010) /* Keypad Interface Rotary Encoder register */
1875#define KPMK __REG(0x41500018) /* Keypad Interface Matrix Key register */
1876#define KPAS __REG(0x41500020) /* Keypad Interface Automatic Scan register */
1877#define KPASMKP0 __REG(0x41500028) /* Keypad Interface Automatic Scan Multiple Key Presser register 0 */
1878#define KPASMKP1 __REG(0x41500030) /* Keypad Interface Automatic Scan Multiple Key Presser register 1 */
1879#define KPASMKP2 __REG(0x41500038) /* Keypad Interface Automatic Scan Multiple Key Presser register 2 */
1880#define KPASMKP3 __REG(0x41500040) /* Keypad Interface Automatic Scan Multiple Key Presser register 3 */
1881#define KPKDI __REG(0x41500048) /* Keypad Interface Key Debounce Interval register */
1882
1883#define KPC_AS (0x1 << 30) /* Automatic Scan bit */
1884#define KPC_ASACT (0x1 << 29) /* Automatic Scan on Activity */
1885#define KPC_MI (0x1 << 22) /* Matrix interrupt bit */
1886#define KPC_IMKP (0x1 << 21) /* Ignore Multiple Key Press */
1887#define KPC_MS7 (0x1 << 20) /* Matrix scan line 7 */
1888#define KPC_MS6 (0x1 << 19) /* Matrix scan line 6 */
1889#define KPC_MS5 (0x1 << 18) /* Matrix scan line 5 */
1890#define KPC_MS4 (0x1 << 17) /* Matrix scan line 4 */
1891#define KPC_MS3 (0x1 << 16) /* Matrix scan line 3 */
1892#define KPC_MS2 (0x1 << 15) /* Matrix scan line 2 */
1893#define KPC_MS1 (0x1 << 14) /* Matrix scan line 1 */
1894#define KPC_MS0 (0x1 << 13) /* Matrix scan line 0 */
1895#define KPC_MS_ALL (KPC_MS0 | KPC_MS1 | KPC_MS2 | KPC_MS3 | KPC_MS4 | KPC_MS5 | KPC_MS6 | KPC_MS7)
1896#define KPC_ME (0x1 << 12) /* Matrix Keypad Enable */
1897#define KPC_MIE (0x1 << 11) /* Matrix Interrupt Enable */
1898#define KPC_DK_DEB_SEL (0x1 << 9) /* Direct Keypad Debounce Select */
1899#define KPC_DI (0x1 << 5) /* Direct key interrupt bit */
1900#define KPC_RE_ZERO_DEB (0x1 << 4) /* Rotary Encoder Zero Debounce */
1901#define KPC_REE1 (0x1 << 3) /* Rotary Encoder1 Enable */
1902#define KPC_REE0 (0x1 << 2) /* Rotary Encoder0 Enable */
1903#define KPC_DE (0x1 << 1) /* Direct Keypad Enable */
1904#define KPC_DIE (0x1 << 0) /* Direct Keypad interrupt Enable */
1905
1906#define KPDK_DKP (0x1 << 31)
1907#define KPDK_DK7 (0x1 << 7)
1908#define KPDK_DK6 (0x1 << 6)
1909#define KPDK_DK5 (0x1 << 5)
1910#define KPDK_DK4 (0x1 << 4)
1911#define KPDK_DK3 (0x1 << 3)
1912#define KPDK_DK2 (0x1 << 2)
1913#define KPDK_DK1 (0x1 << 1)
1914#define KPDK_DK0 (0x1 << 0)
1915
1916#define KPREC_OF1 (0x1 << 31)
1917#define kPREC_UF1 (0x1 << 30)
1918#define KPREC_OF0 (0x1 << 15)
1919#define KPREC_UF0 (0x1 << 14)
1920
1921#define KPMK_MKP (0x1 << 31)
1922#define KPAS_SO (0x1 << 31)
1923#define KPASMKPx_SO (0x1 << 31)
1924
1925/* Camera Interface */ 1411/* Camera Interface */
1926#define CICR0 __REG(0x50000000) 1412#define CICR0 __REG(0x50000000)
1927#define CICR1 __REG(0x50000004) 1413#define CICR1 __REG(0x50000004)
@@ -1953,7 +1439,7 @@
1953#define CICR0_FOM (1 << 0) /* FIFO-overrun mask */ 1439#define CICR0_FOM (1 << 0) /* FIFO-overrun mask */
1954 1440
1955#define CICR1_TBIT (1 << 31) /* Transparency bit */ 1441#define CICR1_TBIT (1 << 31) /* Transparency bit */
1956#define CICR1_RGBT_CONV (0x3 << 30) /* RGBT conversion mask */ 1442#define CICR1_RGBT_CONV (0x3 << 29) /* RGBT conversion mask */
1957#define CICR1_PPL (0x7ff << 15) /* Pixels per line mask */ 1443#define CICR1_PPL (0x7ff << 15) /* Pixels per line mask */
1958#define CICR1_RGB_CONV (0x7 << 12) /* RGB conversion mask */ 1444#define CICR1_RGB_CONV (0x7 << 12) /* RGB conversion mask */
1959#define CICR1_RGB_F (1 << 11) /* RGB format */ 1445#define CICR1_RGB_F (1 << 11) /* RGB format */
diff --git a/include/asm-arm/arch-pxa/pxa27x_keypad.h b/include/asm-arm/arch-pxa/pxa27x_keypad.h
index 644f7609b523..d5a48a96dea7 100644
--- a/include/asm-arm/arch-pxa/pxa27x_keypad.h
+++ b/include/asm-arm/arch-pxa/pxa27x_keypad.h
@@ -53,4 +53,6 @@ struct pxa27x_keypad_platform_data {
53 53
54#define KEY(row, col, val) (((row) << 28) | ((col) << 24) | (val)) 54#define KEY(row, col, val) (((row) << 28) | ((col) << 24) | (val))
55 55
56extern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info);
57
56#endif /* __ASM_ARCH_PXA27x_KEYPAD_H */ 58#endif /* __ASM_ARCH_PXA27x_KEYPAD_H */
diff --git a/include/asm-arm/arch-pxa/pxa2xx-gpio.h b/include/asm-arm/arch-pxa/pxa2xx-gpio.h
new file mode 100644
index 000000000000..763313c5e6be
--- /dev/null
+++ b/include/asm-arm/arch-pxa/pxa2xx-gpio.h
@@ -0,0 +1,357 @@
1#ifndef __ASM_ARCH_PXA2XX_GPIO_H
2#define __ASM_ARCH_PXA2XX_GPIO_H
3
4/* GPIO alternate function assignments */
5
6#define GPIO1_RST 1 /* reset */
7#define GPIO6_MMCCLK 6 /* MMC Clock */
8#define GPIO7_48MHz 7 /* 48 MHz clock output */
9#define GPIO8_MMCCS0 8 /* MMC Chip Select 0 */
10#define GPIO9_MMCCS1 9 /* MMC Chip Select 1 */
11#define GPIO10_RTCCLK 10 /* real time clock (1 Hz) */
12#define GPIO11_3_6MHz 11 /* 3.6 MHz oscillator out */
13#define GPIO12_32KHz 12 /* 32 kHz out */
14#define GPIO12_CIF_DD_7 12 /* Camera data pin 7 */
15#define GPIO13_MBGNT 13 /* memory controller grant */
16#define GPIO14_MBREQ 14 /* alternate bus master request */
17#define GPIO15_nCS_1 15 /* chip select 1 */
18#define GPIO16_PWM0 16 /* PWM0 output */
19#define GPIO17_PWM1 17 /* PWM1 output */
20#define GPIO17_CIF_DD_6 17 /* Camera data pin 6 */
21#define GPIO18_RDY 18 /* Ext. Bus Ready */
22#define GPIO19_DREQ1 19 /* External DMA Request */
23#define GPIO20_DREQ0 20 /* External DMA Request */
24#define GPIO23_SCLK 23 /* SSP clock */
25#define GPIO23_CIF_MCLK 23 /* Camera Master Clock */
26#define GPIO24_SFRM 24 /* SSP Frame */
27#define GPIO24_CIF_FV 24 /* Camera frame start signal */
28#define GPIO25_STXD 25 /* SSP transmit */
29#define GPIO25_CIF_LV 25 /* Camera line start signal */
30#define GPIO26_SRXD 26 /* SSP receive */
31#define GPIO26_CIF_PCLK 26 /* Camera Pixel Clock */
32#define GPIO27_SEXTCLK 27 /* SSP ext_clk */
33#define GPIO27_CIF_DD_0 27 /* Camera data pin 0 */
34#define GPIO28_BITCLK 28 /* AC97/I2S bit_clk */
35#define GPIO29_SDATA_IN 29 /* AC97 Sdata_in0 / I2S Sdata_in */
36#define GPIO30_SDATA_OUT 30 /* AC97/I2S Sdata_out */
37#define GPIO31_SYNC 31 /* AC97/I2S sync */
38#define GPIO32_SDATA_IN1 32 /* AC97 Sdata_in1 */
39#define GPIO32_SYSCLK 32 /* I2S System Clock */
40#define GPIO32_MMCCLK 32 /* MMC Clock (PXA270) */
41#define GPIO33_nCS_5 33 /* chip select 5 */
42#define GPIO34_FFRXD 34 /* FFUART receive */
43#define GPIO34_MMCCS0 34 /* MMC Chip Select 0 */
44#define GPIO35_FFCTS 35 /* FFUART Clear to send */
45#define GPIO36_FFDCD 36 /* FFUART Data carrier detect */
46#define GPIO37_FFDSR 37 /* FFUART data set ready */
47#define GPIO38_FFRI 38 /* FFUART Ring Indicator */
48#define GPIO39_MMCCS1 39 /* MMC Chip Select 1 */
49#define GPIO39_FFTXD 39 /* FFUART transmit data */
50#define GPIO40_FFDTR 40 /* FFUART data terminal Ready */
51#define GPIO41_FFRTS 41 /* FFUART request to send */
52#define GPIO42_BTRXD 42 /* BTUART receive data */
53#define GPIO42_HWRXD 42 /* HWUART receive data */
54#define GPIO42_CIF_MCLK 42 /* Camera Master Clock */
55#define GPIO43_BTTXD 43 /* BTUART transmit data */
56#define GPIO43_HWTXD 43 /* HWUART transmit data */
57#define GPIO43_CIF_FV 43 /* Camera frame start signal */
58#define GPIO44_BTCTS 44 /* BTUART clear to send */
59#define GPIO44_HWCTS 44 /* HWUART clear to send */
60#define GPIO44_CIF_LV 44 /* Camera line start signal */
61#define GPIO45_BTRTS 45 /* BTUART request to send */
62#define GPIO45_HWRTS 45 /* HWUART request to send */
63#define GPIO45_AC97_SYSCLK 45 /* AC97 System Clock */
64#define GPIO45_CIF_PCLK 45 /* Camera Pixel Clock */
65#define GPIO46_ICPRXD 46 /* ICP receive data */
66#define GPIO46_STRXD 46 /* STD_UART receive data */
67#define GPIO47_ICPTXD 47 /* ICP transmit data */
68#define GPIO47_STTXD 47 /* STD_UART transmit data */
69#define GPIO47_CIF_DD_0 47 /* Camera data pin 0 */
70#define GPIO48_nPOE 48 /* Output Enable for Card Space */
71#define GPIO48_CIF_DD_5 48 /* Camera data pin 5 */
72#define GPIO49_nPWE 49 /* Write Enable for Card Space */
73#define GPIO50_nPIOR 50 /* I/O Read for Card Space */
74#define GPIO50_CIF_DD_3 50 /* Camera data pin 3 */
75#define GPIO51_nPIOW 51 /* I/O Write for Card Space */
76#define GPIO51_CIF_DD_2 51 /* Camera data pin 2 */
77#define GPIO52_nPCE_1 52 /* Card Enable for Card Space */
78#define GPIO52_CIF_DD_4 52 /* Camera data pin 4 */
79#define GPIO53_nPCE_2 53 /* Card Enable for Card Space */
80#define GPIO53_MMCCLK 53 /* MMC Clock */
81#define GPIO53_CIF_MCLK 53 /* Camera Master Clock */
82#define GPIO54_MMCCLK 54 /* MMC Clock */
83#define GPIO54_pSKTSEL 54 /* Socket Select for Card Space */
84#define GPIO54_nPCE_2 54 /* Card Enable for Card Space (PXA27x) */
85#define GPIO54_CIF_PCLK 54 /* Camera Pixel Clock */
86#define GPIO55_nPREG 55 /* Card Address bit 26 */
87#define GPIO55_CIF_DD_1 55 /* Camera data pin 1 */
88#define GPIO56_nPWAIT 56 /* Wait signal for Card Space */
89#define GPIO57_nIOIS16 57 /* Bus Width select for I/O Card Space */
90#define GPIO58_LDD_0 58 /* LCD data pin 0 */
91#define GPIO59_LDD_1 59 /* LCD data pin 1 */
92#define GPIO60_LDD_2 60 /* LCD data pin 2 */
93#define GPIO61_LDD_3 61 /* LCD data pin 3 */
94#define GPIO62_LDD_4 62 /* LCD data pin 4 */
95#define GPIO63_LDD_5 63 /* LCD data pin 5 */
96#define GPIO64_LDD_6 64 /* LCD data pin 6 */
97#define GPIO65_LDD_7 65 /* LCD data pin 7 */
98#define GPIO66_LDD_8 66 /* LCD data pin 8 */
99#define GPIO66_MBREQ 66 /* alternate bus master req */
100#define GPIO67_LDD_9 67 /* LCD data pin 9 */
101#define GPIO67_MMCCS0 67 /* MMC Chip Select 0 */
102#define GPIO68_LDD_10 68 /* LCD data pin 10 */
103#define GPIO68_MMCCS1 68 /* MMC Chip Select 1 */
104#define GPIO69_LDD_11 69 /* LCD data pin 11 */
105#define GPIO69_MMCCLK 69 /* MMC_CLK */
106#define GPIO70_LDD_12 70 /* LCD data pin 12 */
107#define GPIO70_RTCCLK 70 /* Real Time clock (1 Hz) */
108#define GPIO71_LDD_13 71 /* LCD data pin 13 */
109#define GPIO71_3_6MHz 71 /* 3.6 MHz Oscillator clock */
110#define GPIO72_LDD_14 72 /* LCD data pin 14 */
111#define GPIO72_32kHz 72 /* 32 kHz clock */
112#define GPIO73_LDD_15 73 /* LCD data pin 15 */
113#define GPIO73_MBGNT 73 /* Memory controller grant */
114#define GPIO74_LCD_FCLK 74 /* LCD Frame clock */
115#define GPIO75_LCD_LCLK 75 /* LCD line clock */
116#define GPIO76_LCD_PCLK 76 /* LCD Pixel clock */
117#define GPIO77_LCD_ACBIAS 77 /* LCD AC Bias */
118#define GPIO78_nCS_2 78 /* chip select 2 */
119#define GPIO79_nCS_3 79 /* chip select 3 */
120#define GPIO80_nCS_4 80 /* chip select 4 */
121#define GPIO81_NSCLK 81 /* NSSP clock */
122#define GPIO81_CIF_DD_0 81 /* Camera data pin 0 */
123#define GPIO82_NSFRM 82 /* NSSP Frame */
124#define GPIO82_CIF_DD_5 82 /* Camera data pin 5 */
125#define GPIO83_NSTXD 83 /* NSSP transmit */
126#define GPIO83_CIF_DD_4 83 /* Camera data pin 4 */
127#define GPIO84_NSRXD 84 /* NSSP receive */
128#define GPIO84_CIF_FV 84 /* Camera frame start signal */
129#define GPIO85_nPCE_1 85 /* Card Enable for Card Space (PXA27x) */
130#define GPIO85_CIF_LV 85 /* Camera line start signal */
131#define GPIO90_CIF_DD_4 90 /* Camera data pin 4 */
132#define GPIO91_CIF_DD_5 91 /* Camera data pin 5 */
133#define GPIO92_MMCDAT0 92 /* MMC DAT0 (PXA27x) */
134#define GPIO93_CIF_DD_6 93 /* Camera data pin 6 */
135#define GPIO94_CIF_DD_5 94 /* Camera data pin 5 */
136#define GPIO95_CIF_DD_4 95 /* Camera data pin 4 */
137#define GPIO98_CIF_DD_0 98 /* Camera data pin 0 */
138#define GPIO102_nPCE_1 102 /* PCMCIA (PXA27x) */
139#define GPIO103_CIF_DD_3 103 /* Camera data pin 3 */
140#define GPIO104_CIF_DD_2 104 /* Camera data pin 2 */
141#define GPIO105_CIF_DD_1 105 /* Camera data pin 1 */
142#define GPIO106_CIF_DD_9 106 /* Camera data pin 9 */
143#define GPIO107_CIF_DD_8 107 /* Camera data pin 8 */
144#define GPIO108_CIF_DD_7 108 /* Camera data pin 7 */
145#define GPIO109_MMCDAT1 109 /* MMC DAT1 (PXA27x) */
146#define GPIO110_MMCDAT2 110 /* MMC DAT2 (PXA27x) */
147#define GPIO110_MMCCS0 110 /* MMC Chip Select 0 (PXA27x) */
148#define GPIO111_MMCDAT3 111 /* MMC DAT3 (PXA27x) */
149#define GPIO111_MMCCS1 111 /* MMC Chip Select 1 (PXA27x) */
150#define GPIO112_MMCCMD 112 /* MMC CMD (PXA27x) */
151#define GPIO113_I2S_SYSCLK 113 /* I2S System Clock (PXA27x) */
152#define GPIO113_AC97_RESET_N 113 /* AC97 NRESET on (PXA27x) */
153#define GPIO114_CIF_DD_1 114 /* Camera data pin 1 */
154#define GPIO115_CIF_DD_3 115 /* Camera data pin 3 */
155#define GPIO116_CIF_DD_2 116 /* Camera data pin 2 */
156
157/* GPIO alternate function mode & direction */
158
159#define GPIO_IN 0x000
160#define GPIO_OUT 0x080
161#define GPIO_ALT_FN_1_IN 0x100
162#define GPIO_ALT_FN_1_OUT 0x180
163#define GPIO_ALT_FN_2_IN 0x200
164#define GPIO_ALT_FN_2_OUT 0x280
165#define GPIO_ALT_FN_3_IN 0x300
166#define GPIO_ALT_FN_3_OUT 0x380
167#define GPIO_MD_MASK_NR 0x07f
168#define GPIO_MD_MASK_DIR 0x080
169#define GPIO_MD_MASK_FN 0x300
170#define GPIO_DFLT_LOW 0x400
171#define GPIO_DFLT_HIGH 0x800
172
173#define GPIO1_RTS_MD ( 1 | GPIO_ALT_FN_1_IN)
174#define GPIO6_MMCCLK_MD ( 6 | GPIO_ALT_FN_1_OUT)
175#define GPIO7_48MHz_MD ( 7 | GPIO_ALT_FN_1_OUT)
176#define GPIO8_MMCCS0_MD ( 8 | GPIO_ALT_FN_1_OUT)
177#define GPIO9_MMCCS1_MD ( 9 | GPIO_ALT_FN_1_OUT)
178#define GPIO10_RTCCLK_MD (10 | GPIO_ALT_FN_1_OUT)
179#define GPIO11_3_6MHz_MD (11 | GPIO_ALT_FN_1_OUT)
180#define GPIO12_32KHz_MD (12 | GPIO_ALT_FN_1_OUT)
181#define GPIO12_CIF_DD_7_MD (12 | GPIO_ALT_FN_2_IN)
182#define GPIO13_MBGNT_MD (13 | GPIO_ALT_FN_2_OUT)
183#define GPIO14_MBREQ_MD (14 | GPIO_ALT_FN_1_IN)
184#define GPIO15_nCS_1_MD (15 | GPIO_ALT_FN_2_OUT)
185#define GPIO16_PWM0_MD (16 | GPIO_ALT_FN_2_OUT)
186#define GPIO17_PWM1_MD (17 | GPIO_ALT_FN_2_OUT)
187#define GPIO17_CIF_DD_6_MD (17 | GPIO_ALT_FN_2_IN)
188#define GPIO18_RDY_MD (18 | GPIO_ALT_FN_1_IN)
189#define GPIO19_DREQ1_MD (19 | GPIO_ALT_FN_1_IN)
190#define GPIO20_DREQ0_MD (20 | GPIO_ALT_FN_1_IN)
191#define GPIO23_CIF_MCLK_MD (23 | GPIO_ALT_FN_1_OUT)
192#define GPIO23_SCLK_MD (23 | GPIO_ALT_FN_2_OUT)
193#define GPIO24_CIF_FV_MD (24 | GPIO_ALT_FN_1_OUT)
194#define GPIO24_SFRM_MD (24 | GPIO_ALT_FN_2_OUT)
195#define GPIO25_CIF_LV_MD (25 | GPIO_ALT_FN_1_OUT)
196#define GPIO25_STXD_MD (25 | GPIO_ALT_FN_2_OUT)
197#define GPIO26_SRXD_MD (26 | GPIO_ALT_FN_1_IN)
198#define GPIO26_CIF_PCLK_MD (26 | GPIO_ALT_FN_2_IN)
199#define GPIO27_SEXTCLK_MD (27 | GPIO_ALT_FN_1_IN)
200#define GPIO27_CIF_DD_0_MD (27 | GPIO_ALT_FN_3_IN)
201#define GPIO28_BITCLK_AC97_MD (28 | GPIO_ALT_FN_1_IN)
202#define GPIO28_BITCLK_IN_I2S_MD (28 | GPIO_ALT_FN_2_IN)
203#define GPIO28_BITCLK_OUT_I2S_MD (28 | GPIO_ALT_FN_1_OUT)
204#define GPIO29_SDATA_IN_AC97_MD (29 | GPIO_ALT_FN_1_IN)
205#define GPIO29_SDATA_IN_I2S_MD (29 | GPIO_ALT_FN_2_IN)
206#define GPIO30_SDATA_OUT_AC97_MD (30 | GPIO_ALT_FN_2_OUT)
207#define GPIO30_SDATA_OUT_I2S_MD (30 | GPIO_ALT_FN_1_OUT)
208#define GPIO31_SYNC_I2S_MD (31 | GPIO_ALT_FN_1_OUT)
209#define GPIO31_SYNC_AC97_MD (31 | GPIO_ALT_FN_2_OUT)
210#define GPIO32_SDATA_IN1_AC97_MD (32 | GPIO_ALT_FN_1_IN)
211#define GPIO32_SYSCLK_I2S_MD (32 | GPIO_ALT_FN_1_OUT)
212#define GPIO32_MMCCLK_MD (32 | GPIO_ALT_FN_2_OUT)
213#define GPIO33_nCS_5_MD (33 | GPIO_ALT_FN_2_OUT)
214#define GPIO34_FFRXD_MD (34 | GPIO_ALT_FN_1_IN)
215#define GPIO34_MMCCS0_MD (34 | GPIO_ALT_FN_2_OUT)
216#define GPIO35_FFCTS_MD (35 | GPIO_ALT_FN_1_IN)
217#define GPIO35_KP_MKOUT6_MD (35 | GPIO_ALT_FN_2_OUT)
218#define GPIO36_FFDCD_MD (36 | GPIO_ALT_FN_1_IN)
219#define GPIO37_FFDSR_MD (37 | GPIO_ALT_FN_1_IN)
220#define GPIO38_FFRI_MD (38 | GPIO_ALT_FN_1_IN)
221#define GPIO39_MMCCS1_MD (39 | GPIO_ALT_FN_1_OUT)
222#define GPIO39_FFTXD_MD (39 | GPIO_ALT_FN_2_OUT)
223#define GPIO40_FFDTR_MD (40 | GPIO_ALT_FN_2_OUT)
224#define GPIO41_FFRTS_MD (41 | GPIO_ALT_FN_2_OUT)
225#define GPIO41_KP_MKOUT7_MD (41 | GPIO_ALT_FN_1_OUT)
226#define GPIO42_BTRXD_MD (42 | GPIO_ALT_FN_1_IN)
227#define GPIO42_HWRXD_MD (42 | GPIO_ALT_FN_3_IN)
228#define GPIO42_CIF_MCLK_MD (42 | GPIO_ALT_FN_3_OUT)
229#define GPIO43_BTTXD_MD (43 | GPIO_ALT_FN_2_OUT)
230#define GPIO43_HWTXD_MD (43 | GPIO_ALT_FN_3_OUT)
231#define GPIO43_CIF_FV_MD (43 | GPIO_ALT_FN_3_OUT)
232#define GPIO44_BTCTS_MD (44 | GPIO_ALT_FN_1_IN)
233#define GPIO44_HWCTS_MD (44 | GPIO_ALT_FN_3_IN)
234#define GPIO44_CIF_LV_MD (44 | GPIO_ALT_FN_3_OUT)
235#define GPIO45_CIF_PCLK_MD (45 | GPIO_ALT_FN_3_IN)
236#define GPIO45_BTRTS_MD (45 | GPIO_ALT_FN_2_OUT)
237#define GPIO45_HWRTS_MD (45 | GPIO_ALT_FN_3_OUT)
238#define GPIO45_SYSCLK_AC97_MD (45 | GPIO_ALT_FN_1_OUT)
239#define GPIO46_ICPRXD_MD (46 | GPIO_ALT_FN_1_IN)
240#define GPIO46_STRXD_MD (46 | GPIO_ALT_FN_2_IN)
241#define GPIO47_CIF_DD_0_MD (47 | GPIO_ALT_FN_1_IN)
242#define GPIO47_ICPTXD_MD (47 | GPIO_ALT_FN_2_OUT)
243#define GPIO47_STTXD_MD (47 | GPIO_ALT_FN_1_OUT)
244#define GPIO48_CIF_DD_5_MD (48 | GPIO_ALT_FN_1_IN)
245#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT)
246#define GPIO48_HWTXD_MD (48 | GPIO_ALT_FN_1_OUT)
247#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT)
248#define GPIO49_HWRXD_MD (49 | GPIO_ALT_FN_1_IN)
249#define GPIO49_nPWE_MD (49 | GPIO_ALT_FN_2_OUT)
250#define GPIO50_CIF_DD_3_MD (50 | GPIO_ALT_FN_1_IN)
251#define GPIO50_nPIOR_MD (50 | GPIO_ALT_FN_2_OUT)
252#define GPIO50_HWCTS_MD (50 | GPIO_ALT_FN_1_IN)
253#define GPIO50_CIF_DD_3_MD (50 | GPIO_ALT_FN_1_IN)
254#define GPIO51_CIF_DD_2_MD (51 | GPIO_ALT_FN_1_IN)
255#define GPIO51_nPIOW_MD (51 | GPIO_ALT_FN_2_OUT)
256#define GPIO51_HWRTS_MD (51 | GPIO_ALT_FN_1_OUT)
257#define GPIO51_CIF_DD_2_MD (51 | GPIO_ALT_FN_1_IN)
258#define GPIO52_nPCE_1_MD (52 | GPIO_ALT_FN_2_OUT)
259#define GPIO52_CIF_DD_4_MD (52 | GPIO_ALT_FN_1_IN)
260#define GPIO53_nPCE_2_MD (53 | GPIO_ALT_FN_2_OUT)
261#define GPIO53_MMCCLK_MD (53 | GPIO_ALT_FN_1_OUT)
262#define GPIO53_CIF_MCLK_MD (53 | GPIO_ALT_FN_2_OUT)
263#define GPIO54_MMCCLK_MD (54 | GPIO_ALT_FN_1_OUT)
264#define GPIO54_nPCE_2_MD (54 | GPIO_ALT_FN_2_OUT)
265#define GPIO54_pSKTSEL_MD (54 | GPIO_ALT_FN_2_OUT)
266#define GPIO54_CIF_PCLK_MD (54 | GPIO_ALT_FN_3_IN)
267#define GPIO55_nPREG_MD (55 | GPIO_ALT_FN_2_OUT)
268#define GPIO55_CIF_DD_1_MD (55 | GPIO_ALT_FN_1_IN)
269#define GPIO56_nPWAIT_MD (56 | GPIO_ALT_FN_1_IN)
270#define GPIO57_nIOIS16_MD (57 | GPIO_ALT_FN_1_IN)
271#define GPIO58_LDD_0_MD (58 | GPIO_ALT_FN_2_OUT)
272#define GPIO59_LDD_1_MD (59 | GPIO_ALT_FN_2_OUT)
273#define GPIO60_LDD_2_MD (60 | GPIO_ALT_FN_2_OUT)
274#define GPIO61_LDD_3_MD (61 | GPIO_ALT_FN_2_OUT)
275#define GPIO62_LDD_4_MD (62 | GPIO_ALT_FN_2_OUT)
276#define GPIO63_LDD_5_MD (63 | GPIO_ALT_FN_2_OUT)
277#define GPIO64_LDD_6_MD (64 | GPIO_ALT_FN_2_OUT)
278#define GPIO65_LDD_7_MD (65 | GPIO_ALT_FN_2_OUT)
279#define GPIO66_LDD_8_MD (66 | GPIO_ALT_FN_2_OUT)
280#define GPIO66_MBREQ_MD (66 | GPIO_ALT_FN_1_IN)
281#define GPIO67_LDD_9_MD (67 | GPIO_ALT_FN_2_OUT)
282#define GPIO67_MMCCS0_MD (67 | GPIO_ALT_FN_1_OUT)
283#define GPIO68_LDD_10_MD (68 | GPIO_ALT_FN_2_OUT)
284#define GPIO68_MMCCS1_MD (68 | GPIO_ALT_FN_1_OUT)
285#define GPIO69_LDD_11_MD (69 | GPIO_ALT_FN_2_OUT)
286#define GPIO69_MMCCLK_MD (69 | GPIO_ALT_FN_1_OUT)
287#define GPIO70_LDD_12_MD (70 | GPIO_ALT_FN_2_OUT)
288#define GPIO70_RTCCLK_MD (70 | GPIO_ALT_FN_1_OUT)
289#define GPIO71_LDD_13_MD (71 | GPIO_ALT_FN_2_OUT)
290#define GPIO71_3_6MHz_MD (71 | GPIO_ALT_FN_1_OUT)
291#define GPIO72_LDD_14_MD (72 | GPIO_ALT_FN_2_OUT)
292#define GPIO72_32kHz_MD (72 | GPIO_ALT_FN_1_OUT)
293#define GPIO73_LDD_15_MD (73 | GPIO_ALT_FN_2_OUT)
294#define GPIO73_MBGNT_MD (73 | GPIO_ALT_FN_1_OUT)
295#define GPIO74_LCD_FCLK_MD (74 | GPIO_ALT_FN_2_OUT)
296#define GPIO75_LCD_LCLK_MD (75 | GPIO_ALT_FN_2_OUT)
297#define GPIO76_LCD_PCLK_MD (76 | GPIO_ALT_FN_2_OUT)
298#define GPIO77_LCD_ACBIAS_MD (77 | GPIO_ALT_FN_2_OUT)
299#define GPIO78_nCS_2_MD (78 | GPIO_ALT_FN_2_OUT)
300#define GPIO78_nPCE_2_MD (78 | GPIO_ALT_FN_1_OUT)
301#define GPIO79_nCS_3_MD (79 | GPIO_ALT_FN_2_OUT)
302#define GPIO79_pSKTSEL_MD (79 | GPIO_ALT_FN_1_OUT)
303#define GPIO80_nCS_4_MD (80 | GPIO_ALT_FN_2_OUT)
304#define GPIO81_NSSP_CLK_OUT (81 | GPIO_ALT_FN_1_OUT)
305#define GPIO81_NSSP_CLK_IN (81 | GPIO_ALT_FN_1_IN)
306#define GPIO81_CIF_DD_0_MD (81 | GPIO_ALT_FN_2_IN)
307#define GPIO82_NSSP_FRM_OUT (82 | GPIO_ALT_FN_1_OUT)
308#define GPIO82_NSSP_FRM_IN (82 | GPIO_ALT_FN_1_IN)
309#define GPIO82_CIF_DD_5_MD (82 | GPIO_ALT_FN_3_IN)
310#define GPIO83_NSSP_TX (83 | GPIO_ALT_FN_1_OUT)
311#define GPIO83_NSSP_RX (83 | GPIO_ALT_FN_2_IN)
312#define GPIO83_CIF_DD_4_MD (83 | GPIO_ALT_FN_3_IN)
313#define GPIO84_NSSP_TX (84 | GPIO_ALT_FN_1_OUT)
314#define GPIO84_NSSP_RX (84 | GPIO_ALT_FN_2_IN)
315#define GPIO84_CIF_FV_MD (84 | GPIO_ALT_FN_3_IN)
316#define GPIO85_nPCE_1_MD (85 | GPIO_ALT_FN_1_OUT)
317#define GPIO85_CIF_LV_MD (85 | GPIO_ALT_FN_3_IN)
318#define GPIO86_nPCE_1_MD (86 | GPIO_ALT_FN_1_OUT)
319#define GPIO90_CIF_DD_4_MD (90 | GPIO_ALT_FN_3_IN)
320#define GPIO91_CIF_DD_5_MD (91 | GPIO_ALT_FN_3_IN)
321#define GPIO92_MMCDAT0_MD (92 | GPIO_ALT_FN_1_OUT)
322#define GPIO93_CIF_DD_6_MD (93 | GPIO_ALT_FN_2_IN)
323#define GPIO94_CIF_DD_5_MD (94 | GPIO_ALT_FN_2_IN)
324#define GPIO95_CIF_DD_4_MD (95 | GPIO_ALT_FN_2_IN)
325#define GPIO95_KP_MKIN6_MD (95 | GPIO_ALT_FN_3_IN)
326#define GPIO96_KP_DKIN3_MD (96 | GPIO_ALT_FN_1_IN)
327#define GPIO97_KP_MKIN3_MD (97 | GPIO_ALT_FN_3_IN)
328#define GPIO98_CIF_DD_0_MD (98 | GPIO_ALT_FN_2_IN)
329#define GPIO100_KP_MKIN0_MD (100 | GPIO_ALT_FN_1_IN)
330#define GPIO101_KP_MKIN1_MD (101 | GPIO_ALT_FN_1_IN)
331#define GPIO102_nPCE_1_MD (102 | GPIO_ALT_FN_1_OUT)
332#define GPIO102_KP_MKIN2_MD (102 | GPIO_ALT_FN_1_IN)
333#define GPIO103_CIF_DD_3_MD (103 | GPIO_ALT_FN_1_IN)
334#define GPIO103_KP_MKOUT0_MD (103 | GPIO_ALT_FN_2_OUT)
335#define GPIO104_CIF_DD_2_MD (104 | GPIO_ALT_FN_1_IN)
336#define GPIO104_pSKTSEL_MD (104 | GPIO_ALT_FN_1_OUT)
337#define GPIO104_KP_MKOUT1_MD (104 | GPIO_ALT_FN_2_OUT)
338#define GPIO105_CIF_DD_1_MD (105 | GPIO_ALT_FN_1_IN)
339#define GPIO105_KP_MKOUT2_MD (105 | GPIO_ALT_FN_2_OUT)
340#define GPIO106_CIF_DD_9_MD (106 | GPIO_ALT_FN_1_IN)
341#define GPIO106_KP_MKOUT3_MD (106 | GPIO_ALT_FN_2_OUT)
342#define GPIO107_CIF_DD_8_MD (107 | GPIO_ALT_FN_1_IN)
343#define GPIO107_KP_MKOUT4_MD (107 | GPIO_ALT_FN_2_OUT)
344#define GPIO108_CIF_DD_7_MD (108 | GPIO_ALT_FN_1_IN)
345#define GPIO108_KP_MKOUT5_MD (108 | GPIO_ALT_FN_2_OUT)
346#define GPIO109_MMCDAT1_MD (109 | GPIO_ALT_FN_1_OUT)
347#define GPIO110_MMCDAT2_MD (110 | GPIO_ALT_FN_1_OUT)
348#define GPIO110_MMCCS0_MD (110 | GPIO_ALT_FN_1_OUT)
349#define GPIO111_MMCDAT3_MD (111 | GPIO_ALT_FN_1_OUT)
350#define GPIO110_MMCCS1_MD (111 | GPIO_ALT_FN_1_OUT)
351#define GPIO112_MMCCMD_MD (112 | GPIO_ALT_FN_1_OUT)
352#define GPIO113_I2S_SYSCLK_MD (113 | GPIO_ALT_FN_1_OUT)
353#define GPIO113_AC97_RESET_N_MD (113 | GPIO_ALT_FN_2_OUT)
354#define GPIO117_I2CSCL_MD (117 | GPIO_ALT_FN_1_IN)
355#define GPIO118_I2CSDA_MD (118 | GPIO_ALT_FN_1_IN)
356
357#endif /* __ASM_ARCH_PXA2XX_GPIO_H */
diff --git a/include/asm-arm/arch-pxa/pxa3xx-regs.h b/include/asm-arm/arch-pxa/pxa3xx-regs.h
index 8e1b3ead827f..fe9364c83a28 100644
--- a/include/asm-arm/arch-pxa/pxa3xx-regs.h
+++ b/include/asm-arm/arch-pxa/pxa3xx-regs.h
@@ -12,6 +12,15 @@
12 12
13#ifndef __ASM_ARCH_PXA3XX_REGS_H 13#ifndef __ASM_ARCH_PXA3XX_REGS_H
14#define __ASM_ARCH_PXA3XX_REGS_H 14#define __ASM_ARCH_PXA3XX_REGS_H
15
16/*
17 * Oscillator Configuration Register (OSCC)
18 */
19#define OSCC __REG(0x41350000) /* Oscillator Configuration Register */
20
21#define OSCC_PEN (1 << 11) /* 13MHz POUT */
22
23
15/* 24/*
16 * Service Power Management Unit (MPMU) 25 * Service Power Management Unit (MPMU)
17 */ 26 */
diff --git a/include/asm-arm/arch-pxa/pxa3xx_nand.h b/include/asm-arm/arch-pxa/pxa3xx_nand.h
new file mode 100644
index 000000000000..81a8937486cb
--- /dev/null
+++ b/include/asm-arm/arch-pxa/pxa3xx_nand.h
@@ -0,0 +1,18 @@
1#ifndef __ASM_ARCH_PXA3XX_NAND_H
2#define __ASM_ARCH_PXA3XX_NAND_H
3
4#include <linux/mtd/mtd.h>
5#include <linux/mtd/partitions.h>
6
7struct pxa3xx_nand_platform_data {
8
9 /* the data flash bus is shared between the Static Memory
10 * Controller and the Data Flash Controller, the arbiter
11 * controls the ownership of the bus
12 */
13 int enable_arbiter;
14
15 struct mtd_partition *parts;
16 unsigned int nr_parts;
17};
18#endif /* __ASM_ARCH_PXA3XX_NAND_H */
diff --git a/include/asm-arm/arch-pxa/pxafb.h b/include/asm-arm/arch-pxa/pxafb.h
index ea2336aa70e4..bbd22396841a 100644
--- a/include/asm-arm/arch-pxa/pxafb.h
+++ b/include/asm-arm/arch-pxa/pxafb.h
@@ -13,6 +13,50 @@
13 */ 13 */
14 14
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <asm/arch/regs-lcd.h>
17
18/*
19 * Supported LCD connections
20 *
21 * bits 0 - 3: for LCD panel type:
22 *
23 * STN - for passive matrix
24 * DSTN - for dual scan passive matrix
25 * TFT - for active matrix
26 *
27 * bits 4 - 9 : for bus width
28 * bits 10-17 : for AC Bias Pin Frequency
29 * bit 18 : for output enable polarity
30 * bit 19 : for pixel clock edge
31 */
32#define LCD_CONN_TYPE(_x) ((_x) & 0x0f)
33#define LCD_CONN_WIDTH(_x) (((_x) >> 4) & 0x1f)
34
35#define LCD_TYPE_UNKNOWN 0
36#define LCD_TYPE_MONO_STN 1
37#define LCD_TYPE_MONO_DSTN 2
38#define LCD_TYPE_COLOR_STN 3
39#define LCD_TYPE_COLOR_DSTN 4
40#define LCD_TYPE_COLOR_TFT 5
41#define LCD_TYPE_SMART_PANEL 6
42#define LCD_TYPE_MAX 7
43
44#define LCD_MONO_STN_4BPP ((4 << 4) | LCD_TYPE_MONO_STN)
45#define LCD_MONO_STN_8BPP ((8 << 4) | LCD_TYPE_MONO_STN)
46#define LCD_MONO_DSTN_8BPP ((8 << 4) | LCD_TYPE_MONO_DSTN)
47#define LCD_COLOR_STN_8BPP ((8 << 4) | LCD_TYPE_COLOR_STN)
48#define LCD_COLOR_DSTN_16BPP ((16 << 4) | LCD_TYPE_COLOR_DSTN)
49#define LCD_COLOR_TFT_16BPP ((16 << 4) | LCD_TYPE_COLOR_TFT)
50#define LCD_COLOR_TFT_18BPP ((18 << 4) | LCD_TYPE_COLOR_TFT)
51#define LCD_SMART_PANEL_8BPP ((8 << 4) | LCD_TYPE_SMART_PANEL)
52#define LCD_SMART_PANEL_16BPP ((16 << 4) | LCD_TYPE_SMART_PANEL)
53#define LCD_SMART_PANEL_18BPP ((18 << 4) | LCD_TYPE_SMART_PANEL)
54
55#define LCD_AC_BIAS_FREQ(x) (((x) & 0xff) << 10)
56#define LCD_BIAS_ACTIVE_HIGH (0 << 17)
57#define LCD_BIAS_ACTIVE_LOW (1 << 17)
58#define LCD_PCLK_EDGE_RISE (0 << 18)
59#define LCD_PCLK_EDGE_FALL (1 << 18)
16 60
17/* 61/*
18 * This structure describes the machine which we are running on. 62 * This structure describes the machine which we are running on.
@@ -26,6 +70,10 @@ struct pxafb_mode_info {
26 u_short yres; 70 u_short yres;
27 71
28 u_char bpp; 72 u_char bpp;
73 u_int cmap_greyscale:1,
74 unused:31;
75
76 /* Parallel Mode Timing */
29 u_char hsync_len; 77 u_char hsync_len;
30 u_char left_margin; 78 u_char left_margin;
31 u_char right_margin; 79 u_char right_margin;
@@ -35,14 +83,28 @@ struct pxafb_mode_info {
35 u_char lower_margin; 83 u_char lower_margin;
36 u_char sync; 84 u_char sync;
37 85
38 u_int cmap_greyscale:1, 86 /* Smart Panel Mode Timing - see PXA27x DM 7.4.15.0.3 for details
39 unused:31; 87 * Note:
88 * 1. all parameters in nanosecond (ns)
89 * 2. a0cs{rd,wr}_set_hld are controlled by the same register bits
90 * in pxa27x and pxa3xx, initialize them to the same value or
91 * the larger one will be used
92 * 3. same to {rd,wr}_pulse_width
93 */
94 unsigned a0csrd_set_hld; /* A0 and CS Setup/Hold Time before/after L_FCLK_RD */
95 unsigned a0cswr_set_hld; /* A0 and CS Setup/Hold Time before/after L_PCLK_WR */
96 unsigned wr_pulse_width; /* L_PCLK_WR pulse width */
97 unsigned rd_pulse_width; /* L_FCLK_RD pulse width */
98 unsigned cmd_inh_time; /* Command Inhibit time between two writes */
99 unsigned op_hold_time; /* Output Hold time from L_FCLK_RD negation */
40}; 100};
41 101
42struct pxafb_mach_info { 102struct pxafb_mach_info {
43 struct pxafb_mode_info *modes; 103 struct pxafb_mode_info *modes;
44 unsigned int num_modes; 104 unsigned int num_modes;
45 105
106 unsigned int lcd_conn;
107
46 u_int fixed_modes:1, 108 u_int fixed_modes:1,
47 cmap_inverse:1, 109 cmap_inverse:1,
48 cmap_static:1, 110 cmap_static:1,
@@ -78,8 +140,11 @@ struct pxafb_mach_info {
78 u_int lccr4; 140 u_int lccr4;
79 void (*pxafb_backlight_power)(int); 141 void (*pxafb_backlight_power)(int);
80 void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *); 142 void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *);
81 143 void (*smart_update)(struct fb_info *);
82}; 144};
83void set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info); 145void set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info);
84void set_pxa_fb_parent(struct device *parent_dev); 146void set_pxa_fb_parent(struct device *parent_dev);
85unsigned long pxafb_get_hsync_time(struct device *dev); 147unsigned long pxafb_get_hsync_time(struct device *dev);
148
149extern int pxafb_smart_queue(struct fb_info *info, uint16_t *cmds, int);
150extern int pxafb_smart_flush(struct fb_info *info);
diff --git a/include/asm-arm/arch-pxa/regs-lcd.h b/include/asm-arm/arch-pxa/regs-lcd.h
new file mode 100644
index 000000000000..f762493f5141
--- /dev/null
+++ b/include/asm-arm/arch-pxa/regs-lcd.h
@@ -0,0 +1,171 @@
1#ifndef __ASM_ARCH_REGS_LCD_H
2#define __ASM_ARCH_REGS_LCD_H
3/*
4 * LCD Controller Registers and Bits Definitions
5 */
6#define LCCR0 (0x000) /* LCD Controller Control Register 0 */
7#define LCCR1 (0x004) /* LCD Controller Control Register 1 */
8#define LCCR2 (0x008) /* LCD Controller Control Register 2 */
9#define LCCR3 (0x00C) /* LCD Controller Control Register 3 */
10#define LCCR4 (0x010) /* LCD Controller Control Register 4 */
11#define LCCR5 (0x014) /* LCD Controller Control Register 5 */
12#define DFBR0 (0x020) /* DMA Channel 0 Frame Branch Register */
13#define DFBR1 (0x024) /* DMA Channel 1 Frame Branch Register */
14#define LCSR (0x038) /* LCD Controller Status Register */
15#define LIIDR (0x03C) /* LCD Controller Interrupt ID Register */
16#define TMEDRGBR (0x040) /* TMED RGB Seed Register */
17#define TMEDCR (0x044) /* TMED Control Register */
18
19#define CMDCR (0x100) /* Command Control Register */
20#define PRSR (0x104) /* Panel Read Status Register */
21
22#define LCCR3_1BPP (0 << 24)
23#define LCCR3_2BPP (1 << 24)
24#define LCCR3_4BPP (2 << 24)
25#define LCCR3_8BPP (3 << 24)
26#define LCCR3_16BPP (4 << 24)
27
28#define LCCR3_PDFOR_0 (0 << 30)
29#define LCCR3_PDFOR_1 (1 << 30)
30#define LCCR3_PDFOR_2 (2 << 30)
31#define LCCR3_PDFOR_3 (3 << 30)
32
33#define LCCR4_PAL_FOR_0 (0 << 15)
34#define LCCR4_PAL_FOR_1 (1 << 15)
35#define LCCR4_PAL_FOR_2 (2 << 15)
36#define LCCR4_PAL_FOR_MASK (3 << 15)
37
38#define FDADR0 (0x200) /* DMA Channel 0 Frame Descriptor Address Register */
39#define FSADR0 (0x204) /* DMA Channel 0 Frame Source Address Register */
40#define FIDR0 (0x208) /* DMA Channel 0 Frame ID Register */
41#define LDCMD0 (0x20C) /* DMA Channel 0 Command Register */
42#define FDADR1 (0x210) /* DMA Channel 1 Frame Descriptor Address Register */
43#define FSADR1 (0x214) /* DMA Channel 1 Frame Source Address Register */
44#define FIDR1 (0x218) /* DMA Channel 1 Frame ID Register */
45#define LDCMD1 (0x21C) /* DMA Channel 1 Command Register */
46#define FDADR6 (0x260) /* DMA Channel 6 Frame Descriptor Address Register */
47#define FSADR6 (0x264) /* DMA Channel 6 Frame Source Address Register */
48#define FIDR6 (0x268) /* DMA Channel 6 Frame ID Register */
49
50#define LCCR0_ENB (1 << 0) /* LCD Controller enable */
51#define LCCR0_CMS (1 << 1) /* Color/Monochrome Display Select */
52#define LCCR0_Color (LCCR0_CMS*0) /* Color display */
53#define LCCR0_Mono (LCCR0_CMS*1) /* Monochrome display */
54#define LCCR0_SDS (1 << 2) /* Single/Dual Panel Display Select */
55#define LCCR0_Sngl (LCCR0_SDS*0) /* Single panel display */
56#define LCCR0_Dual (LCCR0_SDS*1) /* Dual panel display */
57
58#define LCCR0_LDM (1 << 3) /* LCD Disable Done Mask */
59#define LCCR0_SFM (1 << 4) /* Start of frame mask */
60#define LCCR0_IUM (1 << 5) /* Input FIFO underrun mask */
61#define LCCR0_EFM (1 << 6) /* End of Frame mask */
62#define LCCR0_PAS (1 << 7) /* Passive/Active display Select */
63#define LCCR0_Pas (LCCR0_PAS*0) /* Passive display (STN) */
64#define LCCR0_Act (LCCR0_PAS*1) /* Active display (TFT) */
65#define LCCR0_DPD (1 << 9) /* Double Pixel Data (monochrome) */
66#define LCCR0_4PixMono (LCCR0_DPD*0) /* 4-Pixel/clock Monochrome display */
67#define LCCR0_8PixMono (LCCR0_DPD*1) /* 8-Pixel/clock Monochrome display */
68#define LCCR0_DIS (1 << 10) /* LCD Disable */
69#define LCCR0_QDM (1 << 11) /* LCD Quick Disable mask */
70#define LCCR0_PDD (0xff << 12) /* Palette DMA request delay */
71#define LCCR0_PDD_S 12
72#define LCCR0_BM (1 << 20) /* Branch mask */
73#define LCCR0_OUM (1 << 21) /* Output FIFO underrun mask */
74#define LCCR0_LCDT (1 << 22) /* LCD panel type */
75#define LCCR0_RDSTM (1 << 23) /* Read status interrupt mask */
76#define LCCR0_CMDIM (1 << 24) /* Command interrupt mask */
77#define LCCR0_OUC (1 << 25) /* Overlay Underlay control bit */
78#define LCCR0_LDDALT (1 << 26) /* LDD alternate mapping control */
79
80#define LCCR1_PPL Fld (10, 0) /* Pixels Per Line - 1 */
81#define LCCR1_DisWdth(Pixel) (((Pixel) - 1) << FShft (LCCR1_PPL))
82
83#define LCCR1_HSW Fld (6, 10) /* Horizontal Synchronization */
84#define LCCR1_HorSnchWdth(Tpix) (((Tpix) - 1) << FShft (LCCR1_HSW))
85
86#define LCCR1_ELW Fld (8, 16) /* End-of-Line pixel clock Wait - 1 */
87#define LCCR1_EndLnDel(Tpix) (((Tpix) - 1) << FShft (LCCR1_ELW))
88
89#define LCCR1_BLW Fld (8, 24) /* Beginning-of-Line pixel clock */
90#define LCCR1_BegLnDel(Tpix) (((Tpix) - 1) << FShft (LCCR1_BLW))
91
92#define LCCR2_LPP Fld (10, 0) /* Line Per Panel - 1 */
93#define LCCR2_DisHght(Line) (((Line) - 1) << FShft (LCCR2_LPP))
94
95#define LCCR2_VSW Fld (6, 10) /* Vertical Synchronization pulse - 1 */
96#define LCCR2_VrtSnchWdth(Tln) (((Tln) - 1) << FShft (LCCR2_VSW))
97
98#define LCCR2_EFW Fld (8, 16) /* End-of-Frame line clock Wait */
99#define LCCR2_EndFrmDel(Tln) ((Tln) << FShft (LCCR2_EFW))
100
101#define LCCR2_BFW Fld (8, 24) /* Beginning-of-Frame line clock */
102#define LCCR2_BegFrmDel(Tln) ((Tln) << FShft (LCCR2_BFW))
103
104#define LCCR3_API (0xf << 16) /* AC Bias pin trasitions per interrupt */
105#define LCCR3_API_S 16
106#define LCCR3_VSP (1 << 20) /* vertical sync polarity */
107#define LCCR3_HSP (1 << 21) /* horizontal sync polarity */
108#define LCCR3_PCP (1 << 22) /* Pixel Clock Polarity (L_PCLK) */
109#define LCCR3_PixRsEdg (LCCR3_PCP*0) /* Pixel clock Rising-Edge */
110#define LCCR3_PixFlEdg (LCCR3_PCP*1) /* Pixel clock Falling-Edge */
111
112#define LCCR3_OEP (1 << 23) /* Output Enable Polarity */
113#define LCCR3_OutEnH (LCCR3_OEP*0) /* Output Enable active High */
114#define LCCR3_OutEnL (LCCR3_OEP*1) /* Output Enable active Low */
115
116#define LCCR3_DPC (1 << 27) /* double pixel clock mode */
117#define LCCR3_PCD Fld (8, 0) /* Pixel Clock Divisor */
118#define LCCR3_PixClkDiv(Div) (((Div) << FShft (LCCR3_PCD)))
119
120#define LCCR3_BPP Fld (3, 24) /* Bit Per Pixel */
121#define LCCR3_Bpp(Bpp) (((Bpp) << FShft (LCCR3_BPP)))
122
123#define LCCR3_ACB Fld (8, 8) /* AC Bias */
124#define LCCR3_Acb(Acb) (((Acb) << FShft (LCCR3_ACB)))
125
126#define LCCR3_HorSnchH (LCCR3_HSP*0) /* HSP Active High */
127#define LCCR3_HorSnchL (LCCR3_HSP*1) /* HSP Active Low */
128
129#define LCCR3_VrtSnchH (LCCR3_VSP*0) /* VSP Active High */
130#define LCCR3_VrtSnchL (LCCR3_VSP*1) /* VSP Active Low */
131
132#define LCCR5_IUM(x) (1 << ((x) + 23)) /* input underrun mask */
133#define LCCR5_BSM(x) (1 << ((x) + 15)) /* branch mask */
134#define LCCR5_EOFM(x) (1 << ((x) + 7)) /* end of frame mask */
135#define LCCR5_SOFM(x) (1 << ((x) + 0)) /* start of frame mask */
136
137#define LCSR_LDD (1 << 0) /* LCD Disable Done */
138#define LCSR_SOF (1 << 1) /* Start of frame */
139#define LCSR_BER (1 << 2) /* Bus error */
140#define LCSR_ABC (1 << 3) /* AC Bias count */
141#define LCSR_IUL (1 << 4) /* input FIFO underrun Lower panel */
142#define LCSR_IUU (1 << 5) /* input FIFO underrun Upper panel */
143#define LCSR_OU (1 << 6) /* output FIFO underrun */
144#define LCSR_QD (1 << 7) /* quick disable */
145#define LCSR_EOF (1 << 8) /* end of frame */
146#define LCSR_BS (1 << 9) /* branch status */
147#define LCSR_SINT (1 << 10) /* subsequent interrupt */
148#define LCSR_RD_ST (1 << 11) /* read status */
149#define LCSR_CMD_INT (1 << 12) /* command interrupt */
150
151#define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */
152
153/* smartpanel related */
154#define PRSR_DATA(x) ((x) & 0xff) /* Panel Data */
155#define PRSR_A0 (1 << 8) /* Read Data Source */
156#define PRSR_ST_OK (1 << 9) /* Status OK */
157#define PRSR_CON_NT (1 << 10) /* Continue to Next Command */
158
159#define SMART_CMD_A0 (0x1 << 8)
160#define SMART_CMD_READ_STATUS_REG (0x0 << 9)
161#define SMART_CMD_READ_FRAME_BUFFER ((0x0 << 9) | SMART_CMD_A0)
162#define SMART_CMD_WRITE_COMMAND (0x1 << 9)
163#define SMART_CMD_WRITE_DATA ((0x1 << 9) | SMART_CMD_A0)
164#define SMART_CMD_WRITE_FRAME ((0x2 << 9) | SMART_CMD_A0)
165#define SMART_CMD_WAIT_FOR_VSYNC (0x3 << 9)
166#define SMART_CMD_NOOP (0x4 << 9)
167#define SMART_CMD_INTERRUPT (0x5 << 9)
168
169#define SMART_CMD(x) (SMART_CMD_WRITE_COMMAND | ((x) & 0xff))
170#define SMART_DAT(x) (SMART_CMD_WRITE_DATA | ((x) & 0xff))
171#endif /* __ASM_ARCH_REGS_LCD_H */
diff --git a/include/asm-arm/arch-pxa/system.h b/include/asm-arm/arch-pxa/system.h
index 1d56a3ef89fd..a758a719180f 100644
--- a/include/asm-arm/arch-pxa/system.h
+++ b/include/asm-arm/arch-pxa/system.h
@@ -22,6 +22,8 @@ static inline void arch_idle(void)
22 22
23static inline void arch_reset(char mode) 23static inline void arch_reset(char mode)
24{ 24{
25 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
26
25 if (mode == 's') { 27 if (mode == 's') {
26 /* Jump into ROM at address 0 */ 28 /* Jump into ROM at address 0 */
27 cpu_reset(0); 29 cpu_reset(0);
diff --git a/include/asm-arm/arch-pxa/tosa.h b/include/asm-arm/arch-pxa/tosa.h
index c05e4faf85a6..c5b6fde6907c 100644
--- a/include/asm-arm/arch-pxa/tosa.h
+++ b/include/asm-arm/arch-pxa/tosa.h
@@ -23,11 +23,12 @@
23/* 23/*
24 * SCOOP2 internal GPIOs 24 * SCOOP2 internal GPIOs
25 */ 25 */
26#define TOSA_SCOOP_GPIO_BASE NR_BUILTIN_GPIO
26#define TOSA_SCOOP_PXA_VCORE1 SCOOP_GPCR_PA11 27#define TOSA_SCOOP_PXA_VCORE1 SCOOP_GPCR_PA11
27#define TOSA_SCOOP_TC6393_REST_IN SCOOP_GPCR_PA12 28#define TOSA_SCOOP_TC6393_REST_IN SCOOP_GPCR_PA12
28#define TOSA_SCOOP_IR_POWERDWN SCOOP_GPCR_PA13 29#define TOSA_GPIO_IR_POWERDWN (TOSA_SCOOP_GPIO_BASE + 2)
29#define TOSA_SCOOP_SD_WP SCOOP_GPCR_PA14 30#define TOSA_GPIO_SD_WP (TOSA_SCOOP_GPIO_BASE + 3)
30#define TOSA_SCOOP_PWR_ON SCOOP_GPCR_PA15 31#define TOSA_GPIO_PWR_ON (TOSA_SCOOP_GPIO_BASE + 4)
31#define TOSA_SCOOP_AUD_PWR_ON SCOOP_GPCR_PA16 32#define TOSA_SCOOP_AUD_PWR_ON SCOOP_GPCR_PA16
32#define TOSA_SCOOP_BT_RESET SCOOP_GPCR_PA17 33#define TOSA_SCOOP_BT_RESET SCOOP_GPCR_PA17
33#define TOSA_SCOOP_BT_PWR_EN SCOOP_GPCR_PA18 34#define TOSA_SCOOP_BT_PWR_EN SCOOP_GPCR_PA18
@@ -35,7 +36,7 @@
35 36
36/* GPIO Direction 1 : output mode / 0:input mode */ 37/* GPIO Direction 1 : output mode / 0:input mode */
37#define TOSA_SCOOP_IO_DIR ( TOSA_SCOOP_PXA_VCORE1 | TOSA_SCOOP_TC6393_REST_IN | \ 38#define TOSA_SCOOP_IO_DIR ( TOSA_SCOOP_PXA_VCORE1 | TOSA_SCOOP_TC6393_REST_IN | \
38 TOSA_SCOOP_IR_POWERDWN | TOSA_SCOOP_PWR_ON | TOSA_SCOOP_AUD_PWR_ON |\ 39 TOSA_SCOOP_AUD_PWR_ON |\
39 TOSA_SCOOP_BT_RESET | TOSA_SCOOP_BT_PWR_EN ) 40 TOSA_SCOOP_BT_RESET | TOSA_SCOOP_BT_PWR_EN )
40/* GPIO out put level when init 1: Hi */ 41/* GPIO out put level when init 1: Hi */
41#define TOSA_SCOOP_IO_OUT ( TOSA_SCOOP_TC6393_REST_IN ) 42#define TOSA_SCOOP_IO_OUT ( TOSA_SCOOP_TC6393_REST_IN )
@@ -43,23 +44,21 @@
43/* 44/*
44 * SCOOP2 jacket GPIOs 45 * SCOOP2 jacket GPIOs
45 */ 46 */
46#define TOSA_SCOOP_JC_BT_LED SCOOP_GPCR_PA11 47#define TOSA_SCOOP_JC_GPIO_BASE (NR_BUILTIN_GPIO + 12)
47#define TOSA_SCOOP_JC_NOTE_LED SCOOP_GPCR_PA12 48#define TOSA_GPIO_BT_LED (TOSA_SCOOP_JC_GPIO_BASE + 0)
48#define TOSA_SCOOP_JC_CHRG_ERR_LED SCOOP_GPCR_PA13 49#define TOSA_GPIO_NOTE_LED (TOSA_SCOOP_JC_GPIO_BASE + 1)
49#define TOSA_SCOOP_JC_USB_PULLUP SCOOP_GPCR_PA14 50#define TOSA_GPIO_CHRG_ERR_LED (TOSA_SCOOP_JC_GPIO_BASE + 2)
51#define TOSA_GPIO_USB_PULLUP (TOSA_SCOOP_JC_GPIO_BASE + 3)
50#define TOSA_SCOOP_JC_TC6393_SUSPEND SCOOP_GPCR_PA15 52#define TOSA_SCOOP_JC_TC6393_SUSPEND SCOOP_GPCR_PA15
51#define TOSA_SCOOP_JC_TC3693_L3V_ON SCOOP_GPCR_PA16 53#define TOSA_SCOOP_JC_TC3693_L3V_ON SCOOP_GPCR_PA16
52#define TOSA_SCOOP_JC_WLAN_DETECT SCOOP_GPCR_PA17 54#define TOSA_SCOOP_JC_WLAN_DETECT SCOOP_GPCR_PA17
53#define TOSA_SCOOP_JC_WLAN_LED SCOOP_GPCR_PA18 55#define TOSA_GPIO_WLAN_LED (TOSA_SCOOP_JC_GPIO_BASE + 7)
54#define TOSA_SCOOP_JC_CARD_LIMIT_SEL SCOOP_GPCR_PA19 56#define TOSA_SCOOP_JC_CARD_LIMIT_SEL SCOOP_GPCR_PA19
55 57
56/* GPIO Direction 1 : output mode / 0:input mode */ 58/* GPIO Direction 1 : output mode / 0:input mode */
57#define TOSA_SCOOP_JC_IO_DIR ( TOSA_SCOOP_JC_BT_LED | TOSA_SCOOP_JC_NOTE_LED | \ 59#define TOSA_SCOOP_JC_IO_DIR ( \
58 TOSA_SCOOP_JC_CHRG_ERR_LED | TOSA_SCOOP_JC_USB_PULLUP | \
59 TOSA_SCOOP_JC_TC6393_SUSPEND | TOSA_SCOOP_JC_TC3693_L3V_ON | \ 60 TOSA_SCOOP_JC_TC6393_SUSPEND | TOSA_SCOOP_JC_TC3693_L3V_ON | \
60 TOSA_SCOOP_JC_WLAN_LED | TOSA_SCOOP_JC_CARD_LIMIT_SEL ) 61 TOSA_SCOOP_JC_CARD_LIMIT_SEL )
61/* GPIO out put level when init 1: Hi */
62#define TOSA_SCOOP_JC_IO_OUT ( 0 )
63 62
64/* 63/*
65 * Timing Generator 64 * Timing Generator
@@ -74,15 +73,6 @@
74#define TG_HPOSCTL 0x07 73#define TG_HPOSCTL 0x07
75 74
76/* 75/*
77 * LED
78 */
79#define TOSA_SCOOP_LED_BLUE TOSA_SCOOP_GPCR_PA11
80#define TOSA_SCOOP_LED_GREEN TOSA_SCOOP_GPCR_PA12
81#define TOSA_SCOOP_LED_ORANGE TOSA_SCOOP_GPCR_PA13
82#define TOSA_SCOOP_LED_WLAN TOSA_SCOOP_GPCR_PA18
83
84
85/*
86 * PXA GPIOs 76 * PXA GPIOs
87 */ 77 */
88#define TOSA_GPIO_POWERON (0) 78#define TOSA_GPIO_POWERON (0)
@@ -161,12 +151,8 @@
161 151
162#define TOSA_IRQ_GPIO_MAIN_BAT_LOW IRQ_GPIO(TOSA_GPIO_MAIN_BAT_LOW) 152#define TOSA_IRQ_GPIO_MAIN_BAT_LOW IRQ_GPIO(TOSA_GPIO_MAIN_BAT_LOW)
163 153
164extern struct platform_device tosascoop_jc_device;
165extern struct platform_device tosascoop_device;
166
167#define TOSA_KEY_SYNC KEY_102ND /* ??? */ 154#define TOSA_KEY_SYNC KEY_102ND /* ??? */
168 155
169
170#ifndef CONFIG_KEYBOARD_TOSA_USE_EXT_KEYCODES 156#ifndef CONFIG_KEYBOARD_TOSA_USE_EXT_KEYCODES
171#define TOSA_KEY_RECORD KEY_YEN 157#define TOSA_KEY_RECORD KEY_YEN
172#define TOSA_KEY_ADDRESSBOOK KEY_KATAKANA 158#define TOSA_KEY_ADDRESSBOOK KEY_KATAKANA
diff --git a/include/asm-arm/arch-pxa/zylonite.h b/include/asm-arm/arch-pxa/zylonite.h
index 5f717d64ea7d..4881b80f0f90 100644
--- a/include/asm-arm/arch-pxa/zylonite.h
+++ b/include/asm-arm/arch-pxa/zylonite.h
@@ -18,6 +18,8 @@ extern struct platform_mmc_slot zylonite_mmc_slot[];
18extern int gpio_backlight; 18extern int gpio_backlight;
19extern int gpio_eth_irq; 19extern int gpio_eth_irq;
20 20
21extern int wm9713_irq;
22
21extern int lcd_id; 23extern int lcd_id;
22extern int lcd_orientation; 24extern int lcd_orientation;
23 25
diff --git a/include/asm-arm/arch-realview/board-eb.h b/include/asm-arm/arch-realview/board-eb.h
index 3e437b7f425a..206f7a752882 100644
--- a/include/asm-arm/arch-realview/board-eb.h
+++ b/include/asm-arm/arch-realview/board-eb.h
@@ -26,6 +26,26 @@
26/* 26/*
27 * RealView EB + ARM11MPCore peripheral addresses 27 * RealView EB + ARM11MPCore peripheral addresses
28 */ 28 */
29#define REALVIEW_EB_UART0_BASE 0x10009000 /* UART 0 */
30#define REALVIEW_EB_UART1_BASE 0x1000A000 /* UART 1 */
31#define REALVIEW_EB_UART2_BASE 0x1000B000 /* UART 2 */
32#define REALVIEW_EB_UART3_BASE 0x1000C000 /* UART 3 */
33#define REALVIEW_EB_SSP_BASE 0x1000D000 /* Synchronous Serial Port */
34#define REALVIEW_EB_WATCHDOG_BASE 0x10010000 /* watchdog interface */
35#define REALVIEW_EB_TIMER0_1_BASE 0x10011000 /* Timer 0 and 1 */
36#define REALVIEW_EB_TIMER2_3_BASE 0x10012000 /* Timer 2 and 3 */
37#define REALVIEW_EB_GPIO0_BASE 0x10013000 /* GPIO port 0 */
38#define REALVIEW_EB_RTC_BASE 0x10017000 /* Real Time Clock */
39#define REALVIEW_EB_CLCD_BASE 0x10020000 /* CLCD */
40#define REALVIEW_EB_GIC_CPU_BASE 0x10040000 /* Generic interrupt controller CPU interface */
41#define REALVIEW_EB_GIC_DIST_BASE 0x10041000 /* Generic interrupt controller distributor */
42#define REALVIEW_EB_SMC_BASE 0x10080000 /* Static memory controller */
43
44#define REALVIEW_EB_FLASH_BASE 0x40000000
45#define REALVIEW_EB_FLASH_SIZE SZ_64M
46#define REALVIEW_EB_ETH_BASE 0x4E000000 /* Ethernet */
47#define REALVIEW_EB_USB_BASE 0x4F000000 /* USB */
48
29#ifdef CONFIG_REALVIEW_EB_ARM11MP_REVB 49#ifdef CONFIG_REALVIEW_EB_ARM11MP_REVB
30#define REALVIEW_EB11MP_SCU_BASE 0x10100000 /* SCU registers */ 50#define REALVIEW_EB11MP_SCU_BASE 0x10100000 /* SCU registers */
31#define REALVIEW_EB11MP_GIC_CPU_BASE 0x10100100 /* Generic interrupt controller CPU interface */ 51#define REALVIEW_EB11MP_GIC_CPU_BASE 0x10100100 /* Generic interrupt controller CPU interface */
diff --git a/include/asm-arm/arch-realview/board-pb1176.h b/include/asm-arm/arch-realview/board-pb1176.h
new file mode 100644
index 000000000000..48ce9c833705
--- /dev/null
+++ b/include/asm-arm/arch-realview/board-pb1176.h
@@ -0,0 +1,152 @@
1/*
2 * include/asm-arm/arch-realview/board-pb1176.h
3 *
4 * Copyright (C) 2008 ARM Limited
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
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., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20
21#ifndef __ASM_ARCH_BOARD_PB1176_H
22#define __ASM_ARCH_BOARD_PB1176_H
23
24#include <asm/arch/platform.h>
25
26/*
27 * Peripheral addresses
28 */
29#define REALVIEW_PB1176_SCTL_BASE 0x10100000 /* System controller */
30#define REALVIEW_PB1176_SMC_BASE 0x10111000 /* SMC */
31#define REALVIEW_PB1176_DMC_BASE 0x10109000 /* DMC configuration */
32#define REALVIEW_PB1176_SDRAM67_BASE 0x70000000 /* SDRAM banks 6 and 7 */
33#define REALVIEW_PB1176_FLASH_BASE 0x30000000
34#define REALVIEW_PB1176_FLASH_SIZE SZ_64M
35
36#define REALVIEW_PB1176_TIMER0_1_BASE 0x10104000 /* Timer 0 and 1 */
37#define REALVIEW_PB1176_TIMER2_3_BASE 0x10105000 /* Timer 2 and 3 */
38#define REALVIEW_PB1176_TIMER4_5_BASE 0x10106000 /* Timer 4 and 5 */
39#define REALVIEW_PB1176_WATCHDOG_BASE 0x10107000 /* watchdog interface */
40#define REALVIEW_PB1176_RTC_BASE 0x10108000 /* Real Time Clock */
41#define REALVIEW_PB1176_GPIO0_BASE 0x1010A000 /* GPIO port 0 */
42#define REALVIEW_PB1176_SSP_BASE 0x1010B000 /* Synchronous Serial Port */
43#define REALVIEW_PB1176_UART0_BASE 0x1010C000 /* UART 0 */
44#define REALVIEW_PB1176_UART1_BASE 0x1010D000 /* UART 1 */
45#define REALVIEW_PB1176_UART2_BASE 0x1010E000 /* UART 2 */
46#define REALVIEW_PB1176_UART3_BASE 0x1010F000 /* UART 3 */
47#define REALVIEW_PB1176_CLCD_BASE 0x10112000 /* CLCD */
48#define REALVIEW_PB1176_ETH_BASE 0x3A000000 /* Ethernet */
49#define REALVIEW_PB1176_USB_BASE 0x3B000000 /* USB */
50
51/*
52 * PCI regions
53 */
54#define REALVIEW_PB1176_PCI_BASE 0x60000000 /* PCI self config */
55#define REALVIEW_PB1176_PCI_CFG_BASE 0x61000000 /* PCI config */
56#define REALVIEW_PB1176_PCI_IO_BASE0 0x62000000 /* PCI IO region */
57#define REALVIEW_PB1176_PCI_MEM_BASE0 0x63000000 /* Memory region 1 */
58#define REALVIEW_PB1176_PCI_MEM_BASE1 0x64000000 /* Memory region 2 */
59#define REALVIEW_PB1176_PCI_MEM_BASE2 0x68000000 /* Memory region 3 */
60
61#define REALVIEW_PB1176_PCI_BASE_SIZE 0x01000000 /* 16MB */
62#define REALVIEW_PB1176_PCI_CFG_BASE_SIZE 0x01000000 /* 16MB */
63#define REALVIEW_PB1176_PCI_IO_BASE0_SIZE 0x01000000 /* 16MB */
64#define REALVIEW_PB1176_PCI_MEM_BASE0_SIZE 0x01000000 /* 16MB */
65#define REALVIEW_PB1176_PCI_MEM_BASE1_SIZE 0x04000000 /* 64MB */
66#define REALVIEW_PB1176_PCI_MEM_BASE2_SIZE 0x08000000 /* 128MB */
67
68#define REALVIEW_DC1176_GIC_CPU_BASE 0x10120000 /* GIC CPU interface, on devchip */
69#define REALVIEW_DC1176_GIC_DIST_BASE 0x10121000 /* GIC distributor, on devchip */
70#define REALVIEW_PB1176_GIC_CPU_BASE 0x10040000 /* GIC CPU interface, on FPGA */
71#define REALVIEW_PB1176_GIC_DIST_BASE 0x10041000 /* GIC distributor, on FPGA */
72#define REALVIEW_PB1176_L220_BASE 0x10110000 /* L220 registers */
73
74/*
75 * Irqs
76 */
77#define IRQ_DC1176_GIC_START 32
78#define IRQ_PB1176_GIC_START 64
79
80/*
81 * ARM1176 DevChip interrupt sources (primary GIC)
82 */
83#define IRQ_DC1176_WATCHDOG (IRQ_DC1176_GIC_START + 0) /* Watchdog timer */
84#define IRQ_DC1176_SOFTINT (IRQ_DC1176_GIC_START + 1) /* Software interrupt */
85#define IRQ_DC1176_COMMRx (IRQ_DC1176_GIC_START + 2) /* Debug Comm Rx interrupt */
86#define IRQ_DC1176_COMMTx (IRQ_DC1176_GIC_START + 3) /* Debug Comm Tx interrupt */
87#define IRQ_DC1176_TIMER0 (IRQ_DC1176_GIC_START + 8) /* Timer 0 */
88#define IRQ_DC1176_TIMER1 (IRQ_DC1176_GIC_START + 9) /* Timer 1 */
89#define IRQ_DC1176_TIMER2 (IRQ_DC1176_GIC_START + 10) /* Timer 2 */
90#define IRQ_DC1176_APC (IRQ_DC1176_GIC_START + 11)
91#define IRQ_DC1176_IEC (IRQ_DC1176_GIC_START + 12)
92#define IRQ_DC1176_L2CC (IRQ_DC1176_GIC_START + 13)
93#define IRQ_DC1176_RTC (IRQ_DC1176_GIC_START + 14)
94#define IRQ_DC1176_CLCD (IRQ_DC1176_GIC_START + 15) /* CLCD controller */
95#define IRQ_DC1176_UART0 (IRQ_DC1176_GIC_START + 18) /* UART 0 on development chip */
96#define IRQ_DC1176_UART1 (IRQ_DC1176_GIC_START + 19) /* UART 1 on development chip */
97#define IRQ_DC1176_UART2 (IRQ_DC1176_GIC_START + 20) /* UART 2 on development chip */
98#define IRQ_DC1176_UART3 (IRQ_DC1176_GIC_START + 21) /* UART 3 on development chip */
99
100#define IRQ_DC1176_PB_IRQ2 (IRQ_DC1176_GIC_START + 30) /* tile GIC */
101#define IRQ_DC1176_PB_IRQ1 (IRQ_DC1176_GIC_START + 31) /* main GIC */
102
103/*
104 * RealView PB1176 interrupt sources (secondary GIC)
105 */
106#define IRQ_PB1176_MMCI0A (IRQ_PB1176_GIC_START + 1) /* Multimedia Card 0A */
107#define IRQ_PB1176_MMCI0B (IRQ_PB1176_GIC_START + 2) /* Multimedia Card 0A */
108#define IRQ_PB1176_KMI0 (IRQ_PB1176_GIC_START + 3) /* Keyboard/Mouse port 0 */
109#define IRQ_PB1176_KMI1 (IRQ_PB1176_GIC_START + 4) /* Keyboard/Mouse port 1 */
110#define IRQ_PB1176_SCI (IRQ_PB1176_GIC_START + 5)
111#define IRQ_PB1176_UART4 (IRQ_PB1176_GIC_START + 6) /* UART 4 on baseboard */
112#define IRQ_PB1176_CHARLCD (IRQ_PB1176_GIC_START + 7) /* Character LCD */
113#define IRQ_PB1176_GPIO1 (IRQ_PB1176_GIC_START + 8)
114#define IRQ_PB1176_GPIO2 (IRQ_PB1176_GIC_START + 9)
115#define IRQ_PB1176_ETH (IRQ_PB1176_GIC_START + 10) /* Ethernet controller */
116#define IRQ_PB1176_USB (IRQ_PB1176_GIC_START + 11) /* USB controller */
117
118#define IRQ_PB1176_PISMO (IRQ_PB1176_GIC_START + 16)
119
120#define IRQ_PB1176_AACI (IRQ_PB1176_GIC_START + 19) /* Audio Codec */
121
122#define IRQ_PB1176_TIMER0_1 (IRQ_PB1176_GIC_START + 22)
123#define IRQ_PB1176_TIMER2_3 (IRQ_PB1176_GIC_START + 23)
124#define IRQ_PB1176_DMAC (IRQ_PB1176_GIC_START + 24) /* DMA controller */
125#define IRQ_PB1176_RTC (IRQ_PB1176_GIC_START + 25) /* Real Time Clock */
126
127#define IRQ_PB1176_GPIO0 -1
128#define IRQ_PB1176_SSP -1
129#define IRQ_PB1176_SCTL -1
130
131#define NR_GIC_PB1176 2
132
133/*
134 * Only define NR_IRQS if less than NR_IRQS_PB1176
135 */
136#define NR_IRQS_PB1176 (IRQ_DC1176_GIC_START + 96)
137
138#if defined(CONFIG_MACH_REALVIEW_PB1176)
139
140#if !defined(NR_IRQS) || (NR_IRQS < NR_IRQS_PB1176)
141#undef NR_IRQS
142#define NR_IRQS NR_IRQS_PB1176
143#endif
144
145#if !defined(MAX_GIC_NR) || (MAX_GIC_NR < NR_GIC_PB1176)
146#undef MAX_GIC_NR
147#define MAX_GIC_NR NR_GIC_PB1176
148#endif
149
150#endif /* CONFIG_MACH_REALVIEW_PB1176 */
151
152#endif /* __ASM_ARCH_BOARD_PB1176_H */
diff --git a/include/asm-arm/arch-realview/board-pb11mp.h b/include/asm-arm/arch-realview/board-pb11mp.h
new file mode 100644
index 000000000000..a1294d915fa8
--- /dev/null
+++ b/include/asm-arm/arch-realview/board-pb11mp.h
@@ -0,0 +1,186 @@
1/*
2 * include/asm-arm/arch-realview/board-pb11mp.h
3 *
4 * Copyright (C) 2008 ARM Limited
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
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., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20
21#ifndef __ASM_ARCH_BOARD_PB11MP_H
22#define __ASM_ARCH_BOARD_PB11MP_H
23
24#include <asm/arch/platform.h>
25
26/*
27 * Peripheral addresses
28 */
29#define REALVIEW_PB11MP_UART0_BASE 0x10009000 /* UART 0 */
30#define REALVIEW_PB11MP_UART1_BASE 0x1000A000 /* UART 1 */
31#define REALVIEW_PB11MP_UART2_BASE 0x1000B000 /* UART 2 */
32#define REALVIEW_PB11MP_UART3_BASE 0x1000C000 /* UART 3 */
33#define REALVIEW_PB11MP_SSP_BASE 0x1000D000 /* Synchronous Serial Port */
34#define REALVIEW_PB11MP_WATCHDOG0_BASE 0x1000F000 /* Watchdog 0 */
35#define REALVIEW_PB11MP_WATCHDOG_BASE 0x10010000 /* watchdog interface */
36#define REALVIEW_PB11MP_TIMER0_1_BASE 0x10011000 /* Timer 0 and 1 */
37#define REALVIEW_PB11MP_TIMER2_3_BASE 0x10012000 /* Timer 2 and 3 */
38#define REALVIEW_PB11MP_GPIO0_BASE 0x10013000 /* GPIO port 0 */
39#define REALVIEW_PB11MP_RTC_BASE 0x10017000 /* Real Time Clock */
40#define REALVIEW_PB11MP_TIMER4_5_BASE 0x10018000 /* Timer 4/5 */
41#define REALVIEW_PB11MP_TIMER6_7_BASE 0x10019000 /* Timer 6/7 */
42#define REALVIEW_PB11MP_SCTL_BASE 0x1001A000 /* System Controller */
43#define REALVIEW_PB11MP_CLCD_BASE 0x10020000 /* CLCD */
44#define REALVIEW_PB11MP_ONB_SRAM_BASE 0x10060000 /* On-board SRAM */
45#define REALVIEW_PB11MP_DMC_BASE 0x100E0000 /* DMC configuration */
46#define REALVIEW_PB11MP_SMC_BASE 0x100E1000 /* SMC configuration */
47#define REALVIEW_PB11MP_CAN_BASE 0x100E2000 /* CAN bus */
48#define REALVIEW_PB11MP_CF_BASE 0x18000000 /* Compact flash */
49#define REALVIEW_PB11MP_CF_MEM_BASE 0x18003000 /* SMC for Compact flash */
50#define REALVIEW_PB11MP_GIC_CPU_BASE 0x1E000000 /* Generic interrupt controller CPU interface */
51#define REALVIEW_PB11MP_FLASH0_BASE 0x40000000
52#define REALVIEW_PB11MP_FLASH0_SIZE SZ_64M
53#define REALVIEW_PB11MP_FLASH1_BASE 0x44000000
54#define REALVIEW_PB11MP_FLASH1_SIZE SZ_64M
55#define REALVIEW_PB11MP_ETH_BASE 0x4E000000 /* Ethernet */
56#define REALVIEW_PB11MP_USB_BASE 0x4F000000 /* USB */
57#define REALVIEW_PB11MP_GIC_DIST_BASE 0x1E001000 /* Generic interrupt controller distributor */
58#define REALVIEW_PB11MP_LT_BASE 0xC0000000 /* Logic Tile expansion */
59#define REALVIEW_PB11MP_SDRAM6_BASE 0x70000000 /* SDRAM bank 6 256MB */
60#define REALVIEW_PB11MP_SDRAM7_BASE 0x80000000 /* SDRAM bank 7 256MB */
61
62#define REALVIEW_PB11MP_SYS_PLD_CTRL1 0x74
63
64/*
65 * PB11MPCore PCI regions
66 */
67#define REALVIEW_PB11MP_PCI_BASE 0x90040000 /* PCI-X Unit base */
68#define REALVIEW_PB11MP_PCI_IO_BASE 0x90050000 /* IO Region on AHB */
69#define REALVIEW_PB11MP_PCI_MEM_BASE 0xA0000000 /* MEM Region on AHB */
70
71#define REALVIEW_PB11MP_PCI_BASE_SIZE 0x10000 /* 16 Kb */
72#define REALVIEW_PB11MP_PCI_IO_SIZE 0x1000 /* 4 Kb */
73#define REALVIEW_PB11MP_PCI_MEM_SIZE 0x20000000 /* 512 MB */
74
75/*
76 * Testchip peripheral and fpga gic regions
77 */
78#define REALVIEW_TC11MP_SCU_BASE 0x1F000000 /* IRQ, Test chip */
79#define REALVIEW_TC11MP_GIC_CPU_BASE 0x1F000100 /* Test chip interrupt controller CPU interface */
80#define REALVIEW_TC11MP_TWD_BASE 0x1F000700
81#define REALVIEW_TC11MP_TWD_SIZE 0x00000100
82#define REALVIEW_TC11MP_GIC_DIST_BASE 0x1F001000 /* Test chip interrupt controller distributor */
83#define REALVIEW_TC11MP_L220_BASE 0x1F002000 /* L220 registers */
84
85/*
86 * Irqs
87 */
88#define IRQ_TC11MP_GIC_START 32
89#define IRQ_PB11MP_GIC_START 64
90
91/*
92 * ARM11MPCore test chip interrupt sources (primary GIC on the test chip)
93 */
94#define IRQ_TC11MP_AACI (IRQ_TC11MP_GIC_START + 0)
95#define IRQ_TC11MP_TIMER0_1 (IRQ_TC11MP_GIC_START + 1)
96#define IRQ_TC11MP_TIMER2_3 (IRQ_TC11MP_GIC_START + 2)
97#define IRQ_TC11MP_USB (IRQ_TC11MP_GIC_START + 3)
98#define IRQ_TC11MP_UART0 (IRQ_TC11MP_GIC_START + 4)
99#define IRQ_TC11MP_UART1 (IRQ_TC11MP_GIC_START + 5)
100#define IRQ_TC11MP_RTC (IRQ_TC11MP_GIC_START + 6)
101#define IRQ_TC11MP_KMI0 (IRQ_TC11MP_GIC_START + 7)
102#define IRQ_TC11MP_KMI1 (IRQ_TC11MP_GIC_START + 8)
103#define IRQ_TC11MP_ETH (IRQ_TC11MP_GIC_START + 9)
104#define IRQ_TC11MP_PB_IRQ1 (IRQ_TC11MP_GIC_START + 10) /* main GIC */
105#define IRQ_TC11MP_PB_IRQ2 (IRQ_TC11MP_GIC_START + 11) /* tile GIC */
106#define IRQ_TC11MP_PB_FIQ1 (IRQ_TC11MP_GIC_START + 12) /* main GIC */
107#define IRQ_TC11MP_PB_FIQ2 (IRQ_TC11MP_GIC_START + 13) /* tile GIC */
108#define IRQ_TC11MP_MMCI0A (IRQ_TC11MP_GIC_START + 14)
109#define IRQ_TC11MP_MMCI0B (IRQ_TC11MP_GIC_START + 15)
110
111#define IRQ_TC11MP_PMU_CPU0 (IRQ_TC11MP_GIC_START + 17)
112#define IRQ_TC11MP_PMU_CPU1 (IRQ_TC11MP_GIC_START + 18)
113#define IRQ_TC11MP_PMU_CPU2 (IRQ_TC11MP_GIC_START + 19)
114#define IRQ_TC11MP_PMU_CPU3 (IRQ_TC11MP_GIC_START + 20)
115#define IRQ_TC11MP_PMU_SCU0 (IRQ_TC11MP_GIC_START + 21)
116#define IRQ_TC11MP_PMU_SCU1 (IRQ_TC11MP_GIC_START + 22)
117#define IRQ_TC11MP_PMU_SCU2 (IRQ_TC11MP_GIC_START + 23)
118#define IRQ_TC11MP_PMU_SCU3 (IRQ_TC11MP_GIC_START + 24)
119#define IRQ_TC11MP_PMU_SCU4 (IRQ_TC11MP_GIC_START + 25)
120#define IRQ_TC11MP_PMU_SCU5 (IRQ_TC11MP_GIC_START + 26)
121#define IRQ_TC11MP_PMU_SCU6 (IRQ_TC11MP_GIC_START + 27)
122#define IRQ_TC11MP_PMU_SCU7 (IRQ_TC11MP_GIC_START + 28)
123
124#define IRQ_TC11MP_L220_EVENT (IRQ_TC11MP_GIC_START + 29)
125#define IRQ_TC11MP_L220_SLAVE (IRQ_TC11MP_GIC_START + 30)
126#define IRQ_TC11MP_L220_DECODE (IRQ_TC11MP_GIC_START + 31)
127
128/*
129 * RealView PB11MPCore GIC interrupt sources (secondary GIC on the board)
130 */
131#define IRQ_PB11MP_WATCHDOG (IRQ_PB11MP_GIC_START + 0) /* Watchdog timer */
132#define IRQ_PB11MP_SOFT (IRQ_PB11MP_GIC_START + 1) /* Software interrupt */
133#define IRQ_PB11MP_COMMRx (IRQ_PB11MP_GIC_START + 2) /* Debug Comm Rx interrupt */
134#define IRQ_PB11MP_COMMTx (IRQ_PB11MP_GIC_START + 3) /* Debug Comm Tx interrupt */
135#define IRQ_PB11MP_GPIO0 (IRQ_PB11MP_GIC_START + 6) /* GPIO 0 */
136#define IRQ_PB11MP_GPIO1 (IRQ_PB11MP_GIC_START + 7) /* GPIO 1 */
137#define IRQ_PB11MP_GPIO2 (IRQ_PB11MP_GIC_START + 8) /* GPIO 2 */
138 /* 9 reserved */
139#define IRQ_PB11MP_RTC_GIC1 (IRQ_PB11MP_GIC_START + 10) /* Real Time Clock */
140#define IRQ_PB11MP_SSP (IRQ_PB11MP_GIC_START + 11) /* Synchronous Serial Port */
141#define IRQ_PB11MP_UART0_GIC1 (IRQ_PB11MP_GIC_START + 12) /* UART 0 on development chip */
142#define IRQ_PB11MP_UART1_GIC1 (IRQ_PB11MP_GIC_START + 13) /* UART 1 on development chip */
143#define IRQ_PB11MP_UART2 (IRQ_PB11MP_GIC_START + 14) /* UART 2 on development chip */
144#define IRQ_PB11MP_UART3 (IRQ_PB11MP_GIC_START + 15) /* UART 3 on development chip */
145#define IRQ_PB11MP_SCI (IRQ_PB11MP_GIC_START + 16) /* Smart Card Interface */
146#define IRQ_PB11MP_MMCI0A_GIC1 (IRQ_PB11MP_GIC_START + 17) /* Multimedia Card 0A */
147#define IRQ_PB11MP_MMCI0B_GIC1 (IRQ_PB11MP_GIC_START + 18) /* Multimedia Card 0B */
148#define IRQ_PB11MP_AACI_GIC1 (IRQ_PB11MP_GIC_START + 19) /* Audio Codec */
149#define IRQ_PB11MP_KMI0_GIC1 (IRQ_PB11MP_GIC_START + 20) /* Keyboard/Mouse port 0 */
150#define IRQ_PB11MP_KMI1_GIC1 (IRQ_PB11MP_GIC_START + 21) /* Keyboard/Mouse port 1 */
151#define IRQ_PB11MP_CHARLCD (IRQ_PB11MP_GIC_START + 22) /* Character LCD */
152#define IRQ_PB11MP_CLCD (IRQ_PB11MP_GIC_START + 23) /* CLCD controller */
153#define IRQ_PB11MP_DMAC (IRQ_PB11MP_GIC_START + 24) /* DMA controller */
154#define IRQ_PB11MP_PWRFAIL (IRQ_PB11MP_GIC_START + 25) /* Power failure */
155#define IRQ_PB11MP_PISMO (IRQ_PB11MP_GIC_START + 26) /* PISMO interface */
156#define IRQ_PB11MP_DoC (IRQ_PB11MP_GIC_START + 27) /* Disk on Chip memory controller */
157#define IRQ_PB11MP_ETH_GIC1 (IRQ_PB11MP_GIC_START + 28) /* Ethernet controller */
158#define IRQ_PB11MP_USB_GIC1 (IRQ_PB11MP_GIC_START + 29) /* USB controller */
159#define IRQ_PB11MP_TSPEN (IRQ_PB11MP_GIC_START + 30) /* Touchscreen pen */
160#define IRQ_PB11MP_TSKPAD (IRQ_PB11MP_GIC_START + 31) /* Touchscreen keypad */
161
162#define IRQ_PB11MP_SMC -1
163#define IRQ_PB11MP_SCTL -1
164
165#define NR_GIC_PB11MP 2
166
167/*
168 * Only define NR_IRQS if less than NR_IRQS_PB11MP
169 */
170#define NR_IRQS_PB11MP (IRQ_TC11MP_GIC_START + 96)
171
172#if defined(CONFIG_MACH_REALVIEW_PB11MP)
173
174#if !defined(NR_IRQS) || (NR_IRQS < NR_IRQS_PB11MP)
175#undef NR_IRQS
176#define NR_IRQS NR_IRQS_PB11MP
177#endif
178
179#if !defined(MAX_GIC_NR) || (MAX_GIC_NR < NR_GIC_PB11MP)
180#undef MAX_GIC_NR
181#define MAX_GIC_NR NR_GIC_PB11MP
182#endif
183
184#endif /* CONFIG_MACH_REALVIEW_PB11MP */
185
186#endif /* __ASM_ARCH_BOARD_PB11MP_H */
diff --git a/include/asm-arm/arch-realview/debug-macro.S b/include/asm-arm/arch-realview/debug-macro.S
index f17efc65518a..c8c860c3c26e 100644
--- a/include/asm-arm/arch-realview/debug-macro.S
+++ b/include/asm-arm/arch-realview/debug-macro.S
@@ -15,7 +15,7 @@
15 mrc p15, 0, \rx, c1, c0 15 mrc p15, 0, \rx, c1, c0
16 tst \rx, #1 @ MMU enabled? 16 tst \rx, #1 @ MMU enabled?
17 moveq \rx, #0x10000000 17 moveq \rx, #0x10000000
18 movne \rx, #0xf1000000 @ virtual base 18 movne \rx, #0xf0000000 @ virtual base
19 orr \rx, \rx, #0x00009000 19 orr \rx, \rx, #0x00009000
20 .endm 20 .endm
21 21
diff --git a/include/asm-arm/arch-realview/hardware.h b/include/asm-arm/arch-realview/hardware.h
index bad8d7ce9bfe..1ee8313ceb6a 100644
--- a/include/asm-arm/arch-realview/hardware.h
+++ b/include/asm-arm/arch-realview/hardware.h
@@ -25,7 +25,7 @@
25#include <asm/sizes.h> 25#include <asm/sizes.h>
26 26
27/* macro to get at IO space when running virtually */ 27/* macro to get at IO space when running virtually */
28#define IO_ADDRESS(x) ((((x) & 0x0effffff) | (((x) >> 4) & 0x0f000000)) + 0xf0000000) 28#define IO_ADDRESS(x) (((x) & 0x0fffffff) + 0xf0000000)
29#define __io_address(n) __io(IO_ADDRESS(n)) 29#define __io_address(n) __io(IO_ADDRESS(n))
30 30
31#endif 31#endif
diff --git a/include/asm-arm/arch-realview/irqs.h b/include/asm-arm/arch-realview/irqs.h
index ad0c911002fc..ccbac59235c6 100644
--- a/include/asm-arm/arch-realview/irqs.h
+++ b/include/asm-arm/arch-realview/irqs.h
@@ -23,6 +23,8 @@
23#define __ASM_ARCH_IRQS_H 23#define __ASM_ARCH_IRQS_H
24 24
25#include <asm/arch/board-eb.h> 25#include <asm/arch/board-eb.h>
26#include <asm/arch/board-pb11mp.h>
27#include <asm/arch/board-pb1176.h>
26 28
27#define IRQ_LOCALTIMER 29 29#define IRQ_LOCALTIMER 29
28#define IRQ_LOCALWDOG 30 30#define IRQ_LOCALWDOG 30
diff --git a/include/asm-arm/arch-realview/platform.h b/include/asm-arm/arch-realview/platform.h
index 4fd351b5e4a2..424c0aaf46a0 100644
--- a/include/asm-arm/arch-realview/platform.h
+++ b/include/asm-arm/arch-realview/platform.h
@@ -32,9 +32,6 @@
32#define REALVIEW_SSRAM_BASE /* REALVIEW_SSMC_BASE ? */ 32#define REALVIEW_SSRAM_BASE /* REALVIEW_SSMC_BASE ? */
33#define REALVIEW_SSRAM_SIZE SZ_2M 33#define REALVIEW_SSRAM_SIZE SZ_2M
34 34
35#define REALVIEW_FLASH_BASE 0x40000000
36#define REALVIEW_FLASH_SIZE SZ_64M
37
38/* 35/*
39 * SDRAM 36 * SDRAM
40 */ 37 */
@@ -175,42 +172,20 @@
175#define REALVIEW_INTREG_CARDINSERT 0x03 /* Signal insertion of MMC card */ 172#define REALVIEW_INTREG_CARDINSERT 0x03 /* Signal insertion of MMC card */
176 173
177/* 174/*
178 * REALVIEW peripheral addresses 175 * RealView common peripheral addresses
179 */ 176 */
180#define REALVIEW_SCTL_BASE 0x10001000 /* System controller */ 177#define REALVIEW_SCTL_BASE 0x10001000 /* System controller */
181#define REALVIEW_I2C_BASE 0x10002000 /* I2C control */ 178#define REALVIEW_I2C_BASE 0x10002000 /* I2C control */
182 /* Reserved 0x10003000 */
183#define REALVIEW_AACI_BASE 0x10004000 /* Audio */ 179#define REALVIEW_AACI_BASE 0x10004000 /* Audio */
184#define REALVIEW_MMCI0_BASE 0x10005000 /* MMC interface */ 180#define REALVIEW_MMCI0_BASE 0x10005000 /* MMC interface */
185#define REALVIEW_KMI0_BASE 0x10006000 /* KMI interface */ 181#define REALVIEW_KMI0_BASE 0x10006000 /* KMI interface */
186#define REALVIEW_KMI1_BASE 0x10007000 /* KMI 2nd interface */ 182#define REALVIEW_KMI1_BASE 0x10007000 /* KMI 2nd interface */
187#define REALVIEW_CHAR_LCD_BASE 0x10008000 /* Character LCD */ 183#define REALVIEW_CHAR_LCD_BASE 0x10008000 /* Character LCD */
188#define REALVIEW_UART0_BASE 0x10009000 /* UART 0 */
189#define REALVIEW_UART1_BASE 0x1000A000 /* UART 1 */
190#define REALVIEW_UART2_BASE 0x1000B000 /* UART 2 */
191#define REALVIEW_UART3_BASE 0x1000C000 /* UART 3 */
192#define REALVIEW_SSP_BASE 0x1000D000 /* Synchronous Serial Port */
193#define REALVIEW_SCI_BASE 0x1000E000 /* Smart card controller */ 184#define REALVIEW_SCI_BASE 0x1000E000 /* Smart card controller */
194 /* Reserved 0x1000F000 */
195#define REALVIEW_WATCHDOG_BASE 0x10010000 /* watchdog interface */
196#define REALVIEW_TIMER0_1_BASE 0x10011000 /* Timer 0 and 1 */
197#define REALVIEW_TIMER2_3_BASE 0x10012000 /* Timer 2 and 3 */
198#define REALVIEW_GPIO0_BASE 0x10013000 /* GPIO port 0 */
199#define REALVIEW_GPIO1_BASE 0x10014000 /* GPIO port 1 */ 185#define REALVIEW_GPIO1_BASE 0x10014000 /* GPIO port 1 */
200#define REALVIEW_GPIO2_BASE 0x10015000 /* GPIO port 2 */ 186#define REALVIEW_GPIO2_BASE 0x10015000 /* GPIO port 2 */
201 /* Reserved 0x10016000 */
202#define REALVIEW_RTC_BASE 0x10017000 /* Real Time Clock */
203#define REALVIEW_DMC_BASE 0x10018000 /* DMC configuration */ 187#define REALVIEW_DMC_BASE 0x10018000 /* DMC configuration */
204#define REALVIEW_PCI_CORE_BASE 0x10019000 /* PCI configuration */
205 /* Reserved 0x1001A000 - 0x1001FFFF */
206#define REALVIEW_CLCD_BASE 0x10020000 /* CLCD */
207#define REALVIEW_DMAC_BASE 0x10030000 /* DMA controller */ 188#define REALVIEW_DMAC_BASE 0x10030000 /* DMA controller */
208#define REALVIEW_GIC_CPU_BASE 0x10040000 /* Generic interrupt controller CPU interface */
209#define REALVIEW_GIC_DIST_BASE 0x10041000 /* Generic interrupt controller distributor */
210#define REALVIEW_SMC_BASE 0x10080000 /* SMC */
211 /* Reserved 0x10090000 - 0x100EFFFF */
212
213#define REALVIEW_ETH_BASE 0x4E000000 /* Ethernet */
214 189
215/* PCI space */ 190/* PCI space */
216#define REALVIEW_PCI_BASE 0x41000000 /* PCI Interface */ 191#define REALVIEW_PCI_BASE 0x41000000 /* PCI Interface */
diff --git a/include/asm-arm/arch-realview/scu.h b/include/asm-arm/arch-realview/scu.h
index 08b3db883c36..d55802d645af 100644
--- a/include/asm-arm/arch-realview/scu.h
+++ b/include/asm-arm/arch-realview/scu.h
@@ -1,8 +1,13 @@
1#ifndef __ASMARM_ARCH_SCU_H 1#ifndef __ASMARM_ARCH_SCU_H
2#define __ASMARM_ARCH_SCU_H 2#define __ASMARM_ARCH_SCU_H
3 3
4#include <asm/arch/board-eb.h> 4/*
5 5 * SCU registers
6#define SCU_BASE REALVIEW_EB11MP_SCU_BASE 6 */
7#define SCU_CTRL 0x00
8#define SCU_CONFIG 0x04
9#define SCU_CPU_STATUS 0x08
10#define SCU_INVALIDATE 0x0c
11#define SCU_FPGA_REVISION 0x10
7 12
8#endif 13#endif
diff --git a/include/asm-arm/arch-realview/uncompress.h b/include/asm-arm/arch-realview/uncompress.h
index 3d5c2db07a26..4c905d7a13a1 100644
--- a/include/asm-arm/arch-realview/uncompress.h
+++ b/include/asm-arm/arch-realview/uncompress.h
@@ -18,28 +18,50 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#include <asm/hardware.h> 20#include <asm/hardware.h>
21#include <asm/mach-types.h>
21 22
22#include <asm/arch/platform.h> 23#include <asm/arch/board-eb.h>
24#include <asm/arch/board-pb11mp.h>
25#include <asm/arch/board-pb1176.h>
23 26
24#define AMBA_UART_DR (*(volatile unsigned char *) (REALVIEW_UART0_BASE + 0x00)) 27#define AMBA_UART_DR(base) (*(volatile unsigned char *)((base) + 0x00))
25#define AMBA_UART_LCRH (*(volatile unsigned char *) (REALVIEW_UART0_BASE + 0x2c)) 28#define AMBA_UART_LCRH(base) (*(volatile unsigned char *)((base) + 0x2c))
26#define AMBA_UART_CR (*(volatile unsigned char *) (REALVIEW_UART0_BASE + 0x30)) 29#define AMBA_UART_CR(base) (*(volatile unsigned char *)((base) + 0x30))
27#define AMBA_UART_FR (*(volatile unsigned char *) (REALVIEW_UART0_BASE + 0x18)) 30#define AMBA_UART_FR(base) (*(volatile unsigned char *)((base) + 0x18))
31
32/*
33 * Return the UART base address
34 */
35static inline unsigned long get_uart_base(void)
36{
37 if (machine_is_realview_eb())
38 return REALVIEW_EB_UART0_BASE;
39 else if (machine_is_realview_pb11mp())
40 return REALVIEW_PB11MP_UART0_BASE;
41 else if (machine_is_realview_pb1176())
42 return REALVIEW_PB1176_UART0_BASE;
43 else
44 return 0;
45}
28 46
29/* 47/*
30 * This does not append a newline 48 * This does not append a newline
31 */ 49 */
32static inline void putc(int c) 50static inline void putc(int c)
33{ 51{
34 while (AMBA_UART_FR & (1 << 5)) 52 unsigned long base = get_uart_base();
53
54 while (AMBA_UART_FR(base) & (1 << 5))
35 barrier(); 55 barrier();
36 56
37 AMBA_UART_DR = c; 57 AMBA_UART_DR(base) = c;
38} 58}
39 59
40static inline void flush(void) 60static inline void flush(void)
41{ 61{
42 while (AMBA_UART_FR & (1 << 3)) 62 unsigned long base = get_uart_base();
63
64 while (AMBA_UART_FR(base) & (1 << 3))
43 barrier(); 65 barrier();
44} 66}
45 67
diff --git a/include/asm-arm/arch-s3c2410/regs-clock.h b/include/asm-arm/arch-s3c2410/regs-clock.h
index dba9df9d8713..ecae9e7f5e45 100644
--- a/include/asm-arm/arch-s3c2410/regs-clock.h
+++ b/include/asm-arm/arch-s3c2410/regs-clock.h
@@ -137,7 +137,7 @@ s3c2410_get_pll(unsigned int pllval, unsigned int baseclk)
137 137
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 S3C2412_CLKDIVN_ARMDIVN (1<<3)
141#define S3C2412_CLKDIVN_DVSEN (1<<4) 141#define S3C2412_CLKDIVN_DVSEN (1<<4)
142#define S3C2412_CLKDIVN_HALFHCLK (1<<5) 142#define S3C2412_CLKDIVN_HALFHCLK (1<<5)
143#define S3C2412_CLKDIVN_USB48DIV (1<<6) 143#define S3C2412_CLKDIVN_USB48DIV (1<<6)
diff --git a/include/asm-arm/arch-s3c2410/regs-gpio.h b/include/asm-arm/arch-s3c2410/regs-gpio.h
index 0ad75d716ded..497dd06e2c99 100644
--- a/include/asm-arm/arch-s3c2410/regs-gpio.h
+++ b/include/asm-arm/arch-s3c2410/regs-gpio.h
@@ -529,11 +529,13 @@
529#define S3C2410_GPD14_INP (0x00 << 28) 529#define S3C2410_GPD14_INP (0x00 << 28)
530#define S3C2410_GPD14_OUTP (0x01 << 28) 530#define S3C2410_GPD14_OUTP (0x01 << 28)
531#define S3C2410_GPD14_VD22 (0x02 << 28) 531#define S3C2410_GPD14_VD22 (0x02 << 28)
532#define S3C2410_GPD14_nSS1 (0x03 << 28)
532 533
533#define S3C2410_GPD15 S3C2410_GPIONO(S3C2410_GPIO_BANKD, 15) 534#define S3C2410_GPD15 S3C2410_GPIONO(S3C2410_GPIO_BANKD, 15)
534#define S3C2410_GPD15_INP (0x00 << 30) 535#define S3C2410_GPD15_INP (0x00 << 30)
535#define S3C2410_GPD15_OUTP (0x01 << 30) 536#define S3C2410_GPD15_OUTP (0x01 << 30)
536#define S3C2410_GPD15_VD23 (0x02 << 30) 537#define S3C2410_GPD15_VD23 (0x02 << 30)
538#define S3C2410_GPD15_nSS0 (0x03 << 30)
537 539
538#define S3C2410_GPD_PUPDIS(x) (1<<(x)) 540#define S3C2410_GPD_PUPDIS(x) (1<<(x))
539 541
@@ -801,12 +803,14 @@
801#define S3C2410_GPG2_INP (0x00 << 4) 803#define S3C2410_GPG2_INP (0x00 << 4)
802#define S3C2410_GPG2_OUTP (0x01 << 4) 804#define S3C2410_GPG2_OUTP (0x01 << 4)
803#define S3C2410_GPG2_EINT10 (0x02 << 4) 805#define S3C2410_GPG2_EINT10 (0x02 << 4)
806#define S3C2410_GPG2_nSS0 (0x03 << 4)
804#define S3C2400_GPG2_CDCLK (0x02 << 4) 807#define S3C2400_GPG2_CDCLK (0x02 << 4)
805 808
806#define S3C2410_GPG3 S3C2410_GPIONO(S3C2410_GPIO_BANKG, 3) 809#define S3C2410_GPG3 S3C2410_GPIONO(S3C2410_GPIO_BANKG, 3)
807#define S3C2410_GPG3_INP (0x00 << 6) 810#define S3C2410_GPG3_INP (0x00 << 6)
808#define S3C2410_GPG3_OUTP (0x01 << 6) 811#define S3C2410_GPG3_OUTP (0x01 << 6)
809#define S3C2410_GPG3_EINT11 (0x02 << 6) 812#define S3C2410_GPG3_EINT11 (0x02 << 6)
813#define S3C2410_GPG3_nSS1 (0x03 << 6)
810#define S3C2400_GPG3_I2SSDO (0x02 << 6) 814#define S3C2400_GPG3_I2SSDO (0x02 << 6)
811#define S3C2400_GPG3_I2SSDI (0x03 << 6) 815#define S3C2400_GPG3_I2SSDI (0x03 << 6)
812 816
diff --git a/include/asm-arm/arch-s3c2410/regs-s3c2412-mem.h b/include/asm-arm/arch-s3c2410/regs-s3c2412-mem.h
new file mode 100644
index 000000000000..c8c793e78936
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/regs-s3c2412-mem.h
@@ -0,0 +1,29 @@
1/* linux/include/asm-arm/arch-s3c2410/regs-s3c2412-mem.h
2 *
3 * Copyright (c) 2008 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 * http://armlinux.simtec.co.uk/
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 version 2 as
9 * published by the Free Software Foundation.
10 *
11 * S3C2412 memory register definitions
12*/
13
14#ifndef __ASM_ARM_REGS_S3C2412_MEM
15#define __ASM_ARM_REGS_S3C2412_MEM
16
17#ifndef S3C2412_MEMREG
18#define S3C2412_MEMREG(x) (S3C24XX_VA_MEMCTRL + (x))
19#endif
20
21#define S3C2412_BANKCFG S3C2412_MEMREG(0x00)
22#define S3C2412_BANKCON1 S3C2412_MEMREG(0x04)
23#define S3C2412_BANKCON2 S3C2412_MEMREG(0x08)
24#define S3C2412_BANKCON3 S3C2412_MEMREG(0x0C)
25
26#define S3C2412_REFRESH S3C2412_MEMREG(0x10)
27#define S3C2412_TIMEOUT S3C2412_MEMREG(0x14)
28
29#endif /* __ASM_ARM_REGS_S3C2412_MEM */
diff --git a/include/asm-arm/arch-s3c2410/system-reset.h b/include/asm-arm/arch-s3c2410/system-reset.h
new file mode 100644
index 000000000000..1615bce0c026
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/system-reset.h
@@ -0,0 +1,64 @@
1/* linux/include/asm-arm/arch-s3c2410/system-reset.h
2 *
3 * Copyright (c) 2008 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 - System define for arch_reset() function
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
13#include <asm/hardware.h>
14#include <asm/io.h>
15
16#include <asm/plat-s3c/regs-watchdog.h>
17#include <asm/arch/regs-clock.h>
18
19#include <linux/clk.h>
20#include <linux/err.h>
21
22extern void (*s3c24xx_reset_hook)(void);
23
24static void
25arch_reset(char mode)
26{
27 struct clk *wdtclk;
28
29 if (mode == 's') {
30 cpu_reset(0);
31 }
32
33 if (s3c24xx_reset_hook)
34 s3c24xx_reset_hook();
35
36 printk("arch_reset: attempting watchdog reset\n");
37
38 __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */
39
40 wdtclk = clk_get(NULL, "watchdog");
41 if (!IS_ERR(wdtclk)) {
42 clk_enable(wdtclk);
43 } else
44 printk(KERN_WARNING "%s: warning: cannot get watchdog clock\n", __func__);
45
46 /* put initial values into count and data */
47 __raw_writel(0x80, S3C2410_WTCNT);
48 __raw_writel(0x80, S3C2410_WTDAT);
49
50 /* set the watchdog to go and reset... */
51 __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN |
52 S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON);
53
54 /* wait for reset to assert... */
55 mdelay(500);
56
57 printk(KERN_ERR "Watchdog reset failed to assert reset\n");
58
59 /* delay to allow the serial port to show the message */
60 mdelay(50);
61
62 /* we'll take a jump through zero as a poor second */
63 cpu_reset(0);
64}
diff --git a/include/asm-arm/arch-s3c2410/system.h b/include/asm-arm/arch-s3c2410/system.h
index 14de4e596f87..ad258085e53b 100644
--- a/include/asm-arm/arch-s3c2410/system.h
+++ b/include/asm-arm/arch-s3c2410/system.h
@@ -17,12 +17,8 @@
17#include <asm/arch/idle.h> 17#include <asm/arch/idle.h>
18#include <asm/arch/reset.h> 18#include <asm/arch/reset.h>
19 19
20#include <asm/plat-s3c/regs-watchdog.h>
21#include <asm/arch/regs-clock.h> 20#include <asm/arch/regs-clock.h>
22 21
23#include <linux/clk.h>
24#include <linux/err.h>
25
26void (*s3c24xx_idle)(void); 22void (*s3c24xx_idle)(void);
27void (*s3c24xx_reset_hook)(void); 23void (*s3c24xx_reset_hook)(void);
28 24
@@ -59,44 +55,4 @@ static void arch_idle(void)
59 s3c24xx_default_idle(); 55 s3c24xx_default_idle();
60} 56}
61 57
62static void 58#include <asm/arch/system-reset.h>
63arch_reset(char mode)
64{
65 struct clk *wdtclk;
66
67 if (mode == 's') {
68 cpu_reset(0);
69 }
70
71 if (s3c24xx_reset_hook)
72 s3c24xx_reset_hook();
73
74 printk("arch_reset: attempting watchdog reset\n");
75
76 __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */
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
84 /* put initial values into count and data */
85 __raw_writel(0x80, S3C2410_WTCNT);
86 __raw_writel(0x80, S3C2410_WTDAT);
87
88 /* set the watchdog to go and reset... */
89 __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN |
90 S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON);
91
92 /* wait for reset to assert... */
93 mdelay(500);
94
95 printk(KERN_ERR "Watchdog reset failed to assert reset\n");
96
97 /* delay to allow the serial port to show the message */
98 mdelay(50);
99
100 /* we'll take a jump through zero as a poor second */
101 cpu_reset(0);
102}
diff --git a/include/asm-arm/arch-sa1100/gpio.h b/include/asm-arm/arch-sa1100/gpio.h
index e7a9d26e22a8..93d3395b102d 100644
--- a/include/asm-arm/arch-sa1100/gpio.h
+++ b/include/asm-arm/arch-sa1100/gpio.h
@@ -26,35 +26,28 @@
26 26
27#include <asm/hardware.h> 27#include <asm/hardware.h>
28#include <asm/irq.h> 28#include <asm/irq.h>
29 29#include <asm-generic/gpio.h>
30static inline int gpio_request(unsigned gpio, const char *label)
31{
32 return 0;
33}
34
35static inline void gpio_free(unsigned gpio)
36{
37 return;
38}
39
40extern int gpio_direction_input(unsigned gpio);
41extern int gpio_direction_output(unsigned gpio, int value);
42
43 30
44static inline int gpio_get_value(unsigned gpio) 31static inline int gpio_get_value(unsigned gpio)
45{ 32{
46 return GPLR & GPIO_GPIO(gpio); 33 if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX))
34 return GPLR & GPIO_GPIO(gpio);
35 else
36 return __gpio_get_value(gpio);
47} 37}
48 38
49static inline void gpio_set_value(unsigned gpio, int value) 39static inline void gpio_set_value(unsigned gpio, int value)
50{ 40{
51 if (value) 41 if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX))
52 GPSR = GPIO_GPIO(gpio); 42 if (value)
43 GPSR = GPIO_GPIO(gpio);
44 else
45 GPCR = GPIO_GPIO(gpio);
53 else 46 else
54 GPCR = GPIO_GPIO(gpio); 47 __gpio_set_value(gpio, value);
55} 48}
56 49
57#include <asm-generic/gpio.h> /* cansleep wrappers */ 50#define gpio_cansleep __gpio_cansleep
58 51
59static inline unsigned gpio_to_irq(unsigned gpio) 52static inline unsigned gpio_to_irq(unsigned gpio)
60{ 53{
diff --git a/include/asm-arm/arch-sa1100/ide.h b/include/asm-arm/arch-sa1100/ide.h
index 98b10bcf9f1b..b14cbda01dc3 100644
--- a/include/asm-arm/arch-sa1100/ide.h
+++ b/include/asm-arm/arch-sa1100/ide.h
@@ -37,12 +37,12 @@ static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
37 37
38 memset(hw, 0, sizeof(*hw)); 38 memset(hw, 0, sizeof(*hw));
39 39
40 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { 40 for (i = 0; i <= 7; i++) {
41 hw->io_ports[i] = reg; 41 hw->io_ports_array[i] = reg;
42 reg += regincr; 42 reg += regincr;
43 } 43 }
44 44
45 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; 45 hw->io_ports.ctl_addr = ctrl_port;
46 46
47 if (irq) 47 if (irq)
48 *irq = 0; 48 *irq = 0;
diff --git a/include/asm-arm/cpu-multi32.h b/include/asm-arm/cpu-multi32.h
index 715e18a4add1..3479de9266e5 100644
--- a/include/asm-arm/cpu-multi32.h
+++ b/include/asm-arm/cpu-multi32.h
@@ -21,6 +21,10 @@ extern struct processor {
21 */ 21 */
22 void (*_data_abort)(unsigned long pc); 22 void (*_data_abort)(unsigned long pc);
23 /* 23 /*
24 * Retrieve prefetch fault address
25 */
26 unsigned long (*_prefetch_abort)(unsigned long lr);
27 /*
24 * Set up any processor specifics 28 * Set up any processor specifics
25 */ 29 */
26 void (*_proc_init)(void); 30 void (*_proc_init)(void);
diff --git a/include/asm-arm/div64.h b/include/asm-arm/div64.h
index 0b5f881c3d85..5001390be958 100644
--- a/include/asm-arm/div64.h
+++ b/include/asm-arm/div64.h
@@ -224,6 +224,4 @@
224 224
225#endif 225#endif
226 226
227extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
228
229#endif 227#endif
diff --git a/include/asm-arm/glue.h b/include/asm-arm/glue.h
index 22274ce81375..a97a182ba287 100644
--- a/include/asm-arm/glue.h
+++ b/include/asm-arm/glue.h
@@ -40,83 +40,110 @@
40 * v6_early - ARMv6 generic early abort handler 40 * v6_early - ARMv6 generic early abort handler
41 * v7_early - ARMv7 generic early abort handler 41 * v7_early - ARMv7 generic early abort handler
42 */ 42 */
43#undef CPU_ABORT_HANDLER 43#undef CPU_DABORT_HANDLER
44#undef MULTI_ABORT 44#undef MULTI_DABORT
45 45
46#if defined(CONFIG_CPU_ARM610) 46#if defined(CONFIG_CPU_ARM610)
47# ifdef CPU_ABORT_HANDLER 47# ifdef CPU_DABORT_HANDLER
48# define MULTI_ABORT 1 48# define MULTI_DABORT 1
49# else 49# else
50# define CPU_ABORT_HANDLER cpu_arm6_data_abort 50# define CPU_DABORT_HANDLER cpu_arm6_data_abort
51# endif 51# endif
52#endif 52#endif
53 53
54#if defined(CONFIG_CPU_ARM710) 54#if defined(CONFIG_CPU_ARM710)
55# ifdef CPU_ABORT_HANDLER 55# ifdef CPU_DABORT_HANDLER
56# define MULTI_ABORT 1 56# define MULTI_DABORT 1
57# else 57# else
58# define CPU_ABORT_HANDLER cpu_arm7_data_abort 58# define CPU_DABORT_HANDLER cpu_arm7_data_abort
59# endif 59# endif
60#endif 60#endif
61 61
62#ifdef CONFIG_CPU_ABRT_LV4T 62#ifdef CONFIG_CPU_ABRT_LV4T
63# ifdef CPU_ABORT_HANDLER 63# ifdef CPU_DABORT_HANDLER
64# define MULTI_ABORT 1 64# define MULTI_DABORT 1
65# else 65# else
66# define CPU_ABORT_HANDLER v4t_late_abort 66# define CPU_DABORT_HANDLER v4t_late_abort
67# endif 67# endif
68#endif 68#endif
69 69
70#ifdef CONFIG_CPU_ABRT_EV4 70#ifdef CONFIG_CPU_ABRT_EV4
71# ifdef CPU_ABORT_HANDLER 71# ifdef CPU_DABORT_HANDLER
72# define MULTI_ABORT 1 72# define MULTI_DABORT 1
73# else 73# else
74# define CPU_ABORT_HANDLER v4_early_abort 74# define CPU_DABORT_HANDLER v4_early_abort
75# endif 75# endif
76#endif 76#endif
77 77
78#ifdef CONFIG_CPU_ABRT_EV4T 78#ifdef CONFIG_CPU_ABRT_EV4T
79# ifdef CPU_ABORT_HANDLER 79# ifdef CPU_DABORT_HANDLER
80# define MULTI_ABORT 1 80# define MULTI_DABORT 1
81# else 81# else
82# define CPU_ABORT_HANDLER v4t_early_abort 82# define CPU_DABORT_HANDLER v4t_early_abort
83# endif 83# endif
84#endif 84#endif
85 85
86#ifdef CONFIG_CPU_ABRT_EV5TJ 86#ifdef CONFIG_CPU_ABRT_EV5TJ
87# ifdef CPU_ABORT_HANDLER 87# ifdef CPU_DABORT_HANDLER
88# define MULTI_ABORT 1 88# define MULTI_DABORT 1
89# else 89# else
90# define CPU_ABORT_HANDLER v5tj_early_abort 90# define CPU_DABORT_HANDLER v5tj_early_abort
91# endif 91# endif
92#endif 92#endif
93 93
94#ifdef CONFIG_CPU_ABRT_EV5T 94#ifdef CONFIG_CPU_ABRT_EV5T
95# ifdef CPU_ABORT_HANDLER 95# ifdef CPU_DABORT_HANDLER
96# define MULTI_ABORT 1 96# define MULTI_DABORT 1
97# else 97# else
98# define CPU_ABORT_HANDLER v5t_early_abort 98# define CPU_DABORT_HANDLER v5t_early_abort
99# endif 99# endif
100#endif 100#endif
101 101
102#ifdef CONFIG_CPU_ABRT_EV6 102#ifdef CONFIG_CPU_ABRT_EV6
103# ifdef CPU_ABORT_HANDLER 103# ifdef CPU_DABORT_HANDLER
104# define MULTI_ABORT 1 104# define MULTI_DABORT 1
105# else 105# else
106# define CPU_ABORT_HANDLER v6_early_abort 106# define CPU_DABORT_HANDLER v6_early_abort
107# endif 107# endif
108#endif 108#endif
109 109
110#ifdef CONFIG_CPU_ABRT_EV7 110#ifdef CONFIG_CPU_ABRT_EV7
111# ifdef CPU_ABORT_HANDLER 111# ifdef CPU_DABORT_HANDLER
112# define MULTI_ABORT 1 112# define MULTI_DABORT 1
113# else 113# else
114# define CPU_ABORT_HANDLER v7_early_abort 114# define CPU_DABORT_HANDLER v7_early_abort
115# endif 115# endif
116#endif 116#endif
117 117
118#ifndef CPU_ABORT_HANDLER 118#ifndef CPU_DABORT_HANDLER
119#error Unknown data abort handler type 119#error Unknown data abort handler type
120#endif 120#endif
121 121
122/*
123 * Prefetch abort handler. If the CPU has an IFAR use that, otherwise
124 * use the address of the aborted instruction
125 */
126#undef CPU_PABORT_HANDLER
127#undef MULTI_PABORT
128
129#ifdef CONFIG_CPU_PABRT_IFAR
130# ifdef CPU_PABORT_HANDLER
131# define MULTI_PABORT 1
132# else
133# define CPU_PABORT_HANDLER(reg, insn) mrc p15, 0, reg, cr6, cr0, 2
134# endif
135#endif
136
137#ifdef CONFIG_CPU_PABRT_NOIFAR
138# ifdef CPU_PABORT_HANDLER
139# define MULTI_PABORT 1
140# else
141# define CPU_PABORT_HANDLER(reg, insn) mov reg, insn
142# endif
143#endif
144
145#ifndef CPU_PABORT_HANDLER
146#error Unknown prefetch abort handler type
147#endif
148
122#endif 149#endif
diff --git a/include/asm-arm/hardware/arm_scu.h b/include/asm-arm/hardware/arm_scu.h
deleted file mode 100644
index 7d28eb5a1758..000000000000
--- a/include/asm-arm/hardware/arm_scu.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef ASMARM_HARDWARE_ARM_SCU_H
2#define ASMARM_HARDWARE_ARM_SCU_H
3
4#include <asm/arch/scu.h>
5
6/*
7 * SCU registers
8 */
9#define SCU_CTRL 0x00
10#define SCU_CONFIG 0x04
11#define SCU_CPU_STATUS 0x08
12#define SCU_INVALIDATE 0x0c
13#define SCU_FPGA_REVISION 0x10
14
15#endif
diff --git a/include/asm-arm/hardware/iop3xx-adma.h b/include/asm-arm/hardware/iop3xx-adma.h
index 5c529e6a5e3b..a32b86ac62aa 100644
--- a/include/asm-arm/hardware/iop3xx-adma.h
+++ b/include/asm-arm/hardware/iop3xx-adma.h
@@ -260,7 +260,7 @@ static inline int iop_chan_memset_slot_count(size_t len, int *slots_per_op)
260static inline int iop3xx_aau_xor_slot_count(size_t len, int src_cnt, 260static inline int iop3xx_aau_xor_slot_count(size_t len, int src_cnt,
261 int *slots_per_op) 261 int *slots_per_op)
262{ 262{
263 const static int slot_count_table[] = { 0, 263 static const int slot_count_table[] = { 0,
264 1, 1, 1, 1, /* 01 - 04 */ 264 1, 1, 1, 1, /* 01 - 04 */
265 2, 2, 2, 2, /* 05 - 08 */ 265 2, 2, 2, 2, /* 05 - 08 */
266 4, 4, 4, 4, /* 09 - 12 */ 266 4, 4, 4, 4, /* 09 - 12 */
@@ -369,7 +369,7 @@ static inline u32 iop_desc_get_byte_count(struct iop_adma_desc_slot *desc,
369/* translate the src_idx to a descriptor word index */ 369/* translate the src_idx to a descriptor word index */
370static inline int __desc_idx(int src_idx) 370static inline int __desc_idx(int src_idx)
371{ 371{
372 const static int desc_idx_table[] = { 0, 0, 0, 0, 372 static const int desc_idx_table[] = { 0, 0, 0, 0,
373 0, 1, 2, 3, 373 0, 1, 2, 3,
374 5, 6, 7, 8, 374 5, 6, 7, 8,
375 9, 10, 11, 12, 375 9, 10, 11, 12,
@@ -767,20 +767,12 @@ static inline int iop_desc_get_zero_result(struct iop_adma_desc_slot *desc)
767static inline void iop_chan_append(struct iop_adma_chan *chan) 767static inline void iop_chan_append(struct iop_adma_chan *chan)
768{ 768{
769 u32 dma_chan_ctrl; 769 u32 dma_chan_ctrl;
770 /* workaround dropped interrupts on 3xx */
771 mod_timer(&chan->cleanup_watchdog, jiffies + msecs_to_jiffies(3));
772 770
773 dma_chan_ctrl = __raw_readl(DMA_CCR(chan)); 771 dma_chan_ctrl = __raw_readl(DMA_CCR(chan));
774 dma_chan_ctrl |= 0x2; 772 dma_chan_ctrl |= 0x2;
775 __raw_writel(dma_chan_ctrl, DMA_CCR(chan)); 773 __raw_writel(dma_chan_ctrl, DMA_CCR(chan));
776} 774}
777 775
778static inline void iop_chan_idle(int busy, struct iop_adma_chan *chan)
779{
780 if (!busy)
781 del_timer(&chan->cleanup_watchdog);
782}
783
784static inline u32 iop_chan_get_status(struct iop_adma_chan *chan) 776static inline u32 iop_chan_get_status(struct iop_adma_chan *chan)
785{ 777{
786 return __raw_readl(DMA_CSR(chan)); 778 return __raw_readl(DMA_CSR(chan));
diff --git a/include/asm-arm/hardware/iop3xx.h b/include/asm-arm/hardware/iop3xx.h
index ede377ec9147..18f6937f5010 100644
--- a/include/asm-arm/hardware/iop3xx.h
+++ b/include/asm-arm/hardware/iop3xx.h
@@ -29,6 +29,7 @@ extern void gpio_line_config(int line, int direction);
29extern int gpio_line_get(int line); 29extern int gpio_line_get(int line);
30extern void gpio_line_set(int line, int value); 30extern void gpio_line_set(int line, int value);
31extern int init_atu; 31extern int init_atu;
32extern int iop3xx_get_init_atu(void);
32#endif 33#endif
33 34
34 35
@@ -112,14 +113,6 @@ extern int init_atu;
112#define IOP3XX_INIT_ATU_DISABLE -1 113#define IOP3XX_INIT_ATU_DISABLE -1
113#define IOP3XX_INIT_ATU_ENABLE 1 114#define IOP3XX_INIT_ATU_ENABLE 1
114 115
115#ifdef CONFIG_IOP3XX_ATU
116#define iop3xx_get_init_atu(x) (init_atu == IOP3XX_INIT_ATU_DEFAULT ?\
117 IOP3XX_INIT_ATU_ENABLE : init_atu)
118#else
119#define iop3xx_get_init_atu(x) (init_atu == IOP3XX_INIT_ATU_DEFAULT ?\
120 IOP3XX_INIT_ATU_DISABLE : init_atu)
121#endif
122
123/* Messaging Unit */ 116/* Messaging Unit */
124#define IOP3XX_IMR0 (volatile u32 *)IOP3XX_REG_ADDR(0x0310) 117#define IOP3XX_IMR0 (volatile u32 *)IOP3XX_REG_ADDR(0x0310)
125#define IOP3XX_IMR1 (volatile u32 *)IOP3XX_REG_ADDR(0x0314) 118#define IOP3XX_IMR1 (volatile u32 *)IOP3XX_REG_ADDR(0x0314)
diff --git a/include/asm-arm/hardware/iop_adma.h b/include/asm-arm/hardware/iop_adma.h
index ca8e71f44346..cb7e3611bcba 100644
--- a/include/asm-arm/hardware/iop_adma.h
+++ b/include/asm-arm/hardware/iop_adma.h
@@ -51,7 +51,6 @@ struct iop_adma_device {
51 * @common: common dmaengine channel object members 51 * @common: common dmaengine channel object members
52 * @last_used: place holder for allocation to continue from where it left off 52 * @last_used: place holder for allocation to continue from where it left off
53 * @all_slots: complete domain of slots usable by the channel 53 * @all_slots: complete domain of slots usable by the channel
54 * @cleanup_watchdog: workaround missed interrupts on iop3xx
55 * @slots_allocated: records the actual size of the descriptor slot pool 54 * @slots_allocated: records the actual size of the descriptor slot pool
56 * @irq_tasklet: bottom half where iop_adma_slot_cleanup runs 55 * @irq_tasklet: bottom half where iop_adma_slot_cleanup runs
57 */ 56 */
@@ -65,7 +64,6 @@ struct iop_adma_chan {
65 struct dma_chan common; 64 struct dma_chan common;
66 struct iop_adma_desc_slot *last_used; 65 struct iop_adma_desc_slot *last_used;
67 struct list_head all_slots; 66 struct list_head all_slots;
68 struct timer_list cleanup_watchdog;
69 int slots_allocated; 67 int slots_allocated;
70 struct tasklet_struct irq_tasklet; 68 struct tasklet_struct irq_tasklet;
71}; 69};
diff --git a/include/asm-arm/hardware/scoop.h b/include/asm-arm/hardware/scoop.h
index d37bf7443264..dfb8330599f9 100644
--- a/include/asm-arm/hardware/scoop.h
+++ b/include/asm-arm/hardware/scoop.h
@@ -40,6 +40,7 @@ struct scoop_config {
40 unsigned short io_dir; 40 unsigned short io_dir;
41 unsigned short suspend_clr; 41 unsigned short suspend_clr;
42 unsigned short suspend_set; 42 unsigned short suspend_set;
43 int gpio_base;
43}; 44};
44 45
45/* Structure for linking scoop devices to PCMCIA sockets */ 46/* Structure for linking scoop devices to PCMCIA sockets */
@@ -62,7 +63,7 @@ struct scoop_pcmcia_config {
62extern struct scoop_pcmcia_config *platform_scoop_config; 63extern struct scoop_pcmcia_config *platform_scoop_config;
63 64
64void reset_scoop(struct device *dev); 65void reset_scoop(struct device *dev);
65unsigned short set_scoop_gpio(struct device *dev, unsigned short bit); 66unsigned short __deprecated set_scoop_gpio(struct device *dev, unsigned short bit);
66unsigned short reset_scoop_gpio(struct device *dev, unsigned short bit); 67unsigned short __deprecated reset_scoop_gpio(struct device *dev, unsigned short bit);
67unsigned short read_scoop_reg(struct device *dev, unsigned short reg); 68unsigned short read_scoop_reg(struct device *dev, unsigned short reg);
68void write_scoop_reg(struct device *dev, unsigned short reg, unsigned short data); 69void write_scoop_reg(struct device *dev, unsigned short reg, unsigned short data);
diff --git a/include/asm-arm/hwcap.h b/include/asm-arm/hwcap.h
index 01a1391d3014..81f4c899a555 100644
--- a/include/asm-arm/hwcap.h
+++ b/include/asm-arm/hwcap.h
@@ -15,6 +15,7 @@
15#define HWCAP_JAVA 256 15#define HWCAP_JAVA 256
16#define HWCAP_IWMMXT 512 16#define HWCAP_IWMMXT 512
17#define HWCAP_CRUNCH 1024 17#define HWCAP_CRUNCH 1024
18#define HWCAP_THUMBEE 2048
18 19
19#if defined(__KERNEL__) && !defined(__ASSEMBLY__) 20#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
20/* 21/*
diff --git a/include/asm-arm/ide.h b/include/asm-arm/ide.h
index f348fcf3150b..88f4d231ce4f 100644
--- a/include/asm-arm/ide.h
+++ b/include/asm-arm/ide.h
@@ -17,14 +17,6 @@
17#define MAX_HWIFS 4 17#define MAX_HWIFS 4
18#endif 18#endif
19 19
20#if !defined(CONFIG_ARCH_L7200)
21# ifdef CONFIG_ARCH_CLPS7500
22# define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
23# else
24# define ide_default_io_ctl(base) (0)
25# endif
26#endif /* !ARCH_L7200 */
27
28#define __ide_mm_insw(port,addr,len) readsw(port,addr,len) 20#define __ide_mm_insw(port,addr,len) readsw(port,addr,len)
29#define __ide_mm_insl(port,addr,len) readsl(port,addr,len) 21#define __ide_mm_insl(port,addr,len) readsl(port,addr,len)
30#define __ide_mm_outsw(port,addr,len) writesw(port,addr,len) 22#define __ide_mm_outsw(port,addr,len) writesw(port,addr,len)
diff --git a/include/asm-arm/mach/pci.h b/include/asm-arm/mach/pci.h
index 24621c49a0c7..9d4f6b5ea419 100644
--- a/include/asm-arm/mach/pci.h
+++ b/include/asm-arm/mach/pci.h
@@ -55,6 +55,7 @@ void pci_common_init(struct hw_pci *);
55extern int iop3xx_pci_setup(int nr, struct pci_sys_data *); 55extern int iop3xx_pci_setup(int nr, struct pci_sys_data *);
56extern struct pci_bus *iop3xx_pci_scan_bus(int nr, struct pci_sys_data *); 56extern struct pci_bus *iop3xx_pci_scan_bus(int nr, struct pci_sys_data *);
57extern void iop3xx_pci_preinit(void); 57extern void iop3xx_pci_preinit(void);
58extern void iop3xx_pci_preinit_cond(void);
58 59
59extern int dc21285_setup(int nr, struct pci_sys_data *); 60extern int dc21285_setup(int nr, struct pci_sys_data *);
60extern struct pci_bus *dc21285_scan_bus(int nr, struct pci_sys_data *); 61extern struct pci_bus *dc21285_scan_bus(int nr, struct pci_sys_data *);
diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h
index d9bfb39adabf..9ba4d7136e6b 100644
--- a/include/asm-arm/memory.h
+++ b/include/asm-arm/memory.h
@@ -217,7 +217,10 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
217#ifndef CONFIG_DISCONTIGMEM 217#ifndef CONFIG_DISCONTIGMEM
218 218
219#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET 219#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET
220
221#ifndef CONFIG_SPARSEMEM
220#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) 222#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
223#endif
221 224
222#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 225#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
223#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) 226#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory)
diff --git a/include/asm-arm/page.h b/include/asm-arm/page.h
index c86f68ee6511..5c22b0112106 100644
--- a/include/asm-arm/page.h
+++ b/include/asm-arm/page.h
@@ -71,6 +71,14 @@
71# endif 71# endif
72#endif 72#endif
73 73
74#ifdef CONFIG_CPU_COPY_FEROCEON
75# ifdef _USER
76# define MULTI_USER 1
77# else
78# define _USER feroceon
79# endif
80#endif
81
74#ifdef CONFIG_CPU_SA1100 82#ifdef CONFIG_CPU_SA1100
75# ifdef _USER 83# ifdef _USER
76# define MULTI_USER 1 84# define MULTI_USER 1
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index 5e0182485d8c..5571c13c3f3b 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -260,6 +260,7 @@ extern struct page *empty_zero_page;
260#define pte_write(pte) (pte_val(pte) & L_PTE_WRITE) 260#define pte_write(pte) (pte_val(pte) & L_PTE_WRITE)
261#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY) 261#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY)
262#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG) 262#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG)
263#define pte_special(pte) (0)
263 264
264/* 265/*
265 * The following only works if pte_present() is not true. 266 * The following only works if pte_present() is not true.
@@ -280,6 +281,8 @@ PTE_BIT_FUNC(mkdirty, |= L_PTE_DIRTY);
280PTE_BIT_FUNC(mkold, &= ~L_PTE_YOUNG); 281PTE_BIT_FUNC(mkold, &= ~L_PTE_YOUNG);
281PTE_BIT_FUNC(mkyoung, |= L_PTE_YOUNG); 282PTE_BIT_FUNC(mkyoung, |= L_PTE_YOUNG);
282 283
284static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
285
283/* 286/*
284 * Mark the prot value as uncacheable and unbufferable. 287 * Mark the prot value as uncacheable and unbufferable.
285 */ 288 */
diff --git a/include/asm-arm/plat-orion/ehci-orion.h b/include/asm-arm/plat-orion/ehci-orion.h
new file mode 100644
index 000000000000..785705651e24
--- /dev/null
+++ b/include/asm-arm/plat-orion/ehci-orion.h
@@ -0,0 +1,19 @@
1/*
2 * include/asm-arm/plat-orion/ehci-orion.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
9#ifndef __ASM_PLAT_ORION_EHCI_ORION_H
10#define __ASM_PLAT_ORION_EHCI_ORION_H
11
12#include <linux/mbus.h>
13
14struct orion_ehci_data {
15 struct mbus_dram_target_info *dram;
16};
17
18
19#endif
diff --git a/include/asm-arm/plat-orion/irq.h b/include/asm-arm/plat-orion/irq.h
new file mode 100644
index 000000000000..94aeed919d5b
--- /dev/null
+++ b/include/asm-arm/plat-orion/irq.h
@@ -0,0 +1,17 @@
1/*
2 * include/asm-arm/plat-orion/irq.h
3 *
4 * Marvell Orion SoC IRQ handling.
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_PLAT_ORION_IRQ_H
12#define __ASM_PLAT_ORION_IRQ_H
13
14void orion_irq_init(unsigned int irq_start, void __iomem *maskaddr);
15
16
17#endif
diff --git a/include/asm-arm/arch-orion/platform.h b/include/asm-arm/plat-orion/orion_nand.h
index 143c38e2fa0b..ffd3852a0dd7 100644
--- a/include/asm-arm/arch-orion/platform.h
+++ b/include/asm-arm/plat-orion/orion_nand.h
@@ -1,15 +1,13 @@
1/* 1/*
2 * asm-arm/arch-orion/platform.h 2 * include/asm-arm/plat-orion/orion_nand.h
3 *
4 * Tzachi Perelstein <tzachi@marvell.com>
5 * 3 *
6 * This file is licensed under the terms of the GNU General Public 4 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any 5 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied. 6 * warranty of any kind, whether express or implied.
9 */ 7 */
10 8
11#ifndef __ASM_ARCH_PLATFORM_H__ 9#ifndef __ASM_PLAT_ORION_ORION_NAND_H
12#define __ASM_ARCH_PLATFORM_H__ 10#define __ASM_PLAT_ORION_ORION_NAND_H
13 11
14/* 12/*
15 * Device bus NAND private data 13 * Device bus NAND private data
@@ -22,4 +20,5 @@ struct orion_nand_data {
22 u8 width; /* buswidth */ 20 u8 width; /* buswidth */
23}; 21};
24 22
23
25#endif 24#endif
diff --git a/include/asm-arm/plat-orion/pcie.h b/include/asm-arm/plat-orion/pcie.h
new file mode 100644
index 000000000000..6434ac685d21
--- /dev/null
+++ b/include/asm-arm/plat-orion/pcie.h
@@ -0,0 +1,31 @@
1/*
2 * include/asm-arm/plat-orion/pcie.h
3 *
4 * Marvell Orion SoC PCIe handling.
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_PLAT_ORION_PCIE_H
12#define __ASM_PLAT_ORION_PCIE_H
13
14u32 orion_pcie_dev_id(void __iomem *base);
15u32 orion_pcie_rev(void __iomem *base);
16int orion_pcie_link_up(void __iomem *base);
17int orion_pcie_get_local_bus_nr(void __iomem *base);
18void orion_pcie_set_local_bus_nr(void __iomem *base, int nr);
19void orion_pcie_setup(void __iomem *base,
20 struct mbus_dram_target_info *dram);
21int orion_pcie_rd_conf(void __iomem *base, struct pci_bus *bus,
22 u32 devfn, int where, int size, u32 *val);
23int orion_pcie_rd_conf_tlp(void __iomem *base, struct pci_bus *bus,
24 u32 devfn, int where, int size, u32 *val);
25int orion_pcie_rd_conf_wa(void __iomem *wa_base, struct pci_bus *bus,
26 u32 devfn, int where, int size, u32 *val);
27int orion_pcie_wr_conf(void __iomem *base, struct pci_bus *bus,
28 u32 devfn, int where, int size, u32 val);
29
30
31#endif
diff --git a/include/asm-arm/plat-orion/time.h b/include/asm-arm/plat-orion/time.h
new file mode 100644
index 000000000000..0e85cc8f44d9
--- /dev/null
+++ b/include/asm-arm/plat-orion/time.h
@@ -0,0 +1,17 @@
1/*
2 * include/asm-arm/plat-orion/time.h
3 *
4 * Marvell Orion SoC time handling.
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_PLAT_ORION_TIME_H
12#define __ASM_PLAT_ORION_TIME_H
13
14void orion_time_init(unsigned int irq, unsigned int tclk);
15
16
17#endif
diff --git a/include/asm-arm/plat-s3c/nand.h b/include/asm-arm/plat-s3c/nand.h
index 8816f7f9cee1..ad6bbe90616e 100644
--- a/include/asm-arm/plat-s3c/nand.h
+++ b/include/asm-arm/plat-s3c/nand.h
@@ -22,11 +22,14 @@
22*/ 22*/
23 23
24struct s3c2410_nand_set { 24struct s3c2410_nand_set {
25 unsigned int disable_ecc : 1;
26
25 int nr_chips; 27 int nr_chips;
26 int nr_partitions; 28 int nr_partitions;
27 char *name; 29 char *name;
28 int *nr_map; 30 int *nr_map;
29 struct mtd_partition *partitions; 31 struct mtd_partition *partitions;
32 struct nand_ecclayout *ecc_layout;
30}; 33};
31 34
32struct s3c2410_platform_nand { 35struct s3c2410_platform_nand {
@@ -36,6 +39,8 @@ struct s3c2410_platform_nand {
36 int twrph0; /* active time for nWE/nOE */ 39 int twrph0; /* active time for nWE/nOE */
37 int twrph1; /* time for release CLE/ALE from nWE/nOE inactive */ 40 int twrph1; /* time for release CLE/ALE from nWE/nOE inactive */
38 41
42 unsigned int ignore_unset_ecc : 1;
43
39 int nr_sets; 44 int nr_sets;
40 struct s3c2410_nand_set *sets; 45 struct s3c2410_nand_set *sets;
41 46
diff --git a/include/asm-arm/semaphore-helper.h b/include/asm-arm/semaphore-helper.h
deleted file mode 100644
index 1d7f1987edb9..000000000000
--- a/include/asm-arm/semaphore-helper.h
+++ /dev/null
@@ -1,84 +0,0 @@
1#ifndef ASMARM_SEMAPHORE_HELPER_H
2#define ASMARM_SEMAPHORE_HELPER_H
3
4/*
5 * These two _must_ execute atomically wrt each other.
6 */
7static inline void wake_one_more(struct semaphore * sem)
8{
9 unsigned long flags;
10
11 spin_lock_irqsave(&semaphore_wake_lock, flags);
12 if (atomic_read(&sem->count) <= 0)
13 sem->waking++;
14 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
15}
16
17static inline int waking_non_zero(struct semaphore *sem)
18{
19 unsigned long flags;
20 int ret = 0;
21
22 spin_lock_irqsave(&semaphore_wake_lock, flags);
23 if (sem->waking > 0) {
24 sem->waking--;
25 ret = 1;
26 }
27 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
28 return ret;
29}
30
31/*
32 * waking non zero interruptible
33 * 1 got the lock
34 * 0 go to sleep
35 * -EINTR interrupted
36 *
37 * We must undo the sem->count down_interruptible() increment while we are
38 * protected by the spinlock in order to make this atomic_inc() with the
39 * atomic_read() in wake_one_more(), otherwise we can race. -arca
40 */
41static inline int waking_non_zero_interruptible(struct semaphore *sem,
42 struct task_struct *tsk)
43{
44 unsigned long flags;
45 int ret = 0;
46
47 spin_lock_irqsave(&semaphore_wake_lock, flags);
48 if (sem->waking > 0) {
49 sem->waking--;
50 ret = 1;
51 } else if (signal_pending(tsk)) {
52 atomic_inc(&sem->count);
53 ret = -EINTR;
54 }
55 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
56 return ret;
57}
58
59/*
60 * waking_non_zero_try_lock:
61 * 1 failed to lock
62 * 0 got the lock
63 *
64 * We must undo the sem->count down_interruptible() increment while we are
65 * protected by the spinlock in order to make this atomic_inc() with the
66 * atomic_read() in wake_one_more(), otherwise we can race. -arca
67 */
68static inline int waking_non_zero_trylock(struct semaphore *sem)
69{
70 unsigned long flags;
71 int ret = 1;
72
73 spin_lock_irqsave(&semaphore_wake_lock, flags);
74 if (sem->waking <= 0)
75 atomic_inc(&sem->count);
76 else {
77 sem->waking--;
78 ret = 0;
79 }
80 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
81 return ret;
82}
83
84#endif
diff --git a/include/asm-arm/semaphore.h b/include/asm-arm/semaphore.h
index 1c8b441f89e3..d9b2034ed1d2 100644
--- a/include/asm-arm/semaphore.h
+++ b/include/asm-arm/semaphore.h
@@ -1,98 +1 @@
1/* #include <linux/semaphore.h>
2 * linux/include/asm-arm/semaphore.h
3 */
4#ifndef __ASM_ARM_SEMAPHORE_H
5#define __ASM_ARM_SEMAPHORE_H
6
7#include <linux/linkage.h>
8#include <linux/spinlock.h>
9#include <linux/wait.h>
10#include <linux/rwsem.h>
11
12#include <asm/atomic.h>
13#include <asm/locks.h>
14
15struct semaphore {
16 atomic_t count;
17 int sleepers;
18 wait_queue_head_t wait;
19};
20
21#define __SEMAPHORE_INIT(name, cnt) \
22{ \
23 .count = ATOMIC_INIT(cnt), \
24 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \
25}
26
27#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
28 struct semaphore name = __SEMAPHORE_INIT(name,count)
29
30#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
31
32static inline void sema_init(struct semaphore *sem, int val)
33{
34 atomic_set(&sem->count, val);
35 sem->sleepers = 0;
36 init_waitqueue_head(&sem->wait);
37}
38
39static inline void init_MUTEX(struct semaphore *sem)
40{
41 sema_init(sem, 1);
42}
43
44static inline void init_MUTEX_LOCKED(struct semaphore *sem)
45{
46 sema_init(sem, 0);
47}
48
49/*
50 * special register calling convention
51 */
52asmlinkage void __down_failed(void);
53asmlinkage int __down_interruptible_failed(void);
54asmlinkage int __down_trylock_failed(void);
55asmlinkage void __up_wakeup(void);
56
57extern void __down(struct semaphore * sem);
58extern int __down_interruptible(struct semaphore * sem);
59extern int __down_trylock(struct semaphore * sem);
60extern void __up(struct semaphore * sem);
61
62/*
63 * This is ugly, but we want the default case to fall through.
64 * "__down" is the actual routine that waits...
65 */
66static inline void down(struct semaphore * sem)
67{
68 might_sleep();
69 __down_op(sem, __down_failed);
70}
71
72/*
73 * This is ugly, but we want the default case to fall through.
74 * "__down_interruptible" is the actual routine that waits...
75 */
76static inline int down_interruptible (struct semaphore * sem)
77{
78 might_sleep();
79 return __down_op_ret(sem, __down_interruptible_failed);
80}
81
82static inline int down_trylock(struct semaphore *sem)
83{
84 return __down_op_ret(sem, __down_trylock_failed);
85}
86
87/*
88 * Note! This is subtle. We jump to wake people up only if
89 * the semaphore was negative (== somebody was waiting on it).
90 * The default case (no contention) will result in NO
91 * jumps for both down() and up().
92 */
93static inline void up(struct semaphore * sem)
94{
95 __up_op(sem, __up_wakeup);
96}
97
98#endif
diff --git a/include/asm-arm/sparsemem.h b/include/asm-arm/sparsemem.h
new file mode 100644
index 000000000000..277158191a0d
--- /dev/null
+++ b/include/asm-arm/sparsemem.h
@@ -0,0 +1,10 @@
1#ifndef ASMARM_SPARSEMEM_H
2#define ASMARM_SPARSEMEM_H
3
4#include <asm/memory.h>
5
6#define MAX_PHYSADDR_BITS 32
7#define MAX_PHYSMEM_BITS 32
8#define SECTION_SIZE_BITS NODE_MEM_SIZE_BITS
9
10#endif
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
index 41784357a204..f5a664786311 100644
--- a/include/asm-arm/thread_info.h
+++ b/include/asm-arm/thread_info.h
@@ -62,6 +62,9 @@ struct thread_info {
62 struct crunch_state crunchstate; 62 struct crunch_state crunchstate;
63 union fp_state fpstate __attribute__((aligned(8))); 63 union fp_state fpstate __attribute__((aligned(8)));
64 union vfp_state vfpstate; 64 union vfp_state vfpstate;
65#ifdef CONFIG_ARM_THUMBEE
66 unsigned long thumbee_state; /* ThumbEE Handler Base register */
67#endif
65 struct restart_block restart_block; 68 struct restart_block restart_block;
66}; 69};
67 70
diff --git a/include/asm-arm/unaligned.h b/include/asm-arm/unaligned.h
index 5db03cf3b905..44593a894903 100644
--- a/include/asm-arm/unaligned.h
+++ b/include/asm-arm/unaligned.h
@@ -1,171 +1,9 @@
1#ifndef __ASM_ARM_UNALIGNED_H 1#ifndef _ASM_ARM_UNALIGNED_H
2#define __ASM_ARM_UNALIGNED_H 2#define _ASM_ARM_UNALIGNED_H
3 3
4#include <asm/types.h> 4#include <linux/unaligned/le_byteshift.h>
5 5#include <linux/unaligned/be_byteshift.h>
6extern int __bug_unaligned_x(const void *ptr); 6#include <linux/unaligned/generic.h>
7
8/*
9 * What is the most efficient way of loading/storing an unaligned value?
10 *
11 * That is the subject of this file. Efficiency here is defined as
12 * minimum code size with minimum register usage for the common cases.
13 * It is currently not believed that long longs are common, so we
14 * trade efficiency for the chars, shorts and longs against the long
15 * longs.
16 *
17 * Current stats with gcc 2.7.2.2 for these functions:
18 *
19 * ptrsize get: code regs put: code regs
20 * 1 1 1 1 2
21 * 2 3 2 3 2
22 * 4 7 3 7 3
23 * 8 20 6 16 6
24 *
25 * gcc 2.95.1 seems to code differently:
26 *
27 * ptrsize get: code regs put: code regs
28 * 1 1 1 1 2
29 * 2 3 2 3 2
30 * 4 7 4 7 4
31 * 8 19 8 15 6
32 *
33 * which may or may not be more efficient (depending upon whether
34 * you can afford the extra registers). Hopefully the gcc 2.95
35 * is inteligent enough to decide if it is better to use the
36 * extra register, but evidence so far seems to suggest otherwise.
37 *
38 * Unfortunately, gcc is not able to optimise the high word
39 * out of long long >> 32, or the low word from long long << 32
40 */
41
42#define __get_unaligned_2_le(__p) \
43 (unsigned int)(__p[0] | __p[1] << 8)
44
45#define __get_unaligned_2_be(__p) \
46 (unsigned int)(__p[0] << 8 | __p[1])
47
48#define __get_unaligned_4_le(__p) \
49 (unsigned int)(__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24)
50
51#define __get_unaligned_4_be(__p) \
52 (unsigned int)(__p[0] << 24 | __p[1] << 16 | __p[2] << 8 | __p[3])
53
54#define __get_unaligned_8_le(__p) \
55 ((unsigned long long)__get_unaligned_4_le((__p+4)) << 32 | \
56 __get_unaligned_4_le(__p))
57
58#define __get_unaligned_8_be(__p) \
59 ((unsigned long long)__get_unaligned_4_be(__p) << 32 | \
60 __get_unaligned_4_be((__p+4)))
61
62#define __get_unaligned_le(ptr) \
63 ((__force typeof(*(ptr)))({ \
64 const __u8 *__p = (const __u8 *)(ptr); \
65 __builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \
66 __builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_le(__p), \
67 __builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_le(__p), \
68 __builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_le(__p), \
69 (void)__bug_unaligned_x(__p))))); \
70 }))
71
72#define __get_unaligned_be(ptr) \
73 ((__force typeof(*(ptr)))({ \
74 const __u8 *__p = (const __u8 *)(ptr); \
75 __builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \
76 __builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_be(__p), \
77 __builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_be(__p), \
78 __builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_be(__p), \
79 (void)__bug_unaligned_x(__p))))); \
80 }))
81
82
83static inline void __put_unaligned_2_le(__u32 __v, register __u8 *__p)
84{
85 *__p++ = __v;
86 *__p++ = __v >> 8;
87}
88
89static inline void __put_unaligned_2_be(__u32 __v, register __u8 *__p)
90{
91 *__p++ = __v >> 8;
92 *__p++ = __v;
93}
94
95static inline void __put_unaligned_4_le(__u32 __v, register __u8 *__p)
96{
97 __put_unaligned_2_le(__v >> 16, __p + 2);
98 __put_unaligned_2_le(__v, __p);
99}
100
101static inline void __put_unaligned_4_be(__u32 __v, register __u8 *__p)
102{
103 __put_unaligned_2_be(__v >> 16, __p);
104 __put_unaligned_2_be(__v, __p + 2);
105}
106
107static inline void __put_unaligned_8_le(const unsigned long long __v, register __u8 *__p)
108{
109 /*
110 * tradeoff: 8 bytes of stack for all unaligned puts (2
111 * instructions), or an extra register in the long long
112 * case - go for the extra register.
113 */
114 __put_unaligned_4_le(__v >> 32, __p+4);
115 __put_unaligned_4_le(__v, __p);
116}
117
118static inline void __put_unaligned_8_be(const unsigned long long __v, register __u8 *__p)
119{
120 /*
121 * tradeoff: 8 bytes of stack for all unaligned puts (2
122 * instructions), or an extra register in the long long
123 * case - go for the extra register.
124 */
125 __put_unaligned_4_be(__v >> 32, __p);
126 __put_unaligned_4_be(__v, __p+4);
127}
128
129/*
130 * Try to store an unaligned value as efficiently as possible.
131 */
132#define __put_unaligned_le(val,ptr) \
133 ({ \
134 (void)sizeof(*(ptr) = (val)); \
135 switch (sizeof(*(ptr))) { \
136 case 1: \
137 *(ptr) = (val); \
138 break; \
139 case 2: __put_unaligned_2_le((__force u16)(val),(__u8 *)(ptr)); \
140 break; \
141 case 4: __put_unaligned_4_le((__force u32)(val),(__u8 *)(ptr)); \
142 break; \
143 case 8: __put_unaligned_8_le((__force u64)(val),(__u8 *)(ptr)); \
144 break; \
145 default: __bug_unaligned_x(ptr); \
146 break; \
147 } \
148 (void) 0; \
149 })
150
151#define __put_unaligned_be(val,ptr) \
152 ({ \
153 (void)sizeof(*(ptr) = (val)); \
154 switch (sizeof(*(ptr))) { \
155 case 1: \
156 *(ptr) = (val); \
157 break; \
158 case 2: __put_unaligned_2_be((__force u16)(val),(__u8 *)(ptr)); \
159 break; \
160 case 4: __put_unaligned_4_be((__force u32)(val),(__u8 *)(ptr)); \
161 break; \
162 case 8: __put_unaligned_8_be((__force u64)(val),(__u8 *)(ptr)); \
163 break; \
164 default: __bug_unaligned_x(ptr); \
165 break; \
166 } \
167 (void) 0; \
168 })
169 7
170/* 8/*
171 * Select endianness 9 * Select endianness
@@ -178,4 +16,4 @@ static inline void __put_unaligned_8_be(const unsigned long long __v, register _
178#define put_unaligned __put_unaligned_be 16#define put_unaligned __put_unaligned_be
179#endif 17#endif
180 18
181#endif 19#endif /* _ASM_ARM_UNALIGNED_H */
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index 88e868b7aae0..7c570082b1e0 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -376,9 +376,11 @@
376#define __NR_kexec_load (__NR_SYSCALL_BASE+347) 376#define __NR_kexec_load (__NR_SYSCALL_BASE+347)
377#define __NR_utimensat (__NR_SYSCALL_BASE+348) 377#define __NR_utimensat (__NR_SYSCALL_BASE+348)
378#define __NR_signalfd (__NR_SYSCALL_BASE+349) 378#define __NR_signalfd (__NR_SYSCALL_BASE+349)
379#define __NR_timerfd (__NR_SYSCALL_BASE+350) 379#define __NR_timerfd_create (__NR_SYSCALL_BASE+350)
380#define __NR_eventfd (__NR_SYSCALL_BASE+351) 380#define __NR_eventfd (__NR_SYSCALL_BASE+351)
381#define __NR_fallocate (__NR_SYSCALL_BASE+352) 381#define __NR_fallocate (__NR_SYSCALL_BASE+352)
382#define __NR_timerfd_settime (__NR_SYSCALL_BASE+353)
383#define __NR_timerfd_gettime (__NR_SYSCALL_BASE+354)
382 384
383/* 385/*
384 * The following SWIs are ARM private. 386 * The following SWIs are ARM private.
diff --git a/include/asm-avr32/arch-at32ap/board.h b/include/asm-avr32/arch-at32ap/board.h
index 7597b0bd2f01..a4e2d28bfb58 100644
--- a/include/asm-avr32/arch-at32ap/board.h
+++ b/include/asm-avr32/arch-at32ap/board.h
@@ -38,9 +38,7 @@ struct platform_device *
38at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data, 38at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data,
39 unsigned long fbmem_start, unsigned long fbmem_len); 39 unsigned long fbmem_start, unsigned long fbmem_len);
40 40
41struct usba_platform_data { 41struct usba_platform_data;
42 int vbus_pin;
43};
44struct platform_device * 42struct platform_device *
45at32_add_device_usba(unsigned int id, struct usba_platform_data *data); 43at32_add_device_usba(unsigned int id, struct usba_platform_data *data);
46 44
@@ -68,7 +66,10 @@ struct platform_device *at32_add_device_pwm(u32 mask);
68struct platform_device * 66struct platform_device *
69at32_add_device_ssc(unsigned int id, unsigned int flags); 67at32_add_device_ssc(unsigned int id, unsigned int flags);
70 68
71struct platform_device *at32_add_device_twi(unsigned int id); 69struct i2c_board_info;
70struct platform_device *at32_add_device_twi(unsigned int id,
71 struct i2c_board_info *b,
72 unsigned int n);
72struct platform_device *at32_add_device_mci(unsigned int id); 73struct platform_device *at32_add_device_mci(unsigned int id);
73struct platform_device *at32_add_device_ac97c(unsigned int id); 74struct platform_device *at32_add_device_ac97c(unsigned int id);
74struct platform_device *at32_add_device_abdac(unsigned int id); 75struct platform_device *at32_add_device_abdac(unsigned int id);
diff --git a/include/asm-avr32/arch-at32ap/pm.h b/include/asm-avr32/arch-at32ap/pm.h
new file mode 100644
index 000000000000..356e43064903
--- /dev/null
+++ b/include/asm-avr32/arch-at32ap/pm.h
@@ -0,0 +1,48 @@
1/*
2 * AVR32 AP Power Management.
3 *
4 * Copyright (C) 2008 Atmel Corporation
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#ifndef __ASM_AVR32_ARCH_PM_H
11#define __ASM_AVR32_ARCH_PM_H
12
13/* Possible arguments to the "sleep" instruction */
14#define CPU_SLEEP_IDLE 0
15#define CPU_SLEEP_FROZEN 1
16#define CPU_SLEEP_STANDBY 2
17#define CPU_SLEEP_STOP 3
18#define CPU_SLEEP_STATIC 5
19
20#ifndef __ASSEMBLY__
21extern void cpu_enter_idle(void);
22
23extern bool disable_idle_sleep;
24
25static inline void cpu_disable_idle_sleep(void)
26{
27 disable_idle_sleep = true;
28}
29
30static inline void cpu_enable_idle_sleep(void)
31{
32 disable_idle_sleep = false;
33}
34
35static inline void cpu_idle_sleep(void)
36{
37 /*
38 * If we're using the COUNT and COMPARE registers for
39 * timekeeping, we can't use the IDLE state.
40 */
41 if (disable_idle_sleep)
42 cpu_relax();
43 else
44 cpu_enter_idle();
45}
46#endif
47
48#endif /* __ASM_AVR32_ARCH_PM_H */
diff --git a/include/asm-avr32/arch-at32ap/time.h b/include/asm-avr32/arch-at32ap/time.h
deleted file mode 100644
index cc8a43418a4d..000000000000
--- a/include/asm-avr32/arch-at32ap/time.h
+++ /dev/null
@@ -1,112 +0,0 @@
1/*
2 * Copyright (C) 2007 Atmel Corporation
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#ifndef _ASM_AVR32_ARCH_AT32AP_TIME_H
10#define _ASM_AVR32_ARCH_AT32AP_TIME_H
11
12#include <linux/platform_device.h>
13
14extern struct irqaction timer_irqaction;
15extern struct platform_device at32_systc0_device;
16extern void local_timer_interrupt(int irq, void *dev_id);
17
18#define TIMER_BCR 0x000000c0
19#define TIMER_BCR_SYNC 0
20#define TIMER_BMR 0x000000c4
21#define TIMER_BMR_TC0XC0S 0
22#define TIMER_BMR_TC1XC1S 2
23#define TIMER_BMR_TC2XC2S 4
24#define TIMER_CCR 0x00000000
25#define TIMER_CCR_CLKDIS 1
26#define TIMER_CCR_CLKEN 0
27#define TIMER_CCR_SWTRG 2
28#define TIMER_CMR 0x00000004
29#define TIMER_CMR_ABETRG 10
30#define TIMER_CMR_ACPA 16
31#define TIMER_CMR_ACPC 18
32#define TIMER_CMR_AEEVT 20
33#define TIMER_CMR_ASWTRG 22
34#define TIMER_CMR_BCPB 24
35#define TIMER_CMR_BCPC 26
36#define TIMER_CMR_BEEVT 28
37#define TIMER_CMR_BSWTRG 30
38#define TIMER_CMR_BURST 4
39#define TIMER_CMR_CLKI 3
40#define TIMER_CMR_CPCDIS 7
41#define TIMER_CMR_CPCSTOP 6
42#define TIMER_CMR_CPCTRG 14
43#define TIMER_CMR_EEVT 10
44#define TIMER_CMR_EEVTEDG 8
45#define TIMER_CMR_ENETRG 12
46#define TIMER_CMR_ETRGEDG 8
47#define TIMER_CMR_LDBDIS 7
48#define TIMER_CMR_LDBSTOP 6
49#define TIMER_CMR_LDRA 16
50#define TIMER_CMR_LDRB 18
51#define TIMER_CMR_TCCLKS 0
52#define TIMER_CMR_WAVE 15
53#define TIMER_CMR_WAVSEL 13
54#define TIMER_CV 0x00000010
55#define TIMER_CV_CV 0
56#define TIMER_IDR 0x00000028
57#define TIMER_IDR_COVFS 0
58#define TIMER_IDR_CPAS 2
59#define TIMER_IDR_CPBS 3
60#define TIMER_IDR_CPCS 4
61#define TIMER_IDR_ETRGS 7
62#define TIMER_IDR_LDRAS 5
63#define TIMER_IDR_LDRBS 6
64#define TIMER_IDR_LOVRS 1
65#define TIMER_IER 0x00000024
66#define TIMER_IER_COVFS 0
67#define TIMER_IER_CPAS 2
68#define TIMER_IER_CPBS 3
69#define TIMER_IER_CPCS 4
70#define TIMER_IER_ETRGS 7
71#define TIMER_IER_LDRAS 5
72#define TIMER_IER_LDRBS 6
73#define TIMER_IER_LOVRS 1
74#define TIMER_IMR 0x0000002c
75#define TIMER_IMR_COVFS 0
76#define TIMER_IMR_CPAS 2
77#define TIMER_IMR_CPBS 3
78#define TIMER_IMR_CPCS 4
79#define TIMER_IMR_ETRGS 7
80#define TIMER_IMR_LDRAS 5
81#define TIMER_IMR_LDRBS 6
82#define TIMER_IMR_LOVRS 1
83#define TIMER_RA 0x00000014
84#define TIMER_RA_RA 0
85#define TIMER_RB 0x00000018
86#define TIMER_RB_RB 0
87#define TIMER_RC 0x0000001c
88#define TIMER_RC_RC 0
89#define TIMER_SR 0x00000020
90#define TIMER_SR_CLKSTA 16
91#define TIMER_SR_COVFS 0
92#define TIMER_SR_CPAS 2
93#define TIMER_SR_CPBS 3
94#define TIMER_SR_CPCS 4
95#define TIMER_SR_ETRGS 7
96#define TIMER_SR_LDRAS 5
97#define TIMER_SR_LDRBS 6
98#define TIMER_SR_LOVRS 1
99#define TIMER_SR_MTIOA 17
100#define TIMER_SR_MTIOB 18
101
102/* Bit manipulation macros */
103#define TIMER_BIT(name) (1 << TIMER_##name)
104#define TIMER_BF(name,value) ((value) << TIMER_##name)
105
106/* Register access macros */
107#define timer_read(port,instance,reg) \
108 __raw_readl(port + (0x40 * instance) + TIMER_##reg)
109#define timer_write(port,instance,reg,value) \
110 __raw_writel((value), port + (0x40 * instance) + TIMER_##reg)
111
112#endif /* _ASM_AVR32_ARCH_AT32AP_TIME_H */
diff --git a/include/asm-avr32/asm.h b/include/asm-avr32/asm.h
index 515c7618952b..a2c64f404b98 100644
--- a/include/asm-avr32/asm.h
+++ b/include/asm-avr32/asm.h
@@ -12,10 +12,10 @@
12#include <asm/asm-offsets.h> 12#include <asm/asm-offsets.h>
13#include <asm/thread_info.h> 13#include <asm/thread_info.h>
14 14
15#define mask_interrupts ssrf SR_GM_BIT 15#define mask_interrupts ssrf SYSREG_GM_OFFSET
16#define mask_exceptions ssrf SR_EM_BIT 16#define mask_exceptions ssrf SYSREG_EM_OFFSET
17#define unmask_interrupts csrf SR_GM_BIT 17#define unmask_interrupts csrf SYSREG_GM_OFFSET
18#define unmask_exceptions csrf SR_EM_BIT 18#define unmask_exceptions csrf SYSREG_EM_OFFSET
19 19
20#ifdef CONFIG_FRAME_POINTER 20#ifdef CONFIG_FRAME_POINTER
21 .macro save_fp 21 .macro save_fp
diff --git a/include/asm-avr32/intc.h b/include/asm-avr32/intc.h
deleted file mode 100644
index 1ac9ca75e8fd..000000000000
--- a/include/asm-avr32/intc.h
+++ /dev/null
@@ -1,128 +0,0 @@
1#ifndef __ASM_AVR32_INTC_H
2#define __ASM_AVR32_INTC_H
3
4#include <linux/sysdev.h>
5#include <linux/interrupt.h>
6
7struct irq_controller;
8struct irqaction;
9struct pt_regs;
10
11struct platform_device;
12
13/* Information about the internal interrupt controller */
14struct intc_device {
15 /* ioremapped address of configuration block */
16 void __iomem *regs;
17
18 /* the physical device */
19 struct platform_device *pdev;
20
21 /* Number of interrupt lines per group. */
22 unsigned int irqs_per_group;
23
24 /* The highest group ID + 1 */
25 unsigned int nr_groups;
26
27 /*
28 * Bitfield indicating which groups are actually in use. The
29 * size of the array is
30 * ceil(group_max / (8 * sizeof(unsigned int))).
31 */
32 unsigned int group_mask[];
33};
34
35struct irq_controller_class {
36 /*
37 * A short name identifying this kind of controller.
38 */
39 const char *typename;
40 /*
41 * Handle the IRQ. Must do any necessary acking and masking.
42 */
43 irqreturn_t (*handle)(int irq, void *dev_id, struct pt_regs *regs);
44 /*
45 * Register a new IRQ handler.
46 */
47 int (*setup)(struct irq_controller *ctrl, unsigned int irq,
48 struct irqaction *action);
49 /*
50 * Unregister a IRQ handler.
51 */
52 void (*free)(struct irq_controller *ctrl, unsigned int irq,
53 void *dev_id);
54 /*
55 * Mask the IRQ in the interrupt controller.
56 */
57 void (*mask)(struct irq_controller *ctrl, unsigned int irq);
58 /*
59 * Unmask the IRQ in the interrupt controller.
60 */
61 void (*unmask)(struct irq_controller *ctrl, unsigned int irq);
62 /*
63 * Set the type of the IRQ. See below for possible types.
64 * Return -EINVAL if a given type is not supported
65 */
66 int (*set_type)(struct irq_controller *ctrl, unsigned int irq,
67 unsigned int type);
68 /*
69 * Return the IRQ type currently set
70 */
71 unsigned int (*get_type)(struct irq_controller *ctrl, unsigned int irq);
72};
73
74struct irq_controller {
75 struct irq_controller_class *class;
76 unsigned int irq_group;
77 unsigned int first_irq;
78 unsigned int nr_irqs;
79 struct list_head list;
80};
81
82struct intc_group_desc {
83 struct irq_controller *ctrl;
84 irqreturn_t (*handle)(int, void *, struct pt_regs *);
85 unsigned long flags;
86 void *dev_id;
87 const char *devname;
88};
89
90/*
91 * The internal interrupt controller. Defined in board/part-specific
92 * devices.c.
93 * TODO: Should probably be defined per-cpu.
94 */
95extern struct intc_device intc;
96
97extern int request_internal_irq(unsigned int irq,
98 irqreturn_t (*handler)(int, void *, struct pt_regs *),
99 unsigned long irqflags,
100 const char *devname, void *dev_id);
101extern void free_internal_irq(unsigned int irq);
102
103/* Only used by time_init() */
104extern int setup_internal_irq(unsigned int irq, struct intc_group_desc *desc);
105
106/*
107 * Set interrupt priority for a given group. `group' can be found by
108 * using irq_to_group(irq). Priority can be from 0 (lowest) to 3
109 * (highest). Higher-priority interrupts will preempt lower-priority
110 * interrupts (unless interrupts are masked globally).
111 *
112 * This function does not check for conflicts within a group.
113 */
114extern int intc_set_priority(unsigned int group,
115 unsigned int priority);
116
117/*
118 * Returns a bitmask of pending interrupts in a group.
119 */
120extern unsigned long intc_get_pending(unsigned int group);
121
122/*
123 * Register a new external interrupt controller. Returns the first
124 * external IRQ number that is assigned to the new controller.
125 */
126extern int intc_register_controller(struct irq_controller *ctrl);
127
128#endif /* __ASM_AVR32_INTC_H */
diff --git a/include/asm-avr32/irq.h b/include/asm-avr32/irq.h
index 9315724c0596..c563b7720c1a 100644
--- a/include/asm-avr32/irq.h
+++ b/include/asm-avr32/irq.h
@@ -14,6 +14,11 @@
14#ifndef __ASSEMBLER__ 14#ifndef __ASSEMBLER__
15int nmi_enable(void); 15int nmi_enable(void);
16void nmi_disable(void); 16void nmi_disable(void);
17
18/*
19 * Returns a bitmask of pending interrupts in a group.
20 */
21extern unsigned long intc_get_pending(unsigned int group);
17#endif 22#endif
18 23
19#endif /* __ASM_AVR32_IOCTLS_H */ 24#endif /* __ASM_AVR32_IOCTLS_H */
diff --git a/include/asm-avr32/page.h b/include/asm-avr32/page.h
index 5582968feee8..cbbc5ca9728b 100644
--- a/include/asm-avr32/page.h
+++ b/include/asm-avr32/page.h
@@ -8,13 +8,11 @@
8#ifndef __ASM_AVR32_PAGE_H 8#ifndef __ASM_AVR32_PAGE_H
9#define __ASM_AVR32_PAGE_H 9#define __ASM_AVR32_PAGE_H
10 10
11#include <linux/const.h>
12
11/* PAGE_SHIFT determines the page size */ 13/* PAGE_SHIFT determines the page size */
12#define PAGE_SHIFT 12 14#define PAGE_SHIFT 12
13#ifdef __ASSEMBLY__ 15#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
14#define PAGE_SIZE (1 << PAGE_SHIFT)
15#else
16#define PAGE_SIZE (1UL << PAGE_SHIFT)
17#endif
18#define PAGE_MASK (~(PAGE_SIZE-1)) 16#define PAGE_MASK (~(PAGE_SIZE-1))
19#define PTE_MASK PAGE_MASK 17#define PTE_MASK PAGE_MASK
20 18
diff --git a/include/asm-avr32/pgtable.h b/include/asm-avr32/pgtable.h
index 3ae7b548fce7..c0e5e29417df 100644
--- a/include/asm-avr32/pgtable.h
+++ b/include/asm-avr32/pgtable.h
@@ -212,6 +212,10 @@ static inline int pte_young(pte_t pte)
212{ 212{
213 return pte_val(pte) & _PAGE_ACCESSED; 213 return pte_val(pte) & _PAGE_ACCESSED;
214} 214}
215static inline int pte_special(pte_t pte)
216{
217 return 0;
218}
215 219
216/* 220/*
217 * The following only work if pte_present() is not true. 221 * The following only work if pte_present() is not true.
@@ -252,6 +256,10 @@ static inline pte_t pte_mkyoung(pte_t pte)
252 set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); 256 set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED));
253 return pte; 257 return pte;
254} 258}
259static inline pte_t pte_mkspecial(pte_t pte)
260{
261 return pte;
262}
255 263
256#define pmd_none(x) (!pmd_val(x)) 264#define pmd_none(x) (!pmd_val(x))
257#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 265#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
diff --git a/include/asm-avr32/semaphore.h b/include/asm-avr32/semaphore.h
index feaf1d453386..d9b2034ed1d2 100644
--- a/include/asm-avr32/semaphore.h
+++ b/include/asm-avr32/semaphore.h
@@ -1,108 +1 @@
1/* #include <linux/semaphore.h>
2 * SMP- and interrupt-safe semaphores.
3 *
4 * Copyright (C) 2006 Atmel Corporation
5 *
6 * Based on include/asm-i386/semaphore.h
7 * Copyright (C) 1996 Linus Torvalds
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#ifndef __ASM_AVR32_SEMAPHORE_H
14#define __ASM_AVR32_SEMAPHORE_H
15
16#include <linux/linkage.h>
17
18#include <asm/system.h>
19#include <asm/atomic.h>
20#include <linux/wait.h>
21#include <linux/rwsem.h>
22
23struct semaphore {
24 atomic_t count;
25 int sleepers;
26 wait_queue_head_t wait;
27};
28
29#define __SEMAPHORE_INITIALIZER(name, n) \
30{ \
31 .count = ATOMIC_INIT(n), \
32 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
33}
34
35#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
36 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
37
38#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
39
40static inline void sema_init (struct semaphore *sem, int val)
41{
42 atomic_set(&sem->count, val);
43 sem->sleepers = 0;
44 init_waitqueue_head(&sem->wait);
45}
46
47static inline void init_MUTEX (struct semaphore *sem)
48{
49 sema_init(sem, 1);
50}
51
52static inline void init_MUTEX_LOCKED (struct semaphore *sem)
53{
54 sema_init(sem, 0);
55}
56
57void __down(struct semaphore * sem);
58int __down_interruptible(struct semaphore * sem);
59void __up(struct semaphore * sem);
60
61/*
62 * This is ugly, but we want the default case to fall through.
63 * "__down_failed" is a special asm handler that calls the C
64 * routine that actually waits. See arch/i386/kernel/semaphore.c
65 */
66static inline void down(struct semaphore * sem)
67{
68 might_sleep();
69 if (unlikely(atomic_dec_return (&sem->count) < 0))
70 __down (sem);
71}
72
73/*
74 * Interruptible try to acquire a semaphore. If we obtained
75 * it, return zero. If we were interrupted, returns -EINTR
76 */
77static inline int down_interruptible(struct semaphore * sem)
78{
79 int ret = 0;
80
81 might_sleep();
82 if (unlikely(atomic_dec_return (&sem->count) < 0))
83 ret = __down_interruptible (sem);
84 return ret;
85}
86
87/*
88 * Non-blockingly attempt to down() a semaphore.
89 * Returns zero if we acquired it
90 */
91static inline int down_trylock(struct semaphore * sem)
92{
93 return atomic_dec_if_positive(&sem->count) < 0;
94}
95
96/*
97 * Note! This is subtle. We jump to wake people up only if
98 * the semaphore was negative (== somebody was waiting on it).
99 * The default case (no contention) will result in NO
100 * jumps for both down() and up().
101 */
102static inline void up(struct semaphore * sem)
103{
104 if (unlikely(atomic_inc_return (&sem->count) <= 0))
105 __up (sem);
106}
107
108#endif /*__ASM_AVR32_SEMAPHORE_H */
diff --git a/include/asm-avr32/serial.h b/include/asm-avr32/serial.h
new file mode 100644
index 000000000000..5ecaebc22b02
--- /dev/null
+++ b/include/asm-avr32/serial.h
@@ -0,0 +1,13 @@
1#ifndef _ASM_SERIAL_H
2#define _ASM_SERIAL_H
3
4/*
5 * This assumes you have a 1.8432 MHz clock for your UART.
6 *
7 * It'd be nice if someone built a serial card with a 24.576 MHz
8 * clock, since the 16550A is capable of handling a top speed of 1.5
9 * megabits/second; but this requires the faster clock.
10 */
11#define BASE_BAUD (1843200 / 16)
12
13#endif /* _ASM_SERIAL_H */
diff --git a/include/asm-avr32/unaligned.h b/include/asm-avr32/unaligned.h
index 36f5fd430543..041877290470 100644
--- a/include/asm-avr32/unaligned.h
+++ b/include/asm-avr32/unaligned.h
@@ -1,5 +1,5 @@
1#ifndef __ASM_AVR32_UNALIGNED_H 1#ifndef _ASM_AVR32_UNALIGNED_H
2#define __ASM_AVR32_UNALIGNED_H 2#define _ASM_AVR32_UNALIGNED_H
3 3
4/* 4/*
5 * AVR32 can handle some unaligned accesses, depending on the 5 * AVR32 can handle some unaligned accesses, depending on the
@@ -11,6 +11,11 @@
11 * optimize word loads in general. 11 * optimize word loads in general.
12 */ 12 */
13 13
14#include <asm-generic/unaligned.h> 14#include <linux/unaligned/be_struct.h>
15#include <linux/unaligned/le_byteshift.h>
16#include <linux/unaligned/generic.h>
15 17
16#endif /* __ASM_AVR32_UNALIGNED_H */ 18#define get_unaligned __get_unaligned_be
19#define put_unaligned __put_unaligned_be
20
21#endif /* _ASM_AVR32_UNALIGNED_H */
diff --git a/include/asm-avr32/xor.h b/include/asm-avr32/xor.h
new file mode 100644
index 000000000000..99c87aa0af4f
--- /dev/null
+++ b/include/asm-avr32/xor.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_XOR_H
2#define _ASM_XOR_H
3
4#include <asm-generic/xor.h>
5
6#endif
diff --git a/include/asm-blackfin/.gitignore b/include/asm-blackfin/.gitignore
new file mode 100644
index 000000000000..7858564a4466
--- /dev/null
+++ b/include/asm-blackfin/.gitignore
@@ -0,0 +1 @@
+mach
diff --git a/include/asm-blackfin/bfin-global.h b/include/asm-blackfin/bfin-global.h
index 5dba3a735596..716df7c85923 100644
--- a/include/asm-blackfin/bfin-global.h
+++ b/include/asm-blackfin/bfin-global.h
@@ -112,20 +112,10 @@ extern void init_leds(void);
112 112
113extern const char bfin_board_name[]; 113extern const char bfin_board_name[];
114extern unsigned long wall_jiffies; 114extern unsigned long wall_jiffies;
115extern unsigned long ipdt_table[];
116extern unsigned long dpdt_table[];
117extern unsigned long icplb_table[];
118extern unsigned long dcplb_table[];
119
120extern unsigned long ipdt_swapcount_table[];
121extern unsigned long dpdt_swapcount_table[];
122
123extern unsigned long table_start, table_end;
124 115
125extern unsigned long bfin_sic_iwr[]; 116extern unsigned long bfin_sic_iwr[];
126extern u16 _bfin_swrst; /* shadow for Software Reset Register (SWRST) */ 117extern u16 _bfin_swrst; /* shadow for Software Reset Register (SWRST) */
127extern struct file_operations dpmc_fops; 118extern struct file_operations dpmc_fops;
128extern char _start;
129extern unsigned long _ramstart, _ramend, _rambase; 119extern unsigned long _ramstart, _ramend, _rambase;
130extern unsigned long memory_start, memory_end, physical_mem_end; 120extern unsigned long memory_start, memory_end, physical_mem_end;
131extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[], 121extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[],
diff --git a/include/asm-blackfin/bug.h b/include/asm-blackfin/bug.h
index 41e53b29f167..6d3e11b1fc57 100644
--- a/include/asm-blackfin/bug.h
+++ b/include/asm-blackfin/bug.h
@@ -1,4 +1,17 @@
1#ifndef _BLACKFIN_BUG_H 1#ifndef _BLACKFIN_BUG_H
2#define _BLACKFIN_BUG_H 2#define _BLACKFIN_BUG_H
3
4#ifdef CONFIG_BUG
5#define HAVE_ARCH_BUG
6
7#define BUG() do { \
8 dump_bfin_trace_buffer(); \
9 printk(KERN_EMERG "BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
10 panic("BUG!"); \
11} while (0)
12
13#endif
14
3#include <asm-generic/bug.h> 15#include <asm-generic/bug.h>
16
4#endif 17#endif
diff --git a/include/asm-blackfin/cplb.h b/include/asm-blackfin/cplb.h
index 654375c2b746..5b0da9a69b67 100644
--- a/include/asm-blackfin/cplb.h
+++ b/include/asm-blackfin/cplb.h
@@ -74,32 +74,6 @@
74#define ASYNC_MEMORY_CPLB_COVERAGE ((ASYNC_BANK0_SIZE + ASYNC_BANK1_SIZE + \ 74#define ASYNC_MEMORY_CPLB_COVERAGE ((ASYNC_BANK0_SIZE + ASYNC_BANK1_SIZE + \
75 ASYNC_BANK2_SIZE + ASYNC_BANK3_SIZE) / SIZE_4M) 75 ASYNC_BANK2_SIZE + ASYNC_BANK3_SIZE) / SIZE_4M)
76 76
77/*
78* Number of required data CPLB switchtable entries
79* MEMSIZE / 4 (we mostly install 4M page size CPLBs
80* approx 16 for smaller 1MB page size CPLBs for allignment purposes
81* 1 for L1 Data Memory
82* possibly 1 for L2 Data Memory
83* 1 for CONFIG_DEBUG_HUNT_FOR_ZERO
84* 1 for ASYNC Memory
85*/
86
87
88#define MAX_SWITCH_D_CPLBS (((CONFIG_MEM_SIZE / 4) + 16 + 1 + 1 + 1 \
89 + ASYNC_MEMORY_CPLB_COVERAGE) * 2)
90
91/*
92* Number of required instruction CPLB switchtable entries
93* MEMSIZE / 4 (we mostly install 4M page size CPLBs
94* approx 12 for smaller 1MB page size CPLBs for allignment purposes
95* 1 for L1 Instruction Memory
96* possibly 1 for L2 Instruction Memory
97* 1 for CONFIG_DEBUG_HUNT_FOR_ZERO
98*/
99
100#define MAX_SWITCH_I_CPLBS (((CONFIG_MEM_SIZE / 4) + 12 + 1 + 1 + 1) * 2)
101
102
103#define CPLB_ENABLE_ICACHE_P 0 77#define CPLB_ENABLE_ICACHE_P 0
104#define CPLB_ENABLE_DCACHE_P 1 78#define CPLB_ENABLE_DCACHE_P 1
105#define CPLB_ENABLE_DCACHE2_P 2 79#define CPLB_ENABLE_DCACHE2_P 2
diff --git a/include/asm-blackfin/dma-mapping.h b/include/asm-blackfin/dma-mapping.h
index 282fabccf6a6..1a13c2fc3667 100644
--- a/include/asm-blackfin/dma-mapping.h
+++ b/include/asm-blackfin/dma-mapping.h
@@ -27,6 +27,14 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
27extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, 27extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
28 enum dma_data_direction direction); 28 enum dma_data_direction direction);
29 29
30static inline dma_addr_t
31dma_map_page(struct device *dev, struct page *page,
32 unsigned long offset, size_t size,
33 enum dma_data_direction dir)
34{
35 return dma_map_single(dev, page_address(page) + offset, size, dir);
36}
37
30/* 38/*
31 * Unmap a single streaming mode DMA translation. The dma_addr and size 39 * Unmap a single streaming mode DMA translation. The dma_addr and size
32 * must match what was provided for in a previous pci_map_single call. All 40 * must match what was provided for in a previous pci_map_single call. All
@@ -38,6 +46,13 @@ extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
38extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 46extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
39 enum dma_data_direction direction); 47 enum dma_data_direction direction);
40 48
49static inline void
50dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
51 enum dma_data_direction dir)
52{
53 dma_unmap_single(dev, dma_addr, size, dir);
54}
55
41/* 56/*
42 * Map a set of buffers described by scatterlist in streaming 57 * Map a set of buffers described by scatterlist in streaming
43 * mode for DMA. This is the scather-gather version of the 58 * mode for DMA. This is the scather-gather version of the
diff --git a/include/asm-blackfin/dma.h b/include/asm-blackfin/dma.h
index 5abaa2cee8db..c0d5259e315b 100644
--- a/include/asm-blackfin/dma.h
+++ b/include/asm-blackfin/dma.h
@@ -33,7 +33,6 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <asm/signal.h> 35#include <asm/signal.h>
36#include <asm/semaphore.h>
37 36
38#include <linux/kernel.h> 37#include <linux/kernel.h>
39#include <asm/mach/dma.h> 38#include <asm/mach/dma.h>
@@ -192,4 +191,7 @@ void clear_dma_irqstat(unsigned int channel);
192void *dma_memcpy(void *dest, const void *src, size_t count); 191void *dma_memcpy(void *dest, const void *src, size_t count);
193void *safe_dma_memcpy(void *dest, const void *src, size_t count); 192void *safe_dma_memcpy(void *dest, const void *src, size_t count);
194 193
194extern int channel2irq(unsigned int channel);
195extern struct dma_register *dma_io_base_addr[MAX_BLACKFIN_DMA_CHANNEL];
196
195#endif 197#endif
diff --git a/include/asm-blackfin/gptimers.h b/include/asm-blackfin/gptimers.h
index 4f318f1fd2d9..0520d2aac8f3 100644
--- a/include/asm-blackfin/gptimers.h
+++ b/include/asm-blackfin/gptimers.h
@@ -22,6 +22,18 @@
22# define TIMER0_GROUP_REG TIMER_ENABLE 22# define TIMER0_GROUP_REG TIMER_ENABLE
23#endif 23#endif
24/* 24/*
25 * BF54x: 11 timers (BF542: 8 timers):
26 */
27#if defined(BF548_FAMILY)
28# ifdef CONFIG_BF542
29# define MAX_BLACKFIN_GPTIMERS 8
30# else
31# define MAX_BLACKFIN_GPTIMERS 11
32# define TIMER8_GROUP_REG TIMER_ENABLE1
33# endif
34# define TIMER0_GROUP_REG TIMER_ENABLE0
35#endif
36/*
25 * BF561: 12 timers: 37 * BF561: 12 timers:
26 */ 38 */
27#if defined(CONFIG_BF561) 39#if defined(CONFIG_BF561)
@@ -44,40 +56,28 @@
44#define TIMER0bit 0x0001 /* 0001b */ 56#define TIMER0bit 0x0001 /* 0001b */
45#define TIMER1bit 0x0002 /* 0010b */ 57#define TIMER1bit 0x0002 /* 0010b */
46#define TIMER2bit 0x0004 /* 0100b */ 58#define TIMER2bit 0x0004 /* 0100b */
47 59#define TIMER3bit 0x0008
48#if (MAX_BLACKFIN_GPTIMERS > 3) 60#define TIMER4bit 0x0010
49# define TIMER3bit 0x0008 61#define TIMER5bit 0x0020
50# define TIMER4bit 0x0010 62#define TIMER6bit 0x0040
51# define TIMER5bit 0x0020 63#define TIMER7bit 0x0080
52# define TIMER6bit 0x0040 64#define TIMER8bit 0x0100
53# define TIMER7bit 0x0080 65#define TIMER9bit 0x0200
54#endif 66#define TIMER10bit 0x0400
55 67#define TIMER11bit 0x0800
56#if (MAX_BLACKFIN_GPTIMERS > 8)
57# define TIMER8bit 0x0100
58# define TIMER9bit 0x0200
59# define TIMER10bit 0x0400
60# define TIMER11bit 0x0800
61#endif
62 68
63#define TIMER0_id 0 69#define TIMER0_id 0
64#define TIMER1_id 1 70#define TIMER1_id 1
65#define TIMER2_id 2 71#define TIMER2_id 2
66 72#define TIMER3_id 3
67#if (MAX_BLACKFIN_GPTIMERS > 3) 73#define TIMER4_id 4
68# define TIMER3_id 3 74#define TIMER5_id 5
69# define TIMER4_id 4 75#define TIMER6_id 6
70# define TIMER5_id 5 76#define TIMER7_id 7
71# define TIMER6_id 6 77#define TIMER8_id 8
72# define TIMER7_id 7 78#define TIMER9_id 9
73#endif 79#define TIMER10_id 10
74 80#define TIMER11_id 11
75#if (MAX_BLACKFIN_GPTIMERS > 8)
76# define TIMER8_id 8
77# define TIMER9_id 9
78# define TIMER10_id 10
79# define TIMER11_id 11
80#endif
81 81
82/* associated timers for ppi framesync: */ 82/* associated timers for ppi framesync: */
83 83
@@ -124,45 +124,31 @@
124/* 124/*
125 * Timer Status Register Bits 125 * Timer Status Register Bits
126 */ 126 */
127#define TIMER_STATUS_TIMIL0 0x0001 127#define TIMER_STATUS_TIMIL0 0x0001
128#define TIMER_STATUS_TIMIL1 0x0002 128#define TIMER_STATUS_TIMIL1 0x0002
129#define TIMER_STATUS_TIMIL2 0x0004 129#define TIMER_STATUS_TIMIL2 0x0004
130#if (MAX_BLACKFIN_GPTIMERS > 3) 130#define TIMER_STATUS_TIMIL3 0x00000008
131# define TIMER_STATUS_TIMIL3 0x00000008 131#define TIMER_STATUS_TIMIL4 0x00010000
132# define TIMER_STATUS_TIMIL4 0x00010000 132#define TIMER_STATUS_TIMIL5 0x00020000
133# define TIMER_STATUS_TIMIL5 0x00020000 133#define TIMER_STATUS_TIMIL6 0x00040000
134# define TIMER_STATUS_TIMIL6 0x00040000 134#define TIMER_STATUS_TIMIL7 0x00080000
135# define TIMER_STATUS_TIMIL7 0x00080000 135#define TIMER_STATUS_TIMIL8 0x0001
136# if (MAX_BLACKFIN_GPTIMERS > 8) 136#define TIMER_STATUS_TIMIL9 0x0002
137# define TIMER_STATUS_TIMIL8 0x0001 137#define TIMER_STATUS_TIMIL10 0x0004
138# define TIMER_STATUS_TIMIL9 0x0002 138#define TIMER_STATUS_TIMIL11 0x0008
139# define TIMER_STATUS_TIMIL10 0x0004 139
140# define TIMER_STATUS_TIMIL11 0x0008 140#define TIMER_STATUS_TOVF0 0x0010 /* timer 0 overflow error */
141# endif 141#define TIMER_STATUS_TOVF1 0x0020
142# define TIMER_STATUS_INTR 0x000F000F 142#define TIMER_STATUS_TOVF2 0x0040
143#else 143#define TIMER_STATUS_TOVF3 0x00000080
144# define TIMER_STATUS_INTR 0x0007 /* any timer interrupt */ 144#define TIMER_STATUS_TOVF4 0x00100000
145#endif 145#define TIMER_STATUS_TOVF5 0x00200000
146 146#define TIMER_STATUS_TOVF6 0x00400000
147#define TIMER_STATUS_TOVF0 0x0010 /* timer 0 overflow error */ 147#define TIMER_STATUS_TOVF7 0x00800000
148#define TIMER_STATUS_TOVF1 0x0020 148#define TIMER_STATUS_TOVF8 0x0010
149#define TIMER_STATUS_TOVF2 0x0040 149#define TIMER_STATUS_TOVF9 0x0020
150#if (MAX_BLACKFIN_GPTIMERS > 3) 150#define TIMER_STATUS_TOVF10 0x0040
151# define TIMER_STATUS_TOVF3 0x00000080 151#define TIMER_STATUS_TOVF11 0x0080
152# define TIMER_STATUS_TOVF4 0x00100000
153# define TIMER_STATUS_TOVF5 0x00200000
154# define TIMER_STATUS_TOVF6 0x00400000
155# define TIMER_STATUS_TOVF7 0x00800000
156# if (MAX_BLACKFIN_GPTIMERS > 8)
157# define TIMER_STATUS_TOVF8 0x0010
158# define TIMER_STATUS_TOVF9 0x0020
159# define TIMER_STATUS_TOVF10 0x0040
160# define TIMER_STATUS_TOVF11 0x0080
161# endif
162# define TIMER_STATUS_OFLOW 0x00F000F0
163#else
164# define TIMER_STATUS_OFLOW 0x0070 /* any timer overflow */
165#endif
166 152
167/* 153/*
168 * Timer Slave Enable Status : write 1 to clear 154 * Timer Slave Enable Status : write 1 to clear
@@ -170,22 +156,16 @@
170#define TIMER_STATUS_TRUN0 0x1000 156#define TIMER_STATUS_TRUN0 0x1000
171#define TIMER_STATUS_TRUN1 0x2000 157#define TIMER_STATUS_TRUN1 0x2000
172#define TIMER_STATUS_TRUN2 0x4000 158#define TIMER_STATUS_TRUN2 0x4000
173#if (MAX_BLACKFIN_GPTIMERS > 3) 159#define TIMER_STATUS_TRUN3 0x00008000
174# define TIMER_STATUS_TRUN3 0x00008000 160#define TIMER_STATUS_TRUN4 0x10000000
175# define TIMER_STATUS_TRUN4 0x10000000 161#define TIMER_STATUS_TRUN5 0x20000000
176# define TIMER_STATUS_TRUN5 0x20000000 162#define TIMER_STATUS_TRUN6 0x40000000
177# define TIMER_STATUS_TRUN6 0x40000000 163#define TIMER_STATUS_TRUN7 0x80000000
178# define TIMER_STATUS_TRUN7 0x80000000 164#define TIMER_STATUS_TRUN 0xF000F000
179# define TIMER_STATUS_TRUN 0xF000F000 165#define TIMER_STATUS_TRUN8 0x1000
180# if (MAX_BLACKFIN_GPTIMERS > 8) 166#define TIMER_STATUS_TRUN9 0x2000
181# define TIMER_STATUS_TRUN8 0x1000 167#define TIMER_STATUS_TRUN10 0x4000
182# define TIMER_STATUS_TRUN9 0x2000 168#define TIMER_STATUS_TRUN11 0x8000
183# define TIMER_STATUS_TRUN10 0x4000
184# define TIMER_STATUS_TRUN11 0x8000
185# endif
186#else
187# define TIMER_STATUS_TRUN 0x7000
188#endif
189 169
190/* The actual gptimer API */ 170/* The actual gptimer API */
191 171
diff --git a/include/asm-blackfin/ide.h b/include/asm-blackfin/ide.h
index 121e272581d6..5b88de115bf4 100644
--- a/include/asm-blackfin/ide.h
+++ b/include/asm-blackfin/ide.h
@@ -19,10 +19,6 @@
19 19
20#define MAX_HWIFS 1 20#define MAX_HWIFS 1
21 21
22/* Legacy ... BLK_DEV_IDECS */
23#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
24
25
26#include <asm-generic/ide_iops.h> 22#include <asm-generic/ide_iops.h>
27 23
28/****************************************************************************/ 24/****************************************************************************/
diff --git a/include/asm-blackfin/mach-bf527/anomaly.h b/include/asm-blackfin/mach-bf527/anomaly.h
index a89120445be6..735fa02fafb2 100644
--- a/include/asm-blackfin/mach-bf527/anomaly.h
+++ b/include/asm-blackfin/mach-bf527/anomaly.h
@@ -2,12 +2,12 @@
2 * File: include/asm-blackfin/mach-bf527/anomaly.h 2 * File: include/asm-blackfin/mach-bf527/anomaly.h
3 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 3 * Bugs: Enter bugs at http://blackfin.uclinux.org/
4 * 4 *
5 * Copyright (C) 2004-2007 Analog Devices Inc. 5 * Copyright (C) 2004-2008 Analog Devices Inc.
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
8 8
9/* This file shoule be up to date with: 9/* This file shoule be up to date with:
10 * - Revision A, May 30, 2007; ADSP-BF527 Blackfin Processor Anomaly List 10 * - Revision C, 01/25/2008; ADSP-BF527 Blackfin Processor Anomaly List
11 */ 11 */
12 12
13#ifndef _MACH_ANOMALY_H_ 13#ifndef _MACH_ANOMALY_H_
@@ -15,35 +15,85 @@
15 15
16/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot2 Not Supported */ 16/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot2 Not Supported */
17#define ANOMALY_05000074 (1) 17#define ANOMALY_05000074 (1)
18/* DMA_RUN Bit Is Not Valid after a Peripheral Receive Channel DMA Stops */
19#define ANOMALY_05000119 (1)
20/* Rx.H Cannot Be Used to Access 16-bit System MMR Registers */ 18/* Rx.H Cannot Be Used to Access 16-bit System MMR Registers */
21#define ANOMALY_05000122 (1) 19#define ANOMALY_05000122 (1)
22/* Spurious Hardware Error from an Access in the Shadow of a Conditional Branch */ 20/* Spurious Hardware Error from an Access in the Shadow of a Conditional Branch */
23#define ANOMALY_05000245 (1) 21#define ANOMALY_05000245 (1)
24/* Sensitivity To Noise with Slow Input Edge Rates on External SPORT TX and RX Clocks */ 22/* Sensitivity To Noise with Slow Input Edge Rates on External SPORT TX and RX Clocks */
25#define ANOMALY_05000265 (1) 23#define ANOMALY_05000265 (1)
26/* Memory-To-Memory DMA Source/Destination Descriptors Must Be in Same Memory Space */
27#define ANOMALY_05000301 (1)
28/* Errors When SSYNC, CSYNC, or Loads to LT, LB and LC Registers Are Interrupted */
29#define ANOMALY_05000312 (1)
30/* Incorrect Access of OTP_STATUS During otp_write() Function */ 24/* Incorrect Access of OTP_STATUS During otp_write() Function */
31#define ANOMALY_05000328 (1) 25#define ANOMALY_05000328 (1)
32/* Disallowed Configuration Prevents Subsequent Allowed Configuration on Host DMA Port */ 26/* Disallowed Configuration Prevents Subsequent Allowed Configuration on Host DMA Port */
33#define ANOMALY_05000337 (1) 27#define ANOMALY_05000337 (1)
34/* TWI Does Not Operate Correctly Under Certain Signal Termination Conditions */ 28/* Ethernet MAC MDIO Reads Do Not Meet IEEE Specification */
29#define ANOMALY_05000341 (1)
30/* TWI May Not Operate Correctly Under Certain Signal Termination Conditions */
35#define ANOMALY_05000342 (1) 31#define ANOMALY_05000342 (1)
36/* Boot ROM Kernel Incorrectly Alters Reset Value of USB Register */ 32/* USB Calibration Value Is Not Initialized */
33#define ANOMALY_05000346 (1)
34/* Preboot Routine Incorrectly Alters Reset Value of USB Register */
37#define ANOMALY_05000347 (1) 35#define ANOMALY_05000347 (1)
36/* Security Features Are Not Functional */
37#define ANOMALY_05000348 (__SILICON_REVISION__ < 1)
38/* Regulator Programming Blocked when Hibernate Wakeup Source Remains Active */
39#define ANOMALY_05000355 (1)
40/* Serial Port (SPORT) Multichannel Transmit Failure when Channel 0 Is Disabled */
41#define ANOMALY_05000357 (1)
42/* Incorrect Revision Number in DSPID Register */
43#define ANOMALY_05000364 (__SILICON_REVISION__ > 0)
44/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */
45#define ANOMALY_05000366 (1)
46/* New Feature: Higher Default CCLK Rate */
47#define ANOMALY_05000368 (1)
48/* Possible RETS Register Corruption when Subroutine Is under 5 Cycles in Duration */
49#define ANOMALY_05000371 (1)
50/* Authentication Fails To Initiate */
51#define ANOMALY_05000376 (__SILICON_REVISION__ > 0)
52/* Data Read From L3 Memory by USB DMA May be Corrupted */
53#define ANOMALY_05000380 (1)
54/* USB Full-speed Mode not Fully Tested */
55#define ANOMALY_05000381 (1)
56/* New Feature: Boot from OTP Memory */
57#define ANOMALY_05000385 (1)
58/* New Feature: bfrom_SysControl() Routine */
59#define ANOMALY_05000386 (1)
60/* New Feature: Programmable Preboot Settings */
61#define ANOMALY_05000387 (1)
62/* Reset Vector Must Not Be in SDRAM Memory Space */
63#define ANOMALY_05000389 (1)
64/* New Feature: pTempCurrent Added to ADI_BOOT_DATA Structure */
65#define ANOMALY_05000392 (1)
66/* New Feature: dTempByteCount Value Increased in ADI_BOOT_DATA Structure */
67#define ANOMALY_05000393 (1)
68/* New Feature: Log Buffer Functionality */
69#define ANOMALY_05000394 (1)
70/* New Feature: Hook Routine Functionality */
71#define ANOMALY_05000395 (1)
72/* New Feature: Header Indirect Bit */
73#define ANOMALY_05000396 (1)
74/* New Feature: BK_ONES, BK_ZEROS, and BK_DATECODE Constants */
75#define ANOMALY_05000397 (1)
76/* New Feature: SWRESET, DFRESET and WDRESET Bits Added to SYSCR Register */
77#define ANOMALY_05000398 (1)
78/* New Feature: BCODE_NOBOOT Added to BCODE Field of SYSCR Register */
79#define ANOMALY_05000399 (1)
80/* PPI Data Signals D0 and D8 do not Tristate After Disabling PPI */
81#define ANOMALY_05000401 (1)
38 82
39/* Anomalies that don't exist on this proc */ 83/* Anomalies that don't exist on this proc */
40#define ANOMALY_05000323 (0)
41#define ANOMALY_05000244 (0)
42#define ANOMALY_05000198 (0)
43#define ANOMALY_05000125 (0) 84#define ANOMALY_05000125 (0)
44#define ANOMALY_05000158 (0) 85#define ANOMALY_05000158 (0)
45#define ANOMALY_05000273 (0) 86#define ANOMALY_05000183 (0)
87#define ANOMALY_05000198 (0)
88#define ANOMALY_05000230 (0)
89#define ANOMALY_05000244 (0)
90#define ANOMALY_05000261 (0)
46#define ANOMALY_05000263 (0) 91#define ANOMALY_05000263 (0)
92#define ANOMALY_05000266 (0)
93#define ANOMALY_05000273 (0)
47#define ANOMALY_05000311 (0) 94#define ANOMALY_05000311 (0)
48#define ANOMALY_05000230 (0) 95#define ANOMALY_05000312 (0)
96#define ANOMALY_05000323 (0)
97#define ANOMALY_05000363 (0)
98
49#endif 99#endif
diff --git a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
index c0694ecd2ecd..f0ab2736a680 100644
--- a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
@@ -1,22 +1,38 @@
1/*
2 * file: include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
3 * based on:
4 * author:
5 *
6 * created:
7 * description:
8 * blackfin serial driver head file
9 * rev:
10 *
11 * modified:
12 *
13 *
14 * bugs: enter bugs at http://blackfin.uclinux.org/
15 *
16 * this program is free software; you can redistribute it and/or modify
17 * it under the terms of the gnu general public license as published by
18 * the free software foundation; either version 2, or (at your option)
19 * any later version.
20 *
21 * this program is distributed in the hope that it will be useful,
22 * but without any warranty; without even the implied warranty of
23 * merchantability or fitness for a particular purpose. see the
24 * gnu general public license for more details.
25 *
26 * you should have received a copy of the gnu general public license
27 * along with this program; see the file copying.
28 * if not, write to the free software foundation,
29 * 59 temple place - suite 330, boston, ma 02111-1307, usa.
30 */
31
1#include <linux/serial.h> 32#include <linux/serial.h>
2#include <asm/dma.h> 33#include <asm/dma.h>
3#include <asm/portmux.h> 34#include <asm/portmux.h>
4 35
5#define NR_PORTS 2
6
7#define OFFSET_THR 0x00 /* Transmit Holding register */
8#define OFFSET_RBR 0x00 /* Receive Buffer register */
9#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
10#define OFFSET_IER 0x04 /* Interrupt Enable Register */
11#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
12#define OFFSET_IIR 0x08 /* Interrupt Identification Register */
13#define OFFSET_LCR 0x0C /* Line Control Register */
14#define OFFSET_MCR 0x10 /* Modem Control Register */
15#define OFFSET_LSR 0x14 /* Line Status Register */
16#define OFFSET_MSR 0x18 /* Modem Status Register */
17#define OFFSET_SCR 0x1C /* SCR Scratch Register */
18#define OFFSET_GCTL 0x24 /* Global Control Register */
19
20#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR)) 36#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR))
21#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL)) 37#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL))
22#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER)) 38#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER))
@@ -92,7 +108,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
92 bfin_write16(uart->port.membase + OFFSET_LSR, -1); 108 bfin_write16(uart->port.membase + OFFSET_LSR, -1);
93} 109}
94 110
95struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 111struct bfin_serial_port bfin_serial_ports[BFIN_UART_NR_PORTS];
96struct bfin_serial_res { 112struct bfin_serial_res {
97 unsigned long uart_base_addr; 113 unsigned long uart_base_addr;
98 int uart_irq; 114 int uart_irq;
diff --git a/include/asm-blackfin/mach-bf527/bfin_sir.h b/include/asm-blackfin/mach-bf527/bfin_sir.h
new file mode 100644
index 000000000000..0612d0c9501c
--- /dev/null
+++ b/include/asm-blackfin/mach-bf527/bfin_sir.h
@@ -0,0 +1,133 @@
1/*
2 * Blackfin Infra-red Driver
3 *
4 * Copyright 2006-2008 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 *
10 */
11
12#include <linux/serial.h>
13#include <asm/dma.h>
14#include <asm/portmux.h>
15
16#define SIR_UART_GET_CHAR(port) bfin_read16((port)->membase + OFFSET_RBR)
17#define SIR_UART_GET_DLL(port) bfin_read16((port)->membase + OFFSET_DLL)
18#define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER)
19#define SIR_UART_GET_DLH(port) bfin_read16((port)->membase + OFFSET_DLH)
20#define SIR_UART_GET_IIR(port) bfin_read16((port)->membase + OFFSET_IIR)
21#define SIR_UART_GET_LCR(port) bfin_read16((port)->membase + OFFSET_LCR)
22#define SIR_UART_GET_GCTL(port) bfin_read16((port)->membase + OFFSET_GCTL)
23
24#define SIR_UART_PUT_CHAR(port, v) bfin_write16(((port)->membase + OFFSET_THR), v)
25#define SIR_UART_PUT_DLL(port, v) bfin_write16(((port)->membase + OFFSET_DLL), v)
26#define SIR_UART_PUT_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER), v)
27#define SIR_UART_PUT_DLH(port, v) bfin_write16(((port)->membase + OFFSET_DLH), v)
28#define SIR_UART_PUT_LCR(port, v) bfin_write16(((port)->membase + OFFSET_LCR), v)
29#define SIR_UART_PUT_GCTL(port, v) bfin_write16(((port)->membase + OFFSET_GCTL), v)
30
31#ifdef CONFIG_SIR_BFIN_DMA
32struct dma_rx_buf {
33 char *buf;
34 int head;
35 int tail;
36 };
37#endif /* CONFIG_SIR_BFIN_DMA */
38
39struct bfin_sir_port {
40 unsigned char __iomem *membase;
41 unsigned int irq;
42 unsigned int lsr;
43 unsigned long clk;
44 struct net_device *dev;
45#ifdef CONFIG_SIR_BFIN_DMA
46 int tx_done;
47 struct dma_rx_buf rx_dma_buf;
48 struct timer_list rx_dma_timer;
49 int rx_dma_nrows;
50#endif /* CONFIG_SIR_BFIN_DMA */
51 unsigned int tx_dma_channel;
52 unsigned int rx_dma_channel;
53};
54
55struct bfin_sir_port sir_ports[BFIN_UART_NR_PORTS];
56
57struct bfin_sir_port_res {
58 unsigned long base_addr;
59 int irq;
60 unsigned int rx_dma_channel;
61 unsigned int tx_dma_channel;
62};
63
64struct bfin_sir_port_res bfin_sir_port_resource[] = {
65#ifdef CONFIG_BFIN_SIR0
66 {
67 0xFFC00400,
68 IRQ_UART0_RX,
69 CH_UART0_RX,
70 CH_UART0_TX,
71 },
72#endif
73#ifdef CONFIG_BFIN_SIR1
74 {
75 0xFFC02000,
76 IRQ_UART1_RX,
77 CH_UART1_RX,
78 CH_UART1_TX,
79 },
80#endif
81};
82
83int nr_sirs = ARRAY_SIZE(bfin_sir_port_resource);
84
85struct bfin_sir_self {
86 struct bfin_sir_port *sir_port;
87 spinlock_t lock;
88 unsigned int open;
89 int speed;
90 int newspeed;
91
92 struct sk_buff *txskb;
93 struct sk_buff *rxskb;
94 struct net_device_stats stats;
95 struct device *dev;
96 struct irlap_cb *irlap;
97 struct qos_info qos;
98
99 iobuff_t tx_buff;
100 iobuff_t rx_buff;
101
102 struct work_struct work;
103 int mtt;
104};
105
106static inline unsigned int SIR_UART_GET_LSR(struct bfin_sir_port *port)
107{
108 unsigned int lsr = bfin_read16(port->membase + OFFSET_LSR);
109 port->lsr |= (lsr & (BI|FE|PE|OE));
110 return lsr | port->lsr;
111}
112
113static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
114{
115 port->lsr = 0;
116 bfin_read16(port->membase + OFFSET_LSR);
117}
118
119#define DRIVER_NAME "bfin_sir"
120
121static void bfin_sir_hw_init(void)
122{
123#ifdef CONFIG_BFIN_SIR0
124 peripheral_request(P_UART0_TX, DRIVER_NAME);
125 peripheral_request(P_UART0_RX, DRIVER_NAME);
126#endif
127
128#ifdef CONFIG_BFIN_SIR1
129 peripheral_request(P_UART1_TX, DRIVER_NAME);
130 peripheral_request(P_UART1_RX, DRIVER_NAME);
131#endif
132 SSYNC();
133}
diff --git a/include/asm-blackfin/mach-bf527/blackfin.h b/include/asm-blackfin/mach-bf527/blackfin.h
index 1bd07e30781c..2891727b6176 100644
--- a/include/asm-blackfin/mach-bf527/blackfin.h
+++ b/include/asm-blackfin/mach-bf527/blackfin.h
@@ -64,6 +64,21 @@
64#define STATUS_P1 0x02 64#define STATUS_P1 0x02
65#define STATUS_P0 0x01 65#define STATUS_P0 0x01
66 66
67#define BFIN_UART_NR_PORTS 2
68
69#define OFFSET_THR 0x00 /* Transmit Holding register */
70#define OFFSET_RBR 0x00 /* Receive Buffer register */
71#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
72#define OFFSET_IER 0x04 /* Interrupt Enable Register */
73#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
74#define OFFSET_IIR 0x08 /* Interrupt Identification Register */
75#define OFFSET_LCR 0x0C /* Line Control Register */
76#define OFFSET_MCR 0x10 /* Modem Control Register */
77#define OFFSET_LSR 0x14 /* Line Status Register */
78#define OFFSET_MSR 0x18 /* Modem Status Register */
79#define OFFSET_SCR 0x1C /* SCR Scratch Register */
80#define OFFSET_GCTL 0x24 /* Global Control Register */
81
67/* DPMC*/ 82/* DPMC*/
68#define bfin_read_STOPCK_OFF() bfin_read_STOPCK() 83#define bfin_read_STOPCK_OFF() bfin_read_STOPCK()
69#define bfin_write_STOPCK_OFF(val) bfin_write_STOPCK(val) 84#define bfin_write_STOPCK_OFF(val) bfin_write_STOPCK(val)
diff --git a/include/asm-blackfin/mach-bf527/cdefBF52x_base.h b/include/asm-blackfin/mach-bf527/cdefBF52x_base.h
index 3f4de5d9d4cb..9dbdbec8ea1b 100644
--- a/include/asm-blackfin/mach-bf527/cdefBF52x_base.h
+++ b/include/asm-blackfin/mach-bf527/cdefBF52x_base.h
@@ -29,18 +29,71 @@
29 */ 29 */
30 30
31#ifndef _CDEF_BF52X_H 31#ifndef _CDEF_BF52X_H
32#define _CDEF_BF52X_H
33
34#include <asm/system.h>
35#include <asm/blackfin.h>
32 36
33#include "defBF52x_base.h" 37#include "defBF52x_base.h"
34 38
39/* Include core specific register pointer definitions */
40#include <asm/mach-common/cdef_LPBlackfin.h>
41
35/* ==== begin from cdefBF534.h ==== */ 42/* ==== begin from cdefBF534.h ==== */
36 43
37/* Clock and System Control (0xFFC00000 - 0xFFC000FF) */ 44/* Clock and System Control (0xFFC00000 - 0xFFC000FF) */
38#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL) 45#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL)
39#define bfin_write_PLL_CTL(val) bfin_write16(PLL_CTL, val) 46/* Writing to PLL_CTL initiates a PLL relock sequence. */
47static __inline__ void bfin_write_PLL_CTL(unsigned int val)
48{
49 unsigned long flags, iwr0, iwr1;
50
51 if (val == bfin_read_PLL_CTL())
52 return;
53
54 local_irq_save(flags);
55 /* Enable the PLL Wakeup bit in SIC IWR */
56 iwr0 = bfin_read32(SIC_IWR0);
57 iwr1 = bfin_read32(SIC_IWR1);
58 /* Only allow PPL Wakeup) */
59 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
60 bfin_write32(SIC_IWR1, 0);
61
62 bfin_write16(PLL_CTL, val);
63 SSYNC();
64 asm("IDLE;");
65
66 bfin_write32(SIC_IWR0, iwr0);
67 bfin_write32(SIC_IWR1, iwr1);
68 local_irq_restore(flags);
69}
40#define bfin_read_PLL_DIV() bfin_read16(PLL_DIV) 70#define bfin_read_PLL_DIV() bfin_read16(PLL_DIV)
41#define bfin_write_PLL_DIV(val) bfin_write16(PLL_DIV, val) 71#define bfin_write_PLL_DIV(val) bfin_write16(PLL_DIV, val)
42#define bfin_read_VR_CTL() bfin_read16(VR_CTL) 72#define bfin_read_VR_CTL() bfin_read16(VR_CTL)
43#define bfin_write_VR_CTL(val) bfin_write16(VR_CTL, val) 73/* Writing to VR_CTL initiates a PLL relock sequence. */
74static __inline__ void bfin_write_VR_CTL(unsigned int val)
75{
76 unsigned long flags, iwr0, iwr1;
77
78 if (val == bfin_read_VR_CTL())
79 return;
80
81 local_irq_save(flags);
82 /* Enable the PLL Wakeup bit in SIC IWR */
83 iwr0 = bfin_read32(SIC_IWR0);
84 iwr1 = bfin_read32(SIC_IWR1);
85 /* Only allow PPL Wakeup) */
86 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
87 bfin_write32(SIC_IWR1, 0);
88
89 bfin_write16(VR_CTL, val);
90 SSYNC();
91 asm("IDLE;");
92
93 bfin_write32(SIC_IWR0, iwr0);
94 bfin_write32(SIC_IWR1, iwr1);
95 local_irq_restore(flags);
96}
44#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT) 97#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT)
45#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT, val) 98#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT, val)
46#define bfin_read_PLL_LOCKCNT() bfin_read16(PLL_LOCKCNT) 99#define bfin_read_PLL_LOCKCNT() bfin_read16(PLL_LOCKCNT)
@@ -873,39 +926,6 @@
873 926
874 927
875/* Two-Wire Interface (0xFFC01400 - 0xFFC014FF) */ 928/* Two-Wire Interface (0xFFC01400 - 0xFFC014FF) */
876#define bfin_read_TWI_CLKDIV() bfin_read16(TWI_CLKDIV)
877#define bfin_write_TWI_CLKDIV(val) bfin_write16(TWI_CLKDIV, val)
878#define bfin_read_TWI_CONTROL() bfin_read16(TWI_CONTROL)
879#define bfin_write_TWI_CONTROL(val) bfin_write16(TWI_CONTROL, val)
880#define bfin_read_TWI_SLAVE_CTL() bfin_read16(TWI_SLAVE_CTL)
881#define bfin_write_TWI_SLAVE_CTL(val) bfin_write16(TWI_SLAVE_CTL, val)
882#define bfin_read_TWI_SLAVE_STAT() bfin_read16(TWI_SLAVE_STAT)
883#define bfin_write_TWI_SLAVE_STAT(val) bfin_write16(TWI_SLAVE_STAT, val)
884#define bfin_read_TWI_SLAVE_ADDR() bfin_read16(TWI_SLAVE_ADDR)
885#define bfin_write_TWI_SLAVE_ADDR(val) bfin_write16(TWI_SLAVE_ADDR, val)
886#define bfin_read_TWI_MASTER_CTL() bfin_read16(TWI_MASTER_CTL)
887#define bfin_write_TWI_MASTER_CTL(val) bfin_write16(TWI_MASTER_CTL, val)
888#define bfin_read_TWI_MASTER_STAT() bfin_read16(TWI_MASTER_STAT)
889#define bfin_write_TWI_MASTER_STAT(val) bfin_write16(TWI_MASTER_STAT, val)
890#define bfin_read_TWI_MASTER_ADDR() bfin_read16(TWI_MASTER_ADDR)
891#define bfin_write_TWI_MASTER_ADDR(val) bfin_write16(TWI_MASTER_ADDR, val)
892#define bfin_read_TWI_INT_STAT() bfin_read16(TWI_INT_STAT)
893#define bfin_write_TWI_INT_STAT(val) bfin_write16(TWI_INT_STAT, val)
894#define bfin_read_TWI_INT_MASK() bfin_read16(TWI_INT_MASK)
895#define bfin_write_TWI_INT_MASK(val) bfin_write16(TWI_INT_MASK, val)
896#define bfin_read_TWI_FIFO_CTL() bfin_read16(TWI_FIFO_CTL)
897#define bfin_write_TWI_FIFO_CTL(val) bfin_write16(TWI_FIFO_CTL, val)
898#define bfin_read_TWI_FIFO_STAT() bfin_read16(TWI_FIFO_STAT)
899#define bfin_write_TWI_FIFO_STAT(val) bfin_write16(TWI_FIFO_STAT, val)
900#define bfin_read_TWI_XMT_DATA8() bfin_read16(TWI_XMT_DATA8)
901#define bfin_write_TWI_XMT_DATA8(val) bfin_write16(TWI_XMT_DATA8, val)
902#define bfin_read_TWI_XMT_DATA16() bfin_read16(TWI_XMT_DATA16)
903#define bfin_write_TWI_XMT_DATA16(val) bfin_write16(TWI_XMT_DATA16, val)
904#define bfin_read_TWI_RCV_DATA8() bfin_read16(TWI_RCV_DATA8)
905#define bfin_write_TWI_RCV_DATA8(val) bfin_write16(TWI_RCV_DATA8, val)
906#define bfin_read_TWI_RCV_DATA16() bfin_read16(TWI_RCV_DATA16)
907#define bfin_write_TWI_RCV_DATA16(val) bfin_write16(TWI_RCV_DATA16, val)
908
909 929
910/* General Purpose I/O Port G (0xFFC01500 - 0xFFC015FF) */ 930/* General Purpose I/O Port G (0xFFC01500 - 0xFFC015FF) */
911#define bfin_read_PORTGIO() bfin_read16(PORTGIO) 931#define bfin_read_PORTGIO() bfin_read16(PORTGIO)
diff --git a/include/asm-blackfin/mach-bf527/dma.h b/include/asm-blackfin/mach-bf527/dma.h
index 2dfee12864f6..49dd693223e8 100644
--- a/include/asm-blackfin/mach-bf527/dma.h
+++ b/include/asm-blackfin/mach-bf527/dma.h
@@ -59,7 +59,4 @@
59#define CH_NFC CH_EMAC_TX /* PPI receive/transmit or NFC */ 59#define CH_NFC CH_EMAC_TX /* PPI receive/transmit or NFC */
60#endif 60#endif
61 61
62extern int channel2irq(unsigned int channel);
63extern struct dma_register *base_addr[];
64
65#endif 62#endif
diff --git a/include/asm-blackfin/mach-bf533/anomaly.h b/include/asm-blackfin/mach-bf533/anomaly.h
index 98209d40abba..5a6dcc5fa36c 100644
--- a/include/asm-blackfin/mach-bf533/anomaly.h
+++ b/include/asm-blackfin/mach-bf533/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 B, 12/10/2007; ADSP-BF531/BF532/BF533 Blackfin Processor Anomaly List 10 * - Revision C, 02/08/2008; ADSP-BF531/BF532/BF533 Blackfin Processor Anomaly List
11 */ 11 */
12 12
13#ifndef _MACH_ANOMALY_H_ 13#ifndef _MACH_ANOMALY_H_
@@ -251,10 +251,18 @@
251#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 */ 252/* Serial Port (SPORT) Multichannel Transmit Failure when Channel 0 Is Disabled */
253#define ANOMALY_05000357 (1) 253#define ANOMALY_05000357 (1)
254/* UART Break Signal Issues */
255#define ANOMALY_05000363 (__SILICON_REVISION__ < 5)
254/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */ 256/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */
255#define ANOMALY_05000366 (1) 257#define ANOMALY_05000366 (1)
256/* Possible RETS Register Corruption when Subroutine Is under 5 Cycles in Duration */ 258/* Possible RETS Register Corruption when Subroutine Is under 5 Cycles in Duration */
257#define ANOMALY_05000371 (1) 259#define ANOMALY_05000371 (1)
260/* PPI Does Not Start Properly In Specific Mode */
261#define ANOMALY_05000400 (__SILICON_REVISION__ == 5)
262/* SSYNC Stalls Processor when Executed from Non-Cacheable Memory */
263#define ANOMALY_05000402 (__SILICON_REVISION__ == 5)
264/* Level-Sensitive External GPIO Wakeups May Cause Indefinite Stall */
265#define ANOMALY_05000403 (1)
258 266
259/* Anomalies that don't exist on this proc */ 267/* Anomalies that don't exist on this proc */
260#define ANOMALY_05000266 (0) 268#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 b6f513bee56e..fbe88dee3e2d 100644
--- a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
@@ -1,22 +1,38 @@
1/*
2 * file: include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
3 * based on:
4 * author:
5 *
6 * created:
7 * description:
8 * blackfin serial driver head file
9 * rev:
10 *
11 * modified:
12 *
13 *
14 * bugs: enter bugs at http://blackfin.uclinux.org/
15 *
16 * this program is free software; you can redistribute it and/or modify
17 * it under the terms of the gnu general public license as published by
18 * the free software foundation; either version 2, or (at your option)
19 * any later version.
20 *
21 * this program is distributed in the hope that it will be useful,
22 * but without any warranty; without even the implied warranty of
23 * merchantability or fitness for a particular purpose. see the
24 * gnu general public license for more details.
25 *
26 * you should have received a copy of the gnu general public license
27 * along with this program; see the file copying.
28 * if not, write to the free software foundation,
29 * 59 temple place - suite 330, boston, ma 02111-1307, usa.
30 */
31
1#include <linux/serial.h> 32#include <linux/serial.h>
2#include <asm/dma.h> 33#include <asm/dma.h>
3#include <asm/portmux.h> 34#include <asm/portmux.h>
4 35
5#define NR_PORTS 1
6
7#define OFFSET_THR 0x00 /* Transmit Holding register */
8#define OFFSET_RBR 0x00 /* Receive Buffer register */
9#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
10#define OFFSET_IER 0x04 /* Interrupt Enable Register */
11#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
12#define OFFSET_IIR 0x08 /* Interrupt Identification Register */
13#define OFFSET_LCR 0x0C /* Line Control Register */
14#define OFFSET_MCR 0x10 /* Modem Control Register */
15#define OFFSET_LSR 0x14 /* Line Status Register */
16#define OFFSET_MSR 0x18 /* Modem Status Register */
17#define OFFSET_SCR 0x1C /* SCR Scratch Register */
18#define OFFSET_GCTL 0x24 /* Global Control Register */
19
20#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR)) 36#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR))
21#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL)) 37#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL))
22#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER)) 38#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER))
@@ -84,7 +100,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
84 bfin_write16(uart->port.membase + OFFSET_LSR, -1); 100 bfin_write16(uart->port.membase + OFFSET_LSR, -1);
85} 101}
86 102
87struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 103struct bfin_serial_port bfin_serial_ports[BFIN_UART_NR_PORTS];
88struct bfin_serial_res { 104struct bfin_serial_res {
89 unsigned long uart_base_addr; 105 unsigned long uart_base_addr;
90 int uart_irq; 106 int uart_irq;
@@ -115,7 +131,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
115 131
116#define DRIVER_NAME "bfin-uart" 132#define DRIVER_NAME "bfin-uart"
117 133
118int nr_ports = NR_PORTS; 134int nr_ports = BFIN_UART_NR_PORTS;
119static void bfin_serial_hw_init(struct bfin_serial_port *uart) 135static void bfin_serial_hw_init(struct bfin_serial_port *uart)
120{ 136{
121 137
diff --git a/include/asm-blackfin/mach-bf533/bfin_sir.h b/include/asm-blackfin/mach-bf533/bfin_sir.h
new file mode 100644
index 000000000000..cefcf8bb505b
--- /dev/null
+++ b/include/asm-blackfin/mach-bf533/bfin_sir.h
@@ -0,0 +1,120 @@
1/*
2 * Blackfin Infra-red Driver
3 *
4 * Copyright 2006-2008 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 *
10 */
11
12#include <linux/serial.h>
13#include <asm/dma.h>
14#include <asm/portmux.h>
15
16#define SIR_UART_GET_CHAR(port) bfin_read16((port)->membase + OFFSET_RBR)
17#define SIR_UART_GET_DLL(port) bfin_read16((port)->membase + OFFSET_DLL)
18#define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER)
19#define SIR_UART_GET_DLH(port) bfin_read16((port)->membase + OFFSET_DLH)
20#define SIR_UART_GET_IIR(port) bfin_read16((port)->membase + OFFSET_IIR)
21#define SIR_UART_GET_LCR(port) bfin_read16((port)->membase + OFFSET_LCR)
22#define SIR_UART_GET_GCTL(port) bfin_read16((port)->membase + OFFSET_GCTL)
23
24#define SIR_UART_PUT_CHAR(port, v) bfin_write16(((port)->membase + OFFSET_THR), v)
25#define SIR_UART_PUT_DLL(port, v) bfin_write16(((port)->membase + OFFSET_DLL), v)
26#define SIR_UART_PUT_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER), v)
27#define SIR_UART_PUT_DLH(port, v) bfin_write16(((port)->membase + OFFSET_DLH), v)
28#define SIR_UART_PUT_LCR(port, v) bfin_write16(((port)->membase + OFFSET_LCR), v)
29#define SIR_UART_PUT_GCTL(port, v) bfin_write16(((port)->membase + OFFSET_GCTL), v)
30
31#ifdef CONFIG_SIR_BFIN_DMA
32struct dma_rx_buf {
33 char *buf;
34 int head;
35 int tail;
36 };
37#endif /* CONFIG_SIR_BFIN_DMA */
38
39struct bfin_sir_port {
40 unsigned char __iomem *membase;
41 unsigned int irq;
42 unsigned int lsr;
43 unsigned long clk;
44 struct net_device *dev;
45#ifdef CONFIG_SIR_BFIN_DMA
46 int tx_done;
47 struct dma_rx_buf rx_dma_buf;
48 struct timer_list rx_dma_timer;
49 int rx_dma_nrows;
50#endif /* CONFIG_SIR_BFIN_DMA */
51 unsigned int tx_dma_channel;
52 unsigned int rx_dma_channel;
53};
54
55struct bfin_sir_port sir_ports[BFIN_UART_NR_PORTS];
56
57struct bfin_sir_port_res {
58 unsigned long base_addr;
59 int irq;
60 unsigned int rx_dma_channel;
61 unsigned int tx_dma_channel;
62};
63
64struct bfin_sir_port_res bfin_sir_port_resource[] = {
65#ifdef CONFIG_BFIN_SIR0
66 {
67 0xFFC00400,
68 IRQ_UART_RX,
69 CH_UART_RX,
70 CH_UART_TX,
71 },
72#endif
73};
74
75int nr_sirs = ARRAY_SIZE(bfin_sir_port_resource);
76
77struct bfin_sir_self {
78 struct bfin_sir_port *sir_port;
79 spinlock_t lock;
80 unsigned int open;
81 int speed;
82 int newspeed;
83
84 struct sk_buff *txskb;
85 struct sk_buff *rxskb;
86 struct net_device_stats stats;
87 struct device *dev;
88 struct irlap_cb *irlap;
89 struct qos_info qos;
90
91 iobuff_t tx_buff;
92 iobuff_t rx_buff;
93
94 struct work_struct work;
95 int mtt;
96};
97
98static inline unsigned int SIR_UART_GET_LSR(struct bfin_sir_port *port)
99{
100 unsigned int lsr = bfin_read16(port->membase + OFFSET_LSR);
101 port->lsr |= (lsr & (BI|FE|PE|OE));
102 return lsr | port->lsr;
103}
104
105static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
106{
107 port->lsr = 0;
108 bfin_read16(port->membase + OFFSET_LSR);
109}
110
111#define DRIVER_NAME "bfin_sir"
112
113static void bfin_sir_hw_init(void)
114{
115#ifdef CONFIG_BFIN_SIR0
116 peripheral_request(P_UART0_TX, DRIVER_NAME);
117 peripheral_request(P_UART0_RX, DRIVER_NAME);
118#endif
119 SSYNC();
120}
diff --git a/include/asm-blackfin/mach-bf533/blackfin.h b/include/asm-blackfin/mach-bf533/blackfin.h
index f3b240abf170..d80971b4e3aa 100644
--- a/include/asm-blackfin/mach-bf533/blackfin.h
+++ b/include/asm-blackfin/mach-bf533/blackfin.h
@@ -42,4 +42,19 @@
42#include "cdefBF532.h" 42#include "cdefBF532.h"
43#endif 43#endif
44 44
45#define BFIN_UART_NR_PORTS 1
46
47#define OFFSET_THR 0x00 /* Transmit Holding register */
48#define OFFSET_RBR 0x00 /* Receive Buffer register */
49#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
50#define OFFSET_IER 0x04 /* Interrupt Enable Register */
51#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
52#define OFFSET_IIR 0x08 /* Interrupt Identification Register */
53#define OFFSET_LCR 0x0C /* Line Control Register */
54#define OFFSET_MCR 0x10 /* Modem Control Register */
55#define OFFSET_LSR 0x14 /* Line Status Register */
56#define OFFSET_MSR 0x18 /* Modem Status Register */
57#define OFFSET_SCR 0x1C /* SCR Scratch Register */
58#define OFFSET_GCTL 0x24 /* Global Control Register */
59
45#endif /* _MACH_BLACKFIN_H_ */ 60#endif /* _MACH_BLACKFIN_H_ */
diff --git a/include/asm-blackfin/mach-bf533/cdefBF532.h b/include/asm-blackfin/mach-bf533/cdefBF532.h
index c803e14b529c..154655452d4c 100644
--- a/include/asm-blackfin/mach-bf533/cdefBF532.h
+++ b/include/asm-blackfin/mach-bf533/cdefBF532.h
@@ -43,7 +43,27 @@
43 43
44/* Clock and System Control (0xFFC0 0400-0xFFC0 07FF) */ 44/* Clock and System Control (0xFFC0 0400-0xFFC0 07FF) */
45#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL) 45#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL)
46#define bfin_write_PLL_CTL(val) bfin_write16(PLL_CTL,val) 46/* Writing to PLL_CTL initiates a PLL relock sequence. */
47static __inline__ void bfin_write_PLL_CTL(unsigned int val)
48{
49 unsigned long flags, iwr;
50
51 if (val == bfin_read_PLL_CTL())
52 return;
53
54 local_irq_save(flags);
55 /* Enable the PLL Wakeup bit in SIC IWR */
56 iwr = bfin_read32(SIC_IWR);
57 /* Only allow PPL Wakeup) */
58 bfin_write32(SIC_IWR, IWR_ENABLE(0));
59
60 bfin_write16(PLL_CTL, val);
61 SSYNC();
62 asm("IDLE;");
63
64 bfin_write32(SIC_IWR, iwr);
65 local_irq_restore(flags);
66}
47#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT) 67#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT)
48#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT,val) 68#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT,val)
49#define bfin_read_PLL_LOCKCNT() bfin_read16(PLL_LOCKCNT) 69#define bfin_read_PLL_LOCKCNT() bfin_read16(PLL_LOCKCNT)
@@ -57,6 +77,10 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
57{ 77{
58 unsigned long flags, iwr; 78 unsigned long flags, iwr;
59 79
80 if (val == bfin_read_VR_CTL())
81 return;
82
83 local_irq_save(flags);
60 /* Enable the PLL Wakeup bit in SIC IWR */ 84 /* Enable the PLL Wakeup bit in SIC IWR */
61 iwr = bfin_read32(SIC_IWR); 85 iwr = bfin_read32(SIC_IWR);
62 /* Only allow PPL Wakeup) */ 86 /* Only allow PPL Wakeup) */
@@ -64,11 +88,10 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
64 88
65 bfin_write16(VR_CTL, val); 89 bfin_write16(VR_CTL, val);
66 SSYNC(); 90 SSYNC();
67
68 local_irq_save(flags);
69 asm("IDLE;"); 91 asm("IDLE;");
70 local_irq_restore(flags); 92
71 bfin_write32(SIC_IWR, iwr); 93 bfin_write32(SIC_IWR, iwr);
94 local_irq_restore(flags);
72} 95}
73 96
74/* System Interrupt Controller (0xFFC0 0C00-0xFFC0 0FFF) */ 97/* System Interrupt Controller (0xFFC0 0C00-0xFFC0 0FFF) */
diff --git a/include/asm-blackfin/mach-bf533/defBF532.h b/include/asm-blackfin/mach-bf533/defBF532.h
index 37134aaf9954..17e1548cec08 100644
--- a/include/asm-blackfin/mach-bf533/defBF532.h
+++ b/include/asm-blackfin/mach-bf533/defBF532.h
@@ -88,20 +88,25 @@
88#define RTC_PREN 0xFFC00314 /* RTC Prescaler Enable Register (alternate macro) */ 88#define RTC_PREN 0xFFC00314 /* RTC Prescaler Enable Register (alternate macro) */
89 89
90/* UART Controller (0xFFC00400 - 0xFFC004FF) */ 90/* UART Controller (0xFFC00400 - 0xFFC004FF) */
91#define UART_THR 0xFFC00400 /* Transmit Holding register */ 91
92#define UART_RBR 0xFFC00400 /* Receive Buffer register */ 92/*
93#define UART_DLL 0xFFC00400 /* Divisor Latch (Low-Byte) */ 93 * Because include/linux/serial_reg.h have defined UART_*,
94#define UART_IER 0xFFC00404 /* Interrupt Enable Register */ 94 * So we define blackfin uart regs to BFIN_UART_*.
95#define UART_DLH 0xFFC00404 /* Divisor Latch (High-Byte) */ 95 */
96#define UART_IIR 0xFFC00408 /* Interrupt Identification Register */ 96#define BFIN_UART_THR 0xFFC00400 /* Transmit Holding register */
97#define UART_LCR 0xFFC0040C /* Line Control Register */ 97#define BFIN_UART_RBR 0xFFC00400 /* Receive Buffer register */
98#define UART_MCR 0xFFC00410 /* Modem Control Register */ 98#define BFIN_UART_DLL 0xFFC00400 /* Divisor Latch (Low-Byte) */
99#define UART_LSR 0xFFC00414 /* Line Status Register */ 99#define BFIN_UART_IER 0xFFC00404 /* Interrupt Enable Register */
100#define BFIN_UART_DLH 0xFFC00404 /* Divisor Latch (High-Byte) */
101#define BFIN_UART_IIR 0xFFC00408 /* Interrupt Identification Register */
102#define BFIN_UART_LCR 0xFFC0040C /* Line Control Register */
103#define BFIN_UART_MCR 0xFFC00410 /* Modem Control Register */
104#define BFIN_UART_LSR 0xFFC00414 /* Line Status Register */
100#if 0 105#if 0
101#define UART_MSR 0xFFC00418 /* Modem Status Register (UNUSED in ADSP-BF532) */ 106#define BFIN_UART_MSR 0xFFC00418 /* Modem Status Register (UNUSED in ADSP-BF532) */
102#endif 107#endif
103#define UART_SCR 0xFFC0041C /* SCR Scratch Register */ 108#define BFIN_UART_SCR 0xFFC0041C /* SCR Scratch Register */
104#define UART_GCTL 0xFFC00424 /* Global Control Register */ 109#define BFIN_UART_GCTL 0xFFC00424 /* Global Control Register */
105 110
106/* SPI Controller (0xFFC00500 - 0xFFC005FF) */ 111/* SPI Controller (0xFFC00500 - 0xFFC005FF) */
107#define SPI0_REGBASE 0xFFC00500 112#define SPI0_REGBASE 0xFFC00500
diff --git a/include/asm-blackfin/mach-bf533/dma.h b/include/asm-blackfin/mach-bf533/dma.h
index 16c672c01d80..bd9d5e94307d 100644
--- a/include/asm-blackfin/mach-bf533/dma.h
+++ b/include/asm-blackfin/mach-bf533/dma.h
@@ -51,7 +51,4 @@
51#define CH_MEM_STREAM1_DEST 10 /* TX */ 51#define CH_MEM_STREAM1_DEST 10 /* TX */
52#define CH_MEM_STREAM1_SRC 11 /* RX */ 52#define CH_MEM_STREAM1_SRC 11 /* RX */
53 53
54extern int channel2irq(unsigned int channel);
55extern struct dma_register *base_addr[];
56
57#endif 54#endif
diff --git a/include/asm-blackfin/mach-bf533/mem_init.h b/include/asm-blackfin/mach-bf533/mem_init.h
index 1620dae5254d..f8f31901fca9 100644
--- a/include/asm-blackfin/mach-bf533/mem_init.h
+++ b/include/asm-blackfin/mach-bf533/mem_init.h
@@ -29,7 +29,8 @@
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 31
32#if (CONFIG_MEM_MT48LC16M16A2TG_75 || CONFIG_MEM_MT48LC64M4A2FB_7E || CONFIG_MEM_GENERIC_BOARD) 32#if (CONFIG_MEM_MT48LC16M16A2TG_75 || CONFIG_MEM_MT48LC64M4A2FB_7E || \
33 CONFIG_MEM_MT48LC32M16A2TG_75 || CONFIG_MEM_GENERIC_BOARD)
33#if (CONFIG_SCLK_HZ > 119402985) 34#if (CONFIG_SCLK_HZ > 119402985)
34#define SDRAM_tRP TRP_2 35#define SDRAM_tRP TRP_2
35#define SDRAM_tRP_num 2 36#define SDRAM_tRP_num 2
@@ -118,6 +119,13 @@
118#define SDRAM_CL CL_3 119#define SDRAM_CL CL_3
119#endif 120#endif
120 121
122#if (CONFIG_MEM_MT48LC32M16A2TG_75)
123 /*SDRAM INFORMATION: */
124#define SDRAM_Tref 64 /* Refresh period in milliseconds */
125#define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
126#define SDRAM_CL CL_3
127#endif
128
121#if (CONFIG_MEM_GENERIC_BOARD) 129#if (CONFIG_MEM_GENERIC_BOARD)
122 /*SDRAM INFORMATION: Modify this for your board */ 130 /*SDRAM INFORMATION: Modify this for your board */
123#define SDRAM_Tref 64 /* Refresh period in milliseconds */ 131#define SDRAM_Tref 64 /* Refresh period in milliseconds */
diff --git a/include/asm-blackfin/mach-bf537/anomaly.h b/include/asm-blackfin/mach-bf537/anomaly.h
index 746a794b3119..a6b08facb242 100644
--- a/include/asm-blackfin/mach-bf537/anomaly.h
+++ b/include/asm-blackfin/mach-bf537/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 A, 09/04/2007; ADSP-BF534/ADSP-BF536/ADSP-BF537 Blackfin Processor Anomaly List 10 * - Revision C, 02/08/2008; ADSP-BF534/ADSP-BF536/ADSP-BF537 Blackfin Processor Anomaly List
11 */ 11 */
12 12
13#ifndef _MACH_ANOMALY_H_ 13#ifndef _MACH_ANOMALY_H_
@@ -132,10 +132,24 @@
132#define ANOMALY_05000322 (1) 132#define ANOMALY_05000322 (1)
133/* Ethernet MAC MDIO Reads Do Not Meet IEEE Specification */ 133/* Ethernet MAC MDIO Reads Do Not Meet IEEE Specification */
134#define ANOMALY_05000341 (__SILICON_REVISION__ >= 3) 134#define ANOMALY_05000341 (__SILICON_REVISION__ >= 3)
135/* New Feature: UART Remains Enabled after UART Boot (Not Available on Older Silicon) */
136#define ANOMALY_05000350 (__SILICON_REVISION__ < 3)
137/* Regulator Programming Blocked when Hibernate Wakeup Source Remains Active */
138#define ANOMALY_05000355 (1)
135/* Serial Port (SPORT) Multichannel Transmit Failure when Channel 0 Is Disabled */ 139/* Serial Port (SPORT) Multichannel Transmit Failure when Channel 0 Is Disabled */
136#define ANOMALY_05000357 (1) 140#define ANOMALY_05000357 (1)
137/* DMAs that Go Urgent during Tight Core Writes to External Memory Are Blocked */ 141/* DMAs that Go Urgent during Tight Core Writes to External Memory Are Blocked */
138#define ANOMALY_05000359 (1) 142#define ANOMALY_05000359 (1)
143/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */
144#define ANOMALY_05000366 (1)
145/* Possible RETS Register Corruption when Subroutine Is under 5 Cycles in Duration */
146#define ANOMALY_05000371 (1)
147/* SSYNC Stalls Processor when Executed from Non-Cacheable Memory */
148#define ANOMALY_05000402 (__SILICON_REVISION__ >= 3)
149/* Level-Sensitive External GPIO Wakeups May Cause Indefinite Stall */
150#define ANOMALY_05000403 (1)
151
152
139 153
140/* Anomalies that don't exist on this proc */ 154/* Anomalies that don't exist on this proc */
141#define ANOMALY_05000125 (0) 155#define ANOMALY_05000125 (0)
@@ -146,5 +160,6 @@
146#define ANOMALY_05000266 (0) 160#define ANOMALY_05000266 (0)
147#define ANOMALY_05000311 (0) 161#define ANOMALY_05000311 (0)
148#define ANOMALY_05000323 (0) 162#define ANOMALY_05000323 (0)
163#define ANOMALY_05000363 (0)
149 164
150#endif 165#endif
diff --git a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
index 8fc672d31057..fd100a415b98 100644
--- a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
@@ -1,22 +1,38 @@
1/*
2 * file: include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
3 * based on:
4 * author:
5 *
6 * created:
7 * description:
8 * blackfin serial driver header files
9 * rev:
10 *
11 * modified:
12 *
13 *
14 * bugs: enter bugs at http://blackfin.uclinux.org/
15 *
16 * this program is free software; you can redistribute it and/or modify
17 * it under the terms of the gnu general public license as published by
18 * the free software foundation; either version 2, or (at your option)
19 * any later version.
20 *
21 * this program is distributed in the hope that it will be useful,
22 * but without any warranty; without even the implied warranty of
23 * merchantability or fitness for a particular purpose. see the
24 * gnu general public license for more details.
25 *
26 * you should have received a copy of the gnu general public license
27 * along with this program; see the file copying.
28 * if not, write to the free software foundation,
29 * 59 temple place - suite 330, boston, ma 02111-1307, usa.
30 */
31
1#include <linux/serial.h> 32#include <linux/serial.h>
2#include <asm/dma.h> 33#include <asm/dma.h>
3#include <asm/portmux.h> 34#include <asm/portmux.h>
4 35
5#define NR_PORTS 2
6
7#define OFFSET_THR 0x00 /* Transmit Holding register */
8#define OFFSET_RBR 0x00 /* Receive Buffer register */
9#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
10#define OFFSET_IER 0x04 /* Interrupt Enable Register */
11#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
12#define OFFSET_IIR 0x08 /* Interrupt Identification Register */
13#define OFFSET_LCR 0x0C /* Line Control Register */
14#define OFFSET_MCR 0x10 /* Modem Control Register */
15#define OFFSET_LSR 0x14 /* Line Status Register */
16#define OFFSET_MSR 0x18 /* Modem Status Register */
17#define OFFSET_SCR 0x1C /* SCR Scratch Register */
18#define OFFSET_GCTL 0x24 /* Global Control Register */
19
20#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR)) 36#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR))
21#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL)) 37#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL))
22#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER)) 38#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER))
@@ -92,7 +108,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
92 bfin_write16(uart->port.membase + OFFSET_LSR, -1); 108 bfin_write16(uart->port.membase + OFFSET_LSR, -1);
93} 109}
94 110
95struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 111struct bfin_serial_port bfin_serial_ports[BFIN_UART_NR_PORTS];
96struct bfin_serial_res { 112struct bfin_serial_res {
97 unsigned long uart_base_addr; 113 unsigned long uart_base_addr;
98 int uart_irq; 114 int uart_irq;
diff --git a/include/asm-blackfin/mach-bf537/bfin_sir.h b/include/asm-blackfin/mach-bf537/bfin_sir.h
new file mode 100644
index 000000000000..0612d0c9501c
--- /dev/null
+++ b/include/asm-blackfin/mach-bf537/bfin_sir.h
@@ -0,0 +1,133 @@
1/*
2 * Blackfin Infra-red Driver
3 *
4 * Copyright 2006-2008 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 *
10 */
11
12#include <linux/serial.h>
13#include <asm/dma.h>
14#include <asm/portmux.h>
15
16#define SIR_UART_GET_CHAR(port) bfin_read16((port)->membase + OFFSET_RBR)
17#define SIR_UART_GET_DLL(port) bfin_read16((port)->membase + OFFSET_DLL)
18#define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER)
19#define SIR_UART_GET_DLH(port) bfin_read16((port)->membase + OFFSET_DLH)
20#define SIR_UART_GET_IIR(port) bfin_read16((port)->membase + OFFSET_IIR)
21#define SIR_UART_GET_LCR(port) bfin_read16((port)->membase + OFFSET_LCR)
22#define SIR_UART_GET_GCTL(port) bfin_read16((port)->membase + OFFSET_GCTL)
23
24#define SIR_UART_PUT_CHAR(port, v) bfin_write16(((port)->membase + OFFSET_THR), v)
25#define SIR_UART_PUT_DLL(port, v) bfin_write16(((port)->membase + OFFSET_DLL), v)
26#define SIR_UART_PUT_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER), v)
27#define SIR_UART_PUT_DLH(port, v) bfin_write16(((port)->membase + OFFSET_DLH), v)
28#define SIR_UART_PUT_LCR(port, v) bfin_write16(((port)->membase + OFFSET_LCR), v)
29#define SIR_UART_PUT_GCTL(port, v) bfin_write16(((port)->membase + OFFSET_GCTL), v)
30
31#ifdef CONFIG_SIR_BFIN_DMA
32struct dma_rx_buf {
33 char *buf;
34 int head;
35 int tail;
36 };
37#endif /* CONFIG_SIR_BFIN_DMA */
38
39struct bfin_sir_port {
40 unsigned char __iomem *membase;
41 unsigned int irq;
42 unsigned int lsr;
43 unsigned long clk;
44 struct net_device *dev;
45#ifdef CONFIG_SIR_BFIN_DMA
46 int tx_done;
47 struct dma_rx_buf rx_dma_buf;
48 struct timer_list rx_dma_timer;
49 int rx_dma_nrows;
50#endif /* CONFIG_SIR_BFIN_DMA */
51 unsigned int tx_dma_channel;
52 unsigned int rx_dma_channel;
53};
54
55struct bfin_sir_port sir_ports[BFIN_UART_NR_PORTS];
56
57struct bfin_sir_port_res {
58 unsigned long base_addr;
59 int irq;
60 unsigned int rx_dma_channel;
61 unsigned int tx_dma_channel;
62};
63
64struct bfin_sir_port_res bfin_sir_port_resource[] = {
65#ifdef CONFIG_BFIN_SIR0
66 {
67 0xFFC00400,
68 IRQ_UART0_RX,
69 CH_UART0_RX,
70 CH_UART0_TX,
71 },
72#endif
73#ifdef CONFIG_BFIN_SIR1
74 {
75 0xFFC02000,
76 IRQ_UART1_RX,
77 CH_UART1_RX,
78 CH_UART1_TX,
79 },
80#endif
81};
82
83int nr_sirs = ARRAY_SIZE(bfin_sir_port_resource);
84
85struct bfin_sir_self {
86 struct bfin_sir_port *sir_port;
87 spinlock_t lock;
88 unsigned int open;
89 int speed;
90 int newspeed;
91
92 struct sk_buff *txskb;
93 struct sk_buff *rxskb;
94 struct net_device_stats stats;
95 struct device *dev;
96 struct irlap_cb *irlap;
97 struct qos_info qos;
98
99 iobuff_t tx_buff;
100 iobuff_t rx_buff;
101
102 struct work_struct work;
103 int mtt;
104};
105
106static inline unsigned int SIR_UART_GET_LSR(struct bfin_sir_port *port)
107{
108 unsigned int lsr = bfin_read16(port->membase + OFFSET_LSR);
109 port->lsr |= (lsr & (BI|FE|PE|OE));
110 return lsr | port->lsr;
111}
112
113static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
114{
115 port->lsr = 0;
116 bfin_read16(port->membase + OFFSET_LSR);
117}
118
119#define DRIVER_NAME "bfin_sir"
120
121static void bfin_sir_hw_init(void)
122{
123#ifdef CONFIG_BFIN_SIR0
124 peripheral_request(P_UART0_TX, DRIVER_NAME);
125 peripheral_request(P_UART0_RX, DRIVER_NAME);
126#endif
127
128#ifdef CONFIG_BFIN_SIR1
129 peripheral_request(P_UART1_TX, DRIVER_NAME);
130 peripheral_request(P_UART1_RX, DRIVER_NAME);
131#endif
132 SSYNC();
133}
diff --git a/include/asm-blackfin/mach-bf537/blackfin.h b/include/asm-blackfin/mach-bf537/blackfin.h
index 53fcfa3408d0..cffc786b2a2b 100644
--- a/include/asm-blackfin/mach-bf537/blackfin.h
+++ b/include/asm-blackfin/mach-bf537/blackfin.h
@@ -82,8 +82,6 @@
82#define STATUS_P1 0x02 82#define STATUS_P1 0x02
83#define STATUS_P0 0x01 83#define STATUS_P0 0x01
84 84
85/* UART 0*/
86
87/* DMA Channnel */ 85/* DMA Channnel */
88#define bfin_read_CH_UART_RX() bfin_read_CH_UART0_RX() 86#define bfin_read_CH_UART_RX() bfin_read_CH_UART0_RX()
89#define bfin_write_CH_UART_RX(val) bfin_write_CH_UART0_RX(val) 87#define bfin_write_CH_UART_RX(val) bfin_write_CH_UART0_RX(val)
@@ -106,37 +104,52 @@
106/* MMR Registers*/ 104/* MMR Registers*/
107#define bfin_read_UART_THR() bfin_read_UART0_THR() 105#define bfin_read_UART_THR() bfin_read_UART0_THR()
108#define bfin_write_UART_THR(val) bfin_write_UART0_THR(val) 106#define bfin_write_UART_THR(val) bfin_write_UART0_THR(val)
109#define UART_THR UART0_THR 107#define BFIN_UART_THR UART0_THR
110#define bfin_read_UART_RBR() bfin_read_UART0_RBR() 108#define bfin_read_UART_RBR() bfin_read_UART0_RBR()
111#define bfin_write_UART_RBR(val) bfin_write_UART0_RBR(val) 109#define bfin_write_UART_RBR(val) bfin_write_UART0_RBR(val)
112#define UART_RBR UART0_RBR 110#define BFIN_UART_RBR UART0_RBR
113#define bfin_read_UART_DLL() bfin_read_UART0_DLL() 111#define bfin_read_UART_DLL() bfin_read_UART0_DLL()
114#define bfin_write_UART_DLL(val) bfin_write_UART0_DLL(val) 112#define bfin_write_UART_DLL(val) bfin_write_UART0_DLL(val)
115#define UART_DLL UART0_DLL 113#define BFIN_UART_DLL UART0_DLL
116#define bfin_read_UART_IER() bfin_read_UART0_IER() 114#define bfin_read_UART_IER() bfin_read_UART0_IER()
117#define bfin_write_UART_IER(val) bfin_write_UART0_IER(val) 115#define bfin_write_UART_IER(val) bfin_write_UART0_IER(val)
118#define UART_IER UART0_IER 116#define BFIN_UART_IER UART0_IER
119#define bfin_read_UART_DLH() bfin_read_UART0_DLH() 117#define bfin_read_UART_DLH() bfin_read_UART0_DLH()
120#define bfin_write_UART_DLH(val) bfin_write_UART0_DLH(val) 118#define bfin_write_UART_DLH(val) bfin_write_UART0_DLH(val)
121#define UART_DLH UART0_DLH 119#define BFIN_UART_DLH UART0_DLH
122#define bfin_read_UART_IIR() bfin_read_UART0_IIR() 120#define bfin_read_UART_IIR() bfin_read_UART0_IIR()
123#define bfin_write_UART_IIR(val) bfin_write_UART0_IIR(val) 121#define bfin_write_UART_IIR(val) bfin_write_UART0_IIR(val)
124#define UART_IIR UART0_IIR 122#define BFIN_UART_IIR UART0_IIR
125#define bfin_read_UART_LCR() bfin_read_UART0_LCR() 123#define bfin_read_UART_LCR() bfin_read_UART0_LCR()
126#define bfin_write_UART_LCR(val) bfin_write_UART0_LCR(val) 124#define bfin_write_UART_LCR(val) bfin_write_UART0_LCR(val)
127#define UART_LCR UART0_LCR 125#define BFIN_UART_LCR UART0_LCR
128#define bfin_read_UART_MCR() bfin_read_UART0_MCR() 126#define bfin_read_UART_MCR() bfin_read_UART0_MCR()
129#define bfin_write_UART_MCR(val) bfin_write_UART0_MCR(val) 127#define bfin_write_UART_MCR(val) bfin_write_UART0_MCR(val)
130#define UART_MCR UART0_MCR 128#define BFIN_UART_MCR UART0_MCR
131#define bfin_read_UART_LSR() bfin_read_UART0_LSR() 129#define bfin_read_UART_LSR() bfin_read_UART0_LSR()
132#define bfin_write_UART_LSR(val) bfin_write_UART0_LSR(val) 130#define bfin_write_UART_LSR(val) bfin_write_UART0_LSR(val)
133#define UART_LSR UART0_LSR 131#define BFIN_UART_LSR UART0_LSR
134#define bfin_read_UART_SCR() bfin_read_UART0_SCR() 132#define bfin_read_UART_SCR() bfin_read_UART0_SCR()
135#define bfin_write_UART_SCR(val) bfin_write_UART0_SCR(val) 133#define bfin_write_UART_SCR(val) bfin_write_UART0_SCR(val)
136#define UART_SCR UART0_SCR 134#define BFIN_UART_SCR UART0_SCR
137#define bfin_read_UART_GCTL() bfin_read_UART0_GCTL() 135#define bfin_read_UART_GCTL() bfin_read_UART0_GCTL()
138#define bfin_write_UART_GCTL(val) bfin_write_UART0_GCTL(val) 136#define bfin_write_UART_GCTL(val) bfin_write_UART0_GCTL(val)
139#define UART_GCTL UART0_GCTL 137#define BFIN_UART_GCTL UART0_GCTL
138
139#define BFIN_UART_NR_PORTS 2
140
141#define OFFSET_THR 0x00 /* Transmit Holding register */
142#define OFFSET_RBR 0x00 /* Receive Buffer register */
143#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
144#define OFFSET_IER 0x04 /* Interrupt Enable Register */
145#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
146#define OFFSET_IIR 0x08 /* Interrupt Identification Register */
147#define OFFSET_LCR 0x0C /* Line Control Register */
148#define OFFSET_MCR 0x10 /* Modem Control Register */
149#define OFFSET_LSR 0x14 /* Line Status Register */
150#define OFFSET_MSR 0x18 /* Modem Status Register */
151#define OFFSET_SCR 0x1C /* SCR Scratch Register */
152#define OFFSET_GCTL 0x24 /* Global Control Register */
140 153
141/* DPMC*/ 154/* DPMC*/
142#define bfin_read_STOPCK_OFF() bfin_read_STOPCK() 155#define bfin_read_STOPCK_OFF() bfin_read_STOPCK()
diff --git a/include/asm-blackfin/mach-bf537/cdefBF534.h b/include/asm-blackfin/mach-bf537/cdefBF534.h
index 78227bc855df..82de526f8097 100644
--- a/include/asm-blackfin/mach-bf537/cdefBF534.h
+++ b/include/asm-blackfin/mach-bf537/cdefBF534.h
@@ -44,7 +44,27 @@
44 44
45/* Clock and System Control (0xFFC00000 - 0xFFC000FF) */ 45/* Clock and System Control (0xFFC00000 - 0xFFC000FF) */
46#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL) 46#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL)
47#define bfin_write_PLL_CTL(val) bfin_write16(PLL_CTL,val) 47/* Writing to PLL_CTL initiates a PLL relock sequence. */
48static __inline__ void bfin_write_PLL_CTL(unsigned int val)
49{
50 unsigned long flags, iwr;
51
52 if (val == bfin_read_PLL_CTL())
53 return;
54
55 local_irq_save(flags);
56 /* Enable the PLL Wakeup bit in SIC IWR */
57 iwr = bfin_read32(SIC_IWR);
58 /* Only allow PPL Wakeup) */
59 bfin_write32(SIC_IWR, IWR_ENABLE(0));
60
61 bfin_write16(PLL_CTL, val);
62 SSYNC();
63 asm("IDLE;");
64
65 bfin_write32(SIC_IWR, iwr);
66 local_irq_restore(flags);
67}
48#define bfin_read_PLL_DIV() bfin_read16(PLL_DIV) 68#define bfin_read_PLL_DIV() bfin_read16(PLL_DIV)
49#define bfin_write_PLL_DIV(val) bfin_write16(PLL_DIV,val) 69#define bfin_write_PLL_DIV(val) bfin_write16(PLL_DIV,val)
50#define bfin_read_VR_CTL() bfin_read16(VR_CTL) 70#define bfin_read_VR_CTL() bfin_read16(VR_CTL)
@@ -53,6 +73,10 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
53{ 73{
54 unsigned long flags, iwr; 74 unsigned long flags, iwr;
55 75
76 if (val == bfin_read_VR_CTL())
77 return;
78
79 local_irq_save(flags);
56 /* Enable the PLL Wakeup bit in SIC IWR */ 80 /* Enable the PLL Wakeup bit in SIC IWR */
57 iwr = bfin_read32(SIC_IWR); 81 iwr = bfin_read32(SIC_IWR);
58 /* Only allow PPL Wakeup) */ 82 /* Only allow PPL Wakeup) */
@@ -60,11 +84,10 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
60 84
61 bfin_write16(VR_CTL, val); 85 bfin_write16(VR_CTL, val);
62 SSYNC(); 86 SSYNC();
63
64 local_irq_save(flags);
65 asm("IDLE;"); 87 asm("IDLE;");
66 local_irq_restore(flags); 88
67 bfin_write32(SIC_IWR, iwr); 89 bfin_write32(SIC_IWR, iwr);
90 local_irq_restore(flags);
68} 91}
69#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT) 92#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT)
70#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT,val) 93#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT,val)
@@ -858,39 +881,7 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
858#define bfin_read_PPI_FRAME() bfin_read16(PPI_FRAME) 881#define bfin_read_PPI_FRAME() bfin_read16(PPI_FRAME)
859#define bfin_write_PPI_FRAME(val) bfin_write16(PPI_FRAME,val) 882#define bfin_write_PPI_FRAME(val) bfin_write16(PPI_FRAME,val)
860 883
861/* Two-Wire Interface (0xFFC01400 - 0xFFC014FF) */ 884/* Two-Wire Interface (0xFFC01400 - 0xFFC014FF) */
862#define bfin_read_TWI_CLKDIV() bfin_read16(TWI_CLKDIV)
863#define bfin_write_TWI_CLKDIV(val) bfin_write16(TWI_CLKDIV,val)
864#define bfin_read_TWI_CONTROL() bfin_read16(TWI_CONTROL)
865#define bfin_write_TWI_CONTROL(val) bfin_write16(TWI_CONTROL,val)
866#define bfin_read_TWI_SLAVE_CTL() bfin_read16(TWI_SLAVE_CTL)
867#define bfin_write_TWI_SLAVE_CTL(val) bfin_write16(TWI_SLAVE_CTL,val)
868#define bfin_read_TWI_SLAVE_STAT() bfin_read16(TWI_SLAVE_STAT)
869#define bfin_write_TWI_SLAVE_STAT(val) bfin_write16(TWI_SLAVE_STAT,val)
870#define bfin_read_TWI_SLAVE_ADDR() bfin_read16(TWI_SLAVE_ADDR)
871#define bfin_write_TWI_SLAVE_ADDR(val) bfin_write16(TWI_SLAVE_ADDR,val)
872#define bfin_read_TWI_MASTER_CTL() bfin_read16(TWI_MASTER_CTL)
873#define bfin_write_TWI_MASTER_CTL(val) bfin_write16(TWI_MASTER_CTL,val)
874#define bfin_read_TWI_MASTER_STAT() bfin_read16(TWI_MASTER_STAT)
875#define bfin_write_TWI_MASTER_STAT(val) bfin_write16(TWI_MASTER_STAT,val)
876#define bfin_read_TWI_MASTER_ADDR() bfin_read16(TWI_MASTER_ADDR)
877#define bfin_write_TWI_MASTER_ADDR(val) bfin_write16(TWI_MASTER_ADDR,val)
878#define bfin_read_TWI_INT_STAT() bfin_read16(TWI_INT_STAT)
879#define bfin_write_TWI_INT_STAT(val) bfin_write16(TWI_INT_STAT,val)
880#define bfin_read_TWI_INT_MASK() bfin_read16(TWI_INT_MASK)
881#define bfin_write_TWI_INT_MASK(val) bfin_write16(TWI_INT_MASK,val)
882#define bfin_read_TWI_FIFO_CTL() bfin_read16(TWI_FIFO_CTL)
883#define bfin_write_TWI_FIFO_CTL(val) bfin_write16(TWI_FIFO_CTL,val)
884#define bfin_read_TWI_FIFO_STAT() bfin_read16(TWI_FIFO_STAT)
885#define bfin_write_TWI_FIFO_STAT(val) bfin_write16(TWI_FIFO_STAT,val)
886#define bfin_read_TWI_XMT_DATA8() bfin_read16(TWI_XMT_DATA8)
887#define bfin_write_TWI_XMT_DATA8(val) bfin_write16(TWI_XMT_DATA8,val)
888#define bfin_read_TWI_XMT_DATA16() bfin_read16(TWI_XMT_DATA16)
889#define bfin_write_TWI_XMT_DATA16(val) bfin_write16(TWI_XMT_DATA16,val)
890#define bfin_read_TWI_RCV_DATA8() bfin_read16(TWI_RCV_DATA8)
891#define bfin_write_TWI_RCV_DATA8(val) bfin_write16(TWI_RCV_DATA8,val)
892#define bfin_read_TWI_RCV_DATA16() bfin_read16(TWI_RCV_DATA16)
893#define bfin_write_TWI_RCV_DATA16(val) bfin_write16(TWI_RCV_DATA16,val)
894 885
895/* General Purpose I/O Port G (0xFFC01500 - 0xFFC015FF) */ 886/* General Purpose I/O Port G (0xFFC01500 - 0xFFC015FF) */
896#define bfin_read_PORTGIO() bfin_read16(PORTGIO) 887#define bfin_read_PORTGIO() bfin_read16(PORTGIO)
diff --git a/include/asm-blackfin/mach-bf537/dma.h b/include/asm-blackfin/mach-bf537/dma.h
index 021991984e6e..7a964040870a 100644
--- a/include/asm-blackfin/mach-bf537/dma.h
+++ b/include/asm-blackfin/mach-bf537/dma.h
@@ -52,7 +52,4 @@
52#define CH_MEM_STREAM1_DEST 14 /* TX */ 52#define CH_MEM_STREAM1_DEST 14 /* TX */
53#define CH_MEM_STREAM1_SRC 15 /* RX */ 53#define CH_MEM_STREAM1_SRC 15 /* RX */
54 54
55extern int channel2irq(unsigned int channel);
56extern struct dma_register *base_addr[];
57
58#endif 55#endif
diff --git a/include/asm-blackfin/mach-bf548/anomaly.h b/include/asm-blackfin/mach-bf548/anomaly.h
index 850dc12eb7f2..49d3cebc5293 100644
--- a/include/asm-blackfin/mach-bf548/anomaly.h
+++ b/include/asm-blackfin/mach-bf548/anomaly.h
@@ -93,5 +93,6 @@
93#define ANOMALY_05000273 (0) 93#define ANOMALY_05000273 (0)
94#define ANOMALY_05000311 (0) 94#define ANOMALY_05000311 (0)
95#define ANOMALY_05000323 (0) 95#define ANOMALY_05000323 (0)
96#define ANOMALY_05000363 (0)
96 97
97#endif 98#endif
diff --git a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
index 7e6339f62a50..6547027cd3e6 100644
--- a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
@@ -1,22 +1,38 @@
1/*
2 * file: include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
3 * based on:
4 * author:
5 *
6 * created:
7 * description:
8 * blackfin serial driver head file
9 * rev:
10 *
11 * modified:
12 *
13 *
14 * bugs: enter bugs at http://blackfin.uclinux.org/
15 *
16 * this program is free software; you can redistribute it and/or modify
17 * it under the terms of the gnu general public license as published by
18 * the free software foundation; either version 2, or (at your option)
19 * any later version.
20 *
21 * this program is distributed in the hope that it will be useful,
22 * but without any warranty; without even the implied warranty of
23 * merchantability or fitness for a particular purpose. see the
24 * gnu general public license for more details.
25 *
26 * you should have received a copy of the gnu general public license
27 * along with this program; see the file copying.
28 * if not, write to the free software foundation,
29 * 59 temple place - suite 330, boston, ma 02111-1307, usa.
30 */
31
1#include <linux/serial.h> 32#include <linux/serial.h>
2#include <asm/dma.h> 33#include <asm/dma.h>
3#include <asm/portmux.h> 34#include <asm/portmux.h>
4 35
5#define NR_PORTS 4
6
7#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
8#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
9#define OFFSET_GCTL 0x08 /* Global Control Register */
10#define OFFSET_LCR 0x0C /* Line Control Register */
11#define OFFSET_MCR 0x10 /* Modem Control Register */
12#define OFFSET_LSR 0x14 /* Line Status Register */
13#define OFFSET_MSR 0x18 /* Modem Status Register */
14#define OFFSET_SCR 0x1C /* SCR Scratch Register */
15#define OFFSET_IER_SET 0x20 /* Set Interrupt Enable Register */
16#define OFFSET_IER_CLEAR 0x24 /* Clear Interrupt Enable Register */
17#define OFFSET_THR 0x28 /* Transmit Holding register */
18#define OFFSET_RBR 0x2C /* Receive Buffer register */
19
20#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR)) 36#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR))
21#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL)) 37#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL))
22#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH)) 38#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH))
@@ -80,7 +96,7 @@ struct bfin_serial_port {
80#endif 96#endif
81}; 97};
82 98
83struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 99struct bfin_serial_port bfin_serial_ports[BFIN_UART_NR_PORTS];
84struct bfin_serial_res { 100struct bfin_serial_res {
85 unsigned long uart_base_addr; 101 unsigned long uart_base_addr;
86 int uart_irq; 102 int uart_irq;
diff --git a/include/asm-blackfin/mach-bf548/bfin_sir.h b/include/asm-blackfin/mach-bf548/bfin_sir.h
new file mode 100644
index 000000000000..5e94271c7e3b
--- /dev/null
+++ b/include/asm-blackfin/mach-bf548/bfin_sir.h
@@ -0,0 +1,149 @@
1/*
2 * Blackfin Infra-red Driver
3 *
4 * Copyright 2006-2008 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 *
10 */
11
12#include <linux/serial.h>
13#include <asm/dma.h>
14#include <asm/portmux.h>
15
16#define SIR_UART_GET_CHAR(port) bfin_read16((port)->membase + OFFSET_RBR)
17#define SIR_UART_GET_DLL(port) bfin_read16((port)->membase + OFFSET_DLL)
18#define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER_SET)
19#define SIR_UART_GET_DLH(port) bfin_read16((port)->membase + OFFSET_DLH)
20#define SIR_UART_GET_LCR(port) bfin_read16((port)->membase + OFFSET_LCR)
21#define SIR_UART_GET_LSR(port) bfin_read16((port)->membase + OFFSET_LSR)
22#define SIR_UART_GET_GCTL(port) bfin_read16((port)->membase + OFFSET_GCTL)
23
24#define SIR_UART_PUT_CHAR(port, v) bfin_write16(((port)->membase + OFFSET_THR), v)
25#define SIR_UART_PUT_DLL(port, v) bfin_write16(((port)->membase + OFFSET_DLL), v)
26#define SIR_UART_SET_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER_SET), v)
27#define SIR_UART_CLEAR_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER_CLEAR), v)
28#define SIR_UART_PUT_DLH(port, v) bfin_write16(((port)->membase + OFFSET_DLH), v)
29#define SIR_UART_PUT_LSR(port, v) bfin_write16(((port)->membase + OFFSET_LSR), v)
30#define SIR_UART_PUT_LCR(port, v) bfin_write16(((port)->membase + OFFSET_LCR), v)
31#define SIR_UART_CLEAR_LSR(port) bfin_write16(((port)->membase + OFFSET_LSR), -1)
32#define SIR_UART_PUT_GCTL(port, v) bfin_write16(((port)->membase + OFFSET_GCTL), v)
33
34#ifdef CONFIG_SIR_BFIN_DMA
35struct dma_rx_buf {
36 char *buf;
37 int head;
38 int tail;
39 };
40#endif /* CONFIG_SIR_BFIN_DMA */
41
42struct bfin_sir_port {
43 unsigned char __iomem *membase;
44 unsigned int irq;
45 unsigned int lsr;
46 unsigned long clk;
47 struct net_device *dev;
48#ifdef CONFIG_SIR_BFIN_DMA
49 int tx_done;
50 struct dma_rx_buf rx_dma_buf;
51 struct timer_list rx_dma_timer;
52 int rx_dma_nrows;
53#endif /* CONFIG_SIR_BFIN_DMA */
54 unsigned int tx_dma_channel;
55 unsigned int rx_dma_channel;
56};
57
58struct bfin_sir_port sir_ports[BFIN_UART_NR_PORTS];
59
60struct bfin_sir_port_res {
61 unsigned long base_addr;
62 int irq;
63 unsigned int rx_dma_channel;
64 unsigned int tx_dma_channel;
65};
66
67struct bfin_sir_port_res bfin_sir_port_resource[] = {
68#ifdef CONFIG_BFIN_SIR0
69 {
70 0xFFC00400,
71 IRQ_UART0_RX,
72 CH_UART0_RX,
73 CH_UART0_TX,
74 },
75#endif
76#ifdef CONFIG_BFIN_SIR1
77 {
78 0xFFC02000,
79 IRQ_UART1_RX,
80 CH_UART1_RX,
81 CH_UART1_TX,
82 },
83#endif
84#ifdef CONFIG_BFIN_SIR2
85 {
86 0xFFC02100,
87 IRQ_UART2_RX,
88 CH_UART2_RX,
89 CH_UART2_TX,
90 },
91#endif
92#ifdef CONFIG_BFIN_SIR3
93 {
94 0xFFC03100,
95 IRQ_UART3_RX,
96 CH_UART3_RX,
97 CH_UART3_TX,
98 },
99#endif
100};
101
102int nr_sirs = ARRAY_SIZE(bfin_sir_port_resource);
103
104struct bfin_sir_self {
105 struct bfin_sir_port *sir_port;
106 spinlock_t lock;
107 unsigned int open;
108 int speed;
109 int newspeed;
110
111 struct sk_buff *txskb;
112 struct sk_buff *rxskb;
113 struct net_device_stats stats;
114 struct device *dev;
115 struct irlap_cb *irlap;
116 struct qos_info qos;
117
118 iobuff_t tx_buff;
119 iobuff_t rx_buff;
120
121 struct work_struct work;
122 int mtt;
123};
124
125#define DRIVER_NAME "bfin_sir"
126
127static void bfin_sir_hw_init(void)
128{
129#ifdef CONFIG_BFIN_SIR0
130 peripheral_request(P_UART0_TX, DRIVER_NAME);
131 peripheral_request(P_UART0_RX, DRIVER_NAME);
132#endif
133
134#ifdef CONFIG_BFIN_SIR1
135 peripheral_request(P_UART1_TX, DRIVER_NAME);
136 peripheral_request(P_UART1_RX, DRIVER_NAME);
137#endif
138
139#ifdef CONFIG_BFIN_SIR2
140 peripheral_request(P_UART2_TX, DRIVER_NAME);
141 peripheral_request(P_UART2_RX, DRIVER_NAME);
142#endif
143
144#ifdef CONFIG_BFIN_SIR3
145 peripheral_request(P_UART3_TX, DRIVER_NAME);
146 peripheral_request(P_UART3_RX, DRIVER_NAME);
147#endif
148 SSYNC();
149}
diff --git a/include/asm-blackfin/mach-bf548/blackfin.h b/include/asm-blackfin/mach-bf548/blackfin.h
index 3bd67da86053..d6ee74ac0460 100644
--- a/include/asm-blackfin/mach-bf548/blackfin.h
+++ b/include/asm-blackfin/mach-bf548/blackfin.h
@@ -153,17 +153,33 @@
153#define bfin_write_UART_SCR(val) bfin_write_UART1_SCR(val) 153#define bfin_write_UART_SCR(val) bfin_write_UART1_SCR(val)
154#define bfin_read_UART_GCTL() bfin_read_UART1_GCTL() 154#define bfin_read_UART_GCTL() bfin_read_UART1_GCTL()
155#define bfin_write_UART_GCTL(val) bfin_write_UART1_GCTL(val) 155#define bfin_write_UART_GCTL(val) bfin_write_UART1_GCTL(val)
156#define UART_THR UART1_THR 156
157#define UART_RBR UART1_RBR 157#define BFIN_UART_THR UART1_THR
158#define UART_DLL UART1_DLL 158#define BFIN_UART_RBR UART1_RBR
159#define UART_IER UART1_IER 159#define BFIN_UART_DLL UART1_DLL
160#define UART_DLH UART1_DLH 160#define BFIN_UART_IER UART1_IER
161#define UART_IIR UART1_IIR 161#define BFIN_UART_DLH UART1_DLH
162#define UART_LCR UART1_LCR 162#define BFIN_UART_IIR UART1_IIR
163#define UART_MCR UART1_MCR 163#define BFIN_UART_LCR UART1_LCR
164#define UART_LSR UART1_LSR 164#define BFIN_UART_MCR UART1_MCR
165#define UART_SCR UART1_SCR 165#define BFIN_UART_LSR UART1_LSR
166#define UART_GCTL UART1_GCTL 166#define BFIN_UART_SCR UART1_SCR
167#define BFIN_UART_GCTL UART1_GCTL
168
169#define BFIN_UART_NR_PORTS 4
170
171#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
172#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
173#define OFFSET_GCTL 0x08 /* Global Control Register */
174#define OFFSET_LCR 0x0C /* Line Control Register */
175#define OFFSET_MCR 0x10 /* Modem Control Register */
176#define OFFSET_LSR 0x14 /* Line Status Register */
177#define OFFSET_MSR 0x18 /* Modem Status Register */
178#define OFFSET_SCR 0x1C /* SCR Scratch Register */
179#define OFFSET_IER_SET 0x20 /* Set Interrupt Enable Register */
180#define OFFSET_IER_CLEAR 0x24 /* Clear Interrupt Enable Register */
181#define OFFSET_THR 0x28 /* Transmit Holding register */
182#define OFFSET_RBR 0x2C /* Receive Buffer register */
167 183
168/* PLL_DIV Masks */ 184/* PLL_DIV Masks */
169#define CCLK_DIV1 CSEL_DIV1 /* CCLK = VCO / 1 */ 185#define CCLK_DIV1 CSEL_DIV1 /* CCLK = VCO / 1 */
diff --git a/include/asm-blackfin/mach-bf548/cdefBF542.h b/include/asm-blackfin/mach-bf548/cdefBF542.h
index 308b33ab5311..60b9f77576f1 100644
--- a/include/asm-blackfin/mach-bf548/cdefBF542.h
+++ b/include/asm-blackfin/mach-bf548/cdefBF542.h
@@ -123,12 +123,12 @@
123#define bfin_write_SDH_DATA_LGTH(val) bfin_write16(SDH_DATA_LGTH, val) 123#define bfin_write_SDH_DATA_LGTH(val) bfin_write16(SDH_DATA_LGTH, val)
124#define bfin_read_SDH_DATA_CTL() bfin_read16(SDH_DATA_CTL) 124#define bfin_read_SDH_DATA_CTL() bfin_read16(SDH_DATA_CTL)
125#define bfin_write_SDH_DATA_CTL(val) bfin_write16(SDH_DATA_CTL, val) 125#define bfin_write_SDH_DATA_CTL(val) bfin_write16(SDH_DATA_CTL, val)
126#define bfin_read_SDH_DATA_CNT() fin_read16(SDH_DATA_CNT) 126#define bfin_read_SDH_DATA_CNT() bfin_read16(SDH_DATA_CNT)
127#define bfin_write_SDH_DATA_CNT(val) bfin_write16(SDH_DATA_CNT, val) 127#define bfin_write_SDH_DATA_CNT(val) bfin_write16(SDH_DATA_CNT, val)
128#define bfin_read_SDH_STATUS() bfin_read32(SDH_STATUS) 128#define bfin_read_SDH_STATUS() bfin_read32(SDH_STATUS)
129#define bfin_write_SDH_STATUS(val) bfin_write32(SDH_STATUS, val) 129#define bfin_write_SDH_STATUS(val) bfin_write32(SDH_STATUS, val)
130#define bfin_read_SDH_STATUS_CLR() fin_read16(SDH_STATUS_CLR) 130#define bfin_read_SDH_STATUS_CLR() bfin_read16(SDH_STATUS_CLR)
131#define bfin_write_SDH_STATUS_CLR(val) fin_write16(SDH_STATUS_CLR, val) 131#define bfin_write_SDH_STATUS_CLR(val) bfin_write16(SDH_STATUS_CLR, val)
132#define bfin_read_SDH_MASK0() bfin_read32(SDH_MASK0) 132#define bfin_read_SDH_MASK0() bfin_read32(SDH_MASK0)
133#define bfin_write_SDH_MASK0(val) bfin_write32(SDH_MASK0, val) 133#define bfin_write_SDH_MASK0(val) bfin_write32(SDH_MASK0, val)
134#define bfin_read_SDH_MASK1() bfin_read32(SDH_MASK1) 134#define bfin_read_SDH_MASK1() bfin_read32(SDH_MASK1)
@@ -184,8 +184,8 @@
184#define bfin_write_USB_FRAME(val) bfin_write16(USB_FRAME, val) 184#define bfin_write_USB_FRAME(val) bfin_write16(USB_FRAME, val)
185#define bfin_read_USB_INDEX() bfin_read16(USB_INDEX) 185#define bfin_read_USB_INDEX() bfin_read16(USB_INDEX)
186#define bfin_write_USB_INDEX(val) bfin_write16(USB_INDEX, val) 186#define bfin_write_USB_INDEX(val) bfin_write16(USB_INDEX, val)
187#define bfin_read_USB_TESTMODE() fin_read16(USB_TESTMODE) 187#define bfin_read_USB_TESTMODE() bfin_read16(USB_TESTMODE)
188#define bfin_write_USB_TESTMODE(val) fin_write16(USB_TESTMODE, val) 188#define bfin_write_USB_TESTMODE(val) bfin_write16(USB_TESTMODE, val)
189#define bfin_read_USB_GLOBINTR() bfin_read16(USB_GLOBINTR) 189#define bfin_read_USB_GLOBINTR() bfin_read16(USB_GLOBINTR)
190#define bfin_write_USB_GLOBINTR(val) bfin_write16(USB_GLOBINTR, val) 190#define bfin_write_USB_GLOBINTR(val) bfin_write16(USB_GLOBINTR, val)
191#define bfin_read_USB_GLOBAL_CTL() bfin_read16(USB_GLOBAL_CTL) 191#define bfin_read_USB_GLOBAL_CTL() bfin_read16(USB_GLOBAL_CTL)
@@ -244,7 +244,7 @@
244#define bfin_read_USB_OTG_DEV_CTL() bfin_read16(USB_OTG_DEV_CTL) 244#define bfin_read_USB_OTG_DEV_CTL() bfin_read16(USB_OTG_DEV_CTL)
245#define bfin_write_USB_OTG_DEV_CTL(val) bfin_write16(USB_OTG_DEV_CTL, val) 245#define bfin_write_USB_OTG_DEV_CTL(val) bfin_write16(USB_OTG_DEV_CTL, val)
246#define bfin_read_USB_OTG_VBUS_IRQ() bfin_read16(USB_OTG_VBUS_IRQ) 246#define bfin_read_USB_OTG_VBUS_IRQ() bfin_read16(USB_OTG_VBUS_IRQ)
247#define bfin_write_USB_OTG_VBUS_IRQ(val) fin_write16(USB_OTG_VBUS_IRQ, val) 247#define bfin_write_USB_OTG_VBUS_IRQ(val) bfin_write16(USB_OTG_VBUS_IRQ, val)
248#define bfin_read_USB_OTG_VBUS_MASK() bfin_read16(USB_OTG_VBUS_MASK) 248#define bfin_read_USB_OTG_VBUS_MASK() bfin_read16(USB_OTG_VBUS_MASK)
249#define bfin_write_USB_OTG_VBUS_MASK(val) bfin_write16(USB_OTG_VBUS_MASK, val) 249#define bfin_write_USB_OTG_VBUS_MASK(val) bfin_write16(USB_OTG_VBUS_MASK, val)
250 250
diff --git a/include/asm-blackfin/mach-bf548/cdefBF544.h b/include/asm-blackfin/mach-bf548/cdefBF544.h
index 7a2d177c8dc2..ea9b4ab496f3 100644
--- a/include/asm-blackfin/mach-bf548/cdefBF544.h
+++ b/include/asm-blackfin/mach-bf548/cdefBF544.h
@@ -113,39 +113,6 @@
113 113
114/* Two Wire Interface Registers (TWI1) */ 114/* Two Wire Interface Registers (TWI1) */
115 115
116#define bfin_read_TWI1_CLKDIV() bfin_read16(TWI1_CLKDIV)
117#define bfin_write_TWI1_CLKDIV(val) bfin_write16(TWI1_CLKDIV, val)
118#define bfin_read_TWI1_CONTROL() bfin_read16(TWI1_CONTROL)
119#define bfin_write_TWI1_CONTROL(val) bfin_write16(TWI1_CONTROL, val)
120#define bfin_read_TWI1_SLAVE_CTRL() bfin_read16(TWI1_SLAVE_CTRL)
121#define bfin_write_TWI1_SLAVE_CTRL(val) bfin_write16(TWI1_SLAVE_CTRL, val)
122#define bfin_read_TWI1_SLAVE_STAT() bfin_read16(TWI1_SLAVE_STAT)
123#define bfin_write_TWI1_SLAVE_STAT(val) bfin_write16(TWI1_SLAVE_STAT, val)
124#define bfin_read_TWI1_SLAVE_ADDR() bfin_read16(TWI1_SLAVE_ADDR)
125#define bfin_write_TWI1_SLAVE_ADDR(val) bfin_write16(TWI1_SLAVE_ADDR, val)
126#define bfin_read_TWI1_MASTER_CTRL() bfin_read16(TWI1_MASTER_CTRL)
127#define bfin_write_TWI1_MASTER_CTRL(val) bfin_write16(TWI1_MASTER_CTRL, val)
128#define bfin_read_TWI1_MASTER_STAT() bfin_read16(TWI1_MASTER_STAT)
129#define bfin_write_TWI1_MASTER_STAT(val) bfin_write16(TWI1_MASTER_STAT, val)
130#define bfin_read_TWI1_MASTER_ADDR() bfin_read16(TWI1_MASTER_ADDR)
131#define bfin_write_TWI1_MASTER_ADDR(val) bfin_write16(TWI1_MASTER_ADDR, val)
132#define bfin_read_TWI1_INT_STAT() bfin_read16(TWI1_INT_STAT)
133#define bfin_write_TWI1_INT_STAT(val) bfin_write16(TWI1_INT_STAT, val)
134#define bfin_read_TWI1_INT_MASK() bfin_read16(TWI1_INT_MASK)
135#define bfin_write_TWI1_INT_MASK(val) bfin_write16(TWI1_INT_MASK, val)
136#define bfin_read_TWI1_FIFO_CTRL() bfin_read16(TWI1_FIFO_CTRL)
137#define bfin_write_TWI1_FIFO_CTRL(val) bfin_write16(TWI1_FIFO_CTRL, val)
138#define bfin_read_TWI1_FIFO_STAT() bfin_read16(TWI1_FIFO_STAT)
139#define bfin_write_TWI1_FIFO_STAT(val) bfin_write16(TWI1_FIFO_STAT, val)
140#define bfin_read_TWI1_XMT_DATA8() bfin_read16(TWI1_XMT_DATA8)
141#define bfin_write_TWI1_XMT_DATA8(val) bfin_write16(TWI1_XMT_DATA8, val)
142#define bfin_read_TWI1_XMT_DATA16() bfin_read16(TWI1_XMT_DATA16)
143#define bfin_write_TWI1_XMT_DATA16(val) bfin_write16(TWI1_XMT_DATA16, val)
144#define bfin_read_TWI1_RCV_DATA8() bfin_read16(TWI1_RCV_DATA8)
145#define bfin_write_TWI1_RCV_DATA8(val) bfin_write16(TWI1_RCV_DATA8, val)
146#define bfin_read_TWI1_RCV_DATA16() bfin_read16(TWI1_RCV_DATA16)
147#define bfin_write_TWI1_RCV_DATA16(val) bfin_write16(TWI1_RCV_DATA16, val)
148
149/* CAN Controller 1 Config 1 Registers */ 116/* CAN Controller 1 Config 1 Registers */
150 117
151#define bfin_read_CAN1_MC1() bfin_read16(CAN1_MC1) 118#define bfin_read_CAN1_MC1() bfin_read16(CAN1_MC1)
diff --git a/include/asm-blackfin/mach-bf548/cdefBF547.h b/include/asm-blackfin/mach-bf548/cdefBF547.h
index d0a200b08abd..ba716277c00d 100644
--- a/include/asm-blackfin/mach-bf548/cdefBF547.h
+++ b/include/asm-blackfin/mach-bf548/cdefBF547.h
@@ -185,39 +185,6 @@
185 185
186/* Two Wire Interface Registers (TWI1) */ 186/* Two Wire Interface Registers (TWI1) */
187 187
188#define bfin_read_TWI1_CLKDIV() bfin_read16(TWI1_CLKDIV)
189#define bfin_write_TWI1_CLKDIV(val) bfin_write16(TWI1_CLKDIV, val)
190#define bfin_read_TWI1_CONTROL() bfin_read16(TWI1_CONTROL)
191#define bfin_write_TWI1_CONTROL(val) bfin_write16(TWI1_CONTROL, val)
192#define bfin_read_TWI1_SLAVE_CTRL() bfin_read16(TWI1_SLAVE_CTRL)
193#define bfin_write_TWI1_SLAVE_CTRL(val) bfin_write16(TWI1_SLAVE_CTRL, val)
194#define bfin_read_TWI1_SLAVE_STAT() bfin_read16(TWI1_SLAVE_STAT)
195#define bfin_write_TWI1_SLAVE_STAT(val) bfin_write16(TWI1_SLAVE_STAT, val)
196#define bfin_read_TWI1_SLAVE_ADDR() bfin_read16(TWI1_SLAVE_ADDR)
197#define bfin_write_TWI1_SLAVE_ADDR(val) bfin_write16(TWI1_SLAVE_ADDR, val)
198#define bfin_read_TWI1_MASTER_CTRL() bfin_read16(TWI1_MASTER_CTRL)
199#define bfin_write_TWI1_MASTER_CTRL(val) bfin_write16(TWI1_MASTER_CTRL, val)
200#define bfin_read_TWI1_MASTER_STAT() bfin_read16(TWI1_MASTER_STAT)
201#define bfin_write_TWI1_MASTER_STAT(val) bfin_write16(TWI1_MASTER_STAT, val)
202#define bfin_read_TWI1_MASTER_ADDR() bfin_read16(TWI1_MASTER_ADDR)
203#define bfin_write_TWI1_MASTER_ADDR(val) bfin_write16(TWI1_MASTER_ADDR, val)
204#define bfin_read_TWI1_INT_STAT() bfin_read16(TWI1_INT_STAT)
205#define bfin_write_TWI1_INT_STAT(val) bfin_write16(TWI1_INT_STAT, val)
206#define bfin_read_TWI1_INT_MASK() bfin_read16(TWI1_INT_MASK)
207#define bfin_write_TWI1_INT_MASK(val) bfin_write16(TWI1_INT_MASK, val)
208#define bfin_read_TWI1_FIFO_CTRL() bfin_read16(TWI1_FIFO_CTRL)
209#define bfin_write_TWI1_FIFO_CTRL(val) bfin_write16(TWI1_FIFO_CTRL, val)
210#define bfin_read_TWI1_FIFO_STAT() bfin_read16(TWI1_FIFO_STAT)
211#define bfin_write_TWI1_FIFO_STAT(val) bfin_write16(TWI1_FIFO_STAT, val)
212#define bfin_read_TWI1_XMT_DATA8() bfin_read16(TWI1_XMT_DATA8)
213#define bfin_write_TWI1_XMT_DATA8(val) bfin_write16(TWI1_XMT_DATA8, val)
214#define bfin_read_TWI1_XMT_DATA16() bfin_read16(TWI1_XMT_DATA16)
215#define bfin_write_TWI1_XMT_DATA16(val) bfin_write16(TWI1_XMT_DATA16, val)
216#define bfin_read_TWI1_RCV_DATA8() bfin_read16(TWI1_RCV_DATA8)
217#define bfin_write_TWI1_RCV_DATA8(val) bfin_write16(TWI1_RCV_DATA8, val)
218#define bfin_read_TWI1_RCV_DATA16() bfin_read16(TWI1_RCV_DATA16)
219#define bfin_write_TWI1_RCV_DATA16(val) bfin_write16(TWI1_RCV_DATA16, val)
220
221/* SPI2 Registers */ 188/* SPI2 Registers */
222 189
223#define bfin_read_SPI2_CTL() bfin_read16(SPI2_CTL) 190#define bfin_read_SPI2_CTL() bfin_read16(SPI2_CTL)
diff --git a/include/asm-blackfin/mach-bf548/cdefBF548.h b/include/asm-blackfin/mach-bf548/cdefBF548.h
index 674be0216bff..ae971ebff6a0 100644
--- a/include/asm-blackfin/mach-bf548/cdefBF548.h
+++ b/include/asm-blackfin/mach-bf548/cdefBF548.h
@@ -185,39 +185,6 @@
185 185
186/* Two Wire Interface Registers (TWI1) */ 186/* Two Wire Interface Registers (TWI1) */
187 187
188#define bfin_read_TWI1_CLKDIV() bfin_read16(TWI1_CLKDIV)
189#define bfin_write_TWI1_CLKDIV(val) bfin_write16(TWI1_CLKDIV, val)
190#define bfin_read_TWI1_CONTROL() bfin_read16(TWI1_CONTROL)
191#define bfin_write_TWI1_CONTROL(val) bfin_write16(TWI1_CONTROL, val)
192#define bfin_read_TWI1_SLAVE_CTRL() bfin_read16(TWI1_SLAVE_CTRL)
193#define bfin_write_TWI1_SLAVE_CTRL(val) bfin_write16(TWI1_SLAVE_CTRL, val)
194#define bfin_read_TWI1_SLAVE_STAT() bfin_read16(TWI1_SLAVE_STAT)
195#define bfin_write_TWI1_SLAVE_STAT(val) bfin_write16(TWI1_SLAVE_STAT, val)
196#define bfin_read_TWI1_SLAVE_ADDR() bfin_read16(TWI1_SLAVE_ADDR)
197#define bfin_write_TWI1_SLAVE_ADDR(val) bfin_write16(TWI1_SLAVE_ADDR, val)
198#define bfin_read_TWI1_MASTER_CTRL() bfin_read16(TWI1_MASTER_CTRL)
199#define bfin_write_TWI1_MASTER_CTRL(val) bfin_write16(TWI1_MASTER_CTRL, val)
200#define bfin_read_TWI1_MASTER_STAT() bfin_read16(TWI1_MASTER_STAT)
201#define bfin_write_TWI1_MASTER_STAT(val) bfin_write16(TWI1_MASTER_STAT, val)
202#define bfin_read_TWI1_MASTER_ADDR() bfin_read16(TWI1_MASTER_ADDR)
203#define bfin_write_TWI1_MASTER_ADDR(val) bfin_write16(TWI1_MASTER_ADDR, val)
204#define bfin_read_TWI1_INT_STAT() bfin_read16(TWI1_INT_STAT)
205#define bfin_write_TWI1_INT_STAT(val) bfin_write16(TWI1_INT_STAT, val)
206#define bfin_read_TWI1_INT_MASK() bfin_read16(TWI1_INT_MASK)
207#define bfin_write_TWI1_INT_MASK(val) bfin_write16(TWI1_INT_MASK, val)
208#define bfin_read_TWI1_FIFO_CTRL() bfin_read16(TWI1_FIFO_CTRL)
209#define bfin_write_TWI1_FIFO_CTRL(val) bfin_write16(TWI1_FIFO_CTRL, val)
210#define bfin_read_TWI1_FIFO_STAT() bfin_read16(TWI1_FIFO_STAT)
211#define bfin_write_TWI1_FIFO_STAT(val) bfin_write16(TWI1_FIFO_STAT, val)
212#define bfin_read_TWI1_XMT_DATA8() bfin_read16(TWI1_XMT_DATA8)
213#define bfin_write_TWI1_XMT_DATA8(val) bfin_write16(TWI1_XMT_DATA8, val)
214#define bfin_read_TWI1_XMT_DATA16() bfin_read16(TWI1_XMT_DATA16)
215#define bfin_write_TWI1_XMT_DATA16(val) bfin_write16(TWI1_XMT_DATA16, val)
216#define bfin_read_TWI1_RCV_DATA8() bfin_read16(TWI1_RCV_DATA8)
217#define bfin_write_TWI1_RCV_DATA8(val) bfin_write16(TWI1_RCV_DATA8, val)
218#define bfin_read_TWI1_RCV_DATA16() bfin_read16(TWI1_RCV_DATA16)
219#define bfin_write_TWI1_RCV_DATA16(val) bfin_write16(TWI1_RCV_DATA16, val)
220
221/* SPI2 Registers */ 188/* SPI2 Registers */
222 189
223#define bfin_read_SPI2_CTL() bfin_read16(SPI2_CTL) 190#define bfin_read_SPI2_CTL() bfin_read16(SPI2_CTL)
diff --git a/include/asm-blackfin/mach-bf548/cdefBF549.h b/include/asm-blackfin/mach-bf548/cdefBF549.h
index 2ab5b7c00820..92d07d961999 100644
--- a/include/asm-blackfin/mach-bf548/cdefBF549.h
+++ b/include/asm-blackfin/mach-bf548/cdefBF549.h
@@ -185,39 +185,6 @@
185 185
186/* Two Wire Interface Registers (TWI1) */ 186/* Two Wire Interface Registers (TWI1) */
187 187
188#define bfin_read_TWI1_CLKDIV() bfin_read16(TWI1_CLKDIV)
189#define bfin_write_TWI1_CLKDIV(val) bfin_write16(TWI1_CLKDIV, val)
190#define bfin_read_TWI1_CONTROL() bfin_read16(TWI1_CONTROL)
191#define bfin_write_TWI1_CONTROL(val) bfin_write16(TWI1_CONTROL, val)
192#define bfin_read_TWI1_SLAVE_CTRL() bfin_read16(TWI1_SLAVE_CTRL)
193#define bfin_write_TWI1_SLAVE_CTRL(val) bfin_write16(TWI1_SLAVE_CTRL, val)
194#define bfin_read_TWI1_SLAVE_STAT() bfin_read16(TWI1_SLAVE_STAT)
195#define bfin_write_TWI1_SLAVE_STAT(val) bfin_write16(TWI1_SLAVE_STAT, val)
196#define bfin_read_TWI1_SLAVE_ADDR() bfin_read16(TWI1_SLAVE_ADDR)
197#define bfin_write_TWI1_SLAVE_ADDR(val) bfin_write16(TWI1_SLAVE_ADDR, val)
198#define bfin_read_TWI1_MASTER_CTRL() bfin_read16(TWI1_MASTER_CTRL)
199#define bfin_write_TWI1_MASTER_CTRL(val) bfin_write16(TWI1_MASTER_CTRL, val)
200#define bfin_read_TWI1_MASTER_STAT() bfin_read16(TWI1_MASTER_STAT)
201#define bfin_write_TWI1_MASTER_STAT(val) bfin_write16(TWI1_MASTER_STAT, val)
202#define bfin_read_TWI1_MASTER_ADDR() bfin_read16(TWI1_MASTER_ADDR)
203#define bfin_write_TWI1_MASTER_ADDR(val) bfin_write16(TWI1_MASTER_ADDR, val)
204#define bfin_read_TWI1_INT_STAT() bfin_read16(TWI1_INT_STAT)
205#define bfin_write_TWI1_INT_STAT(val) bfin_write16(TWI1_INT_STAT, val)
206#define bfin_read_TWI1_INT_MASK() bfin_read16(TWI1_INT_MASK)
207#define bfin_write_TWI1_INT_MASK(val) bfin_write16(TWI1_INT_MASK, val)
208#define bfin_read_TWI1_FIFO_CTRL() bfin_read16(TWI1_FIFO_CTRL)
209#define bfin_write_TWI1_FIFO_CTRL(val) bfin_write16(TWI1_FIFO_CTRL, val)
210#define bfin_read_TWI1_FIFO_STAT() bfin_read16(TWI1_FIFO_STAT)
211#define bfin_write_TWI1_FIFO_STAT(val) bfin_write16(TWI1_FIFO_STAT, val)
212#define bfin_read_TWI1_XMT_DATA8() bfin_read16(TWI1_XMT_DATA8)
213#define bfin_write_TWI1_XMT_DATA8(val) bfin_write16(TWI1_XMT_DATA8, val)
214#define bfin_read_TWI1_XMT_DATA16() bfin_read16(TWI1_XMT_DATA16)
215#define bfin_write_TWI1_XMT_DATA16(val) bfin_write16(TWI1_XMT_DATA16, val)
216#define bfin_read_TWI1_RCV_DATA8() bfin_read16(TWI1_RCV_DATA8)
217#define bfin_write_TWI1_RCV_DATA8(val) bfin_write16(TWI1_RCV_DATA8, val)
218#define bfin_read_TWI1_RCV_DATA16() bfin_read16(TWI1_RCV_DATA16)
219#define bfin_write_TWI1_RCV_DATA16(val) bfin_write16(TWI1_RCV_DATA16, val)
220
221/* SPI2 Registers */ 188/* SPI2 Registers */
222 189
223#define bfin_read_SPI2_CTL() bfin_read16(SPI2_CTL) 190#define bfin_read_SPI2_CTL() bfin_read16(SPI2_CTL)
@@ -1773,7 +1740,7 @@
1773#define bfin_read_USB_DMA5ADDRHIGH() bfin_read16(USB_DMA5ADDRHIGH) 1740#define bfin_read_USB_DMA5ADDRHIGH() bfin_read16(USB_DMA5ADDRHIGH)
1774#define bfin_write_USB_DMA5ADDRHIGH(val) bfin_write16(USB_DMA5ADDRHIGH, val) 1741#define bfin_write_USB_DMA5ADDRHIGH(val) bfin_write16(USB_DMA5ADDRHIGH, val)
1775#define bfin_read_USB_DMA5COUNTLOW() bfin_read16(USB_DMA5COUNTLOW) 1742#define bfin_read_USB_DMA5COUNTLOW() bfin_read16(USB_DMA5COUNTLOW)
1776#define bfin_write_USB_DMA5COUNTLOW(val) fin_write16(USB_DMA5COUNTLOW, val) 1743#define bfin_write_USB_DMA5COUNTLOW(val) bfin_write16(USB_DMA5COUNTLOW, val)
1777#define bfin_read_USB_DMA5COUNTHIGH() bfin_read16(USB_DMA5COUNTHIGH) 1744#define bfin_read_USB_DMA5COUNTHIGH() bfin_read16(USB_DMA5COUNTHIGH)
1778#define bfin_write_USB_DMA5COUNTHIGH(val) bfin_write16(USB_DMA5COUNTHIGH, val) 1745#define bfin_write_USB_DMA5COUNTHIGH(val) bfin_write16(USB_DMA5COUNTHIGH, val)
1779 1746
diff --git a/include/asm-blackfin/mach-bf548/cdefBF54x_base.h b/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
index 19ddcd83c71f..57ac8cb9b1f6 100644
--- a/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
+++ b/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
@@ -43,7 +43,33 @@
43/* PLL Registers */ 43/* PLL Registers */
44 44
45#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL) 45#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL)
46#define bfin_write_PLL_CTL(val) bfin_write16(PLL_CTL, val) 46/* Writing to PLL_CTL initiates a PLL relock sequence. */
47static __inline__ void bfin_write_PLL_CTL(unsigned int val)
48{
49 unsigned long flags, iwr0, iwr1, iwr2;
50
51 if (val == bfin_read_PLL_CTL())
52 return;
53
54 local_irq_save(flags);
55 /* Enable the PLL Wakeup bit in SIC IWR */
56 iwr0 = bfin_read32(SIC_IWR0);
57 iwr1 = bfin_read32(SIC_IWR1);
58 iwr2 = bfin_read32(SIC_IWR2);
59 /* Only allow PPL Wakeup) */
60 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
61 bfin_write32(SIC_IWR1, 0);
62 bfin_write32(SIC_IWR2, 0);
63
64 bfin_write16(PLL_CTL, val);
65 SSYNC();
66 asm("IDLE;");
67
68 bfin_write32(SIC_IWR0, iwr0);
69 bfin_write32(SIC_IWR1, iwr1);
70 bfin_write32(SIC_IWR2, iwr2);
71 local_irq_restore(flags);
72}
47#define bfin_read_PLL_DIV() bfin_read16(PLL_DIV) 73#define bfin_read_PLL_DIV() bfin_read16(PLL_DIV)
48#define bfin_write_PLL_DIV(val) bfin_write16(PLL_DIV, val) 74#define bfin_write_PLL_DIV(val) bfin_write16(PLL_DIV, val)
49#define bfin_read_VR_CTL() bfin_read16(VR_CTL) 75#define bfin_read_VR_CTL() bfin_read16(VR_CTL)
@@ -52,6 +78,10 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
52{ 78{
53 unsigned long flags, iwr0, iwr1, iwr2; 79 unsigned long flags, iwr0, iwr1, iwr2;
54 80
81 if (val == bfin_read_VR_CTL())
82 return;
83
84 local_irq_save(flags);
55 /* Enable the PLL Wakeup bit in SIC IWR */ 85 /* Enable the PLL Wakeup bit in SIC IWR */
56 iwr0 = bfin_read32(SIC_IWR0); 86 iwr0 = bfin_read32(SIC_IWR0);
57 iwr1 = bfin_read32(SIC_IWR1); 87 iwr1 = bfin_read32(SIC_IWR1);
@@ -63,13 +93,12 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
63 93
64 bfin_write16(VR_CTL, val); 94 bfin_write16(VR_CTL, val);
65 SSYNC(); 95 SSYNC();
66
67 local_irq_save(flags);
68 asm("IDLE;"); 96 asm("IDLE;");
69 local_irq_restore(flags); 97
70 bfin_write32(SIC_IWR0, iwr0); 98 bfin_write32(SIC_IWR0, iwr0);
71 bfin_write32(SIC_IWR1, iwr1); 99 bfin_write32(SIC_IWR1, iwr1);
72 bfin_write32(SIC_IWR2, iwr2); 100 bfin_write32(SIC_IWR2, iwr2);
101 local_irq_restore(flags);
73} 102}
74#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT) 103#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT)
75#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT, val) 104#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT, val)
@@ -211,39 +240,6 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
211 240
212/* Two Wire Interface Registers (TWI0) */ 241/* Two Wire Interface Registers (TWI0) */
213 242
214#define bfin_read_TWI0_CLKDIV() bfin_read16(TWI0_CLKDIV)
215#define bfin_write_TWI0_CLKDIV(val) bfin_write16(TWI0_CLKDIV, val)
216#define bfin_read_TWI0_CONTROL() bfin_read16(TWI0_CONTROL)
217#define bfin_write_TWI0_CONTROL(val) bfin_write16(TWI0_CONTROL, val)
218#define bfin_read_TWI0_SLAVE_CTRL() bfin_read16(TWI0_SLAVE_CTRL)
219#define bfin_write_TWI0_SLAVE_CTRL(val) bfin_write16(TWI0_SLAVE_CTRL, val)
220#define bfin_read_TWI0_SLAVE_STAT() bfin_read16(TWI0_SLAVE_STAT)
221#define bfin_write_TWI0_SLAVE_STAT(val) bfin_write16(TWI0_SLAVE_STAT, val)
222#define bfin_read_TWI0_SLAVE_ADDR() bfin_read16(TWI0_SLAVE_ADDR)
223#define bfin_write_TWI0_SLAVE_ADDR(val) bfin_write16(TWI0_SLAVE_ADDR, val)
224#define bfin_read_TWI0_MASTER_CTRL() bfin_read16(TWI0_MASTER_CTRL)
225#define bfin_write_TWI0_MASTER_CTRL(val) bfin_write16(TWI0_MASTER_CTRL, val)
226#define bfin_read_TWI0_MASTER_STAT() bfin_read16(TWI0_MASTER_STAT)
227#define bfin_write_TWI0_MASTER_STAT(val) bfin_write16(TWI0_MASTER_STAT, val)
228#define bfin_read_TWI0_MASTER_ADDR() bfin_read16(TWI0_MASTER_ADDR)
229#define bfin_write_TWI0_MASTER_ADDR(val) bfin_write16(TWI0_MASTER_ADDR, val)
230#define bfin_read_TWI0_INT_STAT() bfin_read16(TWI0_INT_STAT)
231#define bfin_write_TWI0_INT_STAT(val) bfin_write16(TWI0_INT_STAT, val)
232#define bfin_read_TWI0_INT_MASK() bfin_read16(TWI0_INT_MASK)
233#define bfin_write_TWI0_INT_MASK(val) bfin_write16(TWI0_INT_MASK, val)
234#define bfin_read_TWI0_FIFO_CTRL() bfin_read16(TWI0_FIFO_CTRL)
235#define bfin_write_TWI0_FIFO_CTRL(val) bfin_write16(TWI0_FIFO_CTRL, val)
236#define bfin_read_TWI0_FIFO_STAT() bfin_read16(TWI0_FIFO_STAT)
237#define bfin_write_TWI0_FIFO_STAT(val) bfin_write16(TWI0_FIFO_STAT, val)
238#define bfin_read_TWI0_XMT_DATA8() bfin_read16(TWI0_XMT_DATA8)
239#define bfin_write_TWI0_XMT_DATA8(val) bfin_write16(TWI0_XMT_DATA8, val)
240#define bfin_read_TWI0_XMT_DATA16() bfin_read16(TWI0_XMT_DATA16)
241#define bfin_write_TWI0_XMT_DATA16(val) bfin_write16(TWI0_XMT_DATA16, val)
242#define bfin_read_TWI0_RCV_DATA8() bfin_read16(TWI0_RCV_DATA8)
243#define bfin_write_TWI0_RCV_DATA8(val) bfin_write16(TWI0_RCV_DATA8, val)
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)
246
247/* SPORT0 is not defined in the shared file because it is not available on the ADSP-BF542 and ADSP-BF544 bfin_read_()rocessors */ 243/* SPORT0 is not defined in the shared file because it is not available on the ADSP-BF542 and ADSP-BF544 bfin_read_()rocessors */
248 244
249/* SPORT1 Registers */ 245/* SPORT1 Registers */
@@ -323,7 +319,7 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
323#define bfin_read_EBIU_DDRQUE() bfin_read32(EBIU_DDRQUE) 319#define bfin_read_EBIU_DDRQUE() bfin_read32(EBIU_DDRQUE)
324#define bfin_write_EBIU_DDRQUE(val) bfin_write32(EBIU_DDRQUE, val) 320#define bfin_write_EBIU_DDRQUE(val) bfin_write32(EBIU_DDRQUE, val)
325#define bfin_read_EBIU_ERRADD() bfin_read32(EBIU_ERRADD) 321#define bfin_read_EBIU_ERRADD() bfin_read32(EBIU_ERRADD)
326#define bfin_write_EBIU_ERRADD(val) bfin_write32(EBIU_ERRADD) 322#define bfin_write_EBIU_ERRADD(val) bfin_write32(EBIU_ERRADD, val)
327#define bfin_read_EBIU_ERRMST() bfin_read16(EBIU_ERRMST) 323#define bfin_read_EBIU_ERRMST() bfin_read16(EBIU_ERRMST)
328#define bfin_write_EBIU_ERRMST(val) bfin_write16(EBIU_ERRMST, val) 324#define bfin_write_EBIU_ERRMST(val) bfin_write16(EBIU_ERRMST, val)
329#define bfin_read_EBIU_RSTCTL() bfin_read16(EBIU_RSTCTL) 325#define bfin_read_EBIU_RSTCTL() bfin_read16(EBIU_RSTCTL)
@@ -392,23 +388,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
392/* DMA Channel 0 Registers */ 388/* DMA Channel 0 Registers */
393 389
394#define bfin_read_DMA0_NEXT_DESC_PTR() bfin_read32(DMA0_NEXT_DESC_PTR) 390#define bfin_read_DMA0_NEXT_DESC_PTR() bfin_read32(DMA0_NEXT_DESC_PTR)
395#define bfin_write_DMA0_NEXT_DESC_PTR(val) bfin_write32(DMA0_NEXT_DESC_PTR) 391#define bfin_write_DMA0_NEXT_DESC_PTR(val) bfin_write32(DMA0_NEXT_DESC_PTR, val)
396#define bfin_read_DMA0_START_ADDR() bfin_read32(DMA0_START_ADDR) 392#define bfin_read_DMA0_START_ADDR() bfin_read32(DMA0_START_ADDR)
397#define bfin_write_DMA0_START_ADDR(val) bfin_write32(DMA0_START_ADDR) 393#define bfin_write_DMA0_START_ADDR(val) bfin_write32(DMA0_START_ADDR, val)
398#define bfin_read_DMA0_CONFIG() bfin_read16(DMA0_CONFIG) 394#define bfin_read_DMA0_CONFIG() bfin_read16(DMA0_CONFIG)
399#define bfin_write_DMA0_CONFIG(val) bfin_write16(DMA0_CONFIG, val) 395#define bfin_write_DMA0_CONFIG(val) bfin_write16(DMA0_CONFIG, val)
400#define bfin_read_DMA0_X_COUNT() bfin_read16(DMA0_X_COUNT) 396#define bfin_read_DMA0_X_COUNT() bfin_read16(DMA0_X_COUNT)
401#define bfin_write_DMA0_X_COUNT(val) bfin_write16(DMA0_X_COUNT, val) 397#define bfin_write_DMA0_X_COUNT(val) bfin_write16(DMA0_X_COUNT, val)
402#define bfin_read_DMA0_X_MODIFY() bfin_read16(DMA0_X_MODIFY) 398#define bfin_read_DMA0_X_MODIFY() bfin_read16(DMA0_X_MODIFY)
403#define bfin_write_DMA0_X_MODIFY(val) bfin_write16(DMA0_X_MODIFY) 399#define bfin_write_DMA0_X_MODIFY(val) bfin_write16(DMA0_X_MODIFY, val)
404#define bfin_read_DMA0_Y_COUNT() bfin_read16(DMA0_Y_COUNT) 400#define bfin_read_DMA0_Y_COUNT() bfin_read16(DMA0_Y_COUNT)
405#define bfin_write_DMA0_Y_COUNT(val) bfin_write16(DMA0_Y_COUNT, val) 401#define bfin_write_DMA0_Y_COUNT(val) bfin_write16(DMA0_Y_COUNT, val)
406#define bfin_read_DMA0_Y_MODIFY() bfin_read16(DMA0_Y_MODIFY) 402#define bfin_read_DMA0_Y_MODIFY() bfin_read16(DMA0_Y_MODIFY)
407#define bfin_write_DMA0_Y_MODIFY(val) bfin_write16(DMA0_Y_MODIFY) 403#define bfin_write_DMA0_Y_MODIFY(val) bfin_write16(DMA0_Y_MODIFY, val)
408#define bfin_read_DMA0_CURR_DESC_PTR() bfin_read32(DMA0_CURR_DESC_PTR) 404#define bfin_read_DMA0_CURR_DESC_PTR() bfin_read32(DMA0_CURR_DESC_PTR)
409#define bfin_write_DMA0_CURR_DESC_PTR(val) bfin_write32(DMA0_CURR_DESC_PTR) 405#define bfin_write_DMA0_CURR_DESC_PTR(val) bfin_write32(DMA0_CURR_DESC_PTR, val)
410#define bfin_read_DMA0_CURR_ADDR() bfin_read32(DMA0_CURR_ADDR) 406#define bfin_read_DMA0_CURR_ADDR() bfin_read32(DMA0_CURR_ADDR)
411#define bfin_write_DMA0_CURR_ADDR(val) bfin_write32(DMA0_CURR_ADDR) 407#define bfin_write_DMA0_CURR_ADDR(val) bfin_write32(DMA0_CURR_ADDR, val)
412#define bfin_read_DMA0_IRQ_STATUS() bfin_read16(DMA0_IRQ_STATUS) 408#define bfin_read_DMA0_IRQ_STATUS() bfin_read16(DMA0_IRQ_STATUS)
413#define bfin_write_DMA0_IRQ_STATUS(val) bfin_write16(DMA0_IRQ_STATUS, val) 409#define bfin_write_DMA0_IRQ_STATUS(val) bfin_write16(DMA0_IRQ_STATUS, val)
414#define bfin_read_DMA0_PERIPHERAL_MAP() bfin_read16(DMA0_PERIPHERAL_MAP) 410#define bfin_read_DMA0_PERIPHERAL_MAP() bfin_read16(DMA0_PERIPHERAL_MAP)
@@ -421,23 +417,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
421/* DMA Channel 1 Registers */ 417/* DMA Channel 1 Registers */
422 418
423#define bfin_read_DMA1_NEXT_DESC_PTR() bfin_read32(DMA1_NEXT_DESC_PTR) 419#define bfin_read_DMA1_NEXT_DESC_PTR() bfin_read32(DMA1_NEXT_DESC_PTR)
424#define bfin_write_DMA1_NEXT_DESC_PTR(val) bfin_write32(DMA1_NEXT_DESC_PTR) 420#define bfin_write_DMA1_NEXT_DESC_PTR(val) bfin_write32(DMA1_NEXT_DESC_PTR, val)
425#define bfin_read_DMA1_START_ADDR() bfin_read32(DMA1_START_ADDR) 421#define bfin_read_DMA1_START_ADDR() bfin_read32(DMA1_START_ADDR)
426#define bfin_write_DMA1_START_ADDR(val) bfin_write32(DMA1_START_ADDR) 422#define bfin_write_DMA1_START_ADDR(val) bfin_write32(DMA1_START_ADDR, val)
427#define bfin_read_DMA1_CONFIG() bfin_read16(DMA1_CONFIG) 423#define bfin_read_DMA1_CONFIG() bfin_read16(DMA1_CONFIG)
428#define bfin_write_DMA1_CONFIG(val) bfin_write16(DMA1_CONFIG, val) 424#define bfin_write_DMA1_CONFIG(val) bfin_write16(DMA1_CONFIG, val)
429#define bfin_read_DMA1_X_COUNT() bfin_read16(DMA1_X_COUNT) 425#define bfin_read_DMA1_X_COUNT() bfin_read16(DMA1_X_COUNT)
430#define bfin_write_DMA1_X_COUNT(val) bfin_write16(DMA1_X_COUNT, val) 426#define bfin_write_DMA1_X_COUNT(val) bfin_write16(DMA1_X_COUNT, val)
431#define bfin_read_DMA1_X_MODIFY() bfin_read16(DMA1_X_MODIFY) 427#define bfin_read_DMA1_X_MODIFY() bfin_read16(DMA1_X_MODIFY)
432#define bfin_write_DMA1_X_MODIFY(val) bfin_write16(DMA1_X_MODIFY) 428#define bfin_write_DMA1_X_MODIFY(val) bfin_write16(DMA1_X_MODIFY, val)
433#define bfin_read_DMA1_Y_COUNT() bfin_read16(DMA1_Y_COUNT) 429#define bfin_read_DMA1_Y_COUNT() bfin_read16(DMA1_Y_COUNT)
434#define bfin_write_DMA1_Y_COUNT(val) bfin_write16(DMA1_Y_COUNT, val) 430#define bfin_write_DMA1_Y_COUNT(val) bfin_write16(DMA1_Y_COUNT, val)
435#define bfin_read_DMA1_Y_MODIFY() bfin_read16(DMA1_Y_MODIFY) 431#define bfin_read_DMA1_Y_MODIFY() bfin_read16(DMA1_Y_MODIFY)
436#define bfin_write_DMA1_Y_MODIFY(val) bfin_write16(DMA1_Y_MODIFY) 432#define bfin_write_DMA1_Y_MODIFY(val) bfin_write16(DMA1_Y_MODIFY, val)
437#define bfin_read_DMA1_CURR_DESC_PTR() bfin_read32(DMA1_CURR_DESC_PTR) 433#define bfin_read_DMA1_CURR_DESC_PTR() bfin_read32(DMA1_CURR_DESC_PTR)
438#define bfin_write_DMA1_CURR_DESC_PTR(val) bfin_write32(DMA1_CURR_DESC_PTR) 434#define bfin_write_DMA1_CURR_DESC_PTR(val) bfin_write32(DMA1_CURR_DESC_PTR, val)
439#define bfin_read_DMA1_CURR_ADDR() bfin_read32(DMA1_CURR_ADDR) 435#define bfin_read_DMA1_CURR_ADDR() bfin_read32(DMA1_CURR_ADDR)
440#define bfin_write_DMA1_CURR_ADDR(val) bfin_write32(DMA1_CURR_ADDR) 436#define bfin_write_DMA1_CURR_ADDR(val) bfin_write32(DMA1_CURR_ADDR, val)
441#define bfin_read_DMA1_IRQ_STATUS() bfin_read16(DMA1_IRQ_STATUS) 437#define bfin_read_DMA1_IRQ_STATUS() bfin_read16(DMA1_IRQ_STATUS)
442#define bfin_write_DMA1_IRQ_STATUS(val) bfin_write16(DMA1_IRQ_STATUS, val) 438#define bfin_write_DMA1_IRQ_STATUS(val) bfin_write16(DMA1_IRQ_STATUS, val)
443#define bfin_read_DMA1_PERIPHERAL_MAP() bfin_read16(DMA1_PERIPHERAL_MAP) 439#define bfin_read_DMA1_PERIPHERAL_MAP() bfin_read16(DMA1_PERIPHERAL_MAP)
@@ -450,23 +446,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
450/* DMA Channel 2 Registers */ 446/* DMA Channel 2 Registers */
451 447
452#define bfin_read_DMA2_NEXT_DESC_PTR() bfin_read32(DMA2_NEXT_DESC_PTR) 448#define bfin_read_DMA2_NEXT_DESC_PTR() bfin_read32(DMA2_NEXT_DESC_PTR)
453#define bfin_write_DMA2_NEXT_DESC_PTR(val) bfin_write32(DMA2_NEXT_DESC_PTR) 449#define bfin_write_DMA2_NEXT_DESC_PTR(val) bfin_write32(DMA2_NEXT_DESC_PTR, val)
454#define bfin_read_DMA2_START_ADDR() bfin_read32(DMA2_START_ADDR) 450#define bfin_read_DMA2_START_ADDR() bfin_read32(DMA2_START_ADDR)
455#define bfin_write_DMA2_START_ADDR(val) bfin_write32(DMA2_START_ADDR) 451#define bfin_write_DMA2_START_ADDR(val) bfin_write32(DMA2_START_ADDR, val)
456#define bfin_read_DMA2_CONFIG() bfin_read16(DMA2_CONFIG) 452#define bfin_read_DMA2_CONFIG() bfin_read16(DMA2_CONFIG)
457#define bfin_write_DMA2_CONFIG(val) bfin_write16(DMA2_CONFIG, val) 453#define bfin_write_DMA2_CONFIG(val) bfin_write16(DMA2_CONFIG, val)
458#define bfin_read_DMA2_X_COUNT() bfin_read16(DMA2_X_COUNT) 454#define bfin_read_DMA2_X_COUNT() bfin_read16(DMA2_X_COUNT)
459#define bfin_write_DMA2_X_COUNT(val) bfin_write16(DMA2_X_COUNT, val) 455#define bfin_write_DMA2_X_COUNT(val) bfin_write16(DMA2_X_COUNT, val)
460#define bfin_read_DMA2_X_MODIFY() bfin_read16(DMA2_X_MODIFY) 456#define bfin_read_DMA2_X_MODIFY() bfin_read16(DMA2_X_MODIFY)
461#define bfin_write_DMA2_X_MODIFY(val) bfin_write16(DMA2_X_MODIFY) 457#define bfin_write_DMA2_X_MODIFY(val) bfin_write16(DMA2_X_MODIFY, val)
462#define bfin_read_DMA2_Y_COUNT() bfin_read16(DMA2_Y_COUNT) 458#define bfin_read_DMA2_Y_COUNT() bfin_read16(DMA2_Y_COUNT)
463#define bfin_write_DMA2_Y_COUNT(val) bfin_write16(DMA2_Y_COUNT, val) 459#define bfin_write_DMA2_Y_COUNT(val) bfin_write16(DMA2_Y_COUNT, val)
464#define bfin_read_DMA2_Y_MODIFY() bfin_read16(DMA2_Y_MODIFY) 460#define bfin_read_DMA2_Y_MODIFY() bfin_read16(DMA2_Y_MODIFY)
465#define bfin_write_DMA2_Y_MODIFY(val) bfin_write16(DMA2_Y_MODIFY) 461#define bfin_write_DMA2_Y_MODIFY(val) bfin_write16(DMA2_Y_MODIFY, val)
466#define bfin_read_DMA2_CURR_DESC_PTR() bfin_read32(DMA2_CURR_DESC_PTR) 462#define bfin_read_DMA2_CURR_DESC_PTR() bfin_read32(DMA2_CURR_DESC_PTR)
467#define bfin_write_DMA2_CURR_DESC_PTR(val) bfin_write32(DMA2_CURR_DESC_PTR) 463#define bfin_write_DMA2_CURR_DESC_PTR(val) bfin_write32(DMA2_CURR_DESC_PTR, val)
468#define bfin_read_DMA2_CURR_ADDR() bfin_read32(DMA2_CURR_ADDR) 464#define bfin_read_DMA2_CURR_ADDR() bfin_read32(DMA2_CURR_ADDR)
469#define bfin_write_DMA2_CURR_ADDR(val) bfin_write32(DMA2_CURR_ADDR) 465#define bfin_write_DMA2_CURR_ADDR(val) bfin_write32(DMA2_CURR_ADDR, val)
470#define bfin_read_DMA2_IRQ_STATUS() bfin_read16(DMA2_IRQ_STATUS) 466#define bfin_read_DMA2_IRQ_STATUS() bfin_read16(DMA2_IRQ_STATUS)
471#define bfin_write_DMA2_IRQ_STATUS(val) bfin_write16(DMA2_IRQ_STATUS, val) 467#define bfin_write_DMA2_IRQ_STATUS(val) bfin_write16(DMA2_IRQ_STATUS, val)
472#define bfin_read_DMA2_PERIPHERAL_MAP() bfin_read16(DMA2_PERIPHERAL_MAP) 468#define bfin_read_DMA2_PERIPHERAL_MAP() bfin_read16(DMA2_PERIPHERAL_MAP)
@@ -479,23 +475,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
479/* DMA Channel 3 Registers */ 475/* DMA Channel 3 Registers */
480 476
481#define bfin_read_DMA3_NEXT_DESC_PTR() bfin_read32(DMA3_NEXT_DESC_PTR) 477#define bfin_read_DMA3_NEXT_DESC_PTR() bfin_read32(DMA3_NEXT_DESC_PTR)
482#define bfin_write_DMA3_NEXT_DESC_PTR(val) bfin_write32(DMA3_NEXT_DESC_PTR) 478#define bfin_write_DMA3_NEXT_DESC_PTR(val) bfin_write32(DMA3_NEXT_DESC_PTR, val)
483#define bfin_read_DMA3_START_ADDR() bfin_read32(DMA3_START_ADDR) 479#define bfin_read_DMA3_START_ADDR() bfin_read32(DMA3_START_ADDR)
484#define bfin_write_DMA3_START_ADDR(val) bfin_write32(DMA3_START_ADDR) 480#define bfin_write_DMA3_START_ADDR(val) bfin_write32(DMA3_START_ADDR, val)
485#define bfin_read_DMA3_CONFIG() bfin_read16(DMA3_CONFIG) 481#define bfin_read_DMA3_CONFIG() bfin_read16(DMA3_CONFIG)
486#define bfin_write_DMA3_CONFIG(val) bfin_write16(DMA3_CONFIG, val) 482#define bfin_write_DMA3_CONFIG(val) bfin_write16(DMA3_CONFIG, val)
487#define bfin_read_DMA3_X_COUNT() bfin_read16(DMA3_X_COUNT) 483#define bfin_read_DMA3_X_COUNT() bfin_read16(DMA3_X_COUNT)
488#define bfin_write_DMA3_X_COUNT(val) bfin_write16(DMA3_X_COUNT, val) 484#define bfin_write_DMA3_X_COUNT(val) bfin_write16(DMA3_X_COUNT, val)
489#define bfin_read_DMA3_X_MODIFY() bfin_read16(DMA3_X_MODIFY) 485#define bfin_read_DMA3_X_MODIFY() bfin_read16(DMA3_X_MODIFY)
490#define bfin_write_DMA3_X_MODIFY(val) bfin_write16(DMA3_X_MODIFY) 486#define bfin_write_DMA3_X_MODIFY(val) bfin_write16(DMA3_X_MODIFY, val)
491#define bfin_read_DMA3_Y_COUNT() bfin_read16(DMA3_Y_COUNT) 487#define bfin_read_DMA3_Y_COUNT() bfin_read16(DMA3_Y_COUNT)
492#define bfin_write_DMA3_Y_COUNT(val) bfin_write16(DMA3_Y_COUNT, val) 488#define bfin_write_DMA3_Y_COUNT(val) bfin_write16(DMA3_Y_COUNT, val)
493#define bfin_read_DMA3_Y_MODIFY() bfin_read16(DMA3_Y_MODIFY) 489#define bfin_read_DMA3_Y_MODIFY() bfin_read16(DMA3_Y_MODIFY)
494#define bfin_write_DMA3_Y_MODIFY(val) bfin_write16(DMA3_Y_MODIFY) 490#define bfin_write_DMA3_Y_MODIFY(val) bfin_write16(DMA3_Y_MODIFY, val)
495#define bfin_read_DMA3_CURR_DESC_PTR() bfin_read32(DMA3_CURR_DESC_PTR) 491#define bfin_read_DMA3_CURR_DESC_PTR() bfin_read32(DMA3_CURR_DESC_PTR)
496#define bfin_write_DMA3_CURR_DESC_PTR(val) bfin_write32(DMA3_CURR_DESC_PTR) 492#define bfin_write_DMA3_CURR_DESC_PTR(val) bfin_write32(DMA3_CURR_DESC_PTR, val)
497#define bfin_read_DMA3_CURR_ADDR() bfin_read32(DMA3_CURR_ADDR) 493#define bfin_read_DMA3_CURR_ADDR() bfin_read32(DMA3_CURR_ADDR)
498#define bfin_write_DMA3_CURR_ADDR(val) bfin_write32(DMA3_CURR_ADDR) 494#define bfin_write_DMA3_CURR_ADDR(val) bfin_write32(DMA3_CURR_ADDR, val)
499#define bfin_read_DMA3_IRQ_STATUS() bfin_read16(DMA3_IRQ_STATUS) 495#define bfin_read_DMA3_IRQ_STATUS() bfin_read16(DMA3_IRQ_STATUS)
500#define bfin_write_DMA3_IRQ_STATUS(val) bfin_write16(DMA3_IRQ_STATUS, val) 496#define bfin_write_DMA3_IRQ_STATUS(val) bfin_write16(DMA3_IRQ_STATUS, val)
501#define bfin_read_DMA3_PERIPHERAL_MAP() bfin_read16(DMA3_PERIPHERAL_MAP) 497#define bfin_read_DMA3_PERIPHERAL_MAP() bfin_read16(DMA3_PERIPHERAL_MAP)
@@ -508,23 +504,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
508/* DMA Channel 4 Registers */ 504/* DMA Channel 4 Registers */
509 505
510#define bfin_read_DMA4_NEXT_DESC_PTR() bfin_read32(DMA4_NEXT_DESC_PTR) 506#define bfin_read_DMA4_NEXT_DESC_PTR() bfin_read32(DMA4_NEXT_DESC_PTR)
511#define bfin_write_DMA4_NEXT_DESC_PTR(val) bfin_write32(DMA4_NEXT_DESC_PTR) 507#define bfin_write_DMA4_NEXT_DESC_PTR(val) bfin_write32(DMA4_NEXT_DESC_PTR, val)
512#define bfin_read_DMA4_START_ADDR() bfin_read32(DMA4_START_ADDR) 508#define bfin_read_DMA4_START_ADDR() bfin_read32(DMA4_START_ADDR)
513#define bfin_write_DMA4_START_ADDR(val) bfin_write32(DMA4_START_ADDR) 509#define bfin_write_DMA4_START_ADDR(val) bfin_write32(DMA4_START_ADDR, val)
514#define bfin_read_DMA4_CONFIG() bfin_read16(DMA4_CONFIG) 510#define bfin_read_DMA4_CONFIG() bfin_read16(DMA4_CONFIG)
515#define bfin_write_DMA4_CONFIG(val) bfin_write16(DMA4_CONFIG, val) 511#define bfin_write_DMA4_CONFIG(val) bfin_write16(DMA4_CONFIG, val)
516#define bfin_read_DMA4_X_COUNT() bfin_read16(DMA4_X_COUNT) 512#define bfin_read_DMA4_X_COUNT() bfin_read16(DMA4_X_COUNT)
517#define bfin_write_DMA4_X_COUNT(val) bfin_write16(DMA4_X_COUNT, val) 513#define bfin_write_DMA4_X_COUNT(val) bfin_write16(DMA4_X_COUNT, val)
518#define bfin_read_DMA4_X_MODIFY() bfin_read16(DMA4_X_MODIFY) 514#define bfin_read_DMA4_X_MODIFY() bfin_read16(DMA4_X_MODIFY)
519#define bfin_write_DMA4_X_MODIFY(val) bfin_write16(DMA4_X_MODIFY) 515#define bfin_write_DMA4_X_MODIFY(val) bfin_write16(DMA4_X_MODIFY, val)
520#define bfin_read_DMA4_Y_COUNT() bfin_read16(DMA4_Y_COUNT) 516#define bfin_read_DMA4_Y_COUNT() bfin_read16(DMA4_Y_COUNT)
521#define bfin_write_DMA4_Y_COUNT(val) bfin_write16(DMA4_Y_COUNT, val) 517#define bfin_write_DMA4_Y_COUNT(val) bfin_write16(DMA4_Y_COUNT, val)
522#define bfin_read_DMA4_Y_MODIFY() bfin_read16(DMA4_Y_MODIFY) 518#define bfin_read_DMA4_Y_MODIFY() bfin_read16(DMA4_Y_MODIFY)
523#define bfin_write_DMA4_Y_MODIFY(val) bfin_write16(DMA4_Y_MODIFY) 519#define bfin_write_DMA4_Y_MODIFY(val) bfin_write16(DMA4_Y_MODIFY, val)
524#define bfin_read_DMA4_CURR_DESC_PTR() bfin_read32(DMA4_CURR_DESC_PTR) 520#define bfin_read_DMA4_CURR_DESC_PTR() bfin_read32(DMA4_CURR_DESC_PTR)
525#define bfin_write_DMA4_CURR_DESC_PTR(val) bfin_write32(DMA4_CURR_DESC_PTR) 521#define bfin_write_DMA4_CURR_DESC_PTR(val) bfin_write32(DMA4_CURR_DESC_PTR, val)
526#define bfin_read_DMA4_CURR_ADDR() bfin_read32(DMA4_CURR_ADDR) 522#define bfin_read_DMA4_CURR_ADDR() bfin_read32(DMA4_CURR_ADDR)
527#define bfin_write_DMA4_CURR_ADDR(val) bfin_write32(DMA4_CURR_ADDR) 523#define bfin_write_DMA4_CURR_ADDR(val) bfin_write32(DMA4_CURR_ADDR, val)
528#define bfin_read_DMA4_IRQ_STATUS() bfin_read16(DMA4_IRQ_STATUS) 524#define bfin_read_DMA4_IRQ_STATUS() bfin_read16(DMA4_IRQ_STATUS)
529#define bfin_write_DMA4_IRQ_STATUS(val) bfin_write16(DMA4_IRQ_STATUS, val) 525#define bfin_write_DMA4_IRQ_STATUS(val) bfin_write16(DMA4_IRQ_STATUS, val)
530#define bfin_read_DMA4_PERIPHERAL_MAP() bfin_read16(DMA4_PERIPHERAL_MAP) 526#define bfin_read_DMA4_PERIPHERAL_MAP() bfin_read16(DMA4_PERIPHERAL_MAP)
@@ -537,23 +533,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
537/* DMA Channel 5 Registers */ 533/* DMA Channel 5 Registers */
538 534
539#define bfin_read_DMA5_NEXT_DESC_PTR() bfin_read32(DMA5_NEXT_DESC_PTR) 535#define bfin_read_DMA5_NEXT_DESC_PTR() bfin_read32(DMA5_NEXT_DESC_PTR)
540#define bfin_write_DMA5_NEXT_DESC_PTR(val) bfin_write32(DMA5_NEXT_DESC_PTR) 536#define bfin_write_DMA5_NEXT_DESC_PTR(val) bfin_write32(DMA5_NEXT_DESC_PTR, val)
541#define bfin_read_DMA5_START_ADDR() bfin_read32(DMA5_START_ADDR) 537#define bfin_read_DMA5_START_ADDR() bfin_read32(DMA5_START_ADDR)
542#define bfin_write_DMA5_START_ADDR(val) bfin_write32(DMA5_START_ADDR) 538#define bfin_write_DMA5_START_ADDR(val) bfin_write32(DMA5_START_ADDR, val)
543#define bfin_read_DMA5_CONFIG() bfin_read16(DMA5_CONFIG) 539#define bfin_read_DMA5_CONFIG() bfin_read16(DMA5_CONFIG)
544#define bfin_write_DMA5_CONFIG(val) bfin_write16(DMA5_CONFIG, val) 540#define bfin_write_DMA5_CONFIG(val) bfin_write16(DMA5_CONFIG, val)
545#define bfin_read_DMA5_X_COUNT() bfin_read16(DMA5_X_COUNT) 541#define bfin_read_DMA5_X_COUNT() bfin_read16(DMA5_X_COUNT)
546#define bfin_write_DMA5_X_COUNT(val) bfin_write16(DMA5_X_COUNT, val) 542#define bfin_write_DMA5_X_COUNT(val) bfin_write16(DMA5_X_COUNT, val)
547#define bfin_read_DMA5_X_MODIFY() bfin_read16(DMA5_X_MODIFY) 543#define bfin_read_DMA5_X_MODIFY() bfin_read16(DMA5_X_MODIFY)
548#define bfin_write_DMA5_X_MODIFY(val) bfin_write16(DMA5_X_MODIFY) 544#define bfin_write_DMA5_X_MODIFY(val) bfin_write16(DMA5_X_MODIFY, val)
549#define bfin_read_DMA5_Y_COUNT() bfin_read16(DMA5_Y_COUNT) 545#define bfin_read_DMA5_Y_COUNT() bfin_read16(DMA5_Y_COUNT)
550#define bfin_write_DMA5_Y_COUNT(val) bfin_write16(DMA5_Y_COUNT, val) 546#define bfin_write_DMA5_Y_COUNT(val) bfin_write16(DMA5_Y_COUNT, val)
551#define bfin_read_DMA5_Y_MODIFY() bfin_read16(DMA5_Y_MODIFY) 547#define bfin_read_DMA5_Y_MODIFY() bfin_read16(DMA5_Y_MODIFY)
552#define bfin_write_DMA5_Y_MODIFY(val) bfin_write16(DMA5_Y_MODIFY) 548#define bfin_write_DMA5_Y_MODIFY(val) bfin_write16(DMA5_Y_MODIFY, val)
553#define bfin_read_DMA5_CURR_DESC_PTR() bfin_read32(DMA5_CURR_DESC_PTR) 549#define bfin_read_DMA5_CURR_DESC_PTR() bfin_read32(DMA5_CURR_DESC_PTR)
554#define bfin_write_DMA5_CURR_DESC_PTR(val) bfin_write32(DMA5_CURR_DESC_PTR) 550#define bfin_write_DMA5_CURR_DESC_PTR(val) bfin_write32(DMA5_CURR_DESC_PTR, val)
555#define bfin_read_DMA5_CURR_ADDR() bfin_read32(DMA5_CURR_ADDR) 551#define bfin_read_DMA5_CURR_ADDR() bfin_read32(DMA5_CURR_ADDR)
556#define bfin_write_DMA5_CURR_ADDR(val) bfin_write32(DMA5_CURR_ADDR) 552#define bfin_write_DMA5_CURR_ADDR(val) bfin_write32(DMA5_CURR_ADDR, val)
557#define bfin_read_DMA5_IRQ_STATUS() bfin_read16(DMA5_IRQ_STATUS) 553#define bfin_read_DMA5_IRQ_STATUS() bfin_read16(DMA5_IRQ_STATUS)
558#define bfin_write_DMA5_IRQ_STATUS(val) bfin_write16(DMA5_IRQ_STATUS, val) 554#define bfin_write_DMA5_IRQ_STATUS(val) bfin_write16(DMA5_IRQ_STATUS, val)
559#define bfin_read_DMA5_PERIPHERAL_MAP() bfin_read16(DMA5_PERIPHERAL_MAP) 555#define bfin_read_DMA5_PERIPHERAL_MAP() bfin_read16(DMA5_PERIPHERAL_MAP)
@@ -566,23 +562,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
566/* DMA Channel 6 Registers */ 562/* DMA Channel 6 Registers */
567 563
568#define bfin_read_DMA6_NEXT_DESC_PTR() bfin_read32(DMA6_NEXT_DESC_PTR) 564#define bfin_read_DMA6_NEXT_DESC_PTR() bfin_read32(DMA6_NEXT_DESC_PTR)
569#define bfin_write_DMA6_NEXT_DESC_PTR(val) bfin_write32(DMA6_NEXT_DESC_PTR) 565#define bfin_write_DMA6_NEXT_DESC_PTR(val) bfin_write32(DMA6_NEXT_DESC_PTR, val)
570#define bfin_read_DMA6_START_ADDR() bfin_read32(DMA6_START_ADDR) 566#define bfin_read_DMA6_START_ADDR() bfin_read32(DMA6_START_ADDR)
571#define bfin_write_DMA6_START_ADDR(val) bfin_write32(DMA6_START_ADDR) 567#define bfin_write_DMA6_START_ADDR(val) bfin_write32(DMA6_START_ADDR, val)
572#define bfin_read_DMA6_CONFIG() bfin_read16(DMA6_CONFIG) 568#define bfin_read_DMA6_CONFIG() bfin_read16(DMA6_CONFIG)
573#define bfin_write_DMA6_CONFIG(val) bfin_write16(DMA6_CONFIG, val) 569#define bfin_write_DMA6_CONFIG(val) bfin_write16(DMA6_CONFIG, val)
574#define bfin_read_DMA6_X_COUNT() bfin_read16(DMA6_X_COUNT) 570#define bfin_read_DMA6_X_COUNT() bfin_read16(DMA6_X_COUNT)
575#define bfin_write_DMA6_X_COUNT(val) bfin_write16(DMA6_X_COUNT, val) 571#define bfin_write_DMA6_X_COUNT(val) bfin_write16(DMA6_X_COUNT, val)
576#define bfin_read_DMA6_X_MODIFY() bfin_read16(DMA6_X_MODIFY) 572#define bfin_read_DMA6_X_MODIFY() bfin_read16(DMA6_X_MODIFY)
577#define bfin_write_DMA6_X_MODIFY(val) bfin_write16(DMA6_X_MODIFY) 573#define bfin_write_DMA6_X_MODIFY(val) bfin_write16(DMA6_X_MODIFY, val)
578#define bfin_read_DMA6_Y_COUNT() bfin_read16(DMA6_Y_COUNT) 574#define bfin_read_DMA6_Y_COUNT() bfin_read16(DMA6_Y_COUNT)
579#define bfin_write_DMA6_Y_COUNT(val) bfin_write16(DMA6_Y_COUNT, val) 575#define bfin_write_DMA6_Y_COUNT(val) bfin_write16(DMA6_Y_COUNT, val)
580#define bfin_read_DMA6_Y_MODIFY() bfin_read16(DMA6_Y_MODIFY) 576#define bfin_read_DMA6_Y_MODIFY() bfin_read16(DMA6_Y_MODIFY)
581#define bfin_write_DMA6_Y_MODIFY(val) bfin_write16(DMA6_Y_MODIFY) 577#define bfin_write_DMA6_Y_MODIFY(val) bfin_write16(DMA6_Y_MODIFY, val)
582#define bfin_read_DMA6_CURR_DESC_PTR() bfin_read32(DMA6_CURR_DESC_PTR) 578#define bfin_read_DMA6_CURR_DESC_PTR() bfin_read32(DMA6_CURR_DESC_PTR)
583#define bfin_write_DMA6_CURR_DESC_PTR(val) bfin_write32(DMA6_CURR_DESC_PTR) 579#define bfin_write_DMA6_CURR_DESC_PTR(val) bfin_write32(DMA6_CURR_DESC_PTR, val)
584#define bfin_read_DMA6_CURR_ADDR() bfin_read32(DMA6_CURR_ADDR) 580#define bfin_read_DMA6_CURR_ADDR() bfin_read32(DMA6_CURR_ADDR)
585#define bfin_write_DMA6_CURR_ADDR(val) bfin_write32(DMA6_CURR_ADDR) 581#define bfin_write_DMA6_CURR_ADDR(val) bfin_write32(DMA6_CURR_ADDR, val)
586#define bfin_read_DMA6_IRQ_STATUS() bfin_read16(DMA6_IRQ_STATUS) 582#define bfin_read_DMA6_IRQ_STATUS() bfin_read16(DMA6_IRQ_STATUS)
587#define bfin_write_DMA6_IRQ_STATUS(val) bfin_write16(DMA6_IRQ_STATUS, val) 583#define bfin_write_DMA6_IRQ_STATUS(val) bfin_write16(DMA6_IRQ_STATUS, val)
588#define bfin_read_DMA6_PERIPHERAL_MAP() bfin_read16(DMA6_PERIPHERAL_MAP) 584#define bfin_read_DMA6_PERIPHERAL_MAP() bfin_read16(DMA6_PERIPHERAL_MAP)
@@ -595,23 +591,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
595/* DMA Channel 7 Registers */ 591/* DMA Channel 7 Registers */
596 592
597#define bfin_read_DMA7_NEXT_DESC_PTR() bfin_read32(DMA7_NEXT_DESC_PTR) 593#define bfin_read_DMA7_NEXT_DESC_PTR() bfin_read32(DMA7_NEXT_DESC_PTR)
598#define bfin_write_DMA7_NEXT_DESC_PTR(val) bfin_write32(DMA7_NEXT_DESC_PTR) 594#define bfin_write_DMA7_NEXT_DESC_PTR(val) bfin_write32(DMA7_NEXT_DESC_PTR, val)
599#define bfin_read_DMA7_START_ADDR() bfin_read32(DMA7_START_ADDR) 595#define bfin_read_DMA7_START_ADDR() bfin_read32(DMA7_START_ADDR)
600#define bfin_write_DMA7_START_ADDR(val) bfin_write32(DMA7_START_ADDR) 596#define bfin_write_DMA7_START_ADDR(val) bfin_write32(DMA7_START_ADDR, val)
601#define bfin_read_DMA7_CONFIG() bfin_read16(DMA7_CONFIG) 597#define bfin_read_DMA7_CONFIG() bfin_read16(DMA7_CONFIG)
602#define bfin_write_DMA7_CONFIG(val) bfin_write16(DMA7_CONFIG, val) 598#define bfin_write_DMA7_CONFIG(val) bfin_write16(DMA7_CONFIG, val)
603#define bfin_read_DMA7_X_COUNT() bfin_read16(DMA7_X_COUNT) 599#define bfin_read_DMA7_X_COUNT() bfin_read16(DMA7_X_COUNT)
604#define bfin_write_DMA7_X_COUNT(val) bfin_write16(DMA7_X_COUNT, val) 600#define bfin_write_DMA7_X_COUNT(val) bfin_write16(DMA7_X_COUNT, val)
605#define bfin_read_DMA7_X_MODIFY() bfin_read16(DMA7_X_MODIFY) 601#define bfin_read_DMA7_X_MODIFY() bfin_read16(DMA7_X_MODIFY)
606#define bfin_write_DMA7_X_MODIFY(val) bfin_write16(DMA7_X_MODIFY) 602#define bfin_write_DMA7_X_MODIFY(val) bfin_write16(DMA7_X_MODIFY, val)
607#define bfin_read_DMA7_Y_COUNT() bfin_read16(DMA7_Y_COUNT) 603#define bfin_read_DMA7_Y_COUNT() bfin_read16(DMA7_Y_COUNT)
608#define bfin_write_DMA7_Y_COUNT(val) bfin_write16(DMA7_Y_COUNT, val) 604#define bfin_write_DMA7_Y_COUNT(val) bfin_write16(DMA7_Y_COUNT, val)
609#define bfin_read_DMA7_Y_MODIFY() bfin_read16(DMA7_Y_MODIFY) 605#define bfin_read_DMA7_Y_MODIFY() bfin_read16(DMA7_Y_MODIFY)
610#define bfin_write_DMA7_Y_MODIFY(val) bfin_write16(DMA7_Y_MODIFY) 606#define bfin_write_DMA7_Y_MODIFY(val) bfin_write16(DMA7_Y_MODIFY, val)
611#define bfin_read_DMA7_CURR_DESC_PTR() bfin_read32(DMA7_CURR_DESC_PTR) 607#define bfin_read_DMA7_CURR_DESC_PTR() bfin_read32(DMA7_CURR_DESC_PTR)
612#define bfin_write_DMA7_CURR_DESC_PTR(val) bfin_write32(DMA7_CURR_DESC_PTR) 608#define bfin_write_DMA7_CURR_DESC_PTR(val) bfin_write32(DMA7_CURR_DESC_PTR, val)
613#define bfin_read_DMA7_CURR_ADDR() bfin_read32(DMA7_CURR_ADDR) 609#define bfin_read_DMA7_CURR_ADDR() bfin_read32(DMA7_CURR_ADDR)
614#define bfin_write_DMA7_CURR_ADDR(val) bfin_write32(DMA7_CURR_ADDR) 610#define bfin_write_DMA7_CURR_ADDR(val) bfin_write32(DMA7_CURR_ADDR, val)
615#define bfin_read_DMA7_IRQ_STATUS() bfin_read16(DMA7_IRQ_STATUS) 611#define bfin_read_DMA7_IRQ_STATUS() bfin_read16(DMA7_IRQ_STATUS)
616#define bfin_write_DMA7_IRQ_STATUS(val) bfin_write16(DMA7_IRQ_STATUS, val) 612#define bfin_write_DMA7_IRQ_STATUS(val) bfin_write16(DMA7_IRQ_STATUS, val)
617#define bfin_read_DMA7_PERIPHERAL_MAP() bfin_read16(DMA7_PERIPHERAL_MAP) 613#define bfin_read_DMA7_PERIPHERAL_MAP() bfin_read16(DMA7_PERIPHERAL_MAP)
@@ -624,23 +620,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
624/* DMA Channel 8 Registers */ 620/* DMA Channel 8 Registers */
625 621
626#define bfin_read_DMA8_NEXT_DESC_PTR() bfin_read32(DMA8_NEXT_DESC_PTR) 622#define bfin_read_DMA8_NEXT_DESC_PTR() bfin_read32(DMA8_NEXT_DESC_PTR)
627#define bfin_write_DMA8_NEXT_DESC_PTR(val) bfin_write32(DMA8_NEXT_DESC_PTR) 623#define bfin_write_DMA8_NEXT_DESC_PTR(val) bfin_write32(DMA8_NEXT_DESC_PTR, val)
628#define bfin_read_DMA8_START_ADDR() bfin_read32(DMA8_START_ADDR) 624#define bfin_read_DMA8_START_ADDR() bfin_read32(DMA8_START_ADDR)
629#define bfin_write_DMA8_START_ADDR(val) bfin_write32(DMA8_START_ADDR) 625#define bfin_write_DMA8_START_ADDR(val) bfin_write32(DMA8_START_ADDR, val)
630#define bfin_read_DMA8_CONFIG() bfin_read16(DMA8_CONFIG) 626#define bfin_read_DMA8_CONFIG() bfin_read16(DMA8_CONFIG)
631#define bfin_write_DMA8_CONFIG(val) bfin_write16(DMA8_CONFIG, val) 627#define bfin_write_DMA8_CONFIG(val) bfin_write16(DMA8_CONFIG, val)
632#define bfin_read_DMA8_X_COUNT() bfin_read16(DMA8_X_COUNT) 628#define bfin_read_DMA8_X_COUNT() bfin_read16(DMA8_X_COUNT)
633#define bfin_write_DMA8_X_COUNT(val) bfin_write16(DMA8_X_COUNT, val) 629#define bfin_write_DMA8_X_COUNT(val) bfin_write16(DMA8_X_COUNT, val)
634#define bfin_read_DMA8_X_MODIFY() bfin_read16(DMA8_X_MODIFY) 630#define bfin_read_DMA8_X_MODIFY() bfin_read16(DMA8_X_MODIFY)
635#define bfin_write_DMA8_X_MODIFY(val) bfin_write16(DMA8_X_MODIFY) 631#define bfin_write_DMA8_X_MODIFY(val) bfin_write16(DMA8_X_MODIFY, val)
636#define bfin_read_DMA8_Y_COUNT() bfin_read16(DMA8_Y_COUNT) 632#define bfin_read_DMA8_Y_COUNT() bfin_read16(DMA8_Y_COUNT)
637#define bfin_write_DMA8_Y_COUNT(val) bfin_write16(DMA8_Y_COUNT, val) 633#define bfin_write_DMA8_Y_COUNT(val) bfin_write16(DMA8_Y_COUNT, val)
638#define bfin_read_DMA8_Y_MODIFY() bfin_read16(DMA8_Y_MODIFY) 634#define bfin_read_DMA8_Y_MODIFY() bfin_read16(DMA8_Y_MODIFY)
639#define bfin_write_DMA8_Y_MODIFY(val) bfin_write16(DMA8_Y_MODIFY) 635#define bfin_write_DMA8_Y_MODIFY(val) bfin_write16(DMA8_Y_MODIFY, val)
640#define bfin_read_DMA8_CURR_DESC_PTR() bfin_read32(DMA8_CURR_DESC_PTR) 636#define bfin_read_DMA8_CURR_DESC_PTR() bfin_read32(DMA8_CURR_DESC_PTR)
641#define bfin_write_DMA8_CURR_DESC_PTR(val) bfin_write32(DMA8_CURR_DESC_PTR) 637#define bfin_write_DMA8_CURR_DESC_PTR(val) bfin_write32(DMA8_CURR_DESC_PTR, val)
642#define bfin_read_DMA8_CURR_ADDR() bfin_read32(DMA8_CURR_ADDR) 638#define bfin_read_DMA8_CURR_ADDR() bfin_read32(DMA8_CURR_ADDR)
643#define bfin_write_DMA8_CURR_ADDR(val) bfin_write32(DMA8_CURR_ADDR) 639#define bfin_write_DMA8_CURR_ADDR(val) bfin_write32(DMA8_CURR_ADDR, val)
644#define bfin_read_DMA8_IRQ_STATUS() bfin_read16(DMA8_IRQ_STATUS) 640#define bfin_read_DMA8_IRQ_STATUS() bfin_read16(DMA8_IRQ_STATUS)
645#define bfin_write_DMA8_IRQ_STATUS(val) bfin_write16(DMA8_IRQ_STATUS, val) 641#define bfin_write_DMA8_IRQ_STATUS(val) bfin_write16(DMA8_IRQ_STATUS, val)
646#define bfin_read_DMA8_PERIPHERAL_MAP() bfin_read16(DMA8_PERIPHERAL_MAP) 642#define bfin_read_DMA8_PERIPHERAL_MAP() bfin_read16(DMA8_PERIPHERAL_MAP)
@@ -653,23 +649,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
653/* DMA Channel 9 Registers */ 649/* DMA Channel 9 Registers */
654 650
655#define bfin_read_DMA9_NEXT_DESC_PTR() bfin_read32(DMA9_NEXT_DESC_PTR) 651#define bfin_read_DMA9_NEXT_DESC_PTR() bfin_read32(DMA9_NEXT_DESC_PTR)
656#define bfin_write_DMA9_NEXT_DESC_PTR(val) bfin_write32(DMA9_NEXT_DESC_PTR) 652#define bfin_write_DMA9_NEXT_DESC_PTR(val) bfin_write32(DMA9_NEXT_DESC_PTR, val)
657#define bfin_read_DMA9_START_ADDR() bfin_read32(DMA9_START_ADDR) 653#define bfin_read_DMA9_START_ADDR() bfin_read32(DMA9_START_ADDR)
658#define bfin_write_DMA9_START_ADDR(val) bfin_write32(DMA9_START_ADDR) 654#define bfin_write_DMA9_START_ADDR(val) bfin_write32(DMA9_START_ADDR, val)
659#define bfin_read_DMA9_CONFIG() bfin_read16(DMA9_CONFIG) 655#define bfin_read_DMA9_CONFIG() bfin_read16(DMA9_CONFIG)
660#define bfin_write_DMA9_CONFIG(val) bfin_write16(DMA9_CONFIG, val) 656#define bfin_write_DMA9_CONFIG(val) bfin_write16(DMA9_CONFIG, val)
661#define bfin_read_DMA9_X_COUNT() bfin_read16(DMA9_X_COUNT) 657#define bfin_read_DMA9_X_COUNT() bfin_read16(DMA9_X_COUNT)
662#define bfin_write_DMA9_X_COUNT(val) bfin_write16(DMA9_X_COUNT, val) 658#define bfin_write_DMA9_X_COUNT(val) bfin_write16(DMA9_X_COUNT, val)
663#define bfin_read_DMA9_X_MODIFY() bfin_read16(DMA9_X_MODIFY) 659#define bfin_read_DMA9_X_MODIFY() bfin_read16(DMA9_X_MODIFY)
664#define bfin_write_DMA9_X_MODIFY(val) bfin_write16(DMA9_X_MODIFY) 660#define bfin_write_DMA9_X_MODIFY(val) bfin_write16(DMA9_X_MODIFY, val)
665#define bfin_read_DMA9_Y_COUNT() bfin_read16(DMA9_Y_COUNT) 661#define bfin_read_DMA9_Y_COUNT() bfin_read16(DMA9_Y_COUNT)
666#define bfin_write_DMA9_Y_COUNT(val) bfin_write16(DMA9_Y_COUNT, val) 662#define bfin_write_DMA9_Y_COUNT(val) bfin_write16(DMA9_Y_COUNT, val)
667#define bfin_read_DMA9_Y_MODIFY() bfin_read16(DMA9_Y_MODIFY) 663#define bfin_read_DMA9_Y_MODIFY() bfin_read16(DMA9_Y_MODIFY)
668#define bfin_write_DMA9_Y_MODIFY(val) bfin_write16(DMA9_Y_MODIFY) 664#define bfin_write_DMA9_Y_MODIFY(val) bfin_write16(DMA9_Y_MODIFY, val)
669#define bfin_read_DMA9_CURR_DESC_PTR() bfin_read32(DMA9_CURR_DESC_PTR) 665#define bfin_read_DMA9_CURR_DESC_PTR() bfin_read32(DMA9_CURR_DESC_PTR)
670#define bfin_write_DMA9_CURR_DESC_PTR(val) bfin_write32(DMA9_CURR_DESC_PTR) 666#define bfin_write_DMA9_CURR_DESC_PTR(val) bfin_write32(DMA9_CURR_DESC_PTR, val)
671#define bfin_read_DMA9_CURR_ADDR() bfin_read32(DMA9_CURR_ADDR) 667#define bfin_read_DMA9_CURR_ADDR() bfin_read32(DMA9_CURR_ADDR)
672#define bfin_write_DMA9_CURR_ADDR(val) bfin_write32(DMA9_CURR_ADDR) 668#define bfin_write_DMA9_CURR_ADDR(val) bfin_write32(DMA9_CURR_ADDR, val)
673#define bfin_read_DMA9_IRQ_STATUS() bfin_read16(DMA9_IRQ_STATUS) 669#define bfin_read_DMA9_IRQ_STATUS() bfin_read16(DMA9_IRQ_STATUS)
674#define bfin_write_DMA9_IRQ_STATUS(val) bfin_write16(DMA9_IRQ_STATUS, val) 670#define bfin_write_DMA9_IRQ_STATUS(val) bfin_write16(DMA9_IRQ_STATUS, val)
675#define bfin_read_DMA9_PERIPHERAL_MAP() bfin_read16(DMA9_PERIPHERAL_MAP) 671#define bfin_read_DMA9_PERIPHERAL_MAP() bfin_read16(DMA9_PERIPHERAL_MAP)
@@ -682,23 +678,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
682/* DMA Channel 10 Registers */ 678/* DMA Channel 10 Registers */
683 679
684#define bfin_read_DMA10_NEXT_DESC_PTR() bfin_read32(DMA10_NEXT_DESC_PTR) 680#define bfin_read_DMA10_NEXT_DESC_PTR() bfin_read32(DMA10_NEXT_DESC_PTR)
685#define bfin_write_DMA10_NEXT_DESC_PTR(val) bfin_write32(DMA10_NEXT_DESC_PTR) 681#define bfin_write_DMA10_NEXT_DESC_PTR(val) bfin_write32(DMA10_NEXT_DESC_PTR, val)
686#define bfin_read_DMA10_START_ADDR() bfin_read32(DMA10_START_ADDR) 682#define bfin_read_DMA10_START_ADDR() bfin_read32(DMA10_START_ADDR)
687#define bfin_write_DMA10_START_ADDR(val) bfin_write32(DMA10_START_ADDR) 683#define bfin_write_DMA10_START_ADDR(val) bfin_write32(DMA10_START_ADDR, val)
688#define bfin_read_DMA10_CONFIG() bfin_read16(DMA10_CONFIG) 684#define bfin_read_DMA10_CONFIG() bfin_read16(DMA10_CONFIG)
689#define bfin_write_DMA10_CONFIG(val) bfin_write16(DMA10_CONFIG, val) 685#define bfin_write_DMA10_CONFIG(val) bfin_write16(DMA10_CONFIG, val)
690#define bfin_read_DMA10_X_COUNT() bfin_read16(DMA10_X_COUNT) 686#define bfin_read_DMA10_X_COUNT() bfin_read16(DMA10_X_COUNT)
691#define bfin_write_DMA10_X_COUNT(val) bfin_write16(DMA10_X_COUNT, val) 687#define bfin_write_DMA10_X_COUNT(val) bfin_write16(DMA10_X_COUNT, val)
692#define bfin_read_DMA10_X_MODIFY() bfin_read16(DMA10_X_MODIFY) 688#define bfin_read_DMA10_X_MODIFY() bfin_read16(DMA10_X_MODIFY)
693#define bfin_write_DMA10_X_MODIFY(val) bfin_write16(DMA10_X_MODIFY) 689#define bfin_write_DMA10_X_MODIFY(val) bfin_write16(DMA10_X_MODIFY, val)
694#define bfin_read_DMA10_Y_COUNT() bfin_read16(DMA10_Y_COUNT) 690#define bfin_read_DMA10_Y_COUNT() bfin_read16(DMA10_Y_COUNT)
695#define bfin_write_DMA10_Y_COUNT(val) bfin_write16(DMA10_Y_COUNT, val) 691#define bfin_write_DMA10_Y_COUNT(val) bfin_write16(DMA10_Y_COUNT, val)
696#define bfin_read_DMA10_Y_MODIFY() bfin_read16(DMA10_Y_MODIFY) 692#define bfin_read_DMA10_Y_MODIFY() bfin_read16(DMA10_Y_MODIFY)
697#define bfin_write_DMA10_Y_MODIFY(val) bfin_write16(DMA10_Y_MODIFY) 693#define bfin_write_DMA10_Y_MODIFY(val) bfin_write16(DMA10_Y_MODIFY, val)
698#define bfin_read_DMA10_CURR_DESC_PTR() bfin_read32(DMA10_CURR_DESC_PTR) 694#define bfin_read_DMA10_CURR_DESC_PTR() bfin_read32(DMA10_CURR_DESC_PTR)
699#define bfin_write_DMA10_CURR_DESC_PTR(val) bfin_write32(DMA10_CURR_DESC_PTR) 695#define bfin_write_DMA10_CURR_DESC_PTR(val) bfin_write32(DMA10_CURR_DESC_PTR, val)
700#define bfin_read_DMA10_CURR_ADDR() bfin_read32(DMA10_CURR_ADDR) 696#define bfin_read_DMA10_CURR_ADDR() bfin_read32(DMA10_CURR_ADDR)
701#define bfin_write_DMA10_CURR_ADDR(val) bfin_write32(DMA10_CURR_ADDR) 697#define bfin_write_DMA10_CURR_ADDR(val) bfin_write32(DMA10_CURR_ADDR, val)
702#define bfin_read_DMA10_IRQ_STATUS() bfin_read16(DMA10_IRQ_STATUS) 698#define bfin_read_DMA10_IRQ_STATUS() bfin_read16(DMA10_IRQ_STATUS)
703#define bfin_write_DMA10_IRQ_STATUS(val) bfin_write16(DMA10_IRQ_STATUS, val) 699#define bfin_write_DMA10_IRQ_STATUS(val) bfin_write16(DMA10_IRQ_STATUS, val)
704#define bfin_read_DMA10_PERIPHERAL_MAP() bfin_read16(DMA10_PERIPHERAL_MAP) 700#define bfin_read_DMA10_PERIPHERAL_MAP() bfin_read16(DMA10_PERIPHERAL_MAP)
@@ -711,23 +707,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
711/* DMA Channel 11 Registers */ 707/* DMA Channel 11 Registers */
712 708
713#define bfin_read_DMA11_NEXT_DESC_PTR() bfin_read32(DMA11_NEXT_DESC_PTR) 709#define bfin_read_DMA11_NEXT_DESC_PTR() bfin_read32(DMA11_NEXT_DESC_PTR)
714#define bfin_write_DMA11_NEXT_DESC_PTR(val) bfin_write32(DMA11_NEXT_DESC_PTR) 710#define bfin_write_DMA11_NEXT_DESC_PTR(val) bfin_write32(DMA11_NEXT_DESC_PTR, val)
715#define bfin_read_DMA11_START_ADDR() bfin_read32(DMA11_START_ADDR) 711#define bfin_read_DMA11_START_ADDR() bfin_read32(DMA11_START_ADDR)
716#define bfin_write_DMA11_START_ADDR(val) bfin_write32(DMA11_START_ADDR) 712#define bfin_write_DMA11_START_ADDR(val) bfin_write32(DMA11_START_ADDR, val)
717#define bfin_read_DMA11_CONFIG() bfin_read16(DMA11_CONFIG) 713#define bfin_read_DMA11_CONFIG() bfin_read16(DMA11_CONFIG)
718#define bfin_write_DMA11_CONFIG(val) bfin_write16(DMA11_CONFIG, val) 714#define bfin_write_DMA11_CONFIG(val) bfin_write16(DMA11_CONFIG, val)
719#define bfin_read_DMA11_X_COUNT() bfin_read16(DMA11_X_COUNT) 715#define bfin_read_DMA11_X_COUNT() bfin_read16(DMA11_X_COUNT)
720#define bfin_write_DMA11_X_COUNT(val) bfin_write16(DMA11_X_COUNT, val) 716#define bfin_write_DMA11_X_COUNT(val) bfin_write16(DMA11_X_COUNT, val)
721#define bfin_read_DMA11_X_MODIFY() bfin_read16(DMA11_X_MODIFY) 717#define bfin_read_DMA11_X_MODIFY() bfin_read16(DMA11_X_MODIFY)
722#define bfin_write_DMA11_X_MODIFY(val) bfin_write16(DMA11_X_MODIFY) 718#define bfin_write_DMA11_X_MODIFY(val) bfin_write16(DMA11_X_MODIFY, val)
723#define bfin_read_DMA11_Y_COUNT() bfin_read16(DMA11_Y_COUNT) 719#define bfin_read_DMA11_Y_COUNT() bfin_read16(DMA11_Y_COUNT)
724#define bfin_write_DMA11_Y_COUNT(val) bfin_write16(DMA11_Y_COUNT, val) 720#define bfin_write_DMA11_Y_COUNT(val) bfin_write16(DMA11_Y_COUNT, val)
725#define bfin_read_DMA11_Y_MODIFY() bfin_read16(DMA11_Y_MODIFY) 721#define bfin_read_DMA11_Y_MODIFY() bfin_read16(DMA11_Y_MODIFY)
726#define bfin_write_DMA11_Y_MODIFY(val) bfin_write16(DMA11_Y_MODIFY) 722#define bfin_write_DMA11_Y_MODIFY(val) bfin_write16(DMA11_Y_MODIFY, val)
727#define bfin_read_DMA11_CURR_DESC_PTR() bfin_read32(DMA11_CURR_DESC_PTR) 723#define bfin_read_DMA11_CURR_DESC_PTR() bfin_read32(DMA11_CURR_DESC_PTR)
728#define bfin_write_DMA11_CURR_DESC_PTR(val) bfin_write32(DMA11_CURR_DESC_PTR) 724#define bfin_write_DMA11_CURR_DESC_PTR(val) bfin_write32(DMA11_CURR_DESC_PTR, val)
729#define bfin_read_DMA11_CURR_ADDR() bfin_read32(DMA11_CURR_ADDR) 725#define bfin_read_DMA11_CURR_ADDR() bfin_read32(DMA11_CURR_ADDR)
730#define bfin_write_DMA11_CURR_ADDR(val) bfin_write32(DMA11_CURR_ADDR) 726#define bfin_write_DMA11_CURR_ADDR(val) bfin_write32(DMA11_CURR_ADDR, val)
731#define bfin_read_DMA11_IRQ_STATUS() bfin_read16(DMA11_IRQ_STATUS) 727#define bfin_read_DMA11_IRQ_STATUS() bfin_read16(DMA11_IRQ_STATUS)
732#define bfin_write_DMA11_IRQ_STATUS(val) bfin_write16(DMA11_IRQ_STATUS, val) 728#define bfin_write_DMA11_IRQ_STATUS(val) bfin_write16(DMA11_IRQ_STATUS, val)
733#define bfin_read_DMA11_PERIPHERAL_MAP() bfin_read16(DMA11_PERIPHERAL_MAP) 729#define bfin_read_DMA11_PERIPHERAL_MAP() bfin_read16(DMA11_PERIPHERAL_MAP)
@@ -740,7 +736,7 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
740/* MDMA Stream 0 Registers */ 736/* MDMA Stream 0 Registers */
741 737
742#define bfin_read_MDMA_D0_NEXT_DESC_PTR() bfin_read32(MDMA_D0_NEXT_DESC_PTR) 738#define bfin_read_MDMA_D0_NEXT_DESC_PTR() bfin_read32(MDMA_D0_NEXT_DESC_PTR)
743#define bfin_write_MDMA_D0_NEXT_DESC_PTR(val) bfin_write32(MDMA_D0_NEXT_DESC_PTR) 739#define bfin_write_MDMA_D0_NEXT_DESC_PTR(val) bfin_write32(MDMA_D0_NEXT_DESC_PTR, val)
744#define bfin_read_MDMA_D0_START_ADDR() bfin_read32(MDMA_D0_START_ADDR) 740#define bfin_read_MDMA_D0_START_ADDR() bfin_read32(MDMA_D0_START_ADDR)
745#define bfin_write_MDMA_D0_START_ADDR(val) bfin_write32(MDMA_D0_START_ADDR, val) 741#define bfin_write_MDMA_D0_START_ADDR(val) bfin_write32(MDMA_D0_START_ADDR, val)
746#define bfin_read_MDMA_D0_CONFIG() bfin_read16(MDMA_D0_CONFIG) 742#define bfin_read_MDMA_D0_CONFIG() bfin_read16(MDMA_D0_CONFIG)
@@ -803,11 +799,11 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
803#define bfin_read_MDMA_D1_X_COUNT() bfin_read16(MDMA_D1_X_COUNT) 799#define bfin_read_MDMA_D1_X_COUNT() bfin_read16(MDMA_D1_X_COUNT)
804#define bfin_write_MDMA_D1_X_COUNT(val) bfin_write16(MDMA_D1_X_COUNT, val) 800#define bfin_write_MDMA_D1_X_COUNT(val) bfin_write16(MDMA_D1_X_COUNT, val)
805#define bfin_read_MDMA_D1_X_MODIFY() bfin_read16(MDMA_D1_X_MODIFY) 801#define bfin_read_MDMA_D1_X_MODIFY() bfin_read16(MDMA_D1_X_MODIFY)
806#define bfin_write_MDMA_D1_X_MODIFY(val) bfin_write16(MDMA_D1_X_MODIFY) 802#define bfin_write_MDMA_D1_X_MODIFY(val) bfin_write16(MDMA_D1_X_MODIFY, val)
807#define bfin_read_MDMA_D1_Y_COUNT() bfin_read16(MDMA_D1_Y_COUNT) 803#define bfin_read_MDMA_D1_Y_COUNT() bfin_read16(MDMA_D1_Y_COUNT)
808#define bfin_write_MDMA_D1_Y_COUNT(val) bfin_write16(MDMA_D1_Y_COUNT, val) 804#define bfin_write_MDMA_D1_Y_COUNT(val) bfin_write16(MDMA_D1_Y_COUNT, val)
809#define bfin_read_MDMA_D1_Y_MODIFY() bfin_read16(MDMA_D1_Y_MODIFY) 805#define bfin_read_MDMA_D1_Y_MODIFY() bfin_read16(MDMA_D1_Y_MODIFY)
810#define bfin_write_MDMA_D1_Y_MODIFY(val) bfin_write16(MDMA_D1_Y_MODIFY) 806#define bfin_write_MDMA_D1_Y_MODIFY(val) bfin_write16(MDMA_D1_Y_MODIFY, val)
811#define bfin_read_MDMA_D1_CURR_DESC_PTR() bfin_read32(MDMA_D1_CURR_DESC_PTR) 807#define bfin_read_MDMA_D1_CURR_DESC_PTR() bfin_read32(MDMA_D1_CURR_DESC_PTR)
812#define bfin_write_MDMA_D1_CURR_DESC_PTR(val) bfin_write32(MDMA_D1_CURR_DESC_PTR, val) 808#define bfin_write_MDMA_D1_CURR_DESC_PTR(val) bfin_write32(MDMA_D1_CURR_DESC_PTR, val)
813#define bfin_read_MDMA_D1_CURR_ADDR() bfin_read32(MDMA_D1_CURR_ADDR) 809#define bfin_read_MDMA_D1_CURR_ADDR() bfin_read32(MDMA_D1_CURR_ADDR)
@@ -829,11 +825,11 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
829#define bfin_read_MDMA_S1_X_COUNT() bfin_read16(MDMA_S1_X_COUNT) 825#define bfin_read_MDMA_S1_X_COUNT() bfin_read16(MDMA_S1_X_COUNT)
830#define bfin_write_MDMA_S1_X_COUNT(val) bfin_write16(MDMA_S1_X_COUNT, val) 826#define bfin_write_MDMA_S1_X_COUNT(val) bfin_write16(MDMA_S1_X_COUNT, val)
831#define bfin_read_MDMA_S1_X_MODIFY() bfin_read16(MDMA_S1_X_MODIFY) 827#define bfin_read_MDMA_S1_X_MODIFY() bfin_read16(MDMA_S1_X_MODIFY)
832#define bfin_write_MDMA_S1_X_MODIFY(val) bfin_write16(MDMA_S1_X_MODIFY) 828#define bfin_write_MDMA_S1_X_MODIFY(val) bfin_write16(MDMA_S1_X_MODIFY, val)
833#define bfin_read_MDMA_S1_Y_COUNT() bfin_read16(MDMA_S1_Y_COUNT) 829#define bfin_read_MDMA_S1_Y_COUNT() bfin_read16(MDMA_S1_Y_COUNT)
834#define bfin_write_MDMA_S1_Y_COUNT(val) bfin_write16(MDMA_S1_Y_COUNT, val) 830#define bfin_write_MDMA_S1_Y_COUNT(val) bfin_write16(MDMA_S1_Y_COUNT, val)
835#define bfin_read_MDMA_S1_Y_MODIFY() bfin_read16(MDMA_S1_Y_MODIFY) 831#define bfin_read_MDMA_S1_Y_MODIFY() bfin_read16(MDMA_S1_Y_MODIFY)
836#define bfin_write_MDMA_S1_Y_MODIFY(val) bfin_write16(MDMA_S1_Y_MODIFY) 832#define bfin_write_MDMA_S1_Y_MODIFY(val) bfin_write16(MDMA_S1_Y_MODIFY, val)
837#define bfin_read_MDMA_S1_CURR_DESC_PTR() bfin_read32(MDMA_S1_CURR_DESC_PTR) 833#define bfin_read_MDMA_S1_CURR_DESC_PTR() bfin_read32(MDMA_S1_CURR_DESC_PTR)
838#define bfin_write_MDMA_S1_CURR_DESC_PTR(val) bfin_write32(MDMA_S1_CURR_DESC_PTR, val) 834#define bfin_write_MDMA_S1_CURR_DESC_PTR(val) bfin_write32(MDMA_S1_CURR_DESC_PTR, val)
839#define bfin_read_MDMA_S1_CURR_ADDR() bfin_read32(MDMA_S1_CURR_ADDR) 835#define bfin_read_MDMA_S1_CURR_ADDR() bfin_read32(MDMA_S1_CURR_ADDR)
@@ -1246,23 +1242,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1246/* DMA Channel 12 Registers */ 1242/* DMA Channel 12 Registers */
1247 1243
1248#define bfin_read_DMA12_NEXT_DESC_PTR() bfin_read32(DMA12_NEXT_DESC_PTR) 1244#define bfin_read_DMA12_NEXT_DESC_PTR() bfin_read32(DMA12_NEXT_DESC_PTR)
1249#define bfin_write_DMA12_NEXT_DESC_PTR(val) bfin_write32(DMA12_NEXT_DESC_PTR) 1245#define bfin_write_DMA12_NEXT_DESC_PTR(val) bfin_write32(DMA12_NEXT_DESC_PTR, val)
1250#define bfin_read_DMA12_START_ADDR() bfin_read32(DMA12_START_ADDR) 1246#define bfin_read_DMA12_START_ADDR() bfin_read32(DMA12_START_ADDR)
1251#define bfin_write_DMA12_START_ADDR(val) bfin_write32(DMA12_START_ADDR) 1247#define bfin_write_DMA12_START_ADDR(val) bfin_write32(DMA12_START_ADDR, val)
1252#define bfin_read_DMA12_CONFIG() bfin_read16(DMA12_CONFIG) 1248#define bfin_read_DMA12_CONFIG() bfin_read16(DMA12_CONFIG)
1253#define bfin_write_DMA12_CONFIG(val) bfin_write16(DMA12_CONFIG, val) 1249#define bfin_write_DMA12_CONFIG(val) bfin_write16(DMA12_CONFIG, val)
1254#define bfin_read_DMA12_X_COUNT() bfin_read16(DMA12_X_COUNT) 1250#define bfin_read_DMA12_X_COUNT() bfin_read16(DMA12_X_COUNT)
1255#define bfin_write_DMA12_X_COUNT(val) bfin_write16(DMA12_X_COUNT, val) 1251#define bfin_write_DMA12_X_COUNT(val) bfin_write16(DMA12_X_COUNT, val)
1256#define bfin_read_DMA12_X_MODIFY() bfin_read16(DMA12_X_MODIFY) 1252#define bfin_read_DMA12_X_MODIFY() bfin_read16(DMA12_X_MODIFY)
1257#define bfin_write_DMA12_X_MODIFY(val) bfin_write16(DMA12_X_MODIFY) 1253#define bfin_write_DMA12_X_MODIFY(val) bfin_write16(DMA12_X_MODIFY, val)
1258#define bfin_read_DMA12_Y_COUNT() bfin_read16(DMA12_Y_COUNT) 1254#define bfin_read_DMA12_Y_COUNT() bfin_read16(DMA12_Y_COUNT)
1259#define bfin_write_DMA12_Y_COUNT(val) bfin_write16(DMA12_Y_COUNT, val) 1255#define bfin_write_DMA12_Y_COUNT(val) bfin_write16(DMA12_Y_COUNT, val)
1260#define bfin_read_DMA12_Y_MODIFY() bfin_read16(DMA12_Y_MODIFY) 1256#define bfin_read_DMA12_Y_MODIFY() bfin_read16(DMA12_Y_MODIFY)
1261#define bfin_write_DMA12_Y_MODIFY(val) bfin_write16(DMA12_Y_MODIFY) 1257#define bfin_write_DMA12_Y_MODIFY(val) bfin_write16(DMA12_Y_MODIFY, val)
1262#define bfin_read_DMA12_CURR_DESC_PTR() bfin_read32(DMA12_CURR_DESC_PTR) 1258#define bfin_read_DMA12_CURR_DESC_PTR() bfin_read32(DMA12_CURR_DESC_PTR)
1263#define bfin_write_DMA12_CURR_DESC_PTR(val) bfin_write32(DMA12_CURR_DESC_PTR) 1259#define bfin_write_DMA12_CURR_DESC_PTR(val) bfin_write32(DMA12_CURR_DESC_PTR, val)
1264#define bfin_read_DMA12_CURR_ADDR() bfin_read32(DMA12_CURR_ADDR) 1260#define bfin_read_DMA12_CURR_ADDR() bfin_read32(DMA12_CURR_ADDR)
1265#define bfin_write_DMA12_CURR_ADDR(val) bfin_write32(DMA12_CURR_ADDR) 1261#define bfin_write_DMA12_CURR_ADDR(val) bfin_write32(DMA12_CURR_ADDR, val)
1266#define bfin_read_DMA12_IRQ_STATUS() bfin_read16(DMA12_IRQ_STATUS) 1262#define bfin_read_DMA12_IRQ_STATUS() bfin_read16(DMA12_IRQ_STATUS)
1267#define bfin_write_DMA12_IRQ_STATUS(val) bfin_write16(DMA12_IRQ_STATUS, val) 1263#define bfin_write_DMA12_IRQ_STATUS(val) bfin_write16(DMA12_IRQ_STATUS, val)
1268#define bfin_read_DMA12_PERIPHERAL_MAP() bfin_read16(DMA12_PERIPHERAL_MAP) 1264#define bfin_read_DMA12_PERIPHERAL_MAP() bfin_read16(DMA12_PERIPHERAL_MAP)
@@ -1275,23 +1271,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1275/* DMA Channel 13 Registers */ 1271/* DMA Channel 13 Registers */
1276 1272
1277#define bfin_read_DMA13_NEXT_DESC_PTR() bfin_read32(DMA13_NEXT_DESC_PTR) 1273#define bfin_read_DMA13_NEXT_DESC_PTR() bfin_read32(DMA13_NEXT_DESC_PTR)
1278#define bfin_write_DMA13_NEXT_DESC_PTR(val) bfin_write32(DMA13_NEXT_DESC_PTR) 1274#define bfin_write_DMA13_NEXT_DESC_PTR(val) bfin_write32(DMA13_NEXT_DESC_PTR, val)
1279#define bfin_read_DMA13_START_ADDR() bfin_read32(DMA13_START_ADDR) 1275#define bfin_read_DMA13_START_ADDR() bfin_read32(DMA13_START_ADDR)
1280#define bfin_write_DMA13_START_ADDR(val) bfin_write32(DMA13_START_ADDR) 1276#define bfin_write_DMA13_START_ADDR(val) bfin_write32(DMA13_START_ADDR, val)
1281#define bfin_read_DMA13_CONFIG() bfin_read16(DMA13_CONFIG) 1277#define bfin_read_DMA13_CONFIG() bfin_read16(DMA13_CONFIG)
1282#define bfin_write_DMA13_CONFIG(val) bfin_write16(DMA13_CONFIG, val) 1278#define bfin_write_DMA13_CONFIG(val) bfin_write16(DMA13_CONFIG, val)
1283#define bfin_read_DMA13_X_COUNT() bfin_read16(DMA13_X_COUNT) 1279#define bfin_read_DMA13_X_COUNT() bfin_read16(DMA13_X_COUNT)
1284#define bfin_write_DMA13_X_COUNT(val) bfin_write16(DMA13_X_COUNT, val) 1280#define bfin_write_DMA13_X_COUNT(val) bfin_write16(DMA13_X_COUNT, val)
1285#define bfin_read_DMA13_X_MODIFY() bfin_read16(DMA13_X_MODIFY) 1281#define bfin_read_DMA13_X_MODIFY() bfin_read16(DMA13_X_MODIFY)
1286#define bfin_write_DMA13_X_MODIFY(val) bfin_write16(DMA13_X_MODIFY) 1282#define bfin_write_DMA13_X_MODIFY(val) bfin_write16(DMA13_X_MODIFY, val)
1287#define bfin_read_DMA13_Y_COUNT() bfin_read16(DMA13_Y_COUNT) 1283#define bfin_read_DMA13_Y_COUNT() bfin_read16(DMA13_Y_COUNT)
1288#define bfin_write_DMA13_Y_COUNT(val) bfin_write16(DMA13_Y_COUNT, val) 1284#define bfin_write_DMA13_Y_COUNT(val) bfin_write16(DMA13_Y_COUNT, val)
1289#define bfin_read_DMA13_Y_MODIFY() bfin_read16(DMA13_Y_MODIFY) 1285#define bfin_read_DMA13_Y_MODIFY() bfin_read16(DMA13_Y_MODIFY)
1290#define bfin_write_DMA13_Y_MODIFY(val) bfin_write16(DMA13_Y_MODIFY) 1286#define bfin_write_DMA13_Y_MODIFY(val) bfin_write16(DMA13_Y_MODIFY, val)
1291#define bfin_read_DMA13_CURR_DESC_PTR() bfin_read32(DMA13_CURR_DESC_PTR) 1287#define bfin_read_DMA13_CURR_DESC_PTR() bfin_read32(DMA13_CURR_DESC_PTR)
1292#define bfin_write_DMA13_CURR_DESC_PTR(val) bfin_write32(DMA13_CURR_DESC_PTR) 1288#define bfin_write_DMA13_CURR_DESC_PTR(val) bfin_write32(DMA13_CURR_DESC_PTR, val)
1293#define bfin_read_DMA13_CURR_ADDR() bfin_read32(DMA13_CURR_ADDR) 1289#define bfin_read_DMA13_CURR_ADDR() bfin_read32(DMA13_CURR_ADDR)
1294#define bfin_write_DMA13_CURR_ADDR(val) bfin_write32(DMA13_CURR_ADDR) 1290#define bfin_write_DMA13_CURR_ADDR(val) bfin_write32(DMA13_CURR_ADDR, val)
1295#define bfin_read_DMA13_IRQ_STATUS() bfin_read16(DMA13_IRQ_STATUS) 1291#define bfin_read_DMA13_IRQ_STATUS() bfin_read16(DMA13_IRQ_STATUS)
1296#define bfin_write_DMA13_IRQ_STATUS(val) bfin_write16(DMA13_IRQ_STATUS, val) 1292#define bfin_write_DMA13_IRQ_STATUS(val) bfin_write16(DMA13_IRQ_STATUS, val)
1297#define bfin_read_DMA13_PERIPHERAL_MAP() bfin_read16(DMA13_PERIPHERAL_MAP) 1293#define bfin_read_DMA13_PERIPHERAL_MAP() bfin_read16(DMA13_PERIPHERAL_MAP)
@@ -1304,23 +1300,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1304/* DMA Channel 14 Registers */ 1300/* DMA Channel 14 Registers */
1305 1301
1306#define bfin_read_DMA14_NEXT_DESC_PTR() bfin_read32(DMA14_NEXT_DESC_PTR) 1302#define bfin_read_DMA14_NEXT_DESC_PTR() bfin_read32(DMA14_NEXT_DESC_PTR)
1307#define bfin_write_DMA14_NEXT_DESC_PTR(val) bfin_write32(DMA14_NEXT_DESC_PTR) 1303#define bfin_write_DMA14_NEXT_DESC_PTR(val) bfin_write32(DMA14_NEXT_DESC_PTR, val)
1308#define bfin_read_DMA14_START_ADDR() bfin_read32(DMA14_START_ADDR) 1304#define bfin_read_DMA14_START_ADDR() bfin_read32(DMA14_START_ADDR)
1309#define bfin_write_DMA14_START_ADDR(val) bfin_write32(DMA14_START_ADDR) 1305#define bfin_write_DMA14_START_ADDR(val) bfin_write32(DMA14_START_ADDR, val)
1310#define bfin_read_DMA14_CONFIG() bfin_read16(DMA14_CONFIG) 1306#define bfin_read_DMA14_CONFIG() bfin_read16(DMA14_CONFIG)
1311#define bfin_write_DMA14_CONFIG(val) bfin_write16(DMA14_CONFIG, val) 1307#define bfin_write_DMA14_CONFIG(val) bfin_write16(DMA14_CONFIG, val)
1312#define bfin_read_DMA14_X_COUNT() bfin_read16(DMA14_X_COUNT) 1308#define bfin_read_DMA14_X_COUNT() bfin_read16(DMA14_X_COUNT)
1313#define bfin_write_DMA14_X_COUNT(val) bfin_write16(DMA14_X_COUNT, val) 1309#define bfin_write_DMA14_X_COUNT(val) bfin_write16(DMA14_X_COUNT, val)
1314#define bfin_read_DMA14_X_MODIFY() bfin_read16(DMA14_X_MODIFY) 1310#define bfin_read_DMA14_X_MODIFY() bfin_read16(DMA14_X_MODIFY)
1315#define bfin_write_DMA14_X_MODIFY(val) bfin_write16(DMA14_X_MODIFY) 1311#define bfin_write_DMA14_X_MODIFY(val) bfin_write16(DMA14_X_MODIFY, val)
1316#define bfin_read_DMA14_Y_COUNT() bfin_read16(DMA14_Y_COUNT) 1312#define bfin_read_DMA14_Y_COUNT() bfin_read16(DMA14_Y_COUNT)
1317#define bfin_write_DMA14_Y_COUNT(val) bfin_write16(DMA14_Y_COUNT, val) 1313#define bfin_write_DMA14_Y_COUNT(val) bfin_write16(DMA14_Y_COUNT, val)
1318#define bfin_read_DMA14_Y_MODIFY() bfin_read16(DMA14_Y_MODIFY) 1314#define bfin_read_DMA14_Y_MODIFY() bfin_read16(DMA14_Y_MODIFY)
1319#define bfin_write_DMA14_Y_MODIFY(val) bfin_write16(DMA14_Y_MODIFY) 1315#define bfin_write_DMA14_Y_MODIFY(val) bfin_write16(DMA14_Y_MODIFY, val)
1320#define bfin_read_DMA14_CURR_DESC_PTR() bfin_read32(DMA14_CURR_DESC_PTR) 1316#define bfin_read_DMA14_CURR_DESC_PTR() bfin_read32(DMA14_CURR_DESC_PTR)
1321#define bfin_write_DMA14_CURR_DESC_PTR(val) bfin_write32(DMA14_CURR_DESC_PTR) 1317#define bfin_write_DMA14_CURR_DESC_PTR(val) bfin_write32(DMA14_CURR_DESC_PTR, val)
1322#define bfin_read_DMA14_CURR_ADDR() bfin_read32(DMA14_CURR_ADDR) 1318#define bfin_read_DMA14_CURR_ADDR() bfin_read32(DMA14_CURR_ADDR)
1323#define bfin_write_DMA14_CURR_ADDR(val) bfin_write32(DMA14_CURR_ADDR) 1319#define bfin_write_DMA14_CURR_ADDR(val) bfin_write32(DMA14_CURR_ADDR, val)
1324#define bfin_read_DMA14_IRQ_STATUS() bfin_read16(DMA14_IRQ_STATUS) 1320#define bfin_read_DMA14_IRQ_STATUS() bfin_read16(DMA14_IRQ_STATUS)
1325#define bfin_write_DMA14_IRQ_STATUS(val) bfin_write16(DMA14_IRQ_STATUS, val) 1321#define bfin_write_DMA14_IRQ_STATUS(val) bfin_write16(DMA14_IRQ_STATUS, val)
1326#define bfin_read_DMA14_PERIPHERAL_MAP() bfin_read16(DMA14_PERIPHERAL_MAP) 1322#define bfin_read_DMA14_PERIPHERAL_MAP() bfin_read16(DMA14_PERIPHERAL_MAP)
@@ -1333,23 +1329,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1333/* DMA Channel 15 Registers */ 1329/* DMA Channel 15 Registers */
1334 1330
1335#define bfin_read_DMA15_NEXT_DESC_PTR() bfin_read32(DMA15_NEXT_DESC_PTR) 1331#define bfin_read_DMA15_NEXT_DESC_PTR() bfin_read32(DMA15_NEXT_DESC_PTR)
1336#define bfin_write_DMA15_NEXT_DESC_PTR(val) bfin_write32(DMA15_NEXT_DESC_PTR) 1332#define bfin_write_DMA15_NEXT_DESC_PTR(val) bfin_write32(DMA15_NEXT_DESC_PTR, val)
1337#define bfin_read_DMA15_START_ADDR() bfin_read32(DMA15_START_ADDR) 1333#define bfin_read_DMA15_START_ADDR() bfin_read32(DMA15_START_ADDR)
1338#define bfin_write_DMA15_START_ADDR(val) bfin_write32(DMA15_START_ADDR) 1334#define bfin_write_DMA15_START_ADDR(val) bfin_write32(DMA15_START_ADDR, val)
1339#define bfin_read_DMA15_CONFIG() bfin_read16(DMA15_CONFIG) 1335#define bfin_read_DMA15_CONFIG() bfin_read16(DMA15_CONFIG)
1340#define bfin_write_DMA15_CONFIG(val) bfin_write16(DMA15_CONFIG, val) 1336#define bfin_write_DMA15_CONFIG(val) bfin_write16(DMA15_CONFIG, val)
1341#define bfin_read_DMA15_X_COUNT() bfin_read16(DMA15_X_COUNT) 1337#define bfin_read_DMA15_X_COUNT() bfin_read16(DMA15_X_COUNT)
1342#define bfin_write_DMA15_X_COUNT(val) bfin_write16(DMA15_X_COUNT, val) 1338#define bfin_write_DMA15_X_COUNT(val) bfin_write16(DMA15_X_COUNT, val)
1343#define bfin_read_DMA15_X_MODIFY() bfin_read16(DMA15_X_MODIFY) 1339#define bfin_read_DMA15_X_MODIFY() bfin_read16(DMA15_X_MODIFY)
1344#define bfin_write_DMA15_X_MODIFY(val) bfin_write16(DMA15_X_MODIFY) 1340#define bfin_write_DMA15_X_MODIFY(val) bfin_write16(DMA15_X_MODIFY, val)
1345#define bfin_read_DMA15_Y_COUNT() bfin_read16(DMA15_Y_COUNT) 1341#define bfin_read_DMA15_Y_COUNT() bfin_read16(DMA15_Y_COUNT)
1346#define bfin_write_DMA15_Y_COUNT(val) bfin_write16(DMA15_Y_COUNT, val) 1342#define bfin_write_DMA15_Y_COUNT(val) bfin_write16(DMA15_Y_COUNT, val)
1347#define bfin_read_DMA15_Y_MODIFY() bfin_read16(DMA15_Y_MODIFY) 1343#define bfin_read_DMA15_Y_MODIFY() bfin_read16(DMA15_Y_MODIFY)
1348#define bfin_write_DMA15_Y_MODIFY(val) bfin_write16(DMA15_Y_MODIFY) 1344#define bfin_write_DMA15_Y_MODIFY(val) bfin_write16(DMA15_Y_MODIFY, val)
1349#define bfin_read_DMA15_CURR_DESC_PTR() bfin_read32(DMA15_CURR_DESC_PTR) 1345#define bfin_read_DMA15_CURR_DESC_PTR() bfin_read32(DMA15_CURR_DESC_PTR)
1350#define bfin_write_DMA15_CURR_DESC_PTR(val) bfin_write32(DMA15_CURR_DESC_PTR) 1346#define bfin_write_DMA15_CURR_DESC_PTR(val) bfin_write32(DMA15_CURR_DESC_PTR, val)
1351#define bfin_read_DMA15_CURR_ADDR() bfin_read32(DMA15_CURR_ADDR) 1347#define bfin_read_DMA15_CURR_ADDR() bfin_read32(DMA15_CURR_ADDR)
1352#define bfin_write_DMA15_CURR_ADDR(val) bfin_write32(DMA15_CURR_ADDR) 1348#define bfin_write_DMA15_CURR_ADDR(val) bfin_write32(DMA15_CURR_ADDR, val)
1353#define bfin_read_DMA15_IRQ_STATUS() bfin_read16(DMA15_IRQ_STATUS) 1349#define bfin_read_DMA15_IRQ_STATUS() bfin_read16(DMA15_IRQ_STATUS)
1354#define bfin_write_DMA15_IRQ_STATUS(val) bfin_write16(DMA15_IRQ_STATUS, val) 1350#define bfin_write_DMA15_IRQ_STATUS(val) bfin_write16(DMA15_IRQ_STATUS, val)
1355#define bfin_read_DMA15_PERIPHERAL_MAP() bfin_read16(DMA15_PERIPHERAL_MAP) 1351#define bfin_read_DMA15_PERIPHERAL_MAP() bfin_read16(DMA15_PERIPHERAL_MAP)
@@ -1362,23 +1358,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1362/* DMA Channel 16 Registers */ 1358/* DMA Channel 16 Registers */
1363 1359
1364#define bfin_read_DMA16_NEXT_DESC_PTR() bfin_read32(DMA16_NEXT_DESC_PTR) 1360#define bfin_read_DMA16_NEXT_DESC_PTR() bfin_read32(DMA16_NEXT_DESC_PTR)
1365#define bfin_write_DMA16_NEXT_DESC_PTR(val) bfin_write32(DMA16_NEXT_DESC_PTR) 1361#define bfin_write_DMA16_NEXT_DESC_PTR(val) bfin_write32(DMA16_NEXT_DESC_PTR, val)
1366#define bfin_read_DMA16_START_ADDR() bfin_read32(DMA16_START_ADDR) 1362#define bfin_read_DMA16_START_ADDR() bfin_read32(DMA16_START_ADDR)
1367#define bfin_write_DMA16_START_ADDR(val) bfin_write32(DMA16_START_ADDR) 1363#define bfin_write_DMA16_START_ADDR(val) bfin_write32(DMA16_START_ADDR, val)
1368#define bfin_read_DMA16_CONFIG() bfin_read16(DMA16_CONFIG) 1364#define bfin_read_DMA16_CONFIG() bfin_read16(DMA16_CONFIG)
1369#define bfin_write_DMA16_CONFIG(val) bfin_write16(DMA16_CONFIG, val) 1365#define bfin_write_DMA16_CONFIG(val) bfin_write16(DMA16_CONFIG, val)
1370#define bfin_read_DMA16_X_COUNT() bfin_read16(DMA16_X_COUNT) 1366#define bfin_read_DMA16_X_COUNT() bfin_read16(DMA16_X_COUNT)
1371#define bfin_write_DMA16_X_COUNT(val) bfin_write16(DMA16_X_COUNT, val) 1367#define bfin_write_DMA16_X_COUNT(val) bfin_write16(DMA16_X_COUNT, val)
1372#define bfin_read_DMA16_X_MODIFY() bfin_read16(DMA16_X_MODIFY) 1368#define bfin_read_DMA16_X_MODIFY() bfin_read16(DMA16_X_MODIFY)
1373#define bfin_write_DMA16_X_MODIFY(val) bfin_write16(DMA16_X_MODIFY) 1369#define bfin_write_DMA16_X_MODIFY(val) bfin_write16(DMA16_X_MODIFY, val)
1374#define bfin_read_DMA16_Y_COUNT() bfin_read16(DMA16_Y_COUNT) 1370#define bfin_read_DMA16_Y_COUNT() bfin_read16(DMA16_Y_COUNT)
1375#define bfin_write_DMA16_Y_COUNT(val) bfin_write16(DMA16_Y_COUNT, val) 1371#define bfin_write_DMA16_Y_COUNT(val) bfin_write16(DMA16_Y_COUNT, val)
1376#define bfin_read_DMA16_Y_MODIFY() bfin_read16(DMA16_Y_MODIFY) 1372#define bfin_read_DMA16_Y_MODIFY() bfin_read16(DMA16_Y_MODIFY)
1377#define bfin_write_DMA16_Y_MODIFY(val) bfin_write16(DMA16_Y_MODIFY) 1373#define bfin_write_DMA16_Y_MODIFY(val) bfin_write16(DMA16_Y_MODIFY, val)
1378#define bfin_read_DMA16_CURR_DESC_PTR() bfin_read32(DMA16_CURR_DESC_PTR) 1374#define bfin_read_DMA16_CURR_DESC_PTR() bfin_read32(DMA16_CURR_DESC_PTR)
1379#define bfin_write_DMA16_CURR_DESC_PTR(val) bfin_write32(DMA16_CURR_DESC_PTR) 1375#define bfin_write_DMA16_CURR_DESC_PTR(val) bfin_write32(DMA16_CURR_DESC_PTR, val)
1380#define bfin_read_DMA16_CURR_ADDR() bfin_read32(DMA16_CURR_ADDR) 1376#define bfin_read_DMA16_CURR_ADDR() bfin_read32(DMA16_CURR_ADDR)
1381#define bfin_write_DMA16_CURR_ADDR(val) bfin_write32(DMA16_CURR_ADDR) 1377#define bfin_write_DMA16_CURR_ADDR(val) bfin_write32(DMA16_CURR_ADDR, val)
1382#define bfin_read_DMA16_IRQ_STATUS() bfin_read16(DMA16_IRQ_STATUS) 1378#define bfin_read_DMA16_IRQ_STATUS() bfin_read16(DMA16_IRQ_STATUS)
1383#define bfin_write_DMA16_IRQ_STATUS(val) bfin_write16(DMA16_IRQ_STATUS, val) 1379#define bfin_write_DMA16_IRQ_STATUS(val) bfin_write16(DMA16_IRQ_STATUS, val)
1384#define bfin_read_DMA16_PERIPHERAL_MAP() bfin_read16(DMA16_PERIPHERAL_MAP) 1380#define bfin_read_DMA16_PERIPHERAL_MAP() bfin_read16(DMA16_PERIPHERAL_MAP)
@@ -1391,23 +1387,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1391/* DMA Channel 17 Registers */ 1387/* DMA Channel 17 Registers */
1392 1388
1393#define bfin_read_DMA17_NEXT_DESC_PTR() bfin_read32(DMA17_NEXT_DESC_PTR) 1389#define bfin_read_DMA17_NEXT_DESC_PTR() bfin_read32(DMA17_NEXT_DESC_PTR)
1394#define bfin_write_DMA17_NEXT_DESC_PTR(val) bfin_write32(DMA17_NEXT_DESC_PTR) 1390#define bfin_write_DMA17_NEXT_DESC_PTR(val) bfin_write32(DMA17_NEXT_DESC_PTR, val)
1395#define bfin_read_DMA17_START_ADDR() bfin_read32(DMA17_START_ADDR) 1391#define bfin_read_DMA17_START_ADDR() bfin_read32(DMA17_START_ADDR)
1396#define bfin_write_DMA17_START_ADDR(val) bfin_write32(DMA17_START_ADDR) 1392#define bfin_write_DMA17_START_ADDR(val) bfin_write32(DMA17_START_ADDR, val)
1397#define bfin_read_DMA17_CONFIG() bfin_read16(DMA17_CONFIG) 1393#define bfin_read_DMA17_CONFIG() bfin_read16(DMA17_CONFIG)
1398#define bfin_write_DMA17_CONFIG(val) bfin_write16(DMA17_CONFIG, val) 1394#define bfin_write_DMA17_CONFIG(val) bfin_write16(DMA17_CONFIG, val)
1399#define bfin_read_DMA17_X_COUNT() bfin_read16(DMA17_X_COUNT) 1395#define bfin_read_DMA17_X_COUNT() bfin_read16(DMA17_X_COUNT)
1400#define bfin_write_DMA17_X_COUNT(val) bfin_write16(DMA17_X_COUNT, val) 1396#define bfin_write_DMA17_X_COUNT(val) bfin_write16(DMA17_X_COUNT, val)
1401#define bfin_read_DMA17_X_MODIFY() bfin_read16(DMA17_X_MODIFY) 1397#define bfin_read_DMA17_X_MODIFY() bfin_read16(DMA17_X_MODIFY)
1402#define bfin_write_DMA17_X_MODIFY(val) bfin_write16(DMA17_X_MODIFY) 1398#define bfin_write_DMA17_X_MODIFY(val) bfin_write16(DMA17_X_MODIFY, val)
1403#define bfin_read_DMA17_Y_COUNT() bfin_read16(DMA17_Y_COUNT) 1399#define bfin_read_DMA17_Y_COUNT() bfin_read16(DMA17_Y_COUNT)
1404#define bfin_write_DMA17_Y_COUNT(val) bfin_write16(DMA17_Y_COUNT, val) 1400#define bfin_write_DMA17_Y_COUNT(val) bfin_write16(DMA17_Y_COUNT, val)
1405#define bfin_read_DMA17_Y_MODIFY() bfin_read16(DMA17_Y_MODIFY) 1401#define bfin_read_DMA17_Y_MODIFY() bfin_read16(DMA17_Y_MODIFY)
1406#define bfin_write_DMA17_Y_MODIFY(val) bfin_write16(DMA17_Y_MODIFY) 1402#define bfin_write_DMA17_Y_MODIFY(val) bfin_write16(DMA17_Y_MODIFY, val)
1407#define bfin_read_DMA17_CURR_DESC_PTR() bfin_read32(DMA17_CURR_DESC_PTR) 1403#define bfin_read_DMA17_CURR_DESC_PTR() bfin_read32(DMA17_CURR_DESC_PTR)
1408#define bfin_write_DMA17_CURR_DESC_PTR(val) bfin_write32(DMA17_CURR_DESC_PTR) 1404#define bfin_write_DMA17_CURR_DESC_PTR(val) bfin_write32(DMA17_CURR_DESC_PTR, val)
1409#define bfin_read_DMA17_CURR_ADDR() bfin_read32(DMA17_CURR_ADDR) 1405#define bfin_read_DMA17_CURR_ADDR() bfin_read32(DMA17_CURR_ADDR)
1410#define bfin_write_DMA17_CURR_ADDR(val) bfin_write32(DMA17_CURR_ADDR) 1406#define bfin_write_DMA17_CURR_ADDR(val) bfin_write32(DMA17_CURR_ADDR, val)
1411#define bfin_read_DMA17_IRQ_STATUS() bfin_read16(DMA17_IRQ_STATUS) 1407#define bfin_read_DMA17_IRQ_STATUS() bfin_read16(DMA17_IRQ_STATUS)
1412#define bfin_write_DMA17_IRQ_STATUS(val) bfin_write16(DMA17_IRQ_STATUS, val) 1408#define bfin_write_DMA17_IRQ_STATUS(val) bfin_write16(DMA17_IRQ_STATUS, val)
1413#define bfin_read_DMA17_PERIPHERAL_MAP() bfin_read16(DMA17_PERIPHERAL_MAP) 1409#define bfin_read_DMA17_PERIPHERAL_MAP() bfin_read16(DMA17_PERIPHERAL_MAP)
@@ -1420,23 +1416,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1420/* DMA Channel 18 Registers */ 1416/* DMA Channel 18 Registers */
1421 1417
1422#define bfin_read_DMA18_NEXT_DESC_PTR() bfin_read32(DMA18_NEXT_DESC_PTR) 1418#define bfin_read_DMA18_NEXT_DESC_PTR() bfin_read32(DMA18_NEXT_DESC_PTR)
1423#define bfin_write_DMA18_NEXT_DESC_PTR(val) bfin_write32(DMA18_NEXT_DESC_PTR) 1419#define bfin_write_DMA18_NEXT_DESC_PTR(val) bfin_write32(DMA18_NEXT_DESC_PTR, val)
1424#define bfin_read_DMA18_START_ADDR() bfin_read32(DMA18_START_ADDR) 1420#define bfin_read_DMA18_START_ADDR() bfin_read32(DMA18_START_ADDR)
1425#define bfin_write_DMA18_START_ADDR(val) bfin_write32(DMA18_START_ADDR) 1421#define bfin_write_DMA18_START_ADDR(val) bfin_write32(DMA18_START_ADDR, val)
1426#define bfin_read_DMA18_CONFIG() bfin_read16(DMA18_CONFIG) 1422#define bfin_read_DMA18_CONFIG() bfin_read16(DMA18_CONFIG)
1427#define bfin_write_DMA18_CONFIG(val) bfin_write16(DMA18_CONFIG, val) 1423#define bfin_write_DMA18_CONFIG(val) bfin_write16(DMA18_CONFIG, val)
1428#define bfin_read_DMA18_X_COUNT() bfin_read16(DMA18_X_COUNT) 1424#define bfin_read_DMA18_X_COUNT() bfin_read16(DMA18_X_COUNT)
1429#define bfin_write_DMA18_X_COUNT(val) bfin_write16(DMA18_X_COUNT, val) 1425#define bfin_write_DMA18_X_COUNT(val) bfin_write16(DMA18_X_COUNT, val)
1430#define bfin_read_DMA18_X_MODIFY() bfin_read16(DMA18_X_MODIFY) 1426#define bfin_read_DMA18_X_MODIFY() bfin_read16(DMA18_X_MODIFY)
1431#define bfin_write_DMA18_X_MODIFY(val) bfin_write16(DMA18_X_MODIFY) 1427#define bfin_write_DMA18_X_MODIFY(val) bfin_write16(DMA18_X_MODIFY, val)
1432#define bfin_read_DMA18_Y_COUNT() bfin_read16(DMA18_Y_COUNT) 1428#define bfin_read_DMA18_Y_COUNT() bfin_read16(DMA18_Y_COUNT)
1433#define bfin_write_DMA18_Y_COUNT(val) bfin_write16(DMA18_Y_COUNT, val) 1429#define bfin_write_DMA18_Y_COUNT(val) bfin_write16(DMA18_Y_COUNT, val)
1434#define bfin_read_DMA18_Y_MODIFY() bfin_read16(DMA18_Y_MODIFY) 1430#define bfin_read_DMA18_Y_MODIFY() bfin_read16(DMA18_Y_MODIFY)
1435#define bfin_write_DMA18_Y_MODIFY(val) bfin_write16(DMA18_Y_MODIFY) 1431#define bfin_write_DMA18_Y_MODIFY(val) bfin_write16(DMA18_Y_MODIFY, val)
1436#define bfin_read_DMA18_CURR_DESC_PTR() bfin_read32(DMA18_CURR_DESC_PTR) 1432#define bfin_read_DMA18_CURR_DESC_PTR() bfin_read32(DMA18_CURR_DESC_PTR)
1437#define bfin_write_DMA18_CURR_DESC_PTR(val) bfin_write32(DMA18_CURR_DESC_PTR) 1433#define bfin_write_DMA18_CURR_DESC_PTR(val) bfin_write32(DMA18_CURR_DESC_PTR, val)
1438#define bfin_read_DMA18_CURR_ADDR() bfin_read32(DMA18_CURR_ADDR) 1434#define bfin_read_DMA18_CURR_ADDR() bfin_read32(DMA18_CURR_ADDR)
1439#define bfin_write_DMA18_CURR_ADDR(val) bfin_write32(DMA18_CURR_ADDR) 1435#define bfin_write_DMA18_CURR_ADDR(val) bfin_write32(DMA18_CURR_ADDR, val)
1440#define bfin_read_DMA18_IRQ_STATUS() bfin_read16(DMA18_IRQ_STATUS) 1436#define bfin_read_DMA18_IRQ_STATUS() bfin_read16(DMA18_IRQ_STATUS)
1441#define bfin_write_DMA18_IRQ_STATUS(val) bfin_write16(DMA18_IRQ_STATUS, val) 1437#define bfin_write_DMA18_IRQ_STATUS(val) bfin_write16(DMA18_IRQ_STATUS, val)
1442#define bfin_read_DMA18_PERIPHERAL_MAP() bfin_read16(DMA18_PERIPHERAL_MAP) 1438#define bfin_read_DMA18_PERIPHERAL_MAP() bfin_read16(DMA18_PERIPHERAL_MAP)
@@ -1449,23 +1445,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1449/* DMA Channel 19 Registers */ 1445/* DMA Channel 19 Registers */
1450 1446
1451#define bfin_read_DMA19_NEXT_DESC_PTR() bfin_read32(DMA19_NEXT_DESC_PTR) 1447#define bfin_read_DMA19_NEXT_DESC_PTR() bfin_read32(DMA19_NEXT_DESC_PTR)
1452#define bfin_write_DMA19_NEXT_DESC_PTR(val) bfin_write32(DMA19_NEXT_DESC_PTR) 1448#define bfin_write_DMA19_NEXT_DESC_PTR(val) bfin_write32(DMA19_NEXT_DESC_PTR, val)
1453#define bfin_read_DMA19_START_ADDR() bfin_read32(DMA19_START_ADDR) 1449#define bfin_read_DMA19_START_ADDR() bfin_read32(DMA19_START_ADDR)
1454#define bfin_write_DMA19_START_ADDR(val) bfin_write32(DMA19_START_ADDR) 1450#define bfin_write_DMA19_START_ADDR(val) bfin_write32(DMA19_START_ADDR, val)
1455#define bfin_read_DMA19_CONFIG() bfin_read16(DMA19_CONFIG) 1451#define bfin_read_DMA19_CONFIG() bfin_read16(DMA19_CONFIG)
1456#define bfin_write_DMA19_CONFIG(val) bfin_write16(DMA19_CONFIG, val) 1452#define bfin_write_DMA19_CONFIG(val) bfin_write16(DMA19_CONFIG, val)
1457#define bfin_read_DMA19_X_COUNT() bfin_read16(DMA19_X_COUNT) 1453#define bfin_read_DMA19_X_COUNT() bfin_read16(DMA19_X_COUNT)
1458#define bfin_write_DMA19_X_COUNT(val) bfin_write16(DMA19_X_COUNT, val) 1454#define bfin_write_DMA19_X_COUNT(val) bfin_write16(DMA19_X_COUNT, val)
1459#define bfin_read_DMA19_X_MODIFY() bfin_read16(DMA19_X_MODIFY) 1455#define bfin_read_DMA19_X_MODIFY() bfin_read16(DMA19_X_MODIFY)
1460#define bfin_write_DMA19_X_MODIFY(val) bfin_write16(DMA19_X_MODIFY) 1456#define bfin_write_DMA19_X_MODIFY(val) bfin_write16(DMA19_X_MODIFY, val)
1461#define bfin_read_DMA19_Y_COUNT() bfin_read16(DMA19_Y_COUNT) 1457#define bfin_read_DMA19_Y_COUNT() bfin_read16(DMA19_Y_COUNT)
1462#define bfin_write_DMA19_Y_COUNT(val) bfin_write16(DMA19_Y_COUNT, val) 1458#define bfin_write_DMA19_Y_COUNT(val) bfin_write16(DMA19_Y_COUNT, val)
1463#define bfin_read_DMA19_Y_MODIFY() bfin_read16(DMA19_Y_MODIFY) 1459#define bfin_read_DMA19_Y_MODIFY() bfin_read16(DMA19_Y_MODIFY)
1464#define bfin_write_DMA19_Y_MODIFY(val) bfin_write16(DMA19_Y_MODIFY) 1460#define bfin_write_DMA19_Y_MODIFY(val) bfin_write16(DMA19_Y_MODIFY, val)
1465#define bfin_read_DMA19_CURR_DESC_PTR() bfin_read32(DMA19_CURR_DESC_PTR) 1461#define bfin_read_DMA19_CURR_DESC_PTR() bfin_read32(DMA19_CURR_DESC_PTR)
1466#define bfin_write_DMA19_CURR_DESC_PTR(val) bfin_write32(DMA19_CURR_DESC_PTR) 1462#define bfin_write_DMA19_CURR_DESC_PTR(val) bfin_write32(DMA19_CURR_DESC_PTR, val)
1467#define bfin_read_DMA19_CURR_ADDR() bfin_read32(DMA19_CURR_ADDR) 1463#define bfin_read_DMA19_CURR_ADDR() bfin_read32(DMA19_CURR_ADDR)
1468#define bfin_write_DMA19_CURR_ADDR(val) bfin_write32(DMA19_CURR_ADDR) 1464#define bfin_write_DMA19_CURR_ADDR(val) bfin_write32(DMA19_CURR_ADDR, val)
1469#define bfin_read_DMA19_IRQ_STATUS() bfin_read16(DMA19_IRQ_STATUS) 1465#define bfin_read_DMA19_IRQ_STATUS() bfin_read16(DMA19_IRQ_STATUS)
1470#define bfin_write_DMA19_IRQ_STATUS(val) bfin_write16(DMA19_IRQ_STATUS, val) 1466#define bfin_write_DMA19_IRQ_STATUS(val) bfin_write16(DMA19_IRQ_STATUS, val)
1471#define bfin_read_DMA19_PERIPHERAL_MAP() bfin_read16(DMA19_PERIPHERAL_MAP) 1467#define bfin_read_DMA19_PERIPHERAL_MAP() bfin_read16(DMA19_PERIPHERAL_MAP)
@@ -1478,23 +1474,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1478/* DMA Channel 20 Registers */ 1474/* DMA Channel 20 Registers */
1479 1475
1480#define bfin_read_DMA20_NEXT_DESC_PTR() bfin_read32(DMA20_NEXT_DESC_PTR) 1476#define bfin_read_DMA20_NEXT_DESC_PTR() bfin_read32(DMA20_NEXT_DESC_PTR)
1481#define bfin_write_DMA20_NEXT_DESC_PTR(val) bfin_write32(DMA20_NEXT_DESC_PTR) 1477#define bfin_write_DMA20_NEXT_DESC_PTR(val) bfin_write32(DMA20_NEXT_DESC_PTR, val)
1482#define bfin_read_DMA20_START_ADDR() bfin_read32(DMA20_START_ADDR) 1478#define bfin_read_DMA20_START_ADDR() bfin_read32(DMA20_START_ADDR)
1483#define bfin_write_DMA20_START_ADDR(val) bfin_write32(DMA20_START_ADDR) 1479#define bfin_write_DMA20_START_ADDR(val) bfin_write32(DMA20_START_ADDR, val)
1484#define bfin_read_DMA20_CONFIG() bfin_read16(DMA20_CONFIG) 1480#define bfin_read_DMA20_CONFIG() bfin_read16(DMA20_CONFIG)
1485#define bfin_write_DMA20_CONFIG(val) bfin_write16(DMA20_CONFIG, val) 1481#define bfin_write_DMA20_CONFIG(val) bfin_write16(DMA20_CONFIG, val)
1486#define bfin_read_DMA20_X_COUNT() bfin_read16(DMA20_X_COUNT) 1482#define bfin_read_DMA20_X_COUNT() bfin_read16(DMA20_X_COUNT)
1487#define bfin_write_DMA20_X_COUNT(val) bfin_write16(DMA20_X_COUNT, val) 1483#define bfin_write_DMA20_X_COUNT(val) bfin_write16(DMA20_X_COUNT, val)
1488#define bfin_read_DMA20_X_MODIFY() bfin_read16(DMA20_X_MODIFY) 1484#define bfin_read_DMA20_X_MODIFY() bfin_read16(DMA20_X_MODIFY)
1489#define bfin_write_DMA20_X_MODIFY(val) bfin_write16(DMA20_X_MODIFY) 1485#define bfin_write_DMA20_X_MODIFY(val) bfin_write16(DMA20_X_MODIFY, val)
1490#define bfin_read_DMA20_Y_COUNT() bfin_read16(DMA20_Y_COUNT) 1486#define bfin_read_DMA20_Y_COUNT() bfin_read16(DMA20_Y_COUNT)
1491#define bfin_write_DMA20_Y_COUNT(val) bfin_write16(DMA20_Y_COUNT, val) 1487#define bfin_write_DMA20_Y_COUNT(val) bfin_write16(DMA20_Y_COUNT, val)
1492#define bfin_read_DMA20_Y_MODIFY() bfin_read16(DMA20_Y_MODIFY) 1488#define bfin_read_DMA20_Y_MODIFY() bfin_read16(DMA20_Y_MODIFY)
1493#define bfin_write_DMA20_Y_MODIFY(val) bfin_write16(DMA20_Y_MODIFY) 1489#define bfin_write_DMA20_Y_MODIFY(val) bfin_write16(DMA20_Y_MODIFY, val)
1494#define bfin_read_DMA20_CURR_DESC_PTR() bfin_read32(DMA20_CURR_DESC_PTR) 1490#define bfin_read_DMA20_CURR_DESC_PTR() bfin_read32(DMA20_CURR_DESC_PTR)
1495#define bfin_write_DMA20_CURR_DESC_PTR(val) bfin_write32(DMA20_CURR_DESC_PTR) 1491#define bfin_write_DMA20_CURR_DESC_PTR(val) bfin_write32(DMA20_CURR_DESC_PTR, val)
1496#define bfin_read_DMA20_CURR_ADDR() bfin_read32(DMA20_CURR_ADDR) 1492#define bfin_read_DMA20_CURR_ADDR() bfin_read32(DMA20_CURR_ADDR)
1497#define bfin_write_DMA20_CURR_ADDR(val) bfin_write32(DMA20_CURR_ADDR) 1493#define bfin_write_DMA20_CURR_ADDR(val) bfin_write32(DMA20_CURR_ADDR, val)
1498#define bfin_read_DMA20_IRQ_STATUS() bfin_read16(DMA20_IRQ_STATUS) 1494#define bfin_read_DMA20_IRQ_STATUS() bfin_read16(DMA20_IRQ_STATUS)
1499#define bfin_write_DMA20_IRQ_STATUS(val) bfin_write16(DMA20_IRQ_STATUS, val) 1495#define bfin_write_DMA20_IRQ_STATUS(val) bfin_write16(DMA20_IRQ_STATUS, val)
1500#define bfin_read_DMA20_PERIPHERAL_MAP() bfin_read16(DMA20_PERIPHERAL_MAP) 1496#define bfin_read_DMA20_PERIPHERAL_MAP() bfin_read16(DMA20_PERIPHERAL_MAP)
@@ -1507,23 +1503,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1507/* DMA Channel 21 Registers */ 1503/* DMA Channel 21 Registers */
1508 1504
1509#define bfin_read_DMA21_NEXT_DESC_PTR() bfin_read32(DMA21_NEXT_DESC_PTR) 1505#define bfin_read_DMA21_NEXT_DESC_PTR() bfin_read32(DMA21_NEXT_DESC_PTR)
1510#define bfin_write_DMA21_NEXT_DESC_PTR(val) bfin_write32(DMA21_NEXT_DESC_PTR) 1506#define bfin_write_DMA21_NEXT_DESC_PTR(val) bfin_write32(DMA21_NEXT_DESC_PTR, val)
1511#define bfin_read_DMA21_START_ADDR() bfin_read32(DMA21_START_ADDR) 1507#define bfin_read_DMA21_START_ADDR() bfin_read32(DMA21_START_ADDR)
1512#define bfin_write_DMA21_START_ADDR(val) bfin_write32(DMA21_START_ADDR) 1508#define bfin_write_DMA21_START_ADDR(val) bfin_write32(DMA21_START_ADDR, val)
1513#define bfin_read_DMA21_CONFIG() bfin_read16(DMA21_CONFIG) 1509#define bfin_read_DMA21_CONFIG() bfin_read16(DMA21_CONFIG)
1514#define bfin_write_DMA21_CONFIG(val) bfin_write16(DMA21_CONFIG, val) 1510#define bfin_write_DMA21_CONFIG(val) bfin_write16(DMA21_CONFIG, val)
1515#define bfin_read_DMA21_X_COUNT() bfin_read16(DMA21_X_COUNT) 1511#define bfin_read_DMA21_X_COUNT() bfin_read16(DMA21_X_COUNT)
1516#define bfin_write_DMA21_X_COUNT(val) bfin_write16(DMA21_X_COUNT, val) 1512#define bfin_write_DMA21_X_COUNT(val) bfin_write16(DMA21_X_COUNT, val)
1517#define bfin_read_DMA21_X_MODIFY() bfin_read16(DMA21_X_MODIFY) 1513#define bfin_read_DMA21_X_MODIFY() bfin_read16(DMA21_X_MODIFY)
1518#define bfin_write_DMA21_X_MODIFY(val) bfin_write16(DMA21_X_MODIFY) 1514#define bfin_write_DMA21_X_MODIFY(val) bfin_write16(DMA21_X_MODIFY, val)
1519#define bfin_read_DMA21_Y_COUNT() bfin_read16(DMA21_Y_COUNT) 1515#define bfin_read_DMA21_Y_COUNT() bfin_read16(DMA21_Y_COUNT)
1520#define bfin_write_DMA21_Y_COUNT(val) bfin_write16(DMA21_Y_COUNT, val) 1516#define bfin_write_DMA21_Y_COUNT(val) bfin_write16(DMA21_Y_COUNT, val)
1521#define bfin_read_DMA21_Y_MODIFY() bfin_read16(DMA21_Y_MODIFY) 1517#define bfin_read_DMA21_Y_MODIFY() bfin_read16(DMA21_Y_MODIFY)
1522#define bfin_write_DMA21_Y_MODIFY(val) bfin_write16(DMA21_Y_MODIFY) 1518#define bfin_write_DMA21_Y_MODIFY(val) bfin_write16(DMA21_Y_MODIFY, val)
1523#define bfin_read_DMA21_CURR_DESC_PTR() bfin_read32(DMA21_CURR_DESC_PTR) 1519#define bfin_read_DMA21_CURR_DESC_PTR() bfin_read32(DMA21_CURR_DESC_PTR)
1524#define bfin_write_DMA21_CURR_DESC_PTR(val) bfin_write32(DMA21_CURR_DESC_PTR) 1520#define bfin_write_DMA21_CURR_DESC_PTR(val) bfin_write32(DMA21_CURR_DESC_PTR, val)
1525#define bfin_read_DMA21_CURR_ADDR() bfin_read32(DMA21_CURR_ADDR) 1521#define bfin_read_DMA21_CURR_ADDR() bfin_read32(DMA21_CURR_ADDR)
1526#define bfin_write_DMA21_CURR_ADDR(val) bfin_write32(DMA21_CURR_ADDR) 1522#define bfin_write_DMA21_CURR_ADDR(val) bfin_write32(DMA21_CURR_ADDR, val)
1527#define bfin_read_DMA21_IRQ_STATUS() bfin_read16(DMA21_IRQ_STATUS) 1523#define bfin_read_DMA21_IRQ_STATUS() bfin_read16(DMA21_IRQ_STATUS)
1528#define bfin_write_DMA21_IRQ_STATUS(val) bfin_write16(DMA21_IRQ_STATUS, val) 1524#define bfin_write_DMA21_IRQ_STATUS(val) bfin_write16(DMA21_IRQ_STATUS, val)
1529#define bfin_read_DMA21_PERIPHERAL_MAP() bfin_read16(DMA21_PERIPHERAL_MAP) 1525#define bfin_read_DMA21_PERIPHERAL_MAP() bfin_read16(DMA21_PERIPHERAL_MAP)
@@ -1536,23 +1532,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1536/* DMA Channel 22 Registers */ 1532/* DMA Channel 22 Registers */
1537 1533
1538#define bfin_read_DMA22_NEXT_DESC_PTR() bfin_read32(DMA22_NEXT_DESC_PTR) 1534#define bfin_read_DMA22_NEXT_DESC_PTR() bfin_read32(DMA22_NEXT_DESC_PTR)
1539#define bfin_write_DMA22_NEXT_DESC_PTR(val) bfin_write32(DMA22_NEXT_DESC_PTR) 1535#define bfin_write_DMA22_NEXT_DESC_PTR(val) bfin_write32(DMA22_NEXT_DESC_PTR, val)
1540#define bfin_read_DMA22_START_ADDR() bfin_read32(DMA22_START_ADDR) 1536#define bfin_read_DMA22_START_ADDR() bfin_read32(DMA22_START_ADDR)
1541#define bfin_write_DMA22_START_ADDR(val) bfin_write32(DMA22_START_ADDR) 1537#define bfin_write_DMA22_START_ADDR(val) bfin_write32(DMA22_START_ADDR, val)
1542#define bfin_read_DMA22_CONFIG() bfin_read16(DMA22_CONFIG) 1538#define bfin_read_DMA22_CONFIG() bfin_read16(DMA22_CONFIG)
1543#define bfin_write_DMA22_CONFIG(val) bfin_write16(DMA22_CONFIG, val) 1539#define bfin_write_DMA22_CONFIG(val) bfin_write16(DMA22_CONFIG, val)
1544#define bfin_read_DMA22_X_COUNT() bfin_read16(DMA22_X_COUNT) 1540#define bfin_read_DMA22_X_COUNT() bfin_read16(DMA22_X_COUNT)
1545#define bfin_write_DMA22_X_COUNT(val) bfin_write16(DMA22_X_COUNT, val) 1541#define bfin_write_DMA22_X_COUNT(val) bfin_write16(DMA22_X_COUNT, val)
1546#define bfin_read_DMA22_X_MODIFY() bfin_read16(DMA22_X_MODIFY) 1542#define bfin_read_DMA22_X_MODIFY() bfin_read16(DMA22_X_MODIFY)
1547#define bfin_write_DMA22_X_MODIFY(val) bfin_write16(DMA22_X_MODIFY) 1543#define bfin_write_DMA22_X_MODIFY(val) bfin_write16(DMA22_X_MODIFY, val)
1548#define bfin_read_DMA22_Y_COUNT() bfin_read16(DMA22_Y_COUNT) 1544#define bfin_read_DMA22_Y_COUNT() bfin_read16(DMA22_Y_COUNT)
1549#define bfin_write_DMA22_Y_COUNT(val) bfin_write16(DMA22_Y_COUNT, val) 1545#define bfin_write_DMA22_Y_COUNT(val) bfin_write16(DMA22_Y_COUNT, val)
1550#define bfin_read_DMA22_Y_MODIFY() bfin_read16(DMA22_Y_MODIFY) 1546#define bfin_read_DMA22_Y_MODIFY() bfin_read16(DMA22_Y_MODIFY)
1551#define bfin_write_DMA22_Y_MODIFY(val) bfin_write16(DMA22_Y_MODIFY) 1547#define bfin_write_DMA22_Y_MODIFY(val) bfin_write16(DMA22_Y_MODIFY, val)
1552#define bfin_read_DMA22_CURR_DESC_PTR() bfin_read32(DMA22_CURR_DESC_PTR) 1548#define bfin_read_DMA22_CURR_DESC_PTR() bfin_read32(DMA22_CURR_DESC_PTR)
1553#define bfin_write_DMA22_CURR_DESC_PTR(val) bfin_write32(DMA22_CURR_DESC_PTR) 1549#define bfin_write_DMA22_CURR_DESC_PTR(val) bfin_write32(DMA22_CURR_DESC_PTR, val)
1554#define bfin_read_DMA22_CURR_ADDR() bfin_read32(DMA22_CURR_ADDR) 1550#define bfin_read_DMA22_CURR_ADDR() bfin_read32(DMA22_CURR_ADDR)
1555#define bfin_write_DMA22_CURR_ADDR(val) bfin_write32(DMA22_CURR_ADDR) 1551#define bfin_write_DMA22_CURR_ADDR(val) bfin_write32(DMA22_CURR_ADDR, val)
1556#define bfin_read_DMA22_IRQ_STATUS() bfin_read16(DMA22_IRQ_STATUS) 1552#define bfin_read_DMA22_IRQ_STATUS() bfin_read16(DMA22_IRQ_STATUS)
1557#define bfin_write_DMA22_IRQ_STATUS(val) bfin_write16(DMA22_IRQ_STATUS, val) 1553#define bfin_write_DMA22_IRQ_STATUS(val) bfin_write16(DMA22_IRQ_STATUS, val)
1558#define bfin_read_DMA22_PERIPHERAL_MAP() bfin_read16(DMA22_PERIPHERAL_MAP) 1554#define bfin_read_DMA22_PERIPHERAL_MAP() bfin_read16(DMA22_PERIPHERAL_MAP)
@@ -1565,23 +1561,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1565/* DMA Channel 23 Registers */ 1561/* DMA Channel 23 Registers */
1566 1562
1567#define bfin_read_DMA23_NEXT_DESC_PTR() bfin_read32(DMA23_NEXT_DESC_PTR) 1563#define bfin_read_DMA23_NEXT_DESC_PTR() bfin_read32(DMA23_NEXT_DESC_PTR)
1568#define bfin_write_DMA23_NEXT_DESC_PTR(val) bfin_write32(DMA23_NEXT_DESC_PTR) 1564#define bfin_write_DMA23_NEXT_DESC_PTR(val) bfin_write32(DMA23_NEXT_DESC_PTR, val)
1569#define bfin_read_DMA23_START_ADDR() bfin_read32(DMA23_START_ADDR) 1565#define bfin_read_DMA23_START_ADDR() bfin_read32(DMA23_START_ADDR)
1570#define bfin_write_DMA23_START_ADDR(val) bfin_write32(DMA23_START_ADDR) 1566#define bfin_write_DMA23_START_ADDR(val) bfin_write32(DMA23_START_ADDR, val)
1571#define bfin_read_DMA23_CONFIG() bfin_read16(DMA23_CONFIG) 1567#define bfin_read_DMA23_CONFIG() bfin_read16(DMA23_CONFIG)
1572#define bfin_write_DMA23_CONFIG(val) bfin_write16(DMA23_CONFIG, val) 1568#define bfin_write_DMA23_CONFIG(val) bfin_write16(DMA23_CONFIG, val)
1573#define bfin_read_DMA23_X_COUNT() bfin_read16(DMA23_X_COUNT) 1569#define bfin_read_DMA23_X_COUNT() bfin_read16(DMA23_X_COUNT)
1574#define bfin_write_DMA23_X_COUNT(val) bfin_write16(DMA23_X_COUNT, val) 1570#define bfin_write_DMA23_X_COUNT(val) bfin_write16(DMA23_X_COUNT, val)
1575#define bfin_read_DMA23_X_MODIFY() bfin_read16(DMA23_X_MODIFY) 1571#define bfin_read_DMA23_X_MODIFY() bfin_read16(DMA23_X_MODIFY)
1576#define bfin_write_DMA23_X_MODIFY(val) bfin_write16(DMA23_X_MODIFY) 1572#define bfin_write_DMA23_X_MODIFY(val) bfin_write16(DMA23_X_MODIFY, val)
1577#define bfin_read_DMA23_Y_COUNT() bfin_read16(DMA23_Y_COUNT) 1573#define bfin_read_DMA23_Y_COUNT() bfin_read16(DMA23_Y_COUNT)
1578#define bfin_write_DMA23_Y_COUNT(val) bfin_write16(DMA23_Y_COUNT, val) 1574#define bfin_write_DMA23_Y_COUNT(val) bfin_write16(DMA23_Y_COUNT, val)
1579#define bfin_read_DMA23_Y_MODIFY() bfin_read16(DMA23_Y_MODIFY) 1575#define bfin_read_DMA23_Y_MODIFY() bfin_read16(DMA23_Y_MODIFY)
1580#define bfin_write_DMA23_Y_MODIFY(val) bfin_write16(DMA23_Y_MODIFY) 1576#define bfin_write_DMA23_Y_MODIFY(val) bfin_write16(DMA23_Y_MODIFY, val)
1581#define bfin_read_DMA23_CURR_DESC_PTR() bfin_read32(DMA23_CURR_DESC_PTR) 1577#define bfin_read_DMA23_CURR_DESC_PTR() bfin_read32(DMA23_CURR_DESC_PTR)
1582#define bfin_write_DMA23_CURR_DESC_PTR(val) bfin_write32(DMA23_CURR_DESC_PTR) 1578#define bfin_write_DMA23_CURR_DESC_PTR(val) bfin_write32(DMA23_CURR_DESC_PTR, val)
1583#define bfin_read_DMA23_CURR_ADDR() bfin_read32(DMA23_CURR_ADDR) 1579#define bfin_read_DMA23_CURR_ADDR() bfin_read32(DMA23_CURR_ADDR)
1584#define bfin_write_DMA23_CURR_ADDR(val) bfin_write32(DMA23_CURR_ADDR) 1580#define bfin_write_DMA23_CURR_ADDR(val) bfin_write32(DMA23_CURR_ADDR, val)
1585#define bfin_read_DMA23_IRQ_STATUS() bfin_read16(DMA23_IRQ_STATUS) 1581#define bfin_read_DMA23_IRQ_STATUS() bfin_read16(DMA23_IRQ_STATUS)
1586#define bfin_write_DMA23_IRQ_STATUS(val) bfin_write16(DMA23_IRQ_STATUS, val) 1582#define bfin_write_DMA23_IRQ_STATUS(val) bfin_write16(DMA23_IRQ_STATUS, val)
1587#define bfin_read_DMA23_PERIPHERAL_MAP() bfin_read16(DMA23_PERIPHERAL_MAP) 1583#define bfin_read_DMA23_PERIPHERAL_MAP() bfin_read16(DMA23_PERIPHERAL_MAP)
@@ -1594,23 +1590,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1594/* MDMA Stream 2 Registers */ 1590/* MDMA Stream 2 Registers */
1595 1591
1596#define bfin_read_MDMA_D2_NEXT_DESC_PTR() bfin_read32(MDMA_D2_NEXT_DESC_PTR) 1592#define bfin_read_MDMA_D2_NEXT_DESC_PTR() bfin_read32(MDMA_D2_NEXT_DESC_PTR)
1597#define bfin_write_MDMA_D2_NEXT_DESC_PTR(val) bfin_write32(MDMA_D2_NEXT_DESC_PTR) 1593#define bfin_write_MDMA_D2_NEXT_DESC_PTR(val) bfin_write32(MDMA_D2_NEXT_DESC_PTR, val)
1598#define bfin_read_MDMA_D2_START_ADDR() bfin_read32(MDMA_D2_START_ADDR) 1594#define bfin_read_MDMA_D2_START_ADDR() bfin_read32(MDMA_D2_START_ADDR)
1599#define bfin_write_MDMA_D2_START_ADDR(val) bfin_write32(MDMA_D2_START_ADDR) 1595#define bfin_write_MDMA_D2_START_ADDR(val) bfin_write32(MDMA_D2_START_ADDR, val)
1600#define bfin_read_MDMA_D2_CONFIG() bfin_read16(MDMA_D2_CONFIG) 1596#define bfin_read_MDMA_D2_CONFIG() bfin_read16(MDMA_D2_CONFIG)
1601#define bfin_write_MDMA_D2_CONFIG(val) bfin_write16(MDMA_D2_CONFIG, val) 1597#define bfin_write_MDMA_D2_CONFIG(val) bfin_write16(MDMA_D2_CONFIG, val)
1602#define bfin_read_MDMA_D2_X_COUNT() bfin_read16(MDMA_D2_X_COUNT) 1598#define bfin_read_MDMA_D2_X_COUNT() bfin_read16(MDMA_D2_X_COUNT)
1603#define bfin_write_MDMA_D2_X_COUNT(val) bfin_write16(MDMA_D2_X_COUNT, val) 1599#define bfin_write_MDMA_D2_X_COUNT(val) bfin_write16(MDMA_D2_X_COUNT, val)
1604#define bfin_read_MDMA_D2_X_MODIFY() bfin_read16(MDMA_D2_X_MODIFY) 1600#define bfin_read_MDMA_D2_X_MODIFY() bfin_read16(MDMA_D2_X_MODIFY)
1605#define bfin_write_MDMA_D2_X_MODIFY(val) bfin_write16(MDMA_D2_X_MODIFY) 1601#define bfin_write_MDMA_D2_X_MODIFY(val) bfin_write16(MDMA_D2_X_MODIFY, val)
1606#define bfin_read_MDMA_D2_Y_COUNT() bfin_read16(MDMA_D2_Y_COUNT) 1602#define bfin_read_MDMA_D2_Y_COUNT() bfin_read16(MDMA_D2_Y_COUNT)
1607#define bfin_write_MDMA_D2_Y_COUNT(val) bfin_write16(MDMA_D2_Y_COUNT, val) 1603#define bfin_write_MDMA_D2_Y_COUNT(val) bfin_write16(MDMA_D2_Y_COUNT, val)
1608#define bfin_read_MDMA_D2_Y_MODIFY() bfin_read16(MDMA_D2_Y_MODIFY) 1604#define bfin_read_MDMA_D2_Y_MODIFY() bfin_read16(MDMA_D2_Y_MODIFY)
1609#define bfin_write_MDMA_D2_Y_MODIFY(val) bfin_write16(MDMA_D2_Y_MODIFY) 1605#define bfin_write_MDMA_D2_Y_MODIFY(val) bfin_write16(MDMA_D2_Y_MODIFY, val)
1610#define bfin_read_MDMA_D2_CURR_DESC_PTR() bfin_read32(MDMA_D2_CURR_DESC_PTR) 1606#define bfin_read_MDMA_D2_CURR_DESC_PTR() bfin_read32(MDMA_D2_CURR_DESC_PTR)
1611#define bfin_write_MDMA_D2_CURR_DESC_PTR(val) bfin_write32(MDMA_D2_CURR_DESC_PTR) 1607#define bfin_write_MDMA_D2_CURR_DESC_PTR(val) bfin_write32(MDMA_D2_CURR_DESC_PTR, val)
1612#define bfin_read_MDMA_D2_CURR_ADDR() bfin_read32(MDMA_D2_CURR_ADDR) 1608#define bfin_read_MDMA_D2_CURR_ADDR() bfin_read32(MDMA_D2_CURR_ADDR)
1613#define bfin_write_MDMA_D2_CURR_ADDR(val) bfin_write32(MDMA_D2_CURR_ADDR) 1609#define bfin_write_MDMA_D2_CURR_ADDR(val) bfin_write32(MDMA_D2_CURR_ADDR, val)
1614#define bfin_read_MDMA_D2_IRQ_STATUS() bfin_read16(MDMA_D2_IRQ_STATUS) 1610#define bfin_read_MDMA_D2_IRQ_STATUS() bfin_read16(MDMA_D2_IRQ_STATUS)
1615#define bfin_write_MDMA_D2_IRQ_STATUS(val) bfin_write16(MDMA_D2_IRQ_STATUS, val) 1611#define bfin_write_MDMA_D2_IRQ_STATUS(val) bfin_write16(MDMA_D2_IRQ_STATUS, val)
1616#define bfin_read_MDMA_D2_PERIPHERAL_MAP() bfin_read16(MDMA_D2_PERIPHERAL_MAP) 1612#define bfin_read_MDMA_D2_PERIPHERAL_MAP() bfin_read16(MDMA_D2_PERIPHERAL_MAP)
@@ -1620,23 +1616,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1620#define bfin_read_MDMA_D2_CURR_Y_COUNT() bfin_read16(MDMA_D2_CURR_Y_COUNT) 1616#define bfin_read_MDMA_D2_CURR_Y_COUNT() bfin_read16(MDMA_D2_CURR_Y_COUNT)
1621#define bfin_write_MDMA_D2_CURR_Y_COUNT(val) bfin_write16(MDMA_D2_CURR_Y_COUNT, val) 1617#define bfin_write_MDMA_D2_CURR_Y_COUNT(val) bfin_write16(MDMA_D2_CURR_Y_COUNT, val)
1622#define bfin_read_MDMA_S2_NEXT_DESC_PTR() bfin_read32(MDMA_S2_NEXT_DESC_PTR) 1618#define bfin_read_MDMA_S2_NEXT_DESC_PTR() bfin_read32(MDMA_S2_NEXT_DESC_PTR)
1623#define bfin_write_MDMA_S2_NEXT_DESC_PTR(val) bfin_write32(MDMA_S2_NEXT_DESC_PTR) 1619#define bfin_write_MDMA_S2_NEXT_DESC_PTR(val) bfin_write32(MDMA_S2_NEXT_DESC_PTR, val)
1624#define bfin_read_MDMA_S2_START_ADDR() bfin_read32(MDMA_S2_START_ADDR) 1620#define bfin_read_MDMA_S2_START_ADDR() bfin_read32(MDMA_S2_START_ADDR)
1625#define bfin_write_MDMA_S2_START_ADDR(val) bfin_write32(MDMA_S2_START_ADDR) 1621#define bfin_write_MDMA_S2_START_ADDR(val) bfin_write32(MDMA_S2_START_ADDR, val)
1626#define bfin_read_MDMA_S2_CONFIG() bfin_read16(MDMA_S2_CONFIG) 1622#define bfin_read_MDMA_S2_CONFIG() bfin_read16(MDMA_S2_CONFIG)
1627#define bfin_write_MDMA_S2_CONFIG(val) bfin_write16(MDMA_S2_CONFIG, val) 1623#define bfin_write_MDMA_S2_CONFIG(val) bfin_write16(MDMA_S2_CONFIG, val)
1628#define bfin_read_MDMA_S2_X_COUNT() bfin_read16(MDMA_S2_X_COUNT) 1624#define bfin_read_MDMA_S2_X_COUNT() bfin_read16(MDMA_S2_X_COUNT)
1629#define bfin_write_MDMA_S2_X_COUNT(val) bfin_write16(MDMA_S2_X_COUNT, val) 1625#define bfin_write_MDMA_S2_X_COUNT(val) bfin_write16(MDMA_S2_X_COUNT, val)
1630#define bfin_read_MDMA_S2_X_MODIFY() bfin_read16(MDMA_S2_X_MODIFY) 1626#define bfin_read_MDMA_S2_X_MODIFY() bfin_read16(MDMA_S2_X_MODIFY)
1631#define bfin_write_MDMA_S2_X_MODIFY(val) bfin_write16(MDMA_S2_X_MODIFY) 1627#define bfin_write_MDMA_S2_X_MODIFY(val) bfin_write16(MDMA_S2_X_MODIFY, val)
1632#define bfin_read_MDMA_S2_Y_COUNT() bfin_read16(MDMA_S2_Y_COUNT) 1628#define bfin_read_MDMA_S2_Y_COUNT() bfin_read16(MDMA_S2_Y_COUNT)
1633#define bfin_write_MDMA_S2_Y_COUNT(val) bfin_write16(MDMA_S2_Y_COUNT, val) 1629#define bfin_write_MDMA_S2_Y_COUNT(val) bfin_write16(MDMA_S2_Y_COUNT, val)
1634#define bfin_read_MDMA_S2_Y_MODIFY() bfin_read16(MDMA_S2_Y_MODIFY) 1630#define bfin_read_MDMA_S2_Y_MODIFY() bfin_read16(MDMA_S2_Y_MODIFY)
1635#define bfin_write_MDMA_S2_Y_MODIFY(val) bfin_write16(MDMA_S2_Y_MODIFY) 1631#define bfin_write_MDMA_S2_Y_MODIFY(val) bfin_write16(MDMA_S2_Y_MODIFY, val)
1636#define bfin_read_MDMA_S2_CURR_DESC_PTR() bfin_read32(MDMA_S2_CURR_DESC_PTR) 1632#define bfin_read_MDMA_S2_CURR_DESC_PTR() bfin_read32(MDMA_S2_CURR_DESC_PTR)
1637#define bfin_write_MDMA_S2_CURR_DESC_PTR(val) bfin_write32(MDMA_S2_CURR_DESC_PTR) 1633#define bfin_write_MDMA_S2_CURR_DESC_PTR(val) bfin_write32(MDMA_S2_CURR_DESC_PTR, val)
1638#define bfin_read_MDMA_S2_CURR_ADDR() bfin_read32(MDMA_S2_CURR_ADDR) 1634#define bfin_read_MDMA_S2_CURR_ADDR() bfin_read32(MDMA_S2_CURR_ADDR)
1639#define bfin_write_MDMA_S2_CURR_ADDR(val) bfin_write32(MDMA_S2_CURR_ADDR) 1635#define bfin_write_MDMA_S2_CURR_ADDR(val) bfin_write32(MDMA_S2_CURR_ADDR, val)
1640#define bfin_read_MDMA_S2_IRQ_STATUS() bfin_read16(MDMA_S2_IRQ_STATUS) 1636#define bfin_read_MDMA_S2_IRQ_STATUS() bfin_read16(MDMA_S2_IRQ_STATUS)
1641#define bfin_write_MDMA_S2_IRQ_STATUS(val) bfin_write16(MDMA_S2_IRQ_STATUS, val) 1637#define bfin_write_MDMA_S2_IRQ_STATUS(val) bfin_write16(MDMA_S2_IRQ_STATUS, val)
1642#define bfin_read_MDMA_S2_PERIPHERAL_MAP() bfin_read16(MDMA_S2_PERIPHERAL_MAP) 1638#define bfin_read_MDMA_S2_PERIPHERAL_MAP() bfin_read16(MDMA_S2_PERIPHERAL_MAP)
@@ -1649,23 +1645,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1649/* MDMA Stream 3 Registers */ 1645/* MDMA Stream 3 Registers */
1650 1646
1651#define bfin_read_MDMA_D3_NEXT_DESC_PTR() bfin_read32(MDMA_D3_NEXT_DESC_PTR) 1647#define bfin_read_MDMA_D3_NEXT_DESC_PTR() bfin_read32(MDMA_D3_NEXT_DESC_PTR)
1652#define bfin_write_MDMA_D3_NEXT_DESC_PTR(val) bfin_write32(MDMA_D3_NEXT_DESC_PTR) 1648#define bfin_write_MDMA_D3_NEXT_DESC_PTR(val) bfin_write32(MDMA_D3_NEXT_DESC_PTR, val)
1653#define bfin_read_MDMA_D3_START_ADDR() bfin_read32(MDMA_D3_START_ADDR) 1649#define bfin_read_MDMA_D3_START_ADDR() bfin_read32(MDMA_D3_START_ADDR)
1654#define bfin_write_MDMA_D3_START_ADDR(val) bfin_write32(MDMA_D3_START_ADDR) 1650#define bfin_write_MDMA_D3_START_ADDR(val) bfin_write32(MDMA_D3_START_ADDR, val)
1655#define bfin_read_MDMA_D3_CONFIG() bfin_read16(MDMA_D3_CONFIG) 1651#define bfin_read_MDMA_D3_CONFIG() bfin_read16(MDMA_D3_CONFIG)
1656#define bfin_write_MDMA_D3_CONFIG(val) bfin_write16(MDMA_D3_CONFIG, val) 1652#define bfin_write_MDMA_D3_CONFIG(val) bfin_write16(MDMA_D3_CONFIG, val)
1657#define bfin_read_MDMA_D3_X_COUNT() bfin_read16(MDMA_D3_X_COUNT) 1653#define bfin_read_MDMA_D3_X_COUNT() bfin_read16(MDMA_D3_X_COUNT)
1658#define bfin_write_MDMA_D3_X_COUNT(val) bfin_write16(MDMA_D3_X_COUNT, val) 1654#define bfin_write_MDMA_D3_X_COUNT(val) bfin_write16(MDMA_D3_X_COUNT, val)
1659#define bfin_read_MDMA_D3_X_MODIFY() bfin_read16(MDMA_D3_X_MODIFY) 1655#define bfin_read_MDMA_D3_X_MODIFY() bfin_read16(MDMA_D3_X_MODIFY)
1660#define bfin_write_MDMA_D3_X_MODIFY(val) bfin_write16(MDMA_D3_X_MODIFY) 1656#define bfin_write_MDMA_D3_X_MODIFY(val) bfin_write16(MDMA_D3_X_MODIFY, val)
1661#define bfin_read_MDMA_D3_Y_COUNT() bfin_read16(MDMA_D3_Y_COUNT) 1657#define bfin_read_MDMA_D3_Y_COUNT() bfin_read16(MDMA_D3_Y_COUNT)
1662#define bfin_write_MDMA_D3_Y_COUNT(val) bfin_write16(MDMA_D3_Y_COUNT, val) 1658#define bfin_write_MDMA_D3_Y_COUNT(val) bfin_write16(MDMA_D3_Y_COUNT, val)
1663#define bfin_read_MDMA_D3_Y_MODIFY() bfin_read16(MDMA_D3_Y_MODIFY) 1659#define bfin_read_MDMA_D3_Y_MODIFY() bfin_read16(MDMA_D3_Y_MODIFY)
1664#define bfin_write_MDMA_D3_Y_MODIFY(val) bfin_write16(MDMA_D3_Y_MODIFY) 1660#define bfin_write_MDMA_D3_Y_MODIFY(val) bfin_write16(MDMA_D3_Y_MODIFY, val)
1665#define bfin_read_MDMA_D3_CURR_DESC_PTR() bfin_read32(MDMA_D3_CURR_DESC_PTR) 1661#define bfin_read_MDMA_D3_CURR_DESC_PTR() bfin_read32(MDMA_D3_CURR_DESC_PTR)
1666#define bfin_write_MDMA_D3_CURR_DESC_PTR(val) bfin_write32(MDMA_D3_CURR_DESC_PTR) 1662#define bfin_write_MDMA_D3_CURR_DESC_PTR(val) bfin_write32(MDMA_D3_CURR_DESC_PTR, val)
1667#define bfin_read_MDMA_D3_CURR_ADDR() bfin_read32(MDMA_D3_CURR_ADDR) 1663#define bfin_read_MDMA_D3_CURR_ADDR() bfin_read32(MDMA_D3_CURR_ADDR)
1668#define bfin_write_MDMA_D3_CURR_ADDR(val) bfin_write32(MDMA_D3_CURR_ADDR) 1664#define bfin_write_MDMA_D3_CURR_ADDR(val) bfin_write32(MDMA_D3_CURR_ADDR, val)
1669#define bfin_read_MDMA_D3_IRQ_STATUS() bfin_read16(MDMA_D3_IRQ_STATUS) 1665#define bfin_read_MDMA_D3_IRQ_STATUS() bfin_read16(MDMA_D3_IRQ_STATUS)
1670#define bfin_write_MDMA_D3_IRQ_STATUS(val) bfin_write16(MDMA_D3_IRQ_STATUS, val) 1666#define bfin_write_MDMA_D3_IRQ_STATUS(val) bfin_write16(MDMA_D3_IRQ_STATUS, val)
1671#define bfin_read_MDMA_D3_PERIPHERAL_MAP() bfin_read16(MDMA_D3_PERIPHERAL_MAP) 1667#define bfin_read_MDMA_D3_PERIPHERAL_MAP() bfin_read16(MDMA_D3_PERIPHERAL_MAP)
@@ -1675,23 +1671,23 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
1675#define bfin_read_MDMA_D3_CURR_Y_COUNT() bfin_read16(MDMA_D3_CURR_Y_COUNT) 1671#define bfin_read_MDMA_D3_CURR_Y_COUNT() bfin_read16(MDMA_D3_CURR_Y_COUNT)
1676#define bfin_write_MDMA_D3_CURR_Y_COUNT(val) bfin_write16(MDMA_D3_CURR_Y_COUNT, val) 1672#define bfin_write_MDMA_D3_CURR_Y_COUNT(val) bfin_write16(MDMA_D3_CURR_Y_COUNT, val)
1677#define bfin_read_MDMA_S3_NEXT_DESC_PTR() bfin_read32(MDMA_S3_NEXT_DESC_PTR) 1673#define bfin_read_MDMA_S3_NEXT_DESC_PTR() bfin_read32(MDMA_S3_NEXT_DESC_PTR)
1678#define bfin_write_MDMA_S3_NEXT_DESC_PTR(val) bfin_write32(MDMA_S3_NEXT_DESC_PTR) 1674#define bfin_write_MDMA_S3_NEXT_DESC_PTR(val) bfin_write32(MDMA_S3_NEXT_DESC_PTR, val)
1679#define bfin_read_MDMA_S3_START_ADDR() bfin_read32(MDMA_S3_START_ADDR) 1675#define bfin_read_MDMA_S3_START_ADDR() bfin_read32(MDMA_S3_START_ADDR)
1680#define bfin_write_MDMA_S3_START_ADDR(val) bfin_write32(MDMA_S3_START_ADDR) 1676#define bfin_write_MDMA_S3_START_ADDR(val) bfin_write32(MDMA_S3_START_ADDR, val)
1681#define bfin_read_MDMA_S3_CONFIG() bfin_read16(MDMA_S3_CONFIG) 1677#define bfin_read_MDMA_S3_CONFIG() bfin_read16(MDMA_S3_CONFIG)
1682#define bfin_write_MDMA_S3_CONFIG(val) bfin_write16(MDMA_S3_CONFIG, val) 1678#define bfin_write_MDMA_S3_CONFIG(val) bfin_write16(MDMA_S3_CONFIG, val)
1683#define bfin_read_MDMA_S3_X_COUNT() bfin_read16(MDMA_S3_X_COUNT) 1679#define bfin_read_MDMA_S3_X_COUNT() bfin_read16(MDMA_S3_X_COUNT)
1684#define bfin_write_MDMA_S3_X_COUNT(val) bfin_write16(MDMA_S3_X_COUNT, val) 1680#define bfin_write_MDMA_S3_X_COUNT(val) bfin_write16(MDMA_S3_X_COUNT, val)
1685#define bfin_read_MDMA_S3_X_MODIFY() bfin_read16(MDMA_S3_X_MODIFY) 1681#define bfin_read_MDMA_S3_X_MODIFY() bfin_read16(MDMA_S3_X_MODIFY)
1686#define bfin_write_MDMA_S3_X_MODIFY(val) bfin_write16(MDMA_S3_X_MODIFY) 1682#define bfin_write_MDMA_S3_X_MODIFY(val) bfin_write16(MDMA_S3_X_MODIFY, val)
1687#define bfin_read_MDMA_S3_Y_COUNT() bfin_read16(MDMA_S3_Y_COUNT) 1683#define bfin_read_MDMA_S3_Y_COUNT() bfin_read16(MDMA_S3_Y_COUNT)
1688#define bfin_write_MDMA_S3_Y_COUNT(val) bfin_write16(MDMA_S3_Y_COUNT, val) 1684#define bfin_write_MDMA_S3_Y_COUNT(val) bfin_write16(MDMA_S3_Y_COUNT, val)
1689#define bfin_read_MDMA_S3_Y_MODIFY() bfin_read16(MDMA_S3_Y_MODIFY) 1685#define bfin_read_MDMA_S3_Y_MODIFY() bfin_read16(MDMA_S3_Y_MODIFY)
1690#define bfin_write_MDMA_S3_Y_MODIFY(val) bfin_write16(MDMA_S3_Y_MODIFY) 1686#define bfin_write_MDMA_S3_Y_MODIFY(val) bfin_write16(MDMA_S3_Y_MODIFY, val)
1691#define bfin_read_MDMA_S3_CURR_DESC_PTR() bfin_read32(MDMA_S3_CURR_DESC_PTR) 1687#define bfin_read_MDMA_S3_CURR_DESC_PTR() bfin_read32(MDMA_S3_CURR_DESC_PTR)
1692#define bfin_write_MDMA_S3_CURR_DESC_PTR(val) bfin_write32(MDMA_S3_CURR_DESC_PTR) 1688#define bfin_write_MDMA_S3_CURR_DESC_PTR(val) bfin_write32(MDMA_S3_CURR_DESC_PTR, val)
1693#define bfin_read_MDMA_S3_CURR_ADDR() bfin_read32(MDMA_S3_CURR_ADDR) 1689#define bfin_read_MDMA_S3_CURR_ADDR() bfin_read32(MDMA_S3_CURR_ADDR)
1694#define bfin_write_MDMA_S3_CURR_ADDR(val) bfin_write32(MDMA_S3_CURR_ADDR) 1690#define bfin_write_MDMA_S3_CURR_ADDR(val) bfin_write32(MDMA_S3_CURR_ADDR, val)
1695#define bfin_read_MDMA_S3_IRQ_STATUS() bfin_read16(MDMA_S3_IRQ_STATUS) 1691#define bfin_read_MDMA_S3_IRQ_STATUS() bfin_read16(MDMA_S3_IRQ_STATUS)
1696#define bfin_write_MDMA_S3_IRQ_STATUS(val) bfin_write16(MDMA_S3_IRQ_STATUS, val) 1692#define bfin_write_MDMA_S3_IRQ_STATUS(val) bfin_write16(MDMA_S3_IRQ_STATUS, val)
1697#define bfin_read_MDMA_S3_PERIPHERAL_MAP() bfin_read16(MDMA_S3_PERIPHERAL_MAP) 1693#define bfin_read_MDMA_S3_PERIPHERAL_MAP() bfin_read16(MDMA_S3_PERIPHERAL_MAP)
diff --git a/include/asm-blackfin/mach-bf548/dma.h b/include/asm-blackfin/mach-bf548/dma.h
index 46ff31f20ae5..36a2ef7e7849 100644
--- a/include/asm-blackfin/mach-bf548/dma.h
+++ b/include/asm-blackfin/mach-bf548/dma.h
@@ -73,6 +73,4 @@
73 73
74#define MAX_BLACKFIN_DMA_CHANNEL 32 74#define MAX_BLACKFIN_DMA_CHANNEL 32
75 75
76extern int channel2irq(unsigned int channel);
77extern struct dma_register *base_addr[MAX_BLACKFIN_DMA_CHANNEL];
78#endif 76#endif
diff --git a/include/asm-blackfin/mach-bf548/mem_init.h b/include/asm-blackfin/mach-bf548/mem_init.h
index befc2903d5a5..ab0b863eee66 100644
--- a/include/asm-blackfin/mach-bf548/mem_init.h
+++ b/include/asm-blackfin/mach-bf548/mem_init.h
@@ -29,16 +29,19 @@
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) 31#define MIN_DDR_SCLK(x) (x*(CONFIG_SCLK_HZ/1000/1000)/1000 + 1)
32#define MAX_DDR_SCLK(x) (x*(CONFIG_SCLK_HZ/1000/1000)/1000)
33#define DDR_CLK_HZ(x) (1000*1000*1000/x)
32 34
33#if (CONFIG_MEM_MT46V32M16_6T) 35#if (CONFIG_MEM_MT46V32M16_6T)
34#define DDR_SIZE DEVSZ_512 36#define DDR_SIZE DEVSZ_512
35#define DDR_WIDTH DEVWD_16 37#define DDR_WIDTH DEVWD_16
38#define DDR_MAX_tCK 13
36 39
37#define DDR_tRC DDR_TRC(MIN_DDR_SCLK(60)) 40#define DDR_tRC DDR_TRC(MIN_DDR_SCLK(60))
38#define DDR_tRAS DDR_TRAS(MIN_DDR_SCLK(42)) 41#define DDR_tRAS DDR_TRAS(MIN_DDR_SCLK(42))
39#define DDR_tRP DDR_TRP(MIN_DDR_SCLK(15)) 42#define DDR_tRP DDR_TRP(MIN_DDR_SCLK(15))
40#define DDR_tRFC DDR_TRFC(MIN_DDR_SCLK(72)) 43#define DDR_tRFC DDR_TRFC(MIN_DDR_SCLK(72))
41#define DDR_tREFI DDR_TREFI(MIN_DDR_SCLK(7800)) 44#define DDR_tREFI DDR_TREFI(MAX_DDR_SCLK(7800))
42 45
43#define DDR_tRCD DDR_TRCD(MIN_DDR_SCLK(15)) 46#define DDR_tRCD DDR_TRCD(MIN_DDR_SCLK(15))
44#define DDR_tWTR DDR_TWTR(1) 47#define DDR_tWTR DDR_TWTR(1)
@@ -49,12 +52,13 @@
49#if (CONFIG_MEM_MT46V32M16_5B) 52#if (CONFIG_MEM_MT46V32M16_5B)
50#define DDR_SIZE DEVSZ_512 53#define DDR_SIZE DEVSZ_512
51#define DDR_WIDTH DEVWD_16 54#define DDR_WIDTH DEVWD_16
55#define DDR_MAX_tCK 13
52 56
53#define DDR_tRC DDR_TRC(MIN_DDR_SCLK(55)) 57#define DDR_tRC DDR_TRC(MIN_DDR_SCLK(55))
54#define DDR_tRAS DDR_TRAS(MIN_DDR_SCLK(40)) 58#define DDR_tRAS DDR_TRAS(MIN_DDR_SCLK(40))
55#define DDR_tRP DDR_TRP(MIN_DDR_SCLK(15)) 59#define DDR_tRP DDR_TRP(MIN_DDR_SCLK(15))
56#define DDR_tRFC DDR_TRFC(MIN_DDR_SCLK(70)) 60#define DDR_tRFC DDR_TRFC(MIN_DDR_SCLK(70))
57#define DDR_tREFI DDR_TREFI(MIN_DDR_SCLK(7800)) 61#define DDR_tREFI DDR_TREFI(MAX_DDR_SCLK(7800))
58 62
59#define DDR_tRCD DDR_TRCD(MIN_DDR_SCLK(15)) 63#define DDR_tRCD DDR_TRCD(MIN_DDR_SCLK(15))
60#define DDR_tWTR DDR_TWTR(2) 64#define DDR_tWTR DDR_TWTR(2)
@@ -65,6 +69,7 @@
65#if (CONFIG_MEM_GENERIC_BOARD) 69#if (CONFIG_MEM_GENERIC_BOARD)
66#define DDR_SIZE DEVSZ_512 70#define DDR_SIZE DEVSZ_512
67#define DDR_WIDTH DEVWD_16 71#define DDR_WIDTH DEVWD_16
72#define DDR_MAX_tCK 13
68 73
69#define DDR_tRCD DDR_TRCD(3) 74#define DDR_tRCD DDR_TRCD(3)
70#define DDR_tWTR DDR_TWTR(2) 75#define DDR_tWTR DDR_TWTR(2)
@@ -77,14 +82,15 @@
77#define DDR_tREFI DDR_TREFI(1288) 82#define DDR_tREFI DDR_TREFI(1288)
78#endif 83#endif
79 84
80#if (CONFIG_SCLK_HZ <= 133333333) 85#if (CONFIG_SCLK_HZ < DDR_CLK_HZ(DDR_MAX_tCK))
81#define DDR_CL CL_2 86# error "CONFIG_SCLK_HZ is too small (<DDR_CLK_HZ(DDR_MAX_tCK) Hz)."
82#elif (CONFIG_SCLK_HZ <= 166666666) 87#elif(CONFIG_SCLK_HZ <= 133333333)
83#define DDR_CL CL_2_5 88# define DDR_CL CL_2
84#else 89#else
85#define DDR_CL CL_3 90# error "CONFIG_SCLK_HZ is too large (>133333333 Hz)."
86#endif 91#endif
87 92
93
88#define mem_DDRCTL0 (DDR_tRP | DDR_tRAS | DDR_tRC | DDR_tRFC | DDR_tREFI) 94#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 \ 95#define mem_DDRCTL1 (DDR_DATWIDTH | EXTBANK_1 | DDR_SIZE | DDR_WIDTH | DDR_tWTR \
90 | DDR_tMRD | DDR_tWR | DDR_tRCD) 96 | DDR_tMRD | DDR_tWR | DDR_tRCD)
diff --git a/include/asm-blackfin/mach-bf561/anomaly.h b/include/asm-blackfin/mach-bf561/anomaly.h
index 0c1d46193939..82157caa96a2 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 O, 11/15/2007; ADSP-BF561 Blackfin Processor Anomaly List 10 * - Revision P, 02/08/2008; ADSP-BF561 Blackfin Processor Anomaly List
11 */ 11 */
12 12
13#ifndef _MACH_ANOMALY_H_ 13#ifndef _MACH_ANOMALY_H_
@@ -256,10 +256,14 @@
256#define ANOMALY_05000357 (1) 256#define ANOMALY_05000357 (1)
257/* Conflicting Column Address Widths Causes SDRAM Errors */ 257/* Conflicting Column Address Widths Causes SDRAM Errors */
258#define ANOMALY_05000362 (1) 258#define ANOMALY_05000362 (1)
259/* UART Break Signal Issues */
260#define ANOMALY_05000363 (__SILICON_REVISION__ < 5)
259/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */ 261/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */
260#define ANOMALY_05000366 (1) 262#define ANOMALY_05000366 (1)
261/* Possible RETS Register Corruption when Subroutine Is under 5 Cycles in Duration */ 263/* Possible RETS Register Corruption when Subroutine Is under 5 Cycles in Duration */
262#define ANOMALY_05000371 (1) 264#define ANOMALY_05000371 (1)
265/* Level-Sensitive External GPIO Wakeups May Cause Indefinite Stall */
266#define ANOMALY_05000403 (1)
263 267
264/* Anomalies that don't exist on this proc */ 268/* Anomalies that don't exist on this proc */
265#define ANOMALY_05000158 (0) 269#define ANOMALY_05000158 (0)
diff --git a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
index b6f513bee56e..8a4e66d1db37 100644
--- a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
@@ -1,22 +1,38 @@
1/*
2 * file: include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
3 * based on:
4 * author:
5 *
6 * created:
7 * description:
8 * blackfin serial driver head file
9 * rev:
10 *
11 * modified:
12 *
13 *
14 * bugs: enter bugs at http://blackfin.uclinux.org/
15 *
16 * this program is free software; you can redistribute it and/or modify
17 * it under the terms of the gnu general public license as published by
18 * the free software foundation; either version 2, or (at your option)
19 * any later version.
20 *
21 * this program is distributed in the hope that it will be useful,
22 * but without any warranty; without even the implied warranty of
23 * merchantability or fitness for a particular purpose. see the
24 * gnu general public license for more details.
25 *
26 * you should have received a copy of the gnu general public license
27 * along with this program; see the file copying.
28 * if not, write to the free software foundation,
29 * 59 temple place - suite 330, boston, ma 02111-1307, usa.
30 */
31
1#include <linux/serial.h> 32#include <linux/serial.h>
2#include <asm/dma.h> 33#include <asm/dma.h>
3#include <asm/portmux.h> 34#include <asm/portmux.h>
4 35
5#define NR_PORTS 1
6
7#define OFFSET_THR 0x00 /* Transmit Holding register */
8#define OFFSET_RBR 0x00 /* Receive Buffer register */
9#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
10#define OFFSET_IER 0x04 /* Interrupt Enable Register */
11#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
12#define OFFSET_IIR 0x08 /* Interrupt Identification Register */
13#define OFFSET_LCR 0x0C /* Line Control Register */
14#define OFFSET_MCR 0x10 /* Modem Control Register */
15#define OFFSET_LSR 0x14 /* Line Status Register */
16#define OFFSET_MSR 0x18 /* Modem Status Register */
17#define OFFSET_SCR 0x1C /* SCR Scratch Register */
18#define OFFSET_GCTL 0x24 /* Global Control Register */
19
20#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR)) 36#define UART_GET_CHAR(uart) bfin_read16(((uart)->port.membase + OFFSET_RBR))
21#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL)) 37#define UART_GET_DLL(uart) bfin_read16(((uart)->port.membase + OFFSET_DLL))
22#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER)) 38#define UART_GET_IER(uart) bfin_read16(((uart)->port.membase + OFFSET_IER))
@@ -84,7 +100,7 @@ static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
84 bfin_write16(uart->port.membase + OFFSET_LSR, -1); 100 bfin_write16(uart->port.membase + OFFSET_LSR, -1);
85} 101}
86 102
87struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 103struct bfin_serial_port bfin_serial_ports[BFIN_UART_NR_PORTS];
88struct bfin_serial_res { 104struct bfin_serial_res {
89 unsigned long uart_base_addr; 105 unsigned long uart_base_addr;
90 int uart_irq; 106 int uart_irq;
@@ -115,7 +131,7 @@ struct bfin_serial_res bfin_serial_resource[] = {
115 131
116#define DRIVER_NAME "bfin-uart" 132#define DRIVER_NAME "bfin-uart"
117 133
118int nr_ports = NR_PORTS; 134int nr_ports = BFIN_UART_NR_PORTS;
119static void bfin_serial_hw_init(struct bfin_serial_port *uart) 135static void bfin_serial_hw_init(struct bfin_serial_port *uart)
120{ 136{
121 137
diff --git a/include/asm-blackfin/mach-bf561/bfin_sir.h b/include/asm-blackfin/mach-bf561/bfin_sir.h
new file mode 100644
index 000000000000..cefcf8bb505b
--- /dev/null
+++ b/include/asm-blackfin/mach-bf561/bfin_sir.h
@@ -0,0 +1,120 @@
1/*
2 * Blackfin Infra-red Driver
3 *
4 * Copyright 2006-2008 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 *
10 */
11
12#include <linux/serial.h>
13#include <asm/dma.h>
14#include <asm/portmux.h>
15
16#define SIR_UART_GET_CHAR(port) bfin_read16((port)->membase + OFFSET_RBR)
17#define SIR_UART_GET_DLL(port) bfin_read16((port)->membase + OFFSET_DLL)
18#define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER)
19#define SIR_UART_GET_DLH(port) bfin_read16((port)->membase + OFFSET_DLH)
20#define SIR_UART_GET_IIR(port) bfin_read16((port)->membase + OFFSET_IIR)
21#define SIR_UART_GET_LCR(port) bfin_read16((port)->membase + OFFSET_LCR)
22#define SIR_UART_GET_GCTL(port) bfin_read16((port)->membase + OFFSET_GCTL)
23
24#define SIR_UART_PUT_CHAR(port, v) bfin_write16(((port)->membase + OFFSET_THR), v)
25#define SIR_UART_PUT_DLL(port, v) bfin_write16(((port)->membase + OFFSET_DLL), v)
26#define SIR_UART_PUT_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER), v)
27#define SIR_UART_PUT_DLH(port, v) bfin_write16(((port)->membase + OFFSET_DLH), v)
28#define SIR_UART_PUT_LCR(port, v) bfin_write16(((port)->membase + OFFSET_LCR), v)
29#define SIR_UART_PUT_GCTL(port, v) bfin_write16(((port)->membase + OFFSET_GCTL), v)
30
31#ifdef CONFIG_SIR_BFIN_DMA
32struct dma_rx_buf {
33 char *buf;
34 int head;
35 int tail;
36 };
37#endif /* CONFIG_SIR_BFIN_DMA */
38
39struct bfin_sir_port {
40 unsigned char __iomem *membase;
41 unsigned int irq;
42 unsigned int lsr;
43 unsigned long clk;
44 struct net_device *dev;
45#ifdef CONFIG_SIR_BFIN_DMA
46 int tx_done;
47 struct dma_rx_buf rx_dma_buf;
48 struct timer_list rx_dma_timer;
49 int rx_dma_nrows;
50#endif /* CONFIG_SIR_BFIN_DMA */
51 unsigned int tx_dma_channel;
52 unsigned int rx_dma_channel;
53};
54
55struct bfin_sir_port sir_ports[BFIN_UART_NR_PORTS];
56
57struct bfin_sir_port_res {
58 unsigned long base_addr;
59 int irq;
60 unsigned int rx_dma_channel;
61 unsigned int tx_dma_channel;
62};
63
64struct bfin_sir_port_res bfin_sir_port_resource[] = {
65#ifdef CONFIG_BFIN_SIR0
66 {
67 0xFFC00400,
68 IRQ_UART_RX,
69 CH_UART_RX,
70 CH_UART_TX,
71 },
72#endif
73};
74
75int nr_sirs = ARRAY_SIZE(bfin_sir_port_resource);
76
77struct bfin_sir_self {
78 struct bfin_sir_port *sir_port;
79 spinlock_t lock;
80 unsigned int open;
81 int speed;
82 int newspeed;
83
84 struct sk_buff *txskb;
85 struct sk_buff *rxskb;
86 struct net_device_stats stats;
87 struct device *dev;
88 struct irlap_cb *irlap;
89 struct qos_info qos;
90
91 iobuff_t tx_buff;
92 iobuff_t rx_buff;
93
94 struct work_struct work;
95 int mtt;
96};
97
98static inline unsigned int SIR_UART_GET_LSR(struct bfin_sir_port *port)
99{
100 unsigned int lsr = bfin_read16(port->membase + OFFSET_LSR);
101 port->lsr |= (lsr & (BI|FE|PE|OE));
102 return lsr | port->lsr;
103}
104
105static inline void SIR_UART_CLEAR_LSR(struct bfin_sir_port *port)
106{
107 port->lsr = 0;
108 bfin_read16(port->membase + OFFSET_LSR);
109}
110
111#define DRIVER_NAME "bfin_sir"
112
113static void bfin_sir_hw_init(void)
114{
115#ifdef CONFIG_BFIN_SIR0
116 peripheral_request(P_UART0_TX, DRIVER_NAME);
117 peripheral_request(P_UART0_RX, DRIVER_NAME);
118#endif
119 SSYNC();
120}
diff --git a/include/asm-blackfin/mach-bf561/blackfin.h b/include/asm-blackfin/mach-bf561/blackfin.h
index 3a16df2c86d8..0ea8666e6764 100644
--- a/include/asm-blackfin/mach-bf561/blackfin.h
+++ b/include/asm-blackfin/mach-bf561/blackfin.h
@@ -69,5 +69,19 @@
69#define bfin_read_SIC_ISR(x) bfin_read32(SICA_ISR0 + (x << 2)) 69#define bfin_read_SIC_ISR(x) bfin_read32(SICA_ISR0 + (x << 2))
70#define bfin_write_SIC_ISR(x, val) bfin_write32((SICA_ISR0 + (x << 2)), val) 70#define bfin_write_SIC_ISR(x, val) bfin_write32((SICA_ISR0 + (x << 2)), val)
71 71
72#define BFIN_UART_NR_PORTS 1
73
74#define OFFSET_THR 0x00 /* Transmit Holding register */
75#define OFFSET_RBR 0x00 /* Receive Buffer register */
76#define OFFSET_DLL 0x00 /* Divisor Latch (Low-Byte) */
77#define OFFSET_IER 0x04 /* Interrupt Enable Register */
78#define OFFSET_DLH 0x04 /* Divisor Latch (High-Byte) */
79#define OFFSET_IIR 0x08 /* Interrupt Identification Register */
80#define OFFSET_LCR 0x0C /* Line Control Register */
81#define OFFSET_MCR 0x10 /* Modem Control Register */
82#define OFFSET_LSR 0x14 /* Line Status Register */
83#define OFFSET_MSR 0x18 /* Modem Status Register */
84#define OFFSET_SCR 0x1C /* SCR Scratch Register */
85#define OFFSET_GCTL 0x24 /* Global Control Register */
72 86
73#endif /* _MACH_BLACKFIN_H_ */ 87#endif /* _MACH_BLACKFIN_H_ */
diff --git a/include/asm-blackfin/mach-bf561/cdefBF561.h b/include/asm-blackfin/mach-bf561/cdefBF561.h
index 1bc8d2f89ccc..b07ffccd66dd 100644
--- a/include/asm-blackfin/mach-bf561/cdefBF561.h
+++ b/include/asm-blackfin/mach-bf561/cdefBF561.h
@@ -47,7 +47,30 @@
47 47
48/* Clock and System Control (0xFFC00000 - 0xFFC000FF) */ 48/* Clock and System Control (0xFFC00000 - 0xFFC000FF) */
49#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL) 49#define bfin_read_PLL_CTL() bfin_read16(PLL_CTL)
50#define bfin_write_PLL_CTL(val) bfin_write16(PLL_CTL,val) 50/* Writing to PLL_CTL initiates a PLL relock sequence. */
51static __inline__ void bfin_write_PLL_CTL(unsigned int val)
52{
53 unsigned long flags, iwr0, iwr1;
54
55 if (val == bfin_read_PLL_CTL())
56 return;
57
58 local_irq_save(flags);
59 /* Enable the PLL Wakeup bit in SIC IWR */
60 iwr0 = bfin_read32(SICA_IWR0);
61 iwr1 = bfin_read32(SICA_IWR1);
62 /* Only allow PPL Wakeup) */
63 bfin_write32(SICA_IWR0, IWR_ENABLE(0));
64 bfin_write32(SICA_IWR1, 0);
65
66 bfin_write16(PLL_CTL, val);
67 SSYNC();
68 asm("IDLE;");
69
70 bfin_write32(SICA_IWR0, iwr0);
71 bfin_write32(SICA_IWR1, iwr1);
72 local_irq_restore(flags);
73}
51#define bfin_read_PLL_DIV() bfin_read16(PLL_DIV) 74#define bfin_read_PLL_DIV() bfin_read16(PLL_DIV)
52#define bfin_write_PLL_DIV(val) bfin_write16(PLL_DIV,val) 75#define bfin_write_PLL_DIV(val) bfin_write16(PLL_DIV,val)
53#define bfin_read_VR_CTL() bfin_read16(VR_CTL) 76#define bfin_read_VR_CTL() bfin_read16(VR_CTL)
@@ -56,6 +79,10 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
56{ 79{
57 unsigned long flags, iwr0, iwr1; 80 unsigned long flags, iwr0, iwr1;
58 81
82 if (val == bfin_read_VR_CTL())
83 return;
84
85 local_irq_save(flags);
59 /* Enable the PLL Wakeup bit in SIC IWR */ 86 /* Enable the PLL Wakeup bit in SIC IWR */
60 iwr0 = bfin_read32(SICA_IWR0); 87 iwr0 = bfin_read32(SICA_IWR0);
61 iwr1 = bfin_read32(SICA_IWR1); 88 iwr1 = bfin_read32(SICA_IWR1);
@@ -65,12 +92,11 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
65 92
66 bfin_write16(VR_CTL, val); 93 bfin_write16(VR_CTL, val);
67 SSYNC(); 94 SSYNC();
68
69 local_irq_save(flags);
70 asm("IDLE;"); 95 asm("IDLE;");
71 local_irq_restore(flags); 96
72 bfin_write32(SICA_IWR0, iwr0); 97 bfin_write32(SICA_IWR0, iwr0);
73 bfin_write32(SICA_IWR1, iwr1); 98 bfin_write32(SICA_IWR1, iwr1);
99 local_irq_restore(flags);
74} 100}
75#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT) 101#define bfin_read_PLL_STAT() bfin_read16(PLL_STAT)
76#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT,val) 102#define bfin_write_PLL_STAT(val) bfin_write16(PLL_STAT,val)
diff --git a/include/asm-blackfin/mach-bf561/defBF561.h b/include/asm-blackfin/mach-bf561/defBF561.h
index c3c0eb13c819..366c9b9a0cb7 100644
--- a/include/asm-blackfin/mach-bf561/defBF561.h
+++ b/include/asm-blackfin/mach-bf561/defBF561.h
@@ -110,18 +110,23 @@
110#define WDOGB_STAT 0xFFC01208 /* Watchdog Status register */ 110#define WDOGB_STAT 0xFFC01208 /* Watchdog Status register */
111 111
112/* UART Controller (0xFFC00400 - 0xFFC004FF) */ 112/* UART Controller (0xFFC00400 - 0xFFC004FF) */
113#define UART_THR 0xFFC00400 /* Transmit Holding register */ 113
114#define UART_RBR 0xFFC00400 /* Receive Buffer register */ 114/*
115#define UART_DLL 0xFFC00400 /* Divisor Latch (Low-Byte) */ 115 * Because include/linux/serial_reg.h have defined UART_*,
116#define UART_IER 0xFFC00404 /* Interrupt Enable Register */ 116 * So we define blackfin uart regs to BFIN_UART0_*.
117#define UART_DLH 0xFFC00404 /* Divisor Latch (High-Byte) */ 117 */
118#define UART_IIR 0xFFC00408 /* Interrupt Identification Register */ 118#define BFIN_UART_THR 0xFFC00400 /* Transmit Holding register */
119#define UART_LCR 0xFFC0040C /* Line Control Register */ 119#define BFIN_UART_RBR 0xFFC00400 /* Receive Buffer register */
120#define UART_MCR 0xFFC00410 /* Modem Control Register */ 120#define BFIN_UART_DLL 0xFFC00400 /* Divisor Latch (Low-Byte) */
121#define UART_LSR 0xFFC00414 /* Line Status Register */ 121#define BFIN_UART_IER 0xFFC00404 /* Interrupt Enable Register */
122#define UART_MSR 0xFFC00418 /* Modem Status Register */ 122#define BFIN_UART_DLH 0xFFC00404 /* Divisor Latch (High-Byte) */
123#define UART_SCR 0xFFC0041C /* SCR Scratch Register */ 123#define BFIN_UART_IIR 0xFFC00408 /* Interrupt Identification Register */
124#define UART_GCTL 0xFFC00424 /* Global Control Register */ 124#define BFIN_UART_LCR 0xFFC0040C /* Line Control Register */
125#define BFIN_UART_MCR 0xFFC00410 /* Modem Control Register */
126#define BFIN_UART_LSR 0xFFC00414 /* Line Status Register */
127#define BFIN_UART_MSR 0xFFC00418 /* Modem Status Register */
128#define BFIN_UART_SCR 0xFFC0041C /* SCR Scratch Register */
129#define BFIN_UART_GCTL 0xFFC00424 /* Global Control Register */
125 130
126/* SPI Controller (0xFFC00500 - 0xFFC005FF) */ 131/* SPI Controller (0xFFC00500 - 0xFFC005FF) */
127#define SPI0_REGBASE 0xFFC00500 132#define SPI0_REGBASE 0xFFC00500
@@ -866,6 +871,8 @@
866/* PLL_DIV Masks */ 871/* PLL_DIV Masks */
867#define SCLK_DIV(x) (x) /* SCLK = VCO / x */ 872#define SCLK_DIV(x) (x) /* SCLK = VCO / x */
868 873
874#define CSEL 0x30 /* Core Select */
875#define SSEL 0xf /* System Select */
869#define CCLK_DIV1 0x00000000 /* CCLK = VCO / 1 */ 876#define CCLK_DIV1 0x00000000 /* CCLK = VCO / 1 */
870#define CCLK_DIV2 0x00000010 /* CCLK = VCO / 2 */ 877#define CCLK_DIV2 0x00000010 /* CCLK = VCO / 2 */
871#define CCLK_DIV4 0x00000020 /* CCLK = VCO / 4 */ 878#define CCLK_DIV4 0x00000020 /* CCLK = VCO / 4 */
diff --git a/include/asm-blackfin/mach-bf561/dma.h b/include/asm-blackfin/mach-bf561/dma.h
index 766334b7d8ab..21d982003e75 100644
--- a/include/asm-blackfin/mach-bf561/dma.h
+++ b/include/asm-blackfin/mach-bf561/dma.h
@@ -32,7 +32,4 @@
32#define CH_IMEM_STREAM1_SRC 34 32#define CH_IMEM_STREAM1_SRC 34
33#define CH_IMEM_STREAM1_DEST 35 33#define CH_IMEM_STREAM1_DEST 35
34 34
35extern int channel2irq(unsigned int channel);
36extern struct dma_register *base_addr[];
37
38#endif 35#endif
diff --git a/include/asm-blackfin/portmux.h b/include/asm-blackfin/portmux.h
index 0d3f650d2d99..0807b286cd9e 100644
--- a/include/asm-blackfin/portmux.h
+++ b/include/asm-blackfin/portmux.h
@@ -17,8 +17,8 @@
17 17
18int peripheral_request(unsigned short per, const char *label); 18int peripheral_request(unsigned short per, const char *label);
19void peripheral_free(unsigned short per); 19void peripheral_free(unsigned short per);
20int peripheral_request_list(unsigned short per[], const char *label); 20int peripheral_request_list(const unsigned short per[], const char *label);
21void peripheral_free_list(unsigned short per[]); 21void peripheral_free_list(const unsigned short per[]);
22 22
23#include <asm/gpio.h> 23#include <asm/gpio.h>
24#include <asm/mach/portmux.h> 24#include <asm/mach/portmux.h>
diff --git a/include/asm-blackfin/processor.h b/include/asm-blackfin/processor.h
index 1033e5c76011..1c0040724612 100644
--- a/include/asm-blackfin/processor.h
+++ b/include/asm-blackfin/processor.h
@@ -26,9 +26,10 @@ static inline void wrusp(unsigned long usp)
26 26
27/* 27/*
28 * User space process size: 1st byte beyond user address space. 28 * User space process size: 1st byte beyond user address space.
29 * Fairly meaningless on nommu. Parts of user programs can be scattered
30 * in a lot of places, so just disable this by setting it to 0xFFFFFFFF.
29 */ 31 */
30extern unsigned long memory_end; 32#define TASK_SIZE 0xFFFFFFFF
31#define TASK_SIZE (memory_end)
32 33
33#ifdef __KERNEL__ 34#ifdef __KERNEL__
34#define STACK_TOP TASK_SIZE 35#define STACK_TOP TASK_SIZE
diff --git a/include/asm-blackfin/semaphore-helper.h b/include/asm-blackfin/semaphore-helper.h
deleted file mode 100644
index 9082b0dc3eb5..000000000000
--- a/include/asm-blackfin/semaphore-helper.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/* Based on M68K version, Lineo Inc. May 2001 */
2
3#ifndef _BFIN_SEMAPHORE_HELPER_H
4#define _BFIN_SEMAPHORE_HELPER_H
5
6/*
7 * SMP- and interrupt-safe semaphores helper functions.
8 *
9 * (C) Copyright 1996 Linus Torvalds
10 *
11 */
12
13#include <asm/errno.h>
14
15/*
16 * These two _must_ execute atomically wrt each other.
17 */
18static inline void wake_one_more(struct semaphore *sem)
19{
20 atomic_inc(&sem->waking);
21}
22
23static inline int waking_non_zero(struct semaphore *sem)
24{
25 int ret;
26 unsigned long flags = 0;
27
28 spin_lock_irqsave(&semaphore_wake_lock, flags);
29 ret = 0;
30 if (atomic_read(&sem->waking) > 0) {
31 atomic_dec(&sem->waking);
32 ret = 1;
33 }
34 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
35 return ret;
36}
37
38/*
39 * waking_non_zero_interruptible:
40 * 1 got the lock
41 * 0 go to sleep
42 * -EINTR interrupted
43 */
44static inline int waking_non_zero_interruptible(struct semaphore *sem,
45 struct task_struct *tsk)
46{
47 int ret = 0;
48 unsigned long flags = 0;
49
50 spin_lock_irqsave(&semaphore_wake_lock, flags);
51 if (atomic_read(&sem->waking) > 0) {
52 atomic_dec(&sem->waking);
53 ret = 1;
54 } else if (signal_pending(tsk)) {
55 atomic_inc(&sem->count);
56 ret = -EINTR;
57 }
58 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
59 return ret;
60}
61
62/*
63 * waking_non_zero_trylock:
64 * 1 failed to lock
65 * 0 got the lock
66 */
67static inline int waking_non_zero_trylock(struct semaphore *sem)
68{
69 int ret = 1;
70 unsigned long flags = 0;
71
72 spin_lock_irqsave(&semaphore_wake_lock, flags);
73 if (atomic_read(&sem->waking) > 0) {
74 atomic_dec(&sem->waking);
75 ret = 0;
76 } else
77 atomic_inc(&sem->count);
78 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
79 return ret;
80}
81
82#endif /* _BFIN_SEMAPHORE_HELPER_H */
diff --git a/include/asm-blackfin/semaphore.h b/include/asm-blackfin/semaphore.h
index 533f90fb2e4e..d9b2034ed1d2 100644
--- a/include/asm-blackfin/semaphore.h
+++ b/include/asm-blackfin/semaphore.h
@@ -1,105 +1 @@
1#ifndef _BFIN_SEMAPHORE_H #include <linux/semaphore.h>
2#define _BFIN_SEMAPHORE_H
3
4#ifndef __ASSEMBLY__
5
6#include <linux/linkage.h>
7#include <linux/wait.h>
8#include <linux/spinlock.h>
9#include <linux/rwsem.h>
10#include <asm/atomic.h>
11
12/*
13 * Interrupt-safe semaphores..
14 *
15 * (C) Copyright 1996 Linus Torvalds
16 *
17 * BFIN version by akbar hussain Lineo Inc April 2001
18 *
19 */
20
21struct semaphore {
22 atomic_t count;
23 int sleepers;
24 wait_queue_head_t wait;
25};
26
27#define __SEMAPHORE_INITIALIZER(name, n) \
28{ \
29 .count = ATOMIC_INIT(n), \
30 .sleepers = 0, \
31 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
32}
33
34#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
35 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
36
37#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
38
39static inline void sema_init(struct semaphore *sem, int val)
40{
41 *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
42}
43
44static inline void init_MUTEX(struct semaphore *sem)
45{
46 sema_init(sem, 1);
47}
48
49static inline void init_MUTEX_LOCKED(struct semaphore *sem)
50{
51 sema_init(sem, 0);
52}
53
54asmlinkage void __down(struct semaphore *sem);
55asmlinkage int __down_interruptible(struct semaphore *sem);
56asmlinkage int __down_trylock(struct semaphore *sem);
57asmlinkage void __up(struct semaphore *sem);
58
59extern spinlock_t semaphore_wake_lock;
60
61/*
62 * This is ugly, but we want the default case to fall through.
63 * "down_failed" is a special asm handler that calls the C
64 * routine that actually waits.
65 */
66static inline void down(struct semaphore *sem)
67{
68 might_sleep();
69 if (atomic_dec_return(&sem->count) < 0)
70 __down(sem);
71}
72
73static inline int down_interruptible(struct semaphore *sem)
74{
75 int ret = 0;
76
77 might_sleep();
78 if (atomic_dec_return(&sem->count) < 0)
79 ret = __down_interruptible(sem);
80 return (ret);
81}
82
83static inline int down_trylock(struct semaphore *sem)
84{
85 int ret = 0;
86
87 if (atomic_dec_return(&sem->count) < 0)
88 ret = __down_trylock(sem);
89 return ret;
90}
91
92/*
93 * Note! This is subtle. We jump to wake people up only if
94 * the semaphore was negative (== somebody was waiting on it).
95 * The default case (no contention) will result in NO
96 * jumps for both down() and up().
97 */
98static inline void up(struct semaphore *sem)
99{
100 if (atomic_inc_return(&sem->count) <= 0)
101 __up(sem);
102}
103
104#endif /* __ASSEMBLY__ */
105#endif /* _BFIN_SEMAPHORE_H */
diff --git a/include/asm-blackfin/signal.h b/include/asm-blackfin/signal.h
index 0250429b736a..87951d251458 100644
--- a/include/asm-blackfin/signal.h
+++ b/include/asm-blackfin/signal.h
@@ -143,7 +143,7 @@ struct sigaction {
143#endif /* __KERNEL__ */ 143#endif /* __KERNEL__ */
144 144
145typedef struct sigaltstack { 145typedef struct sigaltstack {
146 void *ss_sp; 146 void __user *ss_sp;
147 int ss_flags; 147 int ss_flags;
148 size_t ss_size; 148 size_t ss_size;
149} stack_t; 149} stack_t;
diff --git a/include/asm-blackfin/thread_info.h b/include/asm-blackfin/thread_info.h
index 15b99cf4f50b..bc2fe5accf20 100644
--- a/include/asm-blackfin/thread_info.h
+++ b/include/asm-blackfin/thread_info.h
@@ -81,14 +81,11 @@ struct thread_info {
81#define init_thread_info (init_thread_union.thread_info) 81#define init_thread_info (init_thread_union.thread_info)
82#define init_stack (init_thread_union.stack) 82#define init_stack (init_thread_union.stack)
83 83
84/* How to get the thread information struct from C */ 84/* Given a task stack pointer, you can find its corresponding
85 85 * thread_info structure just by masking it to the THREAD_SIZE
86static inline struct thread_info *current_thread_info(void) 86 * boundary (currently 8K as you can see above).
87 __attribute__ ((__const__));
88
89/* Given a task stack pointer, you can find it's task structure
90 * just by masking it to the 8K boundary.
91 */ 87 */
88__attribute_const__
92static inline struct thread_info *current_thread_info(void) 89static inline struct thread_info *current_thread_info(void)
93{ 90{
94 struct thread_info *ti; 91 struct thread_info *ti;
diff --git a/include/asm-blackfin/time.h b/include/asm-blackfin/time.h
new file mode 100644
index 000000000000..6e5859b6ea32
--- /dev/null
+++ b/include/asm-blackfin/time.h
@@ -0,0 +1,36 @@
1/*
2 * asm-blackfin/time.h:
3 *
4 * Copyright 2004-2008 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef _ASM_BLACKFIN_TIME_H
10#define _ASM_BLACKFIN_TIME_H
11
12/*
13 * The way that the Blackfin core timer works is:
14 * - CCLK is divided by a programmable 8-bit pre-scaler (TSCALE)
15 * - Every time TSCALE ticks, a 32bit is counted down (TCOUNT)
16 *
17 * If you take the fastest clock (1ns, or 1GHz to make the math work easier)
18 * 10ms is 10,000,000 clock ticks, which fits easy into a 32-bit counter
19 * (32 bit counter is 4,294,967,296ns or 4.2 seconds) so, we don't need
20 * to use TSCALE, and program it to zero (which is pass CCLK through).
21 * If you feel like using it, try to keep HZ * TIMESCALE to some
22 * value that divides easy (like power of 2).
23 */
24
25#ifndef CONFIG_CPU_FREQ
26#define TIME_SCALE 1
27#else
28/*
29 * Blackfin CPU frequency scaling supports max Core Clock 1, 1/2 and 1/4 .
30 * Whenever we change the Core Clock frequency changes we immediately
31 * adjust the Core Timer Presale Register. This way we don't lose time.
32 */
33#define TIME_SCALE 4
34#endif
35
36#endif
diff --git a/include/asm-blackfin/timex.h b/include/asm-blackfin/timex.h
index 828590117f51..22b0806161bb 100644
--- a/include/asm-blackfin/timex.h
+++ b/include/asm-blackfin/timex.h
@@ -1,18 +1,23 @@
1/* blackfin architecture timex specifications: Lineo Inc. 2001 1/*
2 * asm-blackfin/timex.h: cpu cycles!
2 * 3 *
3 * Based on: include/asm-m68knommu/timex.h 4 * Copyright 2004-2008 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
4 */ 7 */
5 8
6#ifndef _ASMBLACKFIN_TIMEX_H 9#ifndef _ASM_BLACKFIN_TIMEX_H
7#define _ASMBLACKFIN_TIMEX_H 10#define _ASM_BLACKFIN_TIMEX_H
8 11
9#define CLOCK_TICK_RATE 1000000 /* Underlying HZ */ 12#define CLOCK_TICK_RATE 1000000 /* Underlying HZ */
10 13
11typedef unsigned long cycles_t; 14typedef unsigned long long cycles_t;
12 15
13static inline cycles_t get_cycles(void) 16static inline cycles_t get_cycles(void)
14{ 17{
15 return 0; 18 unsigned long tmp, tmp2;
19 __asm__("%0 = cycles; %1 = cycles2;" : "=d"(tmp), "=d"(tmp2));
20 return tmp | ((cycles_t)tmp2 << 32);
16} 21}
17 22
18#endif 23#endif
diff --git a/include/asm-blackfin/trace.h b/include/asm-blackfin/trace.h
index ef18afbc2101..312b596b9731 100644
--- a/include/asm-blackfin/trace.h
+++ b/include/asm-blackfin/trace.h
@@ -62,14 +62,14 @@ extern unsigned long software_trace_buff[];
62 preg.L = LO(TBUFCTL); \ 62 preg.L = LO(TBUFCTL); \
63 preg.H = HI(TBUFCTL); \ 63 preg.H = HI(TBUFCTL); \
64 dreg = [preg]; \ 64 dreg = [preg]; \
65 [sp++] = dreg; \ 65 [--sp] = dreg; \
66 dreg = 0x1; \ 66 dreg = 0x1; \
67 [preg] = dreg; 67 [preg] = dreg;
68 68
69#define trace_buffer_restore(preg, dreg) \ 69#define trace_buffer_restore(preg, dreg) \
70 preg.L = LO(TBUFCTL); \ 70 preg.L = LO(TBUFCTL); \
71 preg.H = HI(TBUFCTL); \ 71 preg.H = HI(TBUFCTL); \
72 dreg = [sp--]; \ 72 dreg = [sp++]; \
73 [preg] = dreg; 73 [preg] = dreg;
74 74
75#else /* CONFIG_DEBUG_BFIN_HWTRACE_ON */ 75#else /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
diff --git a/include/asm-blackfin/uaccess.h b/include/asm-blackfin/uaccess.h
index 22a410b8003b..d928b8099056 100644
--- a/include/asm-blackfin/uaccess.h
+++ b/include/asm-blackfin/uaccess.h
@@ -133,7 +133,7 @@ static inline int bad_user_access_length(void)
133} 133}
134 134
135#define __put_user_bad() (printk(KERN_INFO "put_user_bad %s:%d %s\n",\ 135#define __put_user_bad() (printk(KERN_INFO "put_user_bad %s:%d %s\n",\
136 __FILE__, __LINE__, __FUNCTION__),\ 136 __FILE__, __LINE__, __func__),\
137 bad_user_access_length(), (-EFAULT)) 137 bad_user_access_length(), (-EFAULT))
138 138
139/* 139/*
@@ -177,7 +177,7 @@ static inline int bad_user_access_length(void)
177 default: \ 177 default: \
178 x = 0; \ 178 x = 0; \
179 printk(KERN_INFO "get_user_bad: %s:%d %s\n", \ 179 printk(KERN_INFO "get_user_bad: %s:%d %s\n", \
180 __FILE__, __LINE__, __FUNCTION__); \ 180 __FILE__, __LINE__, __func__); \
181 _err = __get_user_bad(); \ 181 _err = __get_user_bad(); \
182 break; \ 182 break; \
183 } \ 183 } \
diff --git a/include/asm-blackfin/unaligned.h b/include/asm-blackfin/unaligned.h
index 10081dc241ef..fd8a1d634945 100644
--- a/include/asm-blackfin/unaligned.h
+++ b/include/asm-blackfin/unaligned.h
@@ -1,6 +1,11 @@
1#ifndef __BFIN_UNALIGNED_H 1#ifndef _ASM_BLACKFIN_UNALIGNED_H
2#define __BFIN_UNALIGNED_H 2#define _ASM_BLACKFIN_UNALIGNED_H
3 3
4#include <asm-generic/unaligned.h> 4#include <linux/unaligned/le_struct.h>
5#include <linux/unaligned/be_byteshift.h>
6#include <linux/unaligned/generic.h>
5 7
6#endif /* __BFIN_UNALIGNED_H */ 8#define get_unaligned __get_unaligned_le
9#define put_unaligned __put_unaligned_le
10
11#endif /* _ASM_BLACKFIN_UNALIGNED_H */
diff --git a/include/asm-blackfin/unistd.h b/include/asm-blackfin/unistd.h
index c18a399f6e3e..42955d0c439b 100644
--- a/include/asm-blackfin/unistd.h
+++ b/include/asm-blackfin/unistd.h
@@ -265,14 +265,14 @@
265 /* 258 __NR_remap_file_pages */ 265 /* 258 __NR_remap_file_pages */
266#define __NR_set_tid_address 259 266#define __NR_set_tid_address 259
267#define __NR_timer_create 260 267#define __NR_timer_create 260
268#define __NR_timer_settime (__NR_timer_create+1) 268#define __NR_timer_settime 261
269#define __NR_timer_gettime (__NR_timer_create+2) 269#define __NR_timer_gettime 262
270#define __NR_timer_getoverrun (__NR_timer_create+3) 270#define __NR_timer_getoverrun 263
271#define __NR_timer_delete (__NR_timer_create+4) 271#define __NR_timer_delete 264
272#define __NR_clock_settime (__NR_timer_create+5) 272#define __NR_clock_settime 265
273#define __NR_clock_gettime (__NR_timer_create+6) 273#define __NR_clock_gettime 266
274#define __NR_clock_getres (__NR_timer_create+7) 274#define __NR_clock_getres 267
275#define __NR_clock_nanosleep (__NR_timer_create+8) 275#define __NR_clock_nanosleep 268
276#define __NR_statfs64 269 276#define __NR_statfs64 269
277#define __NR_fstatfs64 270 277#define __NR_fstatfs64 270
278#define __NR_tgkill 271 278#define __NR_tgkill 271
@@ -283,11 +283,11 @@
283 /* 276 __NR_get_mempolicy */ 283 /* 276 __NR_get_mempolicy */
284 /* 277 __NR_set_mempolicy */ 284 /* 277 __NR_set_mempolicy */
285#define __NR_mq_open 278 285#define __NR_mq_open 278
286#define __NR_mq_unlink (__NR_mq_open+1) 286#define __NR_mq_unlink 279
287#define __NR_mq_timedsend (__NR_mq_open+2) 287#define __NR_mq_timedsend 280
288#define __NR_mq_timedreceive (__NR_mq_open+3) 288#define __NR_mq_timedreceive 281
289#define __NR_mq_notify (__NR_mq_open+4) 289#define __NR_mq_notify 282
290#define __NR_mq_getsetattr (__NR_mq_open+5) 290#define __NR_mq_getsetattr 283
291#define __NR_kexec_load 284 291#define __NR_kexec_load 284
292#define __NR_waitid 285 292#define __NR_waitid 285
293#define __NR_add_key 286 293#define __NR_add_key 286
diff --git a/include/asm-cris/arch-v10/ide.h b/include/asm-cris/arch-v10/ide.h
index ea34e0d0a388..5366e6239328 100644
--- a/include/asm-cris/arch-v10/ide.h
+++ b/include/asm-cris/arch-v10/ide.h
@@ -59,22 +59,19 @@ static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, u
59 int i; 59 int i;
60 60
61 /* fill in ports for ATA addresses 0 to 7 */ 61 /* fill in ports for ATA addresses 0 to 7 */
62 62 for (i = 0; i <= 7; i++) {
63 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { 63 hw->io_ports_array[i] = data_port |
64 hw->io_ports[i] = data_port |
65 IO_FIELD(R_ATA_CTRL_DATA, addr, i) | 64 IO_FIELD(R_ATA_CTRL_DATA, addr, i) |
66 IO_STATE(R_ATA_CTRL_DATA, cs0, active); 65 IO_STATE(R_ATA_CTRL_DATA, cs0, active);
67 } 66 }
68 67
69 /* the IDE control register is at ATA address 6, with CS1 active instead of CS0 */ 68 /* the IDE control register is at ATA address 6, with CS1 active instead of CS0 */
70 69 hw->io_ports.ctl_addr = data_port |
71 hw->io_ports[IDE_CONTROL_OFFSET] = data_port |
72 IO_FIELD(R_ATA_CTRL_DATA, addr, 6) | 70 IO_FIELD(R_ATA_CTRL_DATA, addr, 6) |
73 IO_STATE(R_ATA_CTRL_DATA, cs1, active); 71 IO_STATE(R_ATA_CTRL_DATA, cs1, active);
74 72
75 /* whats this for ? */ 73 /* whats this for ? */
76 74 hw->io_ports.irq_addr = 0;
77 hw->io_ports[IDE_IRQ_OFFSET] = 0;
78} 75}
79 76
80static inline void ide_init_default_hwifs(void) 77static inline void ide_init_default_hwifs(void)
diff --git a/include/asm-cris/pgtable.h b/include/asm-cris/pgtable.h
index a2607575681b..829e7a7d9fb9 100644
--- a/include/asm-cris/pgtable.h
+++ b/include/asm-cris/pgtable.h
@@ -115,6 +115,7 @@ static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WR
115static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_MODIFIED; } 115static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_MODIFIED; }
116static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 116static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
117static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 117static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
118static inline int pte_special(pte_t pte) { return 0; }
118 119
119static inline pte_t pte_wrprotect(pte_t pte) 120static inline pte_t pte_wrprotect(pte_t pte)
120{ 121{
@@ -162,6 +163,7 @@ static inline pte_t pte_mkyoung(pte_t pte)
162 } 163 }
163 return pte; 164 return pte;
164} 165}
166static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
165 167
166/* 168/*
167 * Conversion functions: convert a page and protection to a page entry, 169 * Conversion functions: convert a page and protection to a page entry,
@@ -229,7 +231,7 @@ static inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
229#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 231#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
230 232
231/* to find an entry in a page-table-directory */ 233/* to find an entry in a page-table-directory */
232static inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address) 234static inline pgd_t * pgd_offset(const struct mm_struct *mm, unsigned long address)
233{ 235{
234 return mm->pgd + pgd_index(address); 236 return mm->pgd + pgd_index(address);
235} 237}
diff --git a/include/asm-cris/semaphore-helper.h b/include/asm-cris/semaphore-helper.h
deleted file mode 100644
index 27bfeca1b981..000000000000
--- a/include/asm-cris/semaphore-helper.h
+++ /dev/null
@@ -1,78 +0,0 @@
1/* $Id: semaphore-helper.h,v 1.3 2001/03/26 15:00:33 orjanf Exp $
2 *
3 * SMP- and interrupt-safe semaphores helper functions. Generic versions, no
4 * optimizations whatsoever...
5 *
6 */
7
8#ifndef _ASM_SEMAPHORE_HELPER_H
9#define _ASM_SEMAPHORE_HELPER_H
10
11#include <asm/atomic.h>
12#include <linux/errno.h>
13
14#define read(a) ((a)->counter)
15#define inc(a) (((a)->counter)++)
16#define dec(a) (((a)->counter)--)
17
18#define count_inc(a) ((*(a))++)
19
20/*
21 * These two _must_ execute atomically wrt each other.
22 */
23static inline void wake_one_more(struct semaphore * sem)
24{
25 atomic_inc(&sem->waking);
26}
27
28static inline int waking_non_zero(struct semaphore *sem)
29{
30 unsigned long flags;
31 int ret = 0;
32
33 local_irq_save(flags);
34 if (read(&sem->waking) > 0) {
35 dec(&sem->waking);
36 ret = 1;
37 }
38 local_irq_restore(flags);
39 return ret;
40}
41
42static inline int waking_non_zero_interruptible(struct semaphore *sem,
43 struct task_struct *tsk)
44{
45 int ret = 0;
46 unsigned long flags;
47
48 local_irq_save(flags);
49 if (read(&sem->waking) > 0) {
50 dec(&sem->waking);
51 ret = 1;
52 } else if (signal_pending(tsk)) {
53 inc(&sem->count);
54 ret = -EINTR;
55 }
56 local_irq_restore(flags);
57 return ret;
58}
59
60static inline int waking_non_zero_trylock(struct semaphore *sem)
61{
62 int ret = 1;
63 unsigned long flags;
64
65 local_irq_save(flags);
66 if (read(&sem->waking) <= 0)
67 inc(&sem->count);
68 else {
69 dec(&sem->waking);
70 ret = 0;
71 }
72 local_irq_restore(flags);
73 return ret;
74}
75
76#endif /* _ASM_SEMAPHORE_HELPER_H */
77
78
diff --git a/include/asm-cris/semaphore.h b/include/asm-cris/semaphore.h
index 31a4ac448195..d9b2034ed1d2 100644
--- a/include/asm-cris/semaphore.h
+++ b/include/asm-cris/semaphore.h
@@ -1,133 +1 @@
1/* $Id: semaphore.h,v 1.3 2001/05/08 13:54:09 bjornw Exp $ */ #include <linux/semaphore.h>
2
3/* On the i386 these are coded in asm, perhaps we should as well. Later.. */
4
5#ifndef _CRIS_SEMAPHORE_H
6#define _CRIS_SEMAPHORE_H
7
8#define RW_LOCK_BIAS 0x01000000
9
10#include <linux/wait.h>
11#include <linux/spinlock.h>
12#include <linux/rwsem.h>
13
14#include <asm/system.h>
15#include <asm/atomic.h>
16
17/*
18 * CRIS semaphores, implemented in C-only so far.
19 */
20
21struct semaphore {
22 atomic_t count;
23 atomic_t waking;
24 wait_queue_head_t wait;
25};
26
27#define __SEMAPHORE_INITIALIZER(name, n) \
28{ \
29 .count = ATOMIC_INIT(n), \
30 .waking = ATOMIC_INIT(0), \
31 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
32}
33
34#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
35 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
36
37#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
38
39static inline void sema_init(struct semaphore *sem, int val)
40{
41 *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
42}
43
44static inline void init_MUTEX (struct semaphore *sem)
45{
46 sema_init(sem, 1);
47}
48
49static inline void init_MUTEX_LOCKED (struct semaphore *sem)
50{
51 sema_init(sem, 0);
52}
53
54extern void __down(struct semaphore * sem);
55extern int __down_interruptible(struct semaphore * sem);
56extern int __down_trylock(struct semaphore * sem);
57extern void __up(struct semaphore * sem);
58
59/* notice - we probably can do cli/sti here instead of saving */
60
61static inline void down(struct semaphore * sem)
62{
63 unsigned long flags;
64 int failed;
65
66 might_sleep();
67
68 /* atomically decrement the semaphores count, and if its negative, we wait */
69 cris_atomic_save(sem, flags);
70 failed = --(sem->count.counter) < 0;
71 cris_atomic_restore(sem, flags);
72 if(failed) {
73 __down(sem);
74 }
75}
76
77/*
78 * This version waits in interruptible state so that the waiting
79 * process can be killed. The down_interruptible routine
80 * returns negative for signalled and zero for semaphore acquired.
81 */
82
83static inline int down_interruptible(struct semaphore * sem)
84{
85 unsigned long flags;
86 int failed;
87
88 might_sleep();
89
90 /* atomically decrement the semaphores count, and if its negative, we wait */
91 cris_atomic_save(sem, flags);
92 failed = --(sem->count.counter) < 0;
93 cris_atomic_restore(sem, flags);
94 if(failed)
95 failed = __down_interruptible(sem);
96 return(failed);
97}
98
99static inline int down_trylock(struct semaphore * sem)
100{
101 unsigned long flags;
102 int failed;
103
104 cris_atomic_save(sem, flags);
105 failed = --(sem->count.counter) < 0;
106 cris_atomic_restore(sem, flags);
107 if(failed)
108 failed = __down_trylock(sem);
109 return(failed);
110
111}
112
113/*
114 * Note! This is subtle. We jump to wake people up only if
115 * the semaphore was negative (== somebody was waiting on it).
116 * The default case (no contention) will result in NO
117 * jumps for both down() and up().
118 */
119static inline void up(struct semaphore * sem)
120{
121 unsigned long flags;
122 int wakeup;
123
124 /* atomically increment the semaphores count, and if it was negative, we wake people */
125 cris_atomic_save(sem, flags);
126 wakeup = ++(sem->count.counter) <= 0;
127 cris_atomic_restore(sem, flags);
128 if(wakeup) {
129 __up(sem);
130 }
131}
132
133#endif
diff --git a/include/asm-cris/unaligned.h b/include/asm-cris/unaligned.h
index 7fbbb399f6f1..7b3f3fec567c 100644
--- a/include/asm-cris/unaligned.h
+++ b/include/asm-cris/unaligned.h
@@ -1,16 +1,13 @@
1#ifndef __CRIS_UNALIGNED_H 1#ifndef _ASM_CRIS_UNALIGNED_H
2#define __CRIS_UNALIGNED_H 2#define _ASM_CRIS_UNALIGNED_H
3 3
4/* 4/*
5 * CRIS can do unaligned accesses itself. 5 * CRIS can do unaligned accesses itself.
6 *
7 * The strange macros are there to make sure these can't
8 * be misused in a way that makes them not work on other
9 * architectures where unaligned accesses aren't as simple.
10 */ 6 */
7#include <linux/unaligned/access_ok.h>
8#include <linux/unaligned/generic.h>
11 9
12#define get_unaligned(ptr) (*(ptr)) 10#define get_unaligned __get_unaligned_le
11#define put_unaligned __put_unaligned_le
13 12
14#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) 13#endif /* _ASM_CRIS_UNALIGNED_H */
15
16#endif
diff --git a/include/asm-frv/pgtable.h b/include/asm-frv/pgtable.h
index 4e219046fe42..83c51aba534b 100644
--- a/include/asm-frv/pgtable.h
+++ b/include/asm-frv/pgtable.h
@@ -380,6 +380,7 @@ static inline pmd_t *pmd_offset(pud_t *dir, unsigned long address)
380static inline int pte_dirty(pte_t pte) { return (pte).pte & _PAGE_DIRTY; } 380static inline int pte_dirty(pte_t pte) { return (pte).pte & _PAGE_DIRTY; }
381static inline int pte_young(pte_t pte) { return (pte).pte & _PAGE_ACCESSED; } 381static inline int pte_young(pte_t pte) { return (pte).pte & _PAGE_ACCESSED; }
382static inline int pte_write(pte_t pte) { return !((pte).pte & _PAGE_WP); } 382static inline int pte_write(pte_t pte) { return !((pte).pte & _PAGE_WP); }
383static inline int pte_special(pte_t pte) { return 0; }
383 384
384static inline pte_t pte_mkclean(pte_t pte) { (pte).pte &= ~_PAGE_DIRTY; return pte; } 385static inline pte_t pte_mkclean(pte_t pte) { (pte).pte &= ~_PAGE_DIRTY; return pte; }
385static inline pte_t pte_mkold(pte_t pte) { (pte).pte &= ~_PAGE_ACCESSED; return pte; } 386static inline pte_t pte_mkold(pte_t pte) { (pte).pte &= ~_PAGE_ACCESSED; return pte; }
@@ -387,6 +388,7 @@ static inline pte_t pte_wrprotect(pte_t pte) { (pte).pte |= _PAGE_WP; return pte
387static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte |= _PAGE_DIRTY; return pte; } 388static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte |= _PAGE_DIRTY; return pte; }
388static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte |= _PAGE_ACCESSED; return pte; } 389static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte |= _PAGE_ACCESSED; return pte; }
389static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte &= ~_PAGE_WP; return pte; } 390static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte &= ~_PAGE_WP; return pte; }
391static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
390 392
391static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) 393static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
392{ 394{
diff --git a/include/asm-frv/semaphore.h b/include/asm-frv/semaphore.h
index d7aaa1911a1a..d9b2034ed1d2 100644
--- a/include/asm-frv/semaphore.h
+++ b/include/asm-frv/semaphore.h
@@ -1,155 +1 @@
1/* semaphore.h: semaphores for the FR-V #include <linux/semaphore.h>
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_SEMAPHORE_H
12#define _ASM_SEMAPHORE_H
13
14#define RW_LOCK_BIAS 0x01000000
15
16#ifndef __ASSEMBLY__
17
18#include <linux/linkage.h>
19#include <linux/wait.h>
20#include <linux/spinlock.h>
21#include <linux/rwsem.h>
22
23/*
24 * the semaphore definition
25 * - if counter is >0 then there are tokens available on the semaphore for down to collect
26 * - if counter is <=0 then there are no spare tokens, and anyone that wants one must wait
27 * - if wait_list is not empty, then there are processes waiting for the semaphore
28 */
29struct semaphore {
30 unsigned counter;
31 spinlock_t wait_lock;
32 struct list_head wait_list;
33#ifdef CONFIG_DEBUG_SEMAPHORE
34 unsigned __magic;
35#endif
36};
37
38#ifdef CONFIG_DEBUG_SEMAPHORE
39# define __SEM_DEBUG_INIT(name) , (long)&(name).__magic
40#else
41# define __SEM_DEBUG_INIT(name)
42#endif
43
44
45#define __SEMAPHORE_INITIALIZER(name,count) \
46{ count, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) __SEM_DEBUG_INIT(name) }
47
48#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
49 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
50
51#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
52
53static inline void sema_init (struct semaphore *sem, int val)
54{
55 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
56}
57
58static inline void init_MUTEX (struct semaphore *sem)
59{
60 sema_init(sem, 1);
61}
62
63static inline void init_MUTEX_LOCKED (struct semaphore *sem)
64{
65 sema_init(sem, 0);
66}
67
68extern void __down(struct semaphore *sem, unsigned long flags);
69extern int __down_interruptible(struct semaphore *sem, unsigned long flags);
70extern void __up(struct semaphore *sem);
71
72static inline void down(struct semaphore *sem)
73{
74 unsigned long flags;
75
76#ifdef CONFIG_DEBUG_SEMAPHORE
77 CHECK_MAGIC(sem->__magic);
78#endif
79
80 spin_lock_irqsave(&sem->wait_lock, flags);
81 if (likely(sem->counter > 0)) {
82 sem->counter--;
83 spin_unlock_irqrestore(&sem->wait_lock, flags);
84 }
85 else {
86 __down(sem, flags);
87 }
88}
89
90static inline int down_interruptible(struct semaphore *sem)
91{
92 unsigned long flags;
93 int ret = 0;
94
95#ifdef CONFIG_DEBUG_SEMAPHORE
96 CHECK_MAGIC(sem->__magic);
97#endif
98
99 spin_lock_irqsave(&sem->wait_lock, flags);
100 if (likely(sem->counter > 0)) {
101 sem->counter--;
102 spin_unlock_irqrestore(&sem->wait_lock, flags);
103 }
104 else {
105 ret = __down_interruptible(sem, flags);
106 }
107 return ret;
108}
109
110/*
111 * non-blockingly attempt to down() a semaphore.
112 * - returns zero if we acquired it
113 */
114static inline int down_trylock(struct semaphore *sem)
115{
116 unsigned long flags;
117 int success = 0;
118
119#ifdef CONFIG_DEBUG_SEMAPHORE
120 CHECK_MAGIC(sem->__magic);
121#endif
122
123 spin_lock_irqsave(&sem->wait_lock, flags);
124 if (sem->counter > 0) {
125 sem->counter--;
126 success = 1;
127 }
128 spin_unlock_irqrestore(&sem->wait_lock, flags);
129 return !success;
130}
131
132static inline void up(struct semaphore *sem)
133{
134 unsigned long flags;
135
136#ifdef CONFIG_DEBUG_SEMAPHORE
137 CHECK_MAGIC(sem->__magic);
138#endif
139
140 spin_lock_irqsave(&sem->wait_lock, flags);
141 if (!list_empty(&sem->wait_list))
142 __up(sem);
143 else
144 sem->counter++;
145 spin_unlock_irqrestore(&sem->wait_lock, flags);
146}
147
148static inline int sem_getcount(struct semaphore *sem)
149{
150 return sem->counter;
151}
152
153#endif /* __ASSEMBLY__ */
154
155#endif
diff --git a/include/asm-frv/system.h b/include/asm-frv/system.h
index 30a67a9da11a..cb307f8a6b48 100644
--- a/include/asm-frv/system.h
+++ b/include/asm-frv/system.h
@@ -197,11 +197,6 @@ do { \
197 do { var = (value); barrier(); } while (0) 197 do { var = (value); barrier(); } while (0)
198#endif 198#endif
199 199
200#define HARD_RESET_NOW() \
201do { \
202 cli(); \
203} while(1)
204
205extern void die_if_kernel(const char *, ...) __attribute__((format(printf, 1, 2))); 200extern void die_if_kernel(const char *, ...) __attribute__((format(printf, 1, 2)));
206extern void free_initmem(void); 201extern void free_initmem(void);
207 202
diff --git a/include/asm-frv/topology.h b/include/asm-frv/topology.h
index abe7298742ac..942724352705 100644
--- a/include/asm-frv/topology.h
+++ b/include/asm-frv/topology.h
@@ -5,10 +5,8 @@
5 5
6#error NUMA not supported yet 6#error NUMA not supported yet
7 7
8#else /* !CONFIG_NUMA */ 8#endif /* CONFIG_NUMA */
9 9
10#include <asm-generic/topology.h> 10#include <asm-generic/topology.h>
11 11
12#endif /* CONFIG_NUMA */
13
14#endif /* _ASM_TOPOLOGY_H */ 12#endif /* _ASM_TOPOLOGY_H */
diff --git a/include/asm-frv/unaligned.h b/include/asm-frv/unaligned.h
index dc8e9c9bf6bd..839a2fbffa0f 100644
--- a/include/asm-frv/unaligned.h
+++ b/include/asm-frv/unaligned.h
@@ -12,191 +12,11 @@
12#ifndef _ASM_UNALIGNED_H 12#ifndef _ASM_UNALIGNED_H
13#define _ASM_UNALIGNED_H 13#define _ASM_UNALIGNED_H
14 14
15#include <linux/unaligned/le_byteshift.h>
16#include <linux/unaligned/be_byteshift.h>
17#include <linux/unaligned/generic.h>
15 18
16/* 19#define get_unaligned __get_unaligned_be
17 * Unaligned accesses on uClinux can't be performed in a fault handler - the 20#define put_unaligned __put_unaligned_be
18 * CPU detects them as imprecise exceptions making this impossible.
19 *
20 * With the FR451, however, they are precise, and so we used to fix them up in
21 * the memory access fault handler. However, instruction bundling make this
22 * impractical. So, now we fall back to using memcpy.
23 */
24#ifdef CONFIG_MMU
25
26/*
27 * The asm statement in the macros below is a way to get GCC to copy a
28 * value from one variable to another without having any clue it's
29 * actually doing so, so that it won't have any idea that the values
30 * in the two variables are related.
31 */
32
33#define get_unaligned(ptr) ({ \
34 typeof((*(ptr))) __x; \
35 void *__ptrcopy; \
36 asm("" : "=r" (__ptrcopy) : "0" (ptr)); \
37 memcpy(&__x, __ptrcopy, sizeof(*(ptr))); \
38 __x; \
39})
40
41#define put_unaligned(val, ptr) ({ \
42 typeof((*(ptr))) __x = (val); \
43 void *__ptrcopy; \
44 asm("" : "=r" (__ptrcopy) : "0" (ptr)); \
45 memcpy(__ptrcopy, &__x, sizeof(*(ptr))); \
46})
47
48extern int handle_misalignment(unsigned long esr0, unsigned long ear0, unsigned long epcr0);
49
50#else
51
52#define get_unaligned(ptr) \
53({ \
54 typeof(*(ptr)) x; \
55 const char *__p = (const char *) (ptr); \
56 \
57 switch (sizeof(x)) { \
58 case 1: \
59 x = *(ptr); \
60 break; \
61 case 2: \
62 { \
63 uint8_t a; \
64 asm(" ldub%I2 %M2,%0 \n" \
65 " ldub%I3.p %M3,%1 \n" \
66 " slli %0,#8,%0 \n" \
67 " or %0,%1,%0 \n" \
68 : "=&r"(x), "=&r"(a) \
69 : "m"(__p[0]), "m"(__p[1]) \
70 ); \
71 break; \
72 } \
73 \
74 case 4: \
75 { \
76 uint8_t a; \
77 asm(" ldub%I2 %M2,%0 \n" \
78 " ldub%I3.p %M3,%1 \n" \
79 " slli %0,#8,%0 \n" \
80 " or %0,%1,%0 \n" \
81 " ldub%I4.p %M4,%1 \n" \
82 " slli %0,#8,%0 \n" \
83 " or %0,%1,%0 \n" \
84 " ldub%I5.p %M5,%1 \n" \
85 " slli %0,#8,%0 \n" \
86 " or %0,%1,%0 \n" \
87 : "=&r"(x), "=&r"(a) \
88 : "m"(__p[0]), "m"(__p[1]), "m"(__p[2]), "m"(__p[3]) \
89 ); \
90 break; \
91 } \
92 \
93 case 8: \
94 { \
95 union { uint64_t x; u32 y[2]; } z; \
96 uint8_t a; \
97 asm(" ldub%I3 %M3,%0 \n" \
98 " ldub%I4.p %M4,%2 \n" \
99 " slli %0,#8,%0 \n" \
100 " or %0,%2,%0 \n" \
101 " ldub%I5.p %M5,%2 \n" \
102 " slli %0,#8,%0 \n" \
103 " or %0,%2,%0 \n" \
104 " ldub%I6.p %M6,%2 \n" \
105 " slli %0,#8,%0 \n" \
106 " or %0,%2,%0 \n" \
107 " ldub%I7 %M7,%1 \n" \
108 " ldub%I8.p %M8,%2 \n" \
109 " slli %1,#8,%1 \n" \
110 " or %1,%2,%1 \n" \
111 " ldub%I9.p %M9,%2 \n" \
112 " slli %1,#8,%1 \n" \
113 " or %1,%2,%1 \n" \
114 " ldub%I10.p %M10,%2 \n" \
115 " slli %1,#8,%1 \n" \
116 " or %1,%2,%1 \n" \
117 : "=&r"(z.y[0]), "=&r"(z.y[1]), "=&r"(a) \
118 : "m"(__p[0]), "m"(__p[1]), "m"(__p[2]), "m"(__p[3]), \
119 "m"(__p[4]), "m"(__p[5]), "m"(__p[6]), "m"(__p[7]) \
120 ); \
121 x = z.x; \
122 break; \
123 } \
124 \
125 default: \
126 x = 0; \
127 BUG(); \
128 break; \
129 } \
130 \
131 x; \
132})
133
134#define put_unaligned(val, ptr) \
135do { \
136 char *__p = (char *) (ptr); \
137 int x; \
138 \
139 switch (sizeof(*ptr)) { \
140 case 2: \
141 { \
142 asm(" stb%I1.p %0,%M1 \n" \
143 " srli %0,#8,%0 \n" \
144 " stb%I2 %0,%M2 \n" \
145 : "=r"(x), "=m"(__p[1]), "=m"(__p[0]) \
146 : "0"(val) \
147 ); \
148 break; \
149 } \
150 \
151 case 4: \
152 { \
153 asm(" stb%I1.p %0,%M1 \n" \
154 " srli %0,#8,%0 \n" \
155 " stb%I2.p %0,%M2 \n" \
156 " srli %0,#8,%0 \n" \
157 " stb%I3.p %0,%M3 \n" \
158 " srli %0,#8,%0 \n" \
159 " stb%I4 %0,%M4 \n" \
160 : "=r"(x), "=m"(__p[3]), "=m"(__p[2]), "=m"(__p[1]), "=m"(__p[0]) \
161 : "0"(val) \
162 ); \
163 break; \
164 } \
165 \
166 case 8: \
167 { \
168 uint32_t __high, __low; \
169 __high = (uint64_t)val >> 32; \
170 __low = val & 0xffffffff; \
171 asm(" stb%I2.p %0,%M2 \n" \
172 " srli %0,#8,%0 \n" \
173 " stb%I3.p %0,%M3 \n" \
174 " srli %0,#8,%0 \n" \
175 " stb%I4.p %0,%M4 \n" \
176 " srli %0,#8,%0 \n" \
177 " stb%I5.p %0,%M5 \n" \
178 " srli %0,#8,%0 \n" \
179 " stb%I6.p %1,%M6 \n" \
180 " srli %1,#8,%1 \n" \
181 " stb%I7.p %1,%M7 \n" \
182 " srli %1,#8,%1 \n" \
183 " stb%I8.p %1,%M8 \n" \
184 " srli %1,#8,%1 \n" \
185 " stb%I9 %1,%M9 \n" \
186 : "=&r"(__low), "=&r"(__high), "=m"(__p[7]), "=m"(__p[6]), \
187 "=m"(__p[5]), "=m"(__p[4]), "=m"(__p[3]), "=m"(__p[2]), \
188 "=m"(__p[1]), "=m"(__p[0]) \
189 : "0"(__low), "1"(__high) \
190 ); \
191 break; \
192 } \
193 \
194 default: \
195 *(ptr) = (val); \
196 break; \
197 } \
198} while(0)
199
200#endif
201 21
202#endif 22#endif /* _ASM_UNALIGNED_H */
diff --git a/include/asm-generic/bitops.h b/include/asm-generic/bitops.h
index 15e6f253dda4..c9f369c4bd7e 100644
--- a/include/asm-generic/bitops.h
+++ b/include/asm-generic/bitops.h
@@ -17,8 +17,6 @@
17#include <asm-generic/bitops/fls64.h> 17#include <asm-generic/bitops/fls64.h>
18#include <asm-generic/bitops/find.h> 18#include <asm-generic/bitops/find.h>
19 19
20#ifdef __KERNEL__
21
22#ifndef _LINUX_BITOPS_H 20#ifndef _LINUX_BITOPS_H
23#error only <linux/bitops.h> can be included directly 21#error only <linux/bitops.h> can be included directly
24#endif 22#endif
@@ -32,6 +30,4 @@
32#include <asm-generic/bitops/ext2-atomic.h> 30#include <asm-generic/bitops/ext2-atomic.h>
33#include <asm-generic/bitops/minix.h> 31#include <asm-generic/bitops/minix.h>
34 32
35#endif /* __KERNEL__ */
36
37#endif /* _ASM_GENERIC_BITOPS_H */ 33#endif /* _ASM_GENERIC_BITOPS_H */
diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
new file mode 100644
index 000000000000..be24465403d6
--- /dev/null
+++ b/include/asm-generic/bitops/__fls.h
@@ -0,0 +1,43 @@
1#ifndef _ASM_GENERIC_BITOPS___FLS_H_
2#define _ASM_GENERIC_BITOPS___FLS_H_
3
4#include <asm/types.h>
5
6/**
7 * __fls - find last (most-significant) set bit in a long word
8 * @word: the word to search
9 *
10 * Undefined if no set bit exists, so code should check against 0 first.
11 */
12static inline unsigned long __fls(unsigned long word)
13{
14 int num = BITS_PER_LONG - 1;
15
16#if BITS_PER_LONG == 64
17 if (!(word & (~0ul << 32))) {
18 num -= 32;
19 word <<= 32;
20 }
21#endif
22 if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
23 num -= 16;
24 word <<= 16;
25 }
26 if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
27 num -= 8;
28 word <<= 8;
29 }
30 if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
31 num -= 4;
32 word <<= 4;
33 }
34 if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
35 num -= 2;
36 word <<= 2;
37 }
38 if (!(word & (~0ul << (BITS_PER_LONG-1))))
39 num -= 1;
40 return num;
41}
42
43#endif /* _ASM_GENERIC_BITOPS___FLS_H_ */
diff --git a/include/asm-generic/bitops/find.h b/include/asm-generic/bitops/find.h
index 72a51e5a12ef..1914e9742512 100644
--- a/include/asm-generic/bitops/find.h
+++ b/include/asm-generic/bitops/find.h
@@ -1,11 +1,13 @@
1#ifndef _ASM_GENERIC_BITOPS_FIND_H_ 1#ifndef _ASM_GENERIC_BITOPS_FIND_H_
2#define _ASM_GENERIC_BITOPS_FIND_H_ 2#define _ASM_GENERIC_BITOPS_FIND_H_
3 3
4#ifndef CONFIG_GENERIC_FIND_NEXT_BIT
4extern unsigned long find_next_bit(const unsigned long *addr, unsigned long 5extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
5 size, unsigned long offset); 6 size, unsigned long offset);
6 7
7extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned 8extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
8 long size, unsigned long offset); 9 long size, unsigned long offset);
10#endif
9 11
10#define find_first_bit(addr, size) find_next_bit((addr), (size), 0) 12#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
11#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) 13#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
index 1b6b17ce2428..86d403f8b256 100644
--- a/include/asm-generic/bitops/fls64.h
+++ b/include/asm-generic/bitops/fls64.h
@@ -3,6 +3,18 @@
3 3
4#include <asm/types.h> 4#include <asm/types.h>
5 5
6/**
7 * fls64 - find last set bit in a 64-bit word
8 * @x: the word to search
9 *
10 * This is defined in a similar way as the libc and compiler builtin
11 * ffsll, but returns the position of the most significant set bit.
12 *
13 * fls64(value) returns 0 if value is 0 or the position of the last
14 * set bit if value is nonzero. The last (most significant) bit is
15 * at position 64.
16 */
17#if BITS_PER_LONG == 32
6static inline int fls64(__u64 x) 18static inline int fls64(__u64 x)
7{ 19{
8 __u32 h = x >> 32; 20 __u32 h = x >> 32;
@@ -10,5 +22,15 @@ static inline int fls64(__u64 x)
10 return fls(h) + 32; 22 return fls(h) + 32;
11 return fls(x); 23 return fls(x);
12} 24}
25#elif BITS_PER_LONG == 64
26static inline int fls64(__u64 x)
27{
28 if (x == 0)
29 return 0;
30 return __fls(x) + 1;
31}
32#else
33#error BITS_PER_LONG not 32 or 64
34#endif
13 35
14#endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */ 36#endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index a4a49370793c..8f4e3193342e 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -30,11 +30,6 @@
30 __rem; \ 30 __rem; \
31 }) 31 })
32 32
33static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
34{
35 return dividend / divisor;
36}
37
38#elif BITS_PER_LONG == 32 33#elif BITS_PER_LONG == 32
39 34
40extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); 35extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
@@ -54,8 +49,6 @@ extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
54 __rem; \ 49 __rem; \
55 }) 50 })
56 51
57extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
58
59#else /* BITS_PER_LONG == ?? */ 52#else /* BITS_PER_LONG == ?? */
60 53
61# error do_div() does not yet support the C64 54# error do_div() does not yet support the C64
diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
index f422df0956a2..3c2344f48136 100644
--- a/include/asm-generic/futex.h
+++ b/include/asm-generic/futex.h
@@ -1,11 +1,9 @@
1#ifndef _ASM_GENERIC_FUTEX_H 1#ifndef _ASM_GENERIC_FUTEX_H
2#define _ASM_GENERIC_FUTEX_H 2#define _ASM_GENERIC_FUTEX_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/futex.h> 4#include <linux/futex.h>
5#include <linux/uaccess.h>
7#include <asm/errno.h> 6#include <asm/errno.h>
8#include <asm/uaccess.h>
9 7
10static inline int 8static inline int
11futex_atomic_op_inuser (int encoded_op, int __user *uaddr) 9futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
@@ -56,4 +54,3 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
56} 54}
57 55
58#endif 56#endif
59#endif
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index f29a502f4a6c..ecf675a59d21 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -16,7 +16,14 @@
16#define ARCH_NR_GPIOS 256 16#define ARCH_NR_GPIOS 256
17#endif 17#endif
18 18
19static inline int gpio_is_valid(int number)
20{
21 /* only some non-negative numbers are valid */
22 return ((unsigned)number) < ARCH_NR_GPIOS;
23}
24
19struct seq_file; 25struct seq_file;
26struct module;
20 27
21/** 28/**
22 * struct gpio_chip - abstract a GPIO controller 29 * struct gpio_chip - abstract a GPIO controller
@@ -48,6 +55,7 @@ struct seq_file;
48 */ 55 */
49struct gpio_chip { 56struct gpio_chip {
50 char *label; 57 char *label;
58 struct module *owner;
51 59
52 int (*direction_input)(struct gpio_chip *chip, 60 int (*direction_input)(struct gpio_chip *chip,
53 unsigned offset); 61 unsigned offset);
@@ -66,6 +74,7 @@ struct gpio_chip {
66 74
67extern const char *gpiochip_is_requested(struct gpio_chip *chip, 75extern const char *gpiochip_is_requested(struct gpio_chip *chip,
68 unsigned offset); 76 unsigned offset);
77extern int __init __must_check gpiochip_reserve(int start, int ngpio);
69 78
70/* add/remove chips */ 79/* add/remove chips */
71extern int gpiochip_add(struct gpio_chip *chip); 80extern int gpiochip_add(struct gpio_chip *chip);
@@ -97,6 +106,12 @@ extern int __gpio_cansleep(unsigned gpio);
97 106
98#else 107#else
99 108
109static inline int gpio_is_valid(int number)
110{
111 /* only non-negative numbers are valid */
112 return number >= 0;
113}
114
100/* platforms that don't directly support access to GPIOs through I2C, SPI, 115/* platforms that don't directly support access to GPIOs through I2C, SPI,
101 * or other blocking infrastructure can use these wrappers. 116 * or other blocking infrastructure can use these wrappers.
102 */ 117 */
diff --git a/include/asm-generic/ioctl.h b/include/asm-generic/ioctl.h
index cd027298beb1..864181385579 100644
--- a/include/asm-generic/ioctl.h
+++ b/include/asm-generic/ioctl.h
@@ -21,8 +21,19 @@
21 */ 21 */
22#define _IOC_NRBITS 8 22#define _IOC_NRBITS 8
23#define _IOC_TYPEBITS 8 23#define _IOC_TYPEBITS 8
24#define _IOC_SIZEBITS 14 24
25#define _IOC_DIRBITS 2 25/*
26 * Let any architecture override either of the following before
27 * including this file.
28 */
29
30#ifndef _IOC_SIZEBITS
31# define _IOC_SIZEBITS 14
32#endif
33
34#ifndef _IOC_DIRBITS
35# define _IOC_DIRBITS 2
36#endif
26 37
27#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) 38#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
28#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) 39#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
@@ -35,11 +46,21 @@
35#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) 46#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
36 47
37/* 48/*
38 * Direction bits. 49 * Direction bits, which any architecture can choose to override
50 * before including this file.
39 */ 51 */
40#define _IOC_NONE 0U 52
41#define _IOC_WRITE 1U 53#ifndef _IOC_NONE
42#define _IOC_READ 2U 54# define _IOC_NONE 0U
55#endif
56
57#ifndef _IOC_WRITE
58# define _IOC_WRITE 1U
59#endif
60
61#ifndef _IOC_READ
62# define _IOC_READ 2U
63#endif
43 64
44#define _IOC(dir,type,nr,size) \ 65#define _IOC(dir,type,nr,size) \
45 (((dir) << _IOC_DIRSHIFT) | \ 66 (((dir) << _IOC_DIRSHIFT) | \
diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h
index 67dc84cd1343..76b0cc5637f8 100644
--- a/include/asm-generic/iomap.h
+++ b/include/asm-generic/iomap.h
@@ -60,6 +60,10 @@ extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long cou
60extern void __iomem *ioport_map(unsigned long port, unsigned int nr); 60extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
61extern void ioport_unmap(void __iomem *); 61extern void ioport_unmap(void __iomem *);
62 62
63#ifndef ARCH_HAS_IOREMAP_WC
64#define ioremap_wc ioremap_nocache
65#endif
66
63/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ 67/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
64struct pci_dev; 68struct pci_dev;
65extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max); 69extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h
index 52226e14bd7d..ae060c62aff1 100644
--- a/include/asm-generic/memory_model.h
+++ b/include/asm-generic/memory_model.h
@@ -1,7 +1,6 @@
1#ifndef __ASM_MEMORY_MODEL_H 1#ifndef __ASM_MEMORY_MODEL_H
2#define __ASM_MEMORY_MODEL_H 2#define __ASM_MEMORY_MODEL_H
3 3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
6 5
7#if defined(CONFIG_FLATMEM) 6#if defined(CONFIG_FLATMEM)
@@ -81,6 +80,5 @@ extern unsigned long page_to_pfn(struct page *page);
81#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */ 80#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */
82 81
83#endif /* __ASSEMBLY__ */ 82#endif /* __ASSEMBLY__ */
84#endif /* __KERNEL__ */
85 83
86#endif 84#endif
diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
index a96b5d986b6e..14db733b8e68 100644
--- a/include/asm-generic/page.h
+++ b/include/asm-generic/page.h
@@ -1,7 +1,6 @@
1#ifndef _ASM_GENERIC_PAGE_H 1#ifndef _ASM_GENERIC_PAGE_H
2#define _ASM_GENERIC_PAGE_H 2#define _ASM_GENERIC_PAGE_H
3 3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
6 5
7#include <linux/compiler.h> 6#include <linux/compiler.h>
@@ -21,6 +20,5 @@ static __inline__ __attribute_const__ int get_order(unsigned long size)
21} 20}
22 21
23#endif /* __ASSEMBLY__ */ 22#endif /* __ASSEMBLY__ */
24#endif /* __KERNEL__ */
25 23
26#endif /* _ASM_GENERIC_PAGE_H */ 24#endif /* _ASM_GENERIC_PAGE_H */
diff --git a/include/asm-generic/rtc.h b/include/asm-generic/rtc.h
index dd1bed860e64..be4af0029ac0 100644
--- a/include/asm-generic/rtc.h
+++ b/include/asm-generic/rtc.h
@@ -12,8 +12,6 @@
12#ifndef __ASM_RTC_H__ 12#ifndef __ASM_RTC_H__
13#define __ASM_RTC_H__ 13#define __ASM_RTC_H__
14 14
15#ifdef __KERNEL__
16
17#include <linux/mc146818rtc.h> 15#include <linux/mc146818rtc.h>
18#include <linux/rtc.h> 16#include <linux/rtc.h>
19#include <linux/bcd.h> 17#include <linux/bcd.h>
@@ -213,5 +211,4 @@ static inline int set_rtc_pll(struct rtc_pll_info *pll)
213 return -EINVAL; 211 return -EINVAL;
214} 212}
215 213
216#endif /* __KERNEL__ */
217#endif /* __ASM_RTC_H__ */ 214#endif /* __ASM_RTC_H__ */
diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index 342a2a0105c4..a6aea79bca4f 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -27,6 +27,8 @@
27#ifndef _ASM_GENERIC_TOPOLOGY_H 27#ifndef _ASM_GENERIC_TOPOLOGY_H
28#define _ASM_GENERIC_TOPOLOGY_H 28#define _ASM_GENERIC_TOPOLOGY_H
29 29
30#ifndef CONFIG_NUMA
31
30/* Other architectures wishing to use this simple topology API should fill 32/* Other architectures wishing to use this simple topology API should fill
31 in the below functions as appropriate in their own <asm/topology.h> file. */ 33 in the below functions as appropriate in their own <asm/topology.h> file. */
32#ifndef cpu_to_node 34#ifndef cpu_to_node
@@ -52,4 +54,16 @@
52 ) 54 )
53#endif 55#endif
54 56
57#endif /* CONFIG_NUMA */
58
59/* returns pointer to cpumask for specified node */
60#ifndef node_to_cpumask_ptr
61
62#define node_to_cpumask_ptr(v, node) \
63 cpumask_t _##v = node_to_cpumask(node), *v = &_##v
64
65#define node_to_cpumask_ptr_next(v, node) \
66 _##v = node_to_cpumask(node)
67#endif
68
55#endif /* _ASM_GENERIC_TOPOLOGY_H */ 69#endif /* _ASM_GENERIC_TOPOLOGY_H */
diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h
deleted file mode 100644
index 2fe1b2e67f01..000000000000
--- a/include/asm-generic/unaligned.h
+++ /dev/null
@@ -1,124 +0,0 @@
1#ifndef _ASM_GENERIC_UNALIGNED_H_
2#define _ASM_GENERIC_UNALIGNED_H_
3
4/*
5 * For the benefit of those who are trying to port Linux to another
6 * architecture, here are some C-language equivalents.
7 *
8 * This is based almost entirely upon Richard Henderson's
9 * asm-alpha/unaligned.h implementation. Some comments were
10 * taken from David Mosberger's asm-ia64/unaligned.h header.
11 */
12
13#include <linux/types.h>
14
15/*
16 * The main single-value unaligned transfer routines.
17 */
18#define get_unaligned(ptr) \
19 __get_unaligned((ptr), sizeof(*(ptr)))
20#define put_unaligned(x,ptr) \
21 ((void)sizeof(*(ptr)=(x)),\
22 __put_unaligned((__force __u64)(x), (ptr), sizeof(*(ptr))))
23
24/*
25 * This function doesn't actually exist. The idea is that when
26 * someone uses the macros below with an unsupported size (datatype),
27 * the linker will alert us to the problem via an unresolved reference
28 * error.
29 */
30extern void bad_unaligned_access_length(void) __attribute__((noreturn));
31
32struct __una_u64 { __u64 x __attribute__((packed)); };
33struct __una_u32 { __u32 x __attribute__((packed)); };
34struct __una_u16 { __u16 x __attribute__((packed)); };
35
36/*
37 * Elemental unaligned loads
38 */
39
40static inline __u64 __uldq(const __u64 *addr)
41{
42 const struct __una_u64 *ptr = (const struct __una_u64 *) addr;
43 return ptr->x;
44}
45
46static inline __u32 __uldl(const __u32 *addr)
47{
48 const struct __una_u32 *ptr = (const struct __una_u32 *) addr;
49 return ptr->x;
50}
51
52static inline __u16 __uldw(const __u16 *addr)
53{
54 const struct __una_u16 *ptr = (const struct __una_u16 *) addr;
55 return ptr->x;
56}
57
58/*
59 * Elemental unaligned stores
60 */
61
62static inline void __ustq(__u64 val, __u64 *addr)
63{
64 struct __una_u64 *ptr = (struct __una_u64 *) addr;
65 ptr->x = val;
66}
67
68static inline void __ustl(__u32 val, __u32 *addr)
69{
70 struct __una_u32 *ptr = (struct __una_u32 *) addr;
71 ptr->x = val;
72}
73
74static inline void __ustw(__u16 val, __u16 *addr)
75{
76 struct __una_u16 *ptr = (struct __una_u16 *) addr;
77 ptr->x = val;
78}
79
80#define __get_unaligned(ptr, size) ({ \
81 const void *__gu_p = ptr; \
82 __u64 __val; \
83 switch (size) { \
84 case 1: \
85 __val = *(const __u8 *)__gu_p; \
86 break; \
87 case 2: \
88 __val = __uldw(__gu_p); \
89 break; \
90 case 4: \
91 __val = __uldl(__gu_p); \
92 break; \
93 case 8: \
94 __val = __uldq(__gu_p); \
95 break; \
96 default: \
97 bad_unaligned_access_length(); \
98 }; \
99 (__force __typeof__(*(ptr)))__val; \
100})
101
102#define __put_unaligned(val, ptr, size) \
103({ \
104 void *__gu_p = ptr; \
105 switch (size) { \
106 case 1: \
107 *(__u8 *)__gu_p = (__force __u8)val; \
108 break; \
109 case 2: \
110 __ustw((__force __u16)val, __gu_p); \
111 break; \
112 case 4: \
113 __ustl((__force __u32)val, __gu_p); \
114 break; \
115 case 8: \
116 __ustq(val, __gu_p); \
117 break; \
118 default: \
119 bad_unaligned_access_length(); \
120 }; \
121 (void)0; \
122})
123
124#endif /* _ASM_GENERIC_UNALIGNED_H */
diff --git a/include/asm-h8300/semaphore-helper.h b/include/asm-h8300/semaphore-helper.h
deleted file mode 100644
index 4fea36be5fd8..000000000000
--- a/include/asm-h8300/semaphore-helper.h
+++ /dev/null
@@ -1,85 +0,0 @@
1#ifndef _H8300_SEMAPHORE_HELPER_H
2#define _H8300_SEMAPHORE_HELPER_H
3
4/*
5 * SMP- and interrupt-safe semaphores helper functions.
6 *
7 * (C) Copyright 1996 Linus Torvalds
8 *
9 * based on
10 * m68k version by Andreas Schwab
11 */
12
13#include <linux/errno.h>
14
15/*
16 * These two _must_ execute atomically wrt each other.
17 */
18static inline void wake_one_more(struct semaphore * sem)
19{
20 atomic_inc((atomic_t *)&sem->sleepers);
21}
22
23static inline int waking_non_zero(struct semaphore *sem)
24{
25 int ret;
26 unsigned long flags;
27
28 spin_lock_irqsave(&semaphore_wake_lock, flags);
29 ret = 0;
30 if (sem->sleepers > 0) {
31 sem->sleepers--;
32 ret = 1;
33 }
34 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
35 return ret;
36}
37
38/*
39 * waking_non_zero_interruptible:
40 * 1 got the lock
41 * 0 go to sleep
42 * -EINTR interrupted
43 */
44static inline int waking_non_zero_interruptible(struct semaphore *sem,
45 struct task_struct *tsk)
46{
47 int ret;
48 unsigned long flags;
49
50 spin_lock_irqsave(&semaphore_wake_lock, flags);
51 ret = 0;
52 if (sem->sleepers > 0) {
53 sem->sleepers--;
54 ret = 1;
55 } else if (signal_pending(tsk)) {
56 atomic_inc(&sem->count);
57 ret = -EINTR;
58 }
59 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
60 return ret;
61}
62
63/*
64 * waking_non_zero_trylock:
65 * 1 failed to lock
66 * 0 got the lock
67 */
68static inline int waking_non_zero_trylock(struct semaphore *sem)
69{
70 int ret;
71 unsigned long flags;
72
73 spin_lock_irqsave(&semaphore_wake_lock, flags);
74 ret = 1;
75 if (sem->sleepers <= 0)
76 atomic_inc(&sem->count);
77 else {
78 sem->sleepers--;
79 ret = 0;
80 }
81 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
82 return ret;
83}
84
85#endif
diff --git a/include/asm-h8300/semaphore.h b/include/asm-h8300/semaphore.h
index f3ffff83ff09..d9b2034ed1d2 100644
--- a/include/asm-h8300/semaphore.h
+++ b/include/asm-h8300/semaphore.h
@@ -1,190 +1 @@
1#ifndef _H8300_SEMAPHORE_H #include <linux/semaphore.h>
2#define _H8300_SEMAPHORE_H
3
4#define RW_LOCK_BIAS 0x01000000
5
6#ifndef __ASSEMBLY__
7
8#include <linux/linkage.h>
9#include <linux/wait.h>
10#include <linux/spinlock.h>
11#include <linux/rwsem.h>
12
13#include <asm/system.h>
14#include <asm/atomic.h>
15
16/*
17 * Interrupt-safe semaphores..
18 *
19 * (C) Copyright 1996 Linus Torvalds
20 *
21 * H8/300 version by Yoshinori Sato
22 */
23
24
25struct semaphore {
26 atomic_t count;
27 int sleepers;
28 wait_queue_head_t wait;
29};
30
31#define __SEMAPHORE_INITIALIZER(name, n) \
32{ \
33 .count = ATOMIC_INIT(n), \
34 .sleepers = 0, \
35 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
36}
37
38#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
39 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
40
41#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
42
43static inline void sema_init (struct semaphore *sem, int val)
44{
45 *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
46}
47
48static inline void init_MUTEX (struct semaphore *sem)
49{
50 sema_init(sem, 1);
51}
52
53static inline void init_MUTEX_LOCKED (struct semaphore *sem)
54{
55 sema_init(sem, 0);
56}
57
58asmlinkage void __down_failed(void /* special register calling convention */);
59asmlinkage int __down_failed_interruptible(void /* params in registers */);
60asmlinkage int __down_failed_trylock(void /* params in registers */);
61asmlinkage void __up_wakeup(void /* special register calling convention */);
62
63asmlinkage void __down(struct semaphore * sem);
64asmlinkage int __down_interruptible(struct semaphore * sem);
65asmlinkage int __down_trylock(struct semaphore * sem);
66asmlinkage void __up(struct semaphore * sem);
67
68extern spinlock_t semaphore_wake_lock;
69
70/*
71 * This is ugly, but we want the default case to fall through.
72 * "down_failed" is a special asm handler that calls the C
73 * routine that actually waits. See arch/m68k/lib/semaphore.S
74 */
75static inline void down(struct semaphore * sem)
76{
77 register atomic_t *count asm("er0");
78
79 might_sleep();
80
81 count = &(sem->count);
82 __asm__ __volatile__(
83 "stc ccr,r3l\n\t"
84 "orc #0x80,ccr\n\t"
85 "mov.l %2, er1\n\t"
86 "dec.l #1,er1\n\t"
87 "mov.l er1,%0\n\t"
88 "bpl 1f\n\t"
89 "ldc r3l,ccr\n\t"
90 "mov.l %1,er0\n\t"
91 "jsr @___down\n\t"
92 "bra 2f\n"
93 "1:\n\t"
94 "ldc r3l,ccr\n"
95 "2:"
96 : "=m"(*count)
97 : "g"(sem),"m"(*count)
98 : "cc", "er1", "er2", "er3");
99}
100
101static inline int down_interruptible(struct semaphore * sem)
102{
103 register atomic_t *count asm("er0");
104
105 might_sleep();
106
107 count = &(sem->count);
108 __asm__ __volatile__(
109 "stc ccr,r1l\n\t"
110 "orc #0x80,ccr\n\t"
111 "mov.l %3, er2\n\t"
112 "dec.l #1,er2\n\t"
113 "mov.l er2,%1\n\t"
114 "bpl 1f\n\t"
115 "ldc r1l,ccr\n\t"
116 "mov.l %2,er0\n\t"
117 "jsr @___down_interruptible\n\t"
118 "bra 2f\n"
119 "1:\n\t"
120 "ldc r1l,ccr\n\t"
121 "sub.l %0,%0\n\t"
122 "2:\n\t"
123 : "=r" (count),"=m" (*count)
124 : "g"(sem),"m"(*count)
125 : "cc", "er1", "er2", "er3");
126 return (int)count;
127}
128
129static inline int down_trylock(struct semaphore * sem)
130{
131 register atomic_t *count asm("er0");
132
133 count = &(sem->count);
134 __asm__ __volatile__(
135 "stc ccr,r3l\n\t"
136 "orc #0x80,ccr\n\t"
137 "mov.l %3,er2\n\t"
138 "dec.l #1,er2\n\t"
139 "mov.l er2,%0\n\t"
140 "bpl 1f\n\t"
141 "ldc r3l,ccr\n\t"
142 "jmp @3f\n\t"
143 LOCK_SECTION_START(".align 2\n\t")
144 "3:\n\t"
145 "mov.l %2,er0\n\t"
146 "jsr @___down_trylock\n\t"
147 "jmp @2f\n\t"
148 LOCK_SECTION_END
149 "1:\n\t"
150 "ldc r3l,ccr\n\t"
151 "sub.l %1,%1\n"
152 "2:"
153 : "=m" (*count),"=r"(count)
154 : "g"(sem),"m"(*count)
155 : "cc", "er1","er2", "er3");
156 return (int)count;
157}
158
159/*
160 * Note! This is subtle. We jump to wake people up only if
161 * the semaphore was negative (== somebody was waiting on it).
162 * The default case (no contention) will result in NO
163 * jumps for both down() and up().
164 */
165static inline void up(struct semaphore * sem)
166{
167 register atomic_t *count asm("er0");
168
169 count = &(sem->count);
170 __asm__ __volatile__(
171 "stc ccr,r3l\n\t"
172 "orc #0x80,ccr\n\t"
173 "mov.l %2,er1\n\t"
174 "inc.l #1,er1\n\t"
175 "mov.l er1,%0\n\t"
176 "ldc r3l,ccr\n\t"
177 "sub.l er2,er2\n\t"
178 "cmp.l er2,er1\n\t"
179 "bgt 1f\n\t"
180 "mov.l %1,er0\n\t"
181 "jsr @___up\n"
182 "1:"
183 : "=m"(*count)
184 : "g"(sem),"m"(*count)
185 : "cc", "er1", "er2", "er3");
186}
187
188#endif /* __ASSEMBLY__ */
189
190#endif
diff --git a/include/asm-h8300/unaligned.h b/include/asm-h8300/unaligned.h
index ffb67f472070..b8d06c70c2da 100644
--- a/include/asm-h8300/unaligned.h
+++ b/include/asm-h8300/unaligned.h
@@ -1,15 +1,11 @@
1#ifndef __H8300_UNALIGNED_H 1#ifndef _ASM_H8300_UNALIGNED_H
2#define __H8300_UNALIGNED_H 2#define _ASM_H8300_UNALIGNED_H
3 3
4#include <linux/unaligned/be_memmove.h>
5#include <linux/unaligned/le_byteshift.h>
6#include <linux/unaligned/generic.h>
4 7
5/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ 8#define get_unaligned __get_unaligned_be
9#define put_unaligned __put_unaligned_be
6 10
7#define get_unaligned(ptr) \ 11#endif /* _ASM_H8300_UNALIGNED_H */
8 ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
9
10#define put_unaligned(val, ptr) \
11 ({ __typeof__(*(ptr)) __tmp = (val); \
12 memmove((ptr), &__tmp, sizeof(*(ptr))); \
13 (void)0; })
14
15#endif
diff --git a/include/asm-ia64/acpi.h b/include/asm-ia64/acpi.h
index cd1cc39b5599..fcfad326f4c7 100644
--- a/include/asm-ia64/acpi.h
+++ b/include/asm-ia64/acpi.h
@@ -35,6 +35,7 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/numa.h> 36#include <linux/numa.h>
37#include <asm/system.h> 37#include <asm/system.h>
38#include <asm/numa.h>
38 39
39#define COMPILER_DEPENDENT_INT64 long 40#define COMPILER_DEPENDENT_INT64 long
40#define COMPILER_DEPENDENT_UINT64 unsigned long 41#define COMPILER_DEPENDENT_UINT64 unsigned long
@@ -115,7 +116,11 @@ extern unsigned int is_cpu_cpei_target(unsigned int cpu);
115extern void set_cpei_target_cpu(unsigned int cpu); 116extern void set_cpei_target_cpu(unsigned int cpu);
116extern unsigned int get_cpei_target_cpu(void); 117extern unsigned int get_cpei_target_cpu(void);
117extern void prefill_possible_map(void); 118extern void prefill_possible_map(void);
119#ifdef CONFIG_ACPI_HOTPLUG_CPU
118extern int additional_cpus; 120extern int additional_cpus;
121#else
122#define additional_cpus 0
123#endif
119 124
120#ifdef CONFIG_ACPI_NUMA 125#ifdef CONFIG_ACPI_NUMA
121#if MAX_NUMNODES > 256 126#if MAX_NUMNODES > 256
@@ -129,6 +134,34 @@ extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
129 134
130#define acpi_unlazy_tlb(x) 135#define acpi_unlazy_tlb(x)
131 136
137#ifdef CONFIG_ACPI_NUMA
138extern cpumask_t early_cpu_possible_map;
139#define for_each_possible_early_cpu(cpu) \
140 for_each_cpu_mask((cpu), early_cpu_possible_map)
141
142static inline void per_cpu_scan_finalize(int min_cpus, int reserve_cpus)
143{
144 int low_cpu, high_cpu;
145 int cpu;
146 int next_nid = 0;
147
148 low_cpu = cpus_weight(early_cpu_possible_map);
149
150 high_cpu = max(low_cpu, min_cpus);
151 high_cpu = min(high_cpu + reserve_cpus, NR_CPUS);
152
153 for (cpu = low_cpu; cpu < high_cpu; cpu++) {
154 cpu_set(cpu, early_cpu_possible_map);
155 if (node_cpuid[cpu].nid == NUMA_NO_NODE) {
156 node_cpuid[cpu].nid = next_nid;
157 next_nid++;
158 if (next_nid >= num_online_nodes())
159 next_nid = 0;
160 }
161 }
162}
163#endif /* CONFIG_ACPI_NUMA */
164
132#endif /*__KERNEL__*/ 165#endif /*__KERNEL__*/
133 166
134#endif /*_ASM_ACPI_H*/ 167#endif /*_ASM_ACPI_H*/
diff --git a/include/asm-ia64/bitops.h b/include/asm-ia64/bitops.h
index 953d3df9dd22..e2ca80037335 100644
--- a/include/asm-ia64/bitops.h
+++ b/include/asm-ia64/bitops.h
@@ -407,6 +407,22 @@ fls (int t)
407 return ia64_popcnt(x); 407 return ia64_popcnt(x);
408} 408}
409 409
410/*
411 * Find the last (most significant) bit set. Undefined for x==0.
412 * Bits are numbered from 0..63 (e.g., __fls(9) == 3).
413 */
414static inline unsigned long
415__fls (unsigned long x)
416{
417 x |= x >> 1;
418 x |= x >> 2;
419 x |= x >> 4;
420 x |= x >> 8;
421 x |= x >> 16;
422 x |= x >> 32;
423 return ia64_popcnt(x) - 1;
424}
425
410#include <asm-generic/bitops/fls64.h> 426#include <asm-generic/bitops/fls64.h>
411 427
412/* 428/*
diff --git a/include/asm-ia64/cputime.h b/include/asm-ia64/cputime.h
index 72400a78002a..f9abdec6577a 100644
--- a/include/asm-ia64/cputime.h
+++ b/include/asm-ia64/cputime.h
@@ -1,6 +1,110 @@
1/*
2 * include/asm-ia64/cputime.h:
3 * Definitions for measuring cputime on ia64 machines.
4 *
5 * Based on <asm-powerpc/cputime.h>.
6 *
7 * Copyright (C) 2007 FUJITSU LIMITED
8 * Copyright (C) 2007 Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 *
15 * If we have CONFIG_VIRT_CPU_ACCOUNTING, we measure cpu time in nsec.
16 * Otherwise we measure cpu time in jiffies using the generic definitions.
17 */
18
1#ifndef __IA64_CPUTIME_H 19#ifndef __IA64_CPUTIME_H
2#define __IA64_CPUTIME_H 20#define __IA64_CPUTIME_H
3 21
22#ifndef CONFIG_VIRT_CPU_ACCOUNTING
4#include <asm-generic/cputime.h> 23#include <asm-generic/cputime.h>
24#else
25
26#include <linux/time.h>
27#include <linux/jiffies.h>
28#include <asm/processor.h>
29
30typedef u64 cputime_t;
31typedef u64 cputime64_t;
32
33#define cputime_zero ((cputime_t)0)
34#define cputime_max ((~((cputime_t)0) >> 1) - 1)
35#define cputime_add(__a, __b) ((__a) + (__b))
36#define cputime_sub(__a, __b) ((__a) - (__b))
37#define cputime_div(__a, __n) ((__a) / (__n))
38#define cputime_halve(__a) ((__a) >> 1)
39#define cputime_eq(__a, __b) ((__a) == (__b))
40#define cputime_gt(__a, __b) ((__a) > (__b))
41#define cputime_ge(__a, __b) ((__a) >= (__b))
42#define cputime_lt(__a, __b) ((__a) < (__b))
43#define cputime_le(__a, __b) ((__a) <= (__b))
44
45#define cputime64_zero ((cputime64_t)0)
46#define cputime64_add(__a, __b) ((__a) + (__b))
47#define cputime64_sub(__a, __b) ((__a) - (__b))
48#define cputime_to_cputime64(__ct) (__ct)
49
50/*
51 * Convert cputime <-> jiffies (HZ)
52 */
53#define cputime_to_jiffies(__ct) ((__ct) / (NSEC_PER_SEC / HZ))
54#define jiffies_to_cputime(__jif) ((__jif) * (NSEC_PER_SEC / HZ))
55#define cputime64_to_jiffies64(__ct) ((__ct) / (NSEC_PER_SEC / HZ))
56#define jiffies64_to_cputime64(__jif) ((__jif) * (NSEC_PER_SEC / HZ))
57
58/*
59 * Convert cputime <-> milliseconds
60 */
61#define cputime_to_msecs(__ct) ((__ct) / NSEC_PER_MSEC)
62#define msecs_to_cputime(__msecs) ((__msecs) * NSEC_PER_MSEC)
63
64/*
65 * Convert cputime <-> seconds
66 */
67#define cputime_to_secs(__ct) ((__ct) / NSEC_PER_SEC)
68#define secs_to_cputime(__secs) ((__secs) * NSEC_PER_SEC)
69
70/*
71 * Convert cputime <-> timespec (nsec)
72 */
73static inline cputime_t timespec_to_cputime(const struct timespec *val)
74{
75 cputime_t ret = val->tv_sec * NSEC_PER_SEC;
76 return (ret + val->tv_nsec);
77}
78static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val)
79{
80 val->tv_sec = ct / NSEC_PER_SEC;
81 val->tv_nsec = ct % NSEC_PER_SEC;
82}
83
84/*
85 * Convert cputime <-> timeval (msec)
86 */
87static inline cputime_t timeval_to_cputime(struct timeval *val)
88{
89 cputime_t ret = val->tv_sec * NSEC_PER_SEC;
90 return (ret + val->tv_usec * NSEC_PER_USEC);
91}
92static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val)
93{
94 val->tv_sec = ct / NSEC_PER_SEC;
95 val->tv_usec = (ct % NSEC_PER_SEC) / NSEC_PER_USEC;
96}
97
98/*
99 * Convert cputime <-> clock (USER_HZ)
100 */
101#define cputime_to_clock_t(__ct) ((__ct) / (NSEC_PER_SEC / USER_HZ))
102#define clock_t_to_cputime(__x) ((__x) * (NSEC_PER_SEC / USER_HZ))
103
104/*
105 * Convert cputime64 to clock.
106 */
107#define cputime64_to_clock_t(__ct) cputime_to_clock_t((cputime_t)__ct)
5 108
109#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
6#endif /* __IA64_CPUTIME_H */ 110#endif /* __IA64_CPUTIME_H */
diff --git a/include/asm-ia64/dma-mapping.h b/include/asm-ia64/dma-mapping.h
index f1735a22d0ea..9f0df9bd46b7 100644
--- a/include/asm-ia64/dma-mapping.h
+++ b/include/asm-ia64/dma-mapping.h
@@ -23,10 +23,30 @@ dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr,
23{ 23{
24 dma_free_coherent(dev, size, cpu_addr, dma_handle); 24 dma_free_coherent(dev, size, cpu_addr, dma_handle);
25} 25}
26#define dma_map_single platform_dma_map_single 26#define dma_map_single_attrs platform_dma_map_single_attrs
27#define dma_map_sg platform_dma_map_sg 27static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
28#define dma_unmap_single platform_dma_unmap_single 28 size_t size, int dir)
29#define dma_unmap_sg platform_dma_unmap_sg 29{
30 return dma_map_single_attrs(dev, cpu_addr, size, dir, NULL);
31}
32#define dma_map_sg_attrs platform_dma_map_sg_attrs
33static inline int dma_map_sg(struct device *dev, struct scatterlist *sgl,
34 int nents, int dir)
35{
36 return dma_map_sg_attrs(dev, sgl, nents, dir, NULL);
37}
38#define dma_unmap_single_attrs platform_dma_unmap_single_attrs
39static inline void dma_unmap_single(struct device *dev, dma_addr_t cpu_addr,
40 size_t size, int dir)
41{
42 return dma_unmap_single_attrs(dev, cpu_addr, size, dir, NULL);
43}
44#define dma_unmap_sg_attrs platform_dma_unmap_sg_attrs
45static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sgl,
46 int nents, int dir)
47{
48 return dma_unmap_sg_attrs(dev, sgl, nents, dir, NULL);
49}
30#define dma_sync_single_for_cpu platform_dma_sync_single_for_cpu 50#define dma_sync_single_for_cpu platform_dma_sync_single_for_cpu
31#define dma_sync_sg_for_cpu platform_dma_sync_sg_for_cpu 51#define dma_sync_sg_for_cpu platform_dma_sync_sg_for_cpu
32#define dma_sync_single_for_device platform_dma_sync_single_for_device 52#define dma_sync_single_for_device platform_dma_sync_single_for_device
diff --git a/include/asm-ia64/dmi.h b/include/asm-ia64/dmi.h
index f3efaa229525..00eb1b130b63 100644
--- a/include/asm-ia64/dmi.h
+++ b/include/asm-ia64/dmi.h
@@ -3,4 +3,9 @@
3 3
4#include <asm/io.h> 4#include <asm/io.h>
5 5
6/* Use normal IO mappings for DMI */
7#define dmi_ioremap ioremap
8#define dmi_iounmap(x,l) iounmap(x)
9#define dmi_alloc(l) kmalloc(l, GFP_ATOMIC)
10
6#endif 11#endif
diff --git a/include/asm-ia64/elf.h b/include/asm-ia64/elf.h
index f8e83eca67a2..5e0c1a6bce8d 100644
--- a/include/asm-ia64/elf.h
+++ b/include/asm-ia64/elf.h
@@ -26,6 +26,7 @@
26#define ELF_ARCH EM_IA_64 26#define ELF_ARCH EM_IA_64
27 27
28#define USE_ELF_CORE_DUMP 28#define USE_ELF_CORE_DUMP
29#define CORE_DUMP_USE_REGSET
29 30
30/* Least-significant four bits of ELF header's e_flags are OS-specific. The bits are 31/* Least-significant four bits of ELF header's e_flags are OS-specific. The bits are
31 interpreted as follows by Linux: */ 32 interpreted as follows by Linux: */
@@ -154,6 +155,30 @@ extern void ia64_init_addr_space (void);
154#define ELF_NGREG 128 /* we really need just 72 but let's leave some headroom... */ 155#define ELF_NGREG 128 /* we really need just 72 but let's leave some headroom... */
155#define ELF_NFPREG 128 /* f0 and f1 could be omitted, but so what... */ 156#define ELF_NFPREG 128 /* f0 and f1 could be omitted, but so what... */
156 157
158/* elf_gregset_t register offsets */
159#define ELF_GR_0_OFFSET 0
160#define ELF_NAT_OFFSET (32 * sizeof(elf_greg_t))
161#define ELF_PR_OFFSET (33 * sizeof(elf_greg_t))
162#define ELF_BR_0_OFFSET (34 * sizeof(elf_greg_t))
163#define ELF_CR_IIP_OFFSET (42 * sizeof(elf_greg_t))
164#define ELF_CFM_OFFSET (43 * sizeof(elf_greg_t))
165#define ELF_CR_IPSR_OFFSET (44 * sizeof(elf_greg_t))
166#define ELF_GR_OFFSET(i) (ELF_GR_0_OFFSET + i * sizeof(elf_greg_t))
167#define ELF_BR_OFFSET(i) (ELF_BR_0_OFFSET + i * sizeof(elf_greg_t))
168#define ELF_AR_RSC_OFFSET (45 * sizeof(elf_greg_t))
169#define ELF_AR_BSP_OFFSET (46 * sizeof(elf_greg_t))
170#define ELF_AR_BSPSTORE_OFFSET (47 * sizeof(elf_greg_t))
171#define ELF_AR_RNAT_OFFSET (48 * sizeof(elf_greg_t))
172#define ELF_AR_CCV_OFFSET (49 * sizeof(elf_greg_t))
173#define ELF_AR_UNAT_OFFSET (50 * sizeof(elf_greg_t))
174#define ELF_AR_FPSR_OFFSET (51 * sizeof(elf_greg_t))
175#define ELF_AR_PFS_OFFSET (52 * sizeof(elf_greg_t))
176#define ELF_AR_LC_OFFSET (53 * sizeof(elf_greg_t))
177#define ELF_AR_EC_OFFSET (54 * sizeof(elf_greg_t))
178#define ELF_AR_CSD_OFFSET (55 * sizeof(elf_greg_t))
179#define ELF_AR_SSD_OFFSET (56 * sizeof(elf_greg_t))
180#define ELF_AR_END_OFFSET (57 * sizeof(elf_greg_t))
181
157typedef unsigned long elf_fpxregset_t; 182typedef unsigned long elf_fpxregset_t;
158 183
159typedef unsigned long elf_greg_t; 184typedef unsigned long elf_greg_t;
@@ -183,12 +208,6 @@ extern void ia64_elf_core_copy_regs (struct pt_regs *src, elf_gregset_t dst);
183 208
184struct task_struct; 209struct task_struct;
185 210
186extern int dump_task_regs(struct task_struct *, elf_gregset_t *);
187extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
188
189#define ELF_CORE_COPY_TASK_REGS(tsk, elf_gregs) dump_task_regs(tsk, elf_gregs)
190#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
191
192#define GATE_EHDR ((const struct elfhdr *) GATE_ADDR) 211#define GATE_EHDR ((const struct elfhdr *) GATE_ADDR)
193 212
194/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ 213/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
diff --git a/include/asm-ia64/futex.h b/include/asm-ia64/futex.h
index 8a98a2654139..c7f0f062239c 100644
--- a/include/asm-ia64/futex.h
+++ b/include/asm-ia64/futex.h
@@ -2,9 +2,9 @@
2#define _ASM_FUTEX_H 2#define _ASM_FUTEX_H
3 3
4#include <linux/futex.h> 4#include <linux/futex.h>
5#include <linux/uaccess.h>
5#include <asm/errno.h> 6#include <asm/errno.h>
6#include <asm/system.h> 7#include <asm/system.h>
7#include <asm/uaccess.h>
8 8
9#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \ 9#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
10do { \ 10do { \
diff --git a/include/asm-ia64/gcc_intrin.h b/include/asm-ia64/gcc_intrin.h
index de2ed2cbdd84..2fe292c275fe 100644
--- a/include/asm-ia64/gcc_intrin.h
+++ b/include/asm-ia64/gcc_intrin.h
@@ -21,6 +21,10 @@
21 21
22#define ia64_invala_fr(regnum) asm volatile ("invala.e f%0" :: "i"(regnum)) 22#define ia64_invala_fr(regnum) asm volatile ("invala.e f%0" :: "i"(regnum))
23 23
24#define ia64_flushrs() asm volatile ("flushrs;;":::"memory")
25
26#define ia64_loadrs() asm volatile ("loadrs;;":::"memory")
27
24extern void ia64_bad_param_for_setreg (void); 28extern void ia64_bad_param_for_setreg (void);
25extern void ia64_bad_param_for_getreg (void); 29extern void ia64_bad_param_for_getreg (void);
26 30
@@ -517,6 +521,14 @@ do { \
517#define ia64_ptrd(addr, size) \ 521#define ia64_ptrd(addr, size) \
518 asm volatile ("ptr.d %0,%1" :: "r"(addr), "r"(size) : "memory") 522 asm volatile ("ptr.d %0,%1" :: "r"(addr), "r"(size) : "memory")
519 523
524#define ia64_ttag(addr) \
525({ \
526 __u64 ia64_intri_res; \
527 asm volatile ("ttag %0=%1" : "=r"(ia64_intri_res) : "r" (addr)); \
528 ia64_intri_res; \
529})
530
531
520/* Values for lfhint in ia64_lfetch and ia64_lfetch_fault */ 532/* Values for lfhint in ia64_lfetch and ia64_lfetch_fault */
521 533
522#define ia64_lfhint_none 0 534#define ia64_lfhint_none 0
diff --git a/include/asm-ia64/hugetlb.h b/include/asm-ia64/hugetlb.h
new file mode 100644
index 000000000000..f28a9701f1cf
--- /dev/null
+++ b/include/asm-ia64/hugetlb.h
@@ -0,0 +1,79 @@
1#ifndef _ASM_IA64_HUGETLB_H
2#define _ASM_IA64_HUGETLB_H
3
4#include <asm/page.h>
5
6
7void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
8 unsigned long end, unsigned long floor,
9 unsigned long ceiling);
10
11int prepare_hugepage_range(unsigned long addr, unsigned long len);
12
13static inline int is_hugepage_only_range(struct mm_struct *mm,
14 unsigned long addr,
15 unsigned long len)
16{
17 return (REGION_NUMBER(addr) == RGN_HPAGE ||
18 REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE);
19}
20
21static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm)
22{
23}
24
25static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
26 pte_t *ptep, pte_t pte)
27{
28 set_pte_at(mm, addr, ptep, pte);
29}
30
31static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
32 unsigned long addr, pte_t *ptep)
33{
34 return ptep_get_and_clear(mm, addr, ptep);
35}
36
37static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
38 unsigned long addr, pte_t *ptep)
39{
40}
41
42static inline int huge_pte_none(pte_t pte)
43{
44 return pte_none(pte);
45}
46
47static inline pte_t huge_pte_wrprotect(pte_t pte)
48{
49 return pte_wrprotect(pte);
50}
51
52static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
53 unsigned long addr, pte_t *ptep)
54{
55 ptep_set_wrprotect(mm, addr, ptep);
56}
57
58static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
59 unsigned long addr, pte_t *ptep,
60 pte_t pte, int dirty)
61{
62 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
63}
64
65static inline pte_t huge_ptep_get(pte_t *ptep)
66{
67 return *ptep;
68}
69
70static inline int arch_prepare_hugepage(struct page *page)
71{
72 return 0;
73}
74
75static inline void arch_release_hugepage(struct page *page)
76{
77}
78
79#endif /* _ASM_IA64_HUGETLB_H */
diff --git a/include/asm-ia64/ide.h b/include/asm-ia64/ide.h
index 1ccf23809329..8fa3f8cd067a 100644
--- a/include/asm-ia64/ide.h
+++ b/include/asm-ia64/ide.h
@@ -16,8 +16,6 @@
16 16
17#include <linux/irq.h> 17#include <linux/irq.h>
18 18
19#define IDE_ARCH_OBSOLETE_DEFAULTS
20
21static inline int ide_default_irq(unsigned long base) 19static inline int ide_default_irq(unsigned long base)
22{ 20{
23 switch (base) { 21 switch (base) {
@@ -46,14 +44,6 @@ static inline unsigned long ide_default_io_base(int index)
46 } 44 }
47} 45}
48 46
49#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
50
51#ifdef CONFIG_PCI
52#define ide_init_default_irq(base) (0)
53#else
54#define ide_init_default_irq(base) ide_default_irq(base)
55#endif
56
57#include <asm-generic/ide_iops.h> 47#include <asm-generic/ide_iops.h>
58 48
59#endif /* __KERNEL__ */ 49#endif /* __KERNEL__ */
diff --git a/include/asm-ia64/io.h b/include/asm-ia64/io.h
index 4ebed77aa472..260a85ac9d6a 100644
--- a/include/asm-ia64/io.h
+++ b/include/asm-ia64/io.h
@@ -423,11 +423,6 @@ extern void __iomem * ioremap(unsigned long offset, unsigned long size);
423extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); 423extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
424extern void iounmap (volatile void __iomem *addr); 424extern void iounmap (volatile void __iomem *addr);
425 425
426/* Use normal IO mappings for DMI */
427#define dmi_ioremap ioremap
428#define dmi_iounmap(x,l) iounmap(x)
429#define dmi_alloc(l) kmalloc(l, GFP_ATOMIC)
430
431/* 426/*
432 * String version of IO memory access ops: 427 * String version of IO memory access ops:
433 */ 428 */
diff --git a/include/asm-ia64/kprobes.h b/include/asm-ia64/kprobes.h
index d03bf9ff68e3..ef71b57fc2f4 100644
--- a/include/asm-ia64/kprobes.h
+++ b/include/asm-ia64/kprobes.h
@@ -30,8 +30,12 @@
30#include <asm/break.h> 30#include <asm/break.h>
31 31
32#define __ARCH_WANT_KPROBES_INSN_SLOT 32#define __ARCH_WANT_KPROBES_INSN_SLOT
33#define MAX_INSN_SIZE 1 33#define MAX_INSN_SIZE 2 /* last half is for kprobe-booster */
34#define BREAK_INST (long)(__IA64_BREAK_KPROBE << 6) 34#define BREAK_INST (long)(__IA64_BREAK_KPROBE << 6)
35#define NOP_M_INST (long)(1<<27)
36#define BRL_INST(i1, i2) ((long)((0xcL << 37) | /* brl */ \
37 (0x1L << 12) | /* many */ \
38 (((i1) & 1) << 36) | ((i2) << 13))) /* imm */
35 39
36typedef union cmp_inst { 40typedef union cmp_inst {
37 struct { 41 struct {
@@ -112,6 +116,7 @@ struct arch_specific_insn {
112 #define INST_FLAG_FIX_RELATIVE_IP_ADDR 1 116 #define INST_FLAG_FIX_RELATIVE_IP_ADDR 1
113 #define INST_FLAG_FIX_BRANCH_REG 2 117 #define INST_FLAG_FIX_BRANCH_REG 2
114 #define INST_FLAG_BREAK_INST 4 118 #define INST_FLAG_BREAK_INST 4
119 #define INST_FLAG_BOOSTABLE 8
115 unsigned long inst_flag; 120 unsigned long inst_flag;
116 unsigned short target_br_reg; 121 unsigned short target_br_reg;
117 unsigned short slot; 122 unsigned short slot;
diff --git a/include/asm-ia64/kregs.h b/include/asm-ia64/kregs.h
index 7e55a584975c..aefcdfee7f23 100644
--- a/include/asm-ia64/kregs.h
+++ b/include/asm-ia64/kregs.h
@@ -31,6 +31,9 @@
31#define IA64_TR_PALCODE 1 /* itr1: maps PALcode as required by EFI */ 31#define IA64_TR_PALCODE 1 /* itr1: maps PALcode as required by EFI */
32#define IA64_TR_CURRENT_STACK 1 /* dtr1: maps kernel's memory- & register-stacks */ 32#define IA64_TR_CURRENT_STACK 1 /* dtr1: maps kernel's memory- & register-stacks */
33 33
34#define IA64_TR_ALLOC_BASE 2 /* itr&dtr: Base of dynamic TR resource*/
35#define IA64_TR_ALLOC_MAX 32 /* Max number for dynamic use*/
36
34/* Processor status register bits: */ 37/* Processor status register bits: */
35#define IA64_PSR_BE_BIT 1 38#define IA64_PSR_BE_BIT 1
36#define IA64_PSR_UP_BIT 2 39#define IA64_PSR_UP_BIT 2
diff --git a/include/asm-ia64/kvm.h b/include/asm-ia64/kvm.h
index 030d29b4b26b..eb2d3559d089 100644
--- a/include/asm-ia64/kvm.h
+++ b/include/asm-ia64/kvm.h
@@ -1,6 +1,205 @@
1#ifndef __LINUX_KVM_IA64_H 1#ifndef __ASM_IA64_KVM_H
2#define __LINUX_KVM_IA64_H 2#define __ASM_IA64_KVM_H
3 3
4/* ia64 does not support KVM */ 4/*
5 * asm-ia64/kvm.h: kvm structure definitions for ia64
6 *
7 * Copyright (C) 2007 Xiantao Zhang <xiantao.zhang@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 * Place - Suite 330, Boston, MA 02111-1307 USA.
21 *
22 */
23
24#include <asm/types.h>
25#include <asm/fpu.h>
26
27#include <linux/ioctl.h>
28
29/* Architectural interrupt line count. */
30#define KVM_NR_INTERRUPTS 256
31
32#define KVM_IOAPIC_NUM_PINS 24
33
34struct kvm_ioapic_state {
35 __u64 base_address;
36 __u32 ioregsel;
37 __u32 id;
38 __u32 irr;
39 __u32 pad;
40 union {
41 __u64 bits;
42 struct {
43 __u8 vector;
44 __u8 delivery_mode:3;
45 __u8 dest_mode:1;
46 __u8 delivery_status:1;
47 __u8 polarity:1;
48 __u8 remote_irr:1;
49 __u8 trig_mode:1;
50 __u8 mask:1;
51 __u8 reserve:7;
52 __u8 reserved[4];
53 __u8 dest_id;
54 } fields;
55 } redirtbl[KVM_IOAPIC_NUM_PINS];
56};
57
58#define KVM_IRQCHIP_PIC_MASTER 0
59#define KVM_IRQCHIP_PIC_SLAVE 1
60#define KVM_IRQCHIP_IOAPIC 2
61
62#define KVM_CONTEXT_SIZE 8*1024
63
64union context {
65 /* 8K size */
66 char dummy[KVM_CONTEXT_SIZE];
67 struct {
68 unsigned long psr;
69 unsigned long pr;
70 unsigned long caller_unat;
71 unsigned long pad;
72 unsigned long gr[32];
73 unsigned long ar[128];
74 unsigned long br[8];
75 unsigned long cr[128];
76 unsigned long rr[8];
77 unsigned long ibr[8];
78 unsigned long dbr[8];
79 unsigned long pkr[8];
80 struct ia64_fpreg fr[128];
81 };
82};
83
84struct thash_data {
85 union {
86 struct {
87 unsigned long p : 1; /* 0 */
88 unsigned long rv1 : 1; /* 1 */
89 unsigned long ma : 3; /* 2-4 */
90 unsigned long a : 1; /* 5 */
91 unsigned long d : 1; /* 6 */
92 unsigned long pl : 2; /* 7-8 */
93 unsigned long ar : 3; /* 9-11 */
94 unsigned long ppn : 38; /* 12-49 */
95 unsigned long rv2 : 2; /* 50-51 */
96 unsigned long ed : 1; /* 52 */
97 unsigned long ig1 : 11; /* 53-63 */
98 };
99 struct {
100 unsigned long __rv1 : 53; /* 0-52 */
101 unsigned long contiguous : 1; /*53 */
102 unsigned long tc : 1; /* 54 TR or TC */
103 unsigned long cl : 1;
104 /* 55 I side or D side cache line */
105 unsigned long len : 4; /* 56-59 */
106 unsigned long io : 1; /* 60 entry is for io or not */
107 unsigned long nomap : 1;
108 /* 61 entry cann't be inserted into machine TLB.*/
109 unsigned long checked : 1;
110 /* 62 for VTLB/VHPT sanity check */
111 unsigned long invalid : 1;
112 /* 63 invalid entry */
113 };
114 unsigned long page_flags;
115 }; /* same for VHPT and TLB */
116
117 union {
118 struct {
119 unsigned long rv3 : 2;
120 unsigned long ps : 6;
121 unsigned long key : 24;
122 unsigned long rv4 : 32;
123 };
124 unsigned long itir;
125 };
126 union {
127 struct {
128 unsigned long ig2 : 12;
129 unsigned long vpn : 49;
130 unsigned long vrn : 3;
131 };
132 unsigned long ifa;
133 unsigned long vadr;
134 struct {
135 unsigned long tag : 63;
136 unsigned long ti : 1;
137 };
138 unsigned long etag;
139 };
140 union {
141 struct thash_data *next;
142 unsigned long rid;
143 unsigned long gpaddr;
144 };
145};
146
147#define NITRS 8
148#define NDTRS 8
149
150struct saved_vpd {
151 unsigned long vhpi;
152 unsigned long vgr[16];
153 unsigned long vbgr[16];
154 unsigned long vnat;
155 unsigned long vbnat;
156 unsigned long vcpuid[5];
157 unsigned long vpsr;
158 unsigned long vpr;
159 unsigned long vcr[128];
160};
161
162struct kvm_regs {
163 char *saved_guest;
164 char *saved_stack;
165 struct saved_vpd vpd;
166 /*Arch-regs*/
167 int mp_state;
168 unsigned long vmm_rr;
169 /* TR and TC. */
170 struct thash_data itrs[NITRS];
171 struct thash_data dtrs[NDTRS];
172 /* Bit is set if there is a tr/tc for the region. */
173 unsigned char itr_regions;
174 unsigned char dtr_regions;
175 unsigned char tc_regions;
176
177 char irq_check;
178 unsigned long saved_itc;
179 unsigned long itc_check;
180 unsigned long timer_check;
181 unsigned long timer_pending;
182 unsigned long last_itc;
183
184 unsigned long vrr[8];
185 unsigned long ibr[8];
186 unsigned long dbr[8];
187 unsigned long insvc[4]; /* Interrupt in service. */
188 unsigned long xtp;
189
190 unsigned long metaphysical_rr0; /* from kvm_arch (so is pinned) */
191 unsigned long metaphysical_rr4; /* from kvm_arch (so is pinned) */
192 unsigned long metaphysical_saved_rr0; /* from kvm_arch */
193 unsigned long metaphysical_saved_rr4; /* from kvm_arch */
194 unsigned long fp_psr; /*used for lazy float register */
195 unsigned long saved_gp;
196 /*for phycial emulation */
197};
198
199struct kvm_sregs {
200};
201
202struct kvm_fpu {
203};
5 204
6#endif 205#endif
diff --git a/include/asm-ia64/kvm_host.h b/include/asm-ia64/kvm_host.h
new file mode 100644
index 000000000000..c082c208c1f3
--- /dev/null
+++ b/include/asm-ia64/kvm_host.h
@@ -0,0 +1,524 @@
1/*
2 * kvm_host.h: used for kvm module, and hold ia64-specific sections.
3 *
4 * Copyright (C) 2007, Intel Corporation.
5 *
6 * Xiantao Zhang <xiantao.zhang@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place - Suite 330, Boston, MA 02111-1307 USA.
20 *
21 */
22
23#ifndef __ASM_KVM_HOST_H
24#define __ASM_KVM_HOST_H
25
26
27#include <linux/types.h>
28#include <linux/mm.h>
29#include <linux/kvm.h>
30#include <linux/kvm_para.h>
31#include <linux/kvm_types.h>
32
33#include <asm/pal.h>
34#include <asm/sal.h>
35
36#define KVM_MAX_VCPUS 4
37#define KVM_MEMORY_SLOTS 32
38/* memory slots that does not exposed to userspace */
39#define KVM_PRIVATE_MEM_SLOTS 4
40
41
42/* define exit reasons from vmm to kvm*/
43#define EXIT_REASON_VM_PANIC 0
44#define EXIT_REASON_MMIO_INSTRUCTION 1
45#define EXIT_REASON_PAL_CALL 2
46#define EXIT_REASON_SAL_CALL 3
47#define EXIT_REASON_SWITCH_RR6 4
48#define EXIT_REASON_VM_DESTROY 5
49#define EXIT_REASON_EXTERNAL_INTERRUPT 6
50#define EXIT_REASON_IPI 7
51#define EXIT_REASON_PTC_G 8
52
53/*Define vmm address space and vm data space.*/
54#define KVM_VMM_SIZE (16UL<<20)
55#define KVM_VMM_SHIFT 24
56#define KVM_VMM_BASE 0xD000000000000000UL
57#define VMM_SIZE (8UL<<20)
58
59/*
60 * Define vm_buffer, used by PAL Services, base address.
61 * Note: vmbuffer is in the VMM-BLOCK, the size must be < 8M
62 */
63#define KVM_VM_BUFFER_BASE (KVM_VMM_BASE + VMM_SIZE)
64#define KVM_VM_BUFFER_SIZE (8UL<<20)
65
66/*Define Virtual machine data layout.*/
67#define KVM_VM_DATA_SHIFT 24
68#define KVM_VM_DATA_SIZE (1UL << KVM_VM_DATA_SHIFT)
69#define KVM_VM_DATA_BASE (KVM_VMM_BASE + KVM_VMM_SIZE)
70
71
72#define KVM_P2M_BASE KVM_VM_DATA_BASE
73#define KVM_P2M_OFS 0
74#define KVM_P2M_SIZE (8UL << 20)
75
76#define KVM_VHPT_BASE (KVM_P2M_BASE + KVM_P2M_SIZE)
77#define KVM_VHPT_OFS KVM_P2M_SIZE
78#define KVM_VHPT_BLOCK_SIZE (2UL << 20)
79#define VHPT_SHIFT 18
80#define VHPT_SIZE (1UL << VHPT_SHIFT)
81#define VHPT_NUM_ENTRIES (1<<(VHPT_SHIFT-5))
82
83#define KVM_VTLB_BASE (KVM_VHPT_BASE+KVM_VHPT_BLOCK_SIZE)
84#define KVM_VTLB_OFS (KVM_VHPT_OFS+KVM_VHPT_BLOCK_SIZE)
85#define KVM_VTLB_BLOCK_SIZE (1UL<<20)
86#define VTLB_SHIFT 17
87#define VTLB_SIZE (1UL<<VTLB_SHIFT)
88#define VTLB_NUM_ENTRIES (1<<(VTLB_SHIFT-5))
89
90#define KVM_VPD_BASE (KVM_VTLB_BASE+KVM_VTLB_BLOCK_SIZE)
91#define KVM_VPD_OFS (KVM_VTLB_OFS+KVM_VTLB_BLOCK_SIZE)
92#define KVM_VPD_BLOCK_SIZE (2UL<<20)
93#define VPD_SHIFT 16
94#define VPD_SIZE (1UL<<VPD_SHIFT)
95
96#define KVM_VCPU_BASE (KVM_VPD_BASE+KVM_VPD_BLOCK_SIZE)
97#define KVM_VCPU_OFS (KVM_VPD_OFS+KVM_VPD_BLOCK_SIZE)
98#define KVM_VCPU_BLOCK_SIZE (2UL<<20)
99#define VCPU_SHIFT 18
100#define VCPU_SIZE (1UL<<VCPU_SHIFT)
101#define MAX_VCPU_NUM KVM_VCPU_BLOCK_SIZE/VCPU_SIZE
102
103#define KVM_VM_BASE (KVM_VCPU_BASE+KVM_VCPU_BLOCK_SIZE)
104#define KVM_VM_OFS (KVM_VCPU_OFS+KVM_VCPU_BLOCK_SIZE)
105#define KVM_VM_BLOCK_SIZE (1UL<<19)
106
107#define KVM_MEM_DIRTY_LOG_BASE (KVM_VM_BASE+KVM_VM_BLOCK_SIZE)
108#define KVM_MEM_DIRTY_LOG_OFS (KVM_VM_OFS+KVM_VM_BLOCK_SIZE)
109#define KVM_MEM_DIRTY_LOG_SIZE (1UL<<19)
110
111/* Get vpd, vhpt, tlb, vcpu, base*/
112#define VPD_ADDR(n) (KVM_VPD_BASE+n*VPD_SIZE)
113#define VHPT_ADDR(n) (KVM_VHPT_BASE+n*VHPT_SIZE)
114#define VTLB_ADDR(n) (KVM_VTLB_BASE+n*VTLB_SIZE)
115#define VCPU_ADDR(n) (KVM_VCPU_BASE+n*VCPU_SIZE)
116
117/*IO section definitions*/
118#define IOREQ_READ 1
119#define IOREQ_WRITE 0
120
121#define STATE_IOREQ_NONE 0
122#define STATE_IOREQ_READY 1
123#define STATE_IOREQ_INPROCESS 2
124#define STATE_IORESP_READY 3
125
126/*Guest Physical address layout.*/
127#define GPFN_MEM (0UL << 60) /* Guest pfn is normal mem */
128#define GPFN_FRAME_BUFFER (1UL << 60) /* VGA framebuffer */
129#define GPFN_LOW_MMIO (2UL << 60) /* Low MMIO range */
130#define GPFN_PIB (3UL << 60) /* PIB base */
131#define GPFN_IOSAPIC (4UL << 60) /* IOSAPIC base */
132#define GPFN_LEGACY_IO (5UL << 60) /* Legacy I/O base */
133#define GPFN_GFW (6UL << 60) /* Guest Firmware */
134#define GPFN_HIGH_MMIO (7UL << 60) /* High MMIO range */
135
136#define GPFN_IO_MASK (7UL << 60) /* Guest pfn is I/O type */
137#define GPFN_INV_MASK (1UL << 63) /* Guest pfn is invalid */
138#define INVALID_MFN (~0UL)
139#define MEM_G (1UL << 30)
140#define MEM_M (1UL << 20)
141#define MMIO_START (3 * MEM_G)
142#define MMIO_SIZE (512 * MEM_M)
143#define VGA_IO_START 0xA0000UL
144#define VGA_IO_SIZE 0x20000
145#define LEGACY_IO_START (MMIO_START + MMIO_SIZE)
146#define LEGACY_IO_SIZE (64 * MEM_M)
147#define IO_SAPIC_START 0xfec00000UL
148#define IO_SAPIC_SIZE 0x100000
149#define PIB_START 0xfee00000UL
150#define PIB_SIZE 0x200000
151#define GFW_START (4 * MEM_G - 16 * MEM_M)
152#define GFW_SIZE (16 * MEM_M)
153
154/*Deliver mode, defined for ioapic.c*/
155#define dest_Fixed IOSAPIC_FIXED
156#define dest_LowestPrio IOSAPIC_LOWEST_PRIORITY
157
158#define NMI_VECTOR 2
159#define ExtINT_VECTOR 0
160#define NULL_VECTOR (-1)
161#define IA64_SPURIOUS_INT_VECTOR 0x0f
162
163#define VCPU_LID(v) (((u64)(v)->vcpu_id) << 24)
164
165/*
166 *Delivery mode
167 */
168#define SAPIC_DELIV_SHIFT 8
169#define SAPIC_FIXED 0x0
170#define SAPIC_LOWEST_PRIORITY 0x1
171#define SAPIC_PMI 0x2
172#define SAPIC_NMI 0x4
173#define SAPIC_INIT 0x5
174#define SAPIC_EXTINT 0x7
175
176/*
177 * vcpu->requests bit members for arch
178 */
179#define KVM_REQ_PTC_G 32
180#define KVM_REQ_RESUME 33
181
182#define KVM_PAGES_PER_HPAGE 1
183
184struct kvm;
185struct kvm_vcpu;
186struct kvm_guest_debug{
187};
188
189struct kvm_mmio_req {
190 uint64_t addr; /* physical address */
191 uint64_t size; /* size in bytes */
192 uint64_t data; /* data (or paddr of data) */
193 uint8_t state:4;
194 uint8_t dir:1; /* 1=read, 0=write */
195};
196
197/*Pal data struct */
198struct kvm_pal_call{
199 /*In area*/
200 uint64_t gr28;
201 uint64_t gr29;
202 uint64_t gr30;
203 uint64_t gr31;
204 /*Out area*/
205 struct ia64_pal_retval ret;
206};
207
208/* Sal data structure */
209struct kvm_sal_call{
210 /*In area*/
211 uint64_t in0;
212 uint64_t in1;
213 uint64_t in2;
214 uint64_t in3;
215 uint64_t in4;
216 uint64_t in5;
217 uint64_t in6;
218 uint64_t in7;
219 struct sal_ret_values ret;
220};
221
222/*Guest change rr6*/
223struct kvm_switch_rr6 {
224 uint64_t old_rr;
225 uint64_t new_rr;
226};
227
228union ia64_ipi_a{
229 unsigned long val;
230 struct {
231 unsigned long rv : 3;
232 unsigned long ir : 1;
233 unsigned long eid : 8;
234 unsigned long id : 8;
235 unsigned long ib_base : 44;
236 };
237};
238
239union ia64_ipi_d {
240 unsigned long val;
241 struct {
242 unsigned long vector : 8;
243 unsigned long dm : 3;
244 unsigned long ig : 53;
245 };
246};
247
248/*ipi check exit data*/
249struct kvm_ipi_data{
250 union ia64_ipi_a addr;
251 union ia64_ipi_d data;
252};
253
254/*global purge data*/
255struct kvm_ptc_g {
256 unsigned long vaddr;
257 unsigned long rr;
258 unsigned long ps;
259 struct kvm_vcpu *vcpu;
260};
261
262/*Exit control data */
263struct exit_ctl_data{
264 uint32_t exit_reason;
265 uint32_t vm_status;
266 union {
267 struct kvm_mmio_req ioreq;
268 struct kvm_pal_call pal_data;
269 struct kvm_sal_call sal_data;
270 struct kvm_switch_rr6 rr_data;
271 struct kvm_ipi_data ipi_data;
272 struct kvm_ptc_g ptc_g_data;
273 } u;
274};
275
276union pte_flags {
277 unsigned long val;
278 struct {
279 unsigned long p : 1; /*0 */
280 unsigned long : 1; /* 1 */
281 unsigned long ma : 3; /* 2-4 */
282 unsigned long a : 1; /* 5 */
283 unsigned long d : 1; /* 6 */
284 unsigned long pl : 2; /* 7-8 */
285 unsigned long ar : 3; /* 9-11 */
286 unsigned long ppn : 38; /* 12-49 */
287 unsigned long : 2; /* 50-51 */
288 unsigned long ed : 1; /* 52 */
289 };
290};
291
292union ia64_pta {
293 unsigned long val;
294 struct {
295 unsigned long ve : 1;
296 unsigned long reserved0 : 1;
297 unsigned long size : 6;
298 unsigned long vf : 1;
299 unsigned long reserved1 : 6;
300 unsigned long base : 49;
301 };
302};
303
304struct thash_cb {
305 /* THASH base information */
306 struct thash_data *hash; /* hash table pointer */
307 union ia64_pta pta;
308 int num;
309};
310
311struct kvm_vcpu_stat {
312};
313
314struct kvm_vcpu_arch {
315 int launched;
316 int last_exit;
317 int last_run_cpu;
318 int vmm_tr_slot;
319 int vm_tr_slot;
320
321#define KVM_MP_STATE_RUNNABLE 0
322#define KVM_MP_STATE_UNINITIALIZED 1
323#define KVM_MP_STATE_INIT_RECEIVED 2
324#define KVM_MP_STATE_HALTED 3
325 int mp_state;
326
327#define MAX_PTC_G_NUM 3
328 int ptc_g_count;
329 struct kvm_ptc_g ptc_g_data[MAX_PTC_G_NUM];
330
331 /*halt timer to wake up sleepy vcpus*/
332 struct hrtimer hlt_timer;
333 long ht_active;
334
335 struct kvm_lapic *apic; /* kernel irqchip context */
336 struct vpd *vpd;
337
338 /* Exit data for vmm_transition*/
339 struct exit_ctl_data exit_data;
340
341 cpumask_t cache_coherent_map;
342
343 unsigned long vmm_rr;
344 unsigned long host_rr6;
345 unsigned long psbits[8];
346 unsigned long cr_iipa;
347 unsigned long cr_isr;
348 unsigned long vsa_base;
349 unsigned long dirty_log_lock_pa;
350 unsigned long __gp;
351 /* TR and TC. */
352 struct thash_data itrs[NITRS];
353 struct thash_data dtrs[NDTRS];
354 /* Bit is set if there is a tr/tc for the region. */
355 unsigned char itr_regions;
356 unsigned char dtr_regions;
357 unsigned char tc_regions;
358 /* purge all */
359 unsigned long ptce_base;
360 unsigned long ptce_count[2];
361 unsigned long ptce_stride[2];
362 /* itc/itm */
363 unsigned long last_itc;
364 long itc_offset;
365 unsigned long itc_check;
366 unsigned long timer_check;
367 unsigned long timer_pending;
368
369 unsigned long vrr[8];
370 unsigned long ibr[8];
371 unsigned long dbr[8];
372 unsigned long insvc[4]; /* Interrupt in service. */
373 unsigned long xtp;
374
375 unsigned long metaphysical_rr0; /* from kvm_arch (so is pinned) */
376 unsigned long metaphysical_rr4; /* from kvm_arch (so is pinned) */
377 unsigned long metaphysical_saved_rr0; /* from kvm_arch */
378 unsigned long metaphysical_saved_rr4; /* from kvm_arch */
379 unsigned long fp_psr; /*used for lazy float register */
380 unsigned long saved_gp;
381 /*for phycial emulation */
382 int mode_flags;
383 struct thash_cb vtlb;
384 struct thash_cb vhpt;
385 char irq_check;
386 char irq_new_pending;
387
388 unsigned long opcode;
389 unsigned long cause;
390 union context host;
391 union context guest;
392};
393
394struct kvm_vm_stat {
395 u64 remote_tlb_flush;
396};
397
398struct kvm_sal_data {
399 unsigned long boot_ip;
400 unsigned long boot_gp;
401};
402
403struct kvm_arch {
404 unsigned long vm_base;
405 unsigned long metaphysical_rr0;
406 unsigned long metaphysical_rr4;
407 unsigned long vmm_init_rr;
408 unsigned long vhpt_base;
409 unsigned long vtlb_base;
410 unsigned long vpd_base;
411 spinlock_t dirty_log_lock;
412 struct kvm_ioapic *vioapic;
413 struct kvm_vm_stat stat;
414 struct kvm_sal_data rdv_sal_data;
415};
416
417union cpuid3_t {
418 u64 value;
419 struct {
420 u64 number : 8;
421 u64 revision : 8;
422 u64 model : 8;
423 u64 family : 8;
424 u64 archrev : 8;
425 u64 rv : 24;
426 };
427};
428
429struct kvm_pt_regs {
430 /* The following registers are saved by SAVE_MIN: */
431 unsigned long b6; /* scratch */
432 unsigned long b7; /* scratch */
433
434 unsigned long ar_csd; /* used by cmp8xchg16 (scratch) */
435 unsigned long ar_ssd; /* reserved for future use (scratch) */
436
437 unsigned long r8; /* scratch (return value register 0) */
438 unsigned long r9; /* scratch (return value register 1) */
439 unsigned long r10; /* scratch (return value register 2) */
440 unsigned long r11; /* scratch (return value register 3) */
441
442 unsigned long cr_ipsr; /* interrupted task's psr */
443 unsigned long cr_iip; /* interrupted task's instruction pointer */
444 unsigned long cr_ifs; /* interrupted task's function state */
445
446 unsigned long ar_unat; /* interrupted task's NaT register (preserved) */
447 unsigned long ar_pfs; /* prev function state */
448 unsigned long ar_rsc; /* RSE configuration */
449 /* The following two are valid only if cr_ipsr.cpl > 0: */
450 unsigned long ar_rnat; /* RSE NaT */
451 unsigned long ar_bspstore; /* RSE bspstore */
452
453 unsigned long pr; /* 64 predicate registers (1 bit each) */
454 unsigned long b0; /* return pointer (bp) */
455 unsigned long loadrs; /* size of dirty partition << 16 */
456
457 unsigned long r1; /* the gp pointer */
458 unsigned long r12; /* interrupted task's memory stack pointer */
459 unsigned long r13; /* thread pointer */
460
461 unsigned long ar_fpsr; /* floating point status (preserved) */
462 unsigned long r15; /* scratch */
463
464 /* The remaining registers are NOT saved for system calls. */
465 unsigned long r14; /* scratch */
466 unsigned long r2; /* scratch */
467 unsigned long r3; /* scratch */
468 unsigned long r16; /* scratch */
469 unsigned long r17; /* scratch */
470 unsigned long r18; /* scratch */
471 unsigned long r19; /* scratch */
472 unsigned long r20; /* scratch */
473 unsigned long r21; /* scratch */
474 unsigned long r22; /* scratch */
475 unsigned long r23; /* scratch */
476 unsigned long r24; /* scratch */
477 unsigned long r25; /* scratch */
478 unsigned long r26; /* scratch */
479 unsigned long r27; /* scratch */
480 unsigned long r28; /* scratch */
481 unsigned long r29; /* scratch */
482 unsigned long r30; /* scratch */
483 unsigned long r31; /* scratch */
484 unsigned long ar_ccv; /* compare/exchange value (scratch) */
485
486 /*
487 * Floating point registers that the kernel considers scratch:
488 */
489 struct ia64_fpreg f6; /* scratch */
490 struct ia64_fpreg f7; /* scratch */
491 struct ia64_fpreg f8; /* scratch */
492 struct ia64_fpreg f9; /* scratch */
493 struct ia64_fpreg f10; /* scratch */
494 struct ia64_fpreg f11; /* scratch */
495
496 unsigned long r4; /* preserved */
497 unsigned long r5; /* preserved */
498 unsigned long r6; /* preserved */
499 unsigned long r7; /* preserved */
500 unsigned long eml_unat; /* used for emulating instruction */
501 unsigned long pad0; /* alignment pad */
502};
503
504static inline struct kvm_pt_regs *vcpu_regs(struct kvm_vcpu *v)
505{
506 return (struct kvm_pt_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1;
507}
508
509typedef int kvm_vmm_entry(void);
510typedef void kvm_tramp_entry(union context *host, union context *guest);
511
512struct kvm_vmm_info{
513 struct module *module;
514 kvm_vmm_entry *vmm_entry;
515 kvm_tramp_entry *tramp_entry;
516 unsigned long vmm_ivt;
517};
518
519int kvm_highest_pending_irq(struct kvm_vcpu *vcpu);
520int kvm_emulate_halt(struct kvm_vcpu *vcpu);
521int kvm_pal_emul(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
522void kvm_sal_emul(struct kvm_vcpu *vcpu);
523
524#endif
diff --git a/include/asm-ia64/kvm_para.h b/include/asm-ia64/kvm_para.h
new file mode 100644
index 000000000000..9f9796bb3441
--- /dev/null
+++ b/include/asm-ia64/kvm_para.h
@@ -0,0 +1,29 @@
1#ifndef __IA64_KVM_PARA_H
2#define __IA64_KVM_PARA_H
3
4/*
5 * asm-ia64/kvm_para.h
6 *
7 * Copyright (C) 2007 Xiantao Zhang <xiantao.zhang@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 * Place - Suite 330, Boston, MA 02111-1307 USA.
21 *
22 */
23
24static inline unsigned int kvm_arch_para_features(void)
25{
26 return 0;
27}
28
29#endif
diff --git a/include/asm-ia64/machvec.h b/include/asm-ia64/machvec.h
index c201a2020aa4..9f020eb825c5 100644
--- a/include/asm-ia64/machvec.h
+++ b/include/asm-ia64/machvec.h
@@ -22,6 +22,7 @@ struct pci_bus;
22struct task_struct; 22struct task_struct;
23struct pci_dev; 23struct pci_dev;
24struct msi_desc; 24struct msi_desc;
25struct dma_attrs;
25 26
26typedef void ia64_mv_setup_t (char **); 27typedef void ia64_mv_setup_t (char **);
27typedef void ia64_mv_cpu_init_t (void); 28typedef void ia64_mv_cpu_init_t (void);
@@ -56,6 +57,11 @@ typedef void ia64_mv_dma_sync_sg_for_device (struct device *, struct scatterlist
56typedef int ia64_mv_dma_mapping_error (dma_addr_t dma_addr); 57typedef int ia64_mv_dma_mapping_error (dma_addr_t dma_addr);
57typedef int ia64_mv_dma_supported (struct device *, u64); 58typedef int ia64_mv_dma_supported (struct device *, u64);
58 59
60typedef dma_addr_t ia64_mv_dma_map_single_attrs (struct device *, void *, size_t, int, struct dma_attrs *);
61typedef void ia64_mv_dma_unmap_single_attrs (struct device *, dma_addr_t, size_t, int, struct dma_attrs *);
62typedef int ia64_mv_dma_map_sg_attrs (struct device *, struct scatterlist *, int, int, struct dma_attrs *);
63typedef void ia64_mv_dma_unmap_sg_attrs (struct device *, struct scatterlist *, int, int, struct dma_attrs *);
64
59/* 65/*
60 * WARNING: The legacy I/O space is _architected_. Platforms are 66 * WARNING: The legacy I/O space is _architected_. Platforms are
61 * expected to follow this architected model (see Section 10.7 in the 67 * expected to follow this architected model (see Section 10.7 in the
@@ -136,10 +142,10 @@ extern void machvec_tlb_migrate_finish (struct mm_struct *);
136# define platform_dma_init ia64_mv.dma_init 142# define platform_dma_init ia64_mv.dma_init
137# define platform_dma_alloc_coherent ia64_mv.dma_alloc_coherent 143# define platform_dma_alloc_coherent ia64_mv.dma_alloc_coherent
138# define platform_dma_free_coherent ia64_mv.dma_free_coherent 144# define platform_dma_free_coherent ia64_mv.dma_free_coherent
139# define platform_dma_map_single ia64_mv.dma_map_single 145# define platform_dma_map_single_attrs ia64_mv.dma_map_single_attrs
140# define platform_dma_unmap_single ia64_mv.dma_unmap_single 146# define platform_dma_unmap_single_attrs ia64_mv.dma_unmap_single_attrs
141# define platform_dma_map_sg ia64_mv.dma_map_sg 147# define platform_dma_map_sg_attrs ia64_mv.dma_map_sg_attrs
142# define platform_dma_unmap_sg ia64_mv.dma_unmap_sg 148# define platform_dma_unmap_sg_attrs ia64_mv.dma_unmap_sg_attrs
143# define platform_dma_sync_single_for_cpu ia64_mv.dma_sync_single_for_cpu 149# define platform_dma_sync_single_for_cpu ia64_mv.dma_sync_single_for_cpu
144# define platform_dma_sync_sg_for_cpu ia64_mv.dma_sync_sg_for_cpu 150# define platform_dma_sync_sg_for_cpu ia64_mv.dma_sync_sg_for_cpu
145# define platform_dma_sync_single_for_device ia64_mv.dma_sync_single_for_device 151# define platform_dma_sync_single_for_device ia64_mv.dma_sync_single_for_device
@@ -190,10 +196,10 @@ struct ia64_machine_vector {
190 ia64_mv_dma_init *dma_init; 196 ia64_mv_dma_init *dma_init;
191 ia64_mv_dma_alloc_coherent *dma_alloc_coherent; 197 ia64_mv_dma_alloc_coherent *dma_alloc_coherent;
192 ia64_mv_dma_free_coherent *dma_free_coherent; 198 ia64_mv_dma_free_coherent *dma_free_coherent;
193 ia64_mv_dma_map_single *dma_map_single; 199 ia64_mv_dma_map_single_attrs *dma_map_single_attrs;
194 ia64_mv_dma_unmap_single *dma_unmap_single; 200 ia64_mv_dma_unmap_single_attrs *dma_unmap_single_attrs;
195 ia64_mv_dma_map_sg *dma_map_sg; 201 ia64_mv_dma_map_sg_attrs *dma_map_sg_attrs;
196 ia64_mv_dma_unmap_sg *dma_unmap_sg; 202 ia64_mv_dma_unmap_sg_attrs *dma_unmap_sg_attrs;
197 ia64_mv_dma_sync_single_for_cpu *dma_sync_single_for_cpu; 203 ia64_mv_dma_sync_single_for_cpu *dma_sync_single_for_cpu;
198 ia64_mv_dma_sync_sg_for_cpu *dma_sync_sg_for_cpu; 204 ia64_mv_dma_sync_sg_for_cpu *dma_sync_sg_for_cpu;
199 ia64_mv_dma_sync_single_for_device *dma_sync_single_for_device; 205 ia64_mv_dma_sync_single_for_device *dma_sync_single_for_device;
@@ -240,10 +246,10 @@ struct ia64_machine_vector {
240 platform_dma_init, \ 246 platform_dma_init, \
241 platform_dma_alloc_coherent, \ 247 platform_dma_alloc_coherent, \
242 platform_dma_free_coherent, \ 248 platform_dma_free_coherent, \
243 platform_dma_map_single, \ 249 platform_dma_map_single_attrs, \
244 platform_dma_unmap_single, \ 250 platform_dma_unmap_single_attrs, \
245 platform_dma_map_sg, \ 251 platform_dma_map_sg_attrs, \
246 platform_dma_unmap_sg, \ 252 platform_dma_unmap_sg_attrs, \
247 platform_dma_sync_single_for_cpu, \ 253 platform_dma_sync_single_for_cpu, \
248 platform_dma_sync_sg_for_cpu, \ 254 platform_dma_sync_sg_for_cpu, \
249 platform_dma_sync_single_for_device, \ 255 platform_dma_sync_single_for_device, \
@@ -292,9 +298,13 @@ extern ia64_mv_dma_init swiotlb_init;
292extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent; 298extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent;
293extern ia64_mv_dma_free_coherent swiotlb_free_coherent; 299extern ia64_mv_dma_free_coherent swiotlb_free_coherent;
294extern ia64_mv_dma_map_single swiotlb_map_single; 300extern ia64_mv_dma_map_single swiotlb_map_single;
301extern ia64_mv_dma_map_single_attrs swiotlb_map_single_attrs;
295extern ia64_mv_dma_unmap_single swiotlb_unmap_single; 302extern ia64_mv_dma_unmap_single swiotlb_unmap_single;
303extern ia64_mv_dma_unmap_single_attrs swiotlb_unmap_single_attrs;
296extern ia64_mv_dma_map_sg swiotlb_map_sg; 304extern ia64_mv_dma_map_sg swiotlb_map_sg;
305extern ia64_mv_dma_map_sg_attrs swiotlb_map_sg_attrs;
297extern ia64_mv_dma_unmap_sg swiotlb_unmap_sg; 306extern ia64_mv_dma_unmap_sg swiotlb_unmap_sg;
307extern ia64_mv_dma_unmap_sg_attrs swiotlb_unmap_sg_attrs;
298extern ia64_mv_dma_sync_single_for_cpu swiotlb_sync_single_for_cpu; 308extern ia64_mv_dma_sync_single_for_cpu swiotlb_sync_single_for_cpu;
299extern ia64_mv_dma_sync_sg_for_cpu swiotlb_sync_sg_for_cpu; 309extern ia64_mv_dma_sync_sg_for_cpu swiotlb_sync_sg_for_cpu;
300extern ia64_mv_dma_sync_single_for_device swiotlb_sync_single_for_device; 310extern ia64_mv_dma_sync_single_for_device swiotlb_sync_single_for_device;
@@ -340,17 +350,17 @@ extern ia64_mv_dma_supported swiotlb_dma_supported;
340#ifndef platform_dma_free_coherent 350#ifndef platform_dma_free_coherent
341# define platform_dma_free_coherent swiotlb_free_coherent 351# define platform_dma_free_coherent swiotlb_free_coherent
342#endif 352#endif
343#ifndef platform_dma_map_single 353#ifndef platform_dma_map_single_attrs
344# define platform_dma_map_single swiotlb_map_single 354# define platform_dma_map_single_attrs swiotlb_map_single_attrs
345#endif 355#endif
346#ifndef platform_dma_unmap_single 356#ifndef platform_dma_unmap_single_attrs
347# define platform_dma_unmap_single swiotlb_unmap_single 357# define platform_dma_unmap_single_attrs swiotlb_unmap_single_attrs
348#endif 358#endif
349#ifndef platform_dma_map_sg 359#ifndef platform_dma_map_sg_attrs
350# define platform_dma_map_sg swiotlb_map_sg 360# define platform_dma_map_sg_attrs swiotlb_map_sg_attrs
351#endif 361#endif
352#ifndef platform_dma_unmap_sg 362#ifndef platform_dma_unmap_sg_attrs
353# define platform_dma_unmap_sg swiotlb_unmap_sg 363# define platform_dma_unmap_sg_attrs swiotlb_unmap_sg_attrs
354#endif 364#endif
355#ifndef platform_dma_sync_single_for_cpu 365#ifndef platform_dma_sync_single_for_cpu
356# define platform_dma_sync_single_for_cpu swiotlb_sync_single_for_cpu 366# define platform_dma_sync_single_for_cpu swiotlb_sync_single_for_cpu
diff --git a/include/asm-ia64/machvec_hpzx1.h b/include/asm-ia64/machvec_hpzx1.h
index e90daf9ce340..2f57f5144b9f 100644
--- a/include/asm-ia64/machvec_hpzx1.h
+++ b/include/asm-ia64/machvec_hpzx1.h
@@ -4,10 +4,10 @@
4extern ia64_mv_setup_t dig_setup; 4extern ia64_mv_setup_t dig_setup;
5extern ia64_mv_dma_alloc_coherent sba_alloc_coherent; 5extern ia64_mv_dma_alloc_coherent sba_alloc_coherent;
6extern ia64_mv_dma_free_coherent sba_free_coherent; 6extern ia64_mv_dma_free_coherent sba_free_coherent;
7extern ia64_mv_dma_map_single sba_map_single; 7extern ia64_mv_dma_map_single_attrs sba_map_single_attrs;
8extern ia64_mv_dma_unmap_single sba_unmap_single; 8extern ia64_mv_dma_unmap_single_attrs sba_unmap_single_attrs;
9extern ia64_mv_dma_map_sg sba_map_sg; 9extern ia64_mv_dma_map_sg_attrs sba_map_sg_attrs;
10extern ia64_mv_dma_unmap_sg sba_unmap_sg; 10extern ia64_mv_dma_unmap_sg_attrs sba_unmap_sg_attrs;
11extern ia64_mv_dma_supported sba_dma_supported; 11extern ia64_mv_dma_supported sba_dma_supported;
12extern ia64_mv_dma_mapping_error sba_dma_mapping_error; 12extern ia64_mv_dma_mapping_error sba_dma_mapping_error;
13 13
@@ -23,10 +23,10 @@ extern ia64_mv_dma_mapping_error sba_dma_mapping_error;
23#define platform_dma_init machvec_noop 23#define platform_dma_init machvec_noop
24#define platform_dma_alloc_coherent sba_alloc_coherent 24#define platform_dma_alloc_coherent sba_alloc_coherent
25#define platform_dma_free_coherent sba_free_coherent 25#define platform_dma_free_coherent sba_free_coherent
26#define platform_dma_map_single sba_map_single 26#define platform_dma_map_single_attrs sba_map_single_attrs
27#define platform_dma_unmap_single sba_unmap_single 27#define platform_dma_unmap_single_attrs sba_unmap_single_attrs
28#define platform_dma_map_sg sba_map_sg 28#define platform_dma_map_sg_attrs sba_map_sg_attrs
29#define platform_dma_unmap_sg sba_unmap_sg 29#define platform_dma_unmap_sg_attrs sba_unmap_sg_attrs
30#define platform_dma_sync_single_for_cpu machvec_dma_sync_single 30#define platform_dma_sync_single_for_cpu machvec_dma_sync_single
31#define platform_dma_sync_sg_for_cpu machvec_dma_sync_sg 31#define platform_dma_sync_sg_for_cpu machvec_dma_sync_sg
32#define platform_dma_sync_single_for_device machvec_dma_sync_single 32#define platform_dma_sync_single_for_device machvec_dma_sync_single
diff --git a/include/asm-ia64/machvec_hpzx1_swiotlb.h b/include/asm-ia64/machvec_hpzx1_swiotlb.h
index f00a34a148ff..a842cdda827b 100644
--- a/include/asm-ia64/machvec_hpzx1_swiotlb.h
+++ b/include/asm-ia64/machvec_hpzx1_swiotlb.h
@@ -4,10 +4,10 @@
4extern ia64_mv_setup_t dig_setup; 4extern ia64_mv_setup_t dig_setup;
5extern ia64_mv_dma_alloc_coherent hwsw_alloc_coherent; 5extern ia64_mv_dma_alloc_coherent hwsw_alloc_coherent;
6extern ia64_mv_dma_free_coherent hwsw_free_coherent; 6extern ia64_mv_dma_free_coherent hwsw_free_coherent;
7extern ia64_mv_dma_map_single hwsw_map_single; 7extern ia64_mv_dma_map_single_attrs hwsw_map_single_attrs;
8extern ia64_mv_dma_unmap_single hwsw_unmap_single; 8extern ia64_mv_dma_unmap_single_attrs hwsw_unmap_single_attrs;
9extern ia64_mv_dma_map_sg hwsw_map_sg; 9extern ia64_mv_dma_map_sg_attrs hwsw_map_sg_attrs;
10extern ia64_mv_dma_unmap_sg hwsw_unmap_sg; 10extern ia64_mv_dma_unmap_sg_attrs hwsw_unmap_sg_attrs;
11extern ia64_mv_dma_supported hwsw_dma_supported; 11extern ia64_mv_dma_supported hwsw_dma_supported;
12extern ia64_mv_dma_mapping_error hwsw_dma_mapping_error; 12extern ia64_mv_dma_mapping_error hwsw_dma_mapping_error;
13extern ia64_mv_dma_sync_single_for_cpu hwsw_sync_single_for_cpu; 13extern ia64_mv_dma_sync_single_for_cpu hwsw_sync_single_for_cpu;
@@ -28,10 +28,10 @@ extern ia64_mv_dma_sync_sg_for_device hwsw_sync_sg_for_device;
28#define platform_dma_init machvec_noop 28#define platform_dma_init machvec_noop
29#define platform_dma_alloc_coherent hwsw_alloc_coherent 29#define platform_dma_alloc_coherent hwsw_alloc_coherent
30#define platform_dma_free_coherent hwsw_free_coherent 30#define platform_dma_free_coherent hwsw_free_coherent
31#define platform_dma_map_single hwsw_map_single 31#define platform_dma_map_single_attrs hwsw_map_single_attrs
32#define platform_dma_unmap_single hwsw_unmap_single 32#define platform_dma_unmap_single_attrs hwsw_unmap_single_attrs
33#define platform_dma_map_sg hwsw_map_sg 33#define platform_dma_map_sg_attrs hwsw_map_sg_attrs
34#define platform_dma_unmap_sg hwsw_unmap_sg 34#define platform_dma_unmap_sg_attrs hwsw_unmap_sg_attrs
35#define platform_dma_supported hwsw_dma_supported 35#define platform_dma_supported hwsw_dma_supported
36#define platform_dma_mapping_error hwsw_dma_mapping_error 36#define platform_dma_mapping_error hwsw_dma_mapping_error
37#define platform_dma_sync_single_for_cpu hwsw_sync_single_for_cpu 37#define platform_dma_sync_single_for_cpu hwsw_sync_single_for_cpu
diff --git a/include/asm-ia64/machvec_sn2.h b/include/asm-ia64/machvec_sn2.h
index 61439a7f5b08..781308ea7b88 100644
--- a/include/asm-ia64/machvec_sn2.h
+++ b/include/asm-ia64/machvec_sn2.h
@@ -57,10 +57,10 @@ extern ia64_mv_readl_t __sn_readl_relaxed;
57extern ia64_mv_readq_t __sn_readq_relaxed; 57extern ia64_mv_readq_t __sn_readq_relaxed;
58extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent; 58extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent;
59extern ia64_mv_dma_free_coherent sn_dma_free_coherent; 59extern ia64_mv_dma_free_coherent sn_dma_free_coherent;
60extern ia64_mv_dma_map_single sn_dma_map_single; 60extern ia64_mv_dma_map_single_attrs sn_dma_map_single_attrs;
61extern ia64_mv_dma_unmap_single sn_dma_unmap_single; 61extern ia64_mv_dma_unmap_single_attrs sn_dma_unmap_single_attrs;
62extern ia64_mv_dma_map_sg sn_dma_map_sg; 62extern ia64_mv_dma_map_sg_attrs sn_dma_map_sg_attrs;
63extern ia64_mv_dma_unmap_sg sn_dma_unmap_sg; 63extern ia64_mv_dma_unmap_sg_attrs sn_dma_unmap_sg_attrs;
64extern ia64_mv_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu; 64extern ia64_mv_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu;
65extern ia64_mv_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu; 65extern ia64_mv_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu;
66extern ia64_mv_dma_sync_single_for_device sn_dma_sync_single_for_device; 66extern ia64_mv_dma_sync_single_for_device sn_dma_sync_single_for_device;
@@ -113,10 +113,10 @@ extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus;
113#define platform_dma_init machvec_noop 113#define platform_dma_init machvec_noop
114#define platform_dma_alloc_coherent sn_dma_alloc_coherent 114#define platform_dma_alloc_coherent sn_dma_alloc_coherent
115#define platform_dma_free_coherent sn_dma_free_coherent 115#define platform_dma_free_coherent sn_dma_free_coherent
116#define platform_dma_map_single sn_dma_map_single 116#define platform_dma_map_single_attrs sn_dma_map_single_attrs
117#define platform_dma_unmap_single sn_dma_unmap_single 117#define platform_dma_unmap_single_attrs sn_dma_unmap_single_attrs
118#define platform_dma_map_sg sn_dma_map_sg 118#define platform_dma_map_sg_attrs sn_dma_map_sg_attrs
119#define platform_dma_unmap_sg sn_dma_unmap_sg 119#define platform_dma_unmap_sg_attrs sn_dma_unmap_sg_attrs
120#define platform_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu 120#define platform_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu
121#define platform_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu 121#define platform_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu
122#define platform_dma_sync_single_for_device sn_dma_sync_single_for_device 122#define platform_dma_sync_single_for_device sn_dma_sync_single_for_device
diff --git a/include/asm-ia64/mca.h b/include/asm-ia64/mca.h
index f1663aa94a52..18a4321349a3 100644
--- a/include/asm-ia64/mca.h
+++ b/include/asm-ia64/mca.h
@@ -157,6 +157,7 @@ extern void ia64_mca_printk(const char * fmt, ...)
157struct ia64_mca_notify_die { 157struct ia64_mca_notify_die {
158 struct ia64_sal_os_state *sos; 158 struct ia64_sal_os_state *sos;
159 int *monarch_cpu; 159 int *monarch_cpu;
160 int *data;
160}; 161};
161 162
162DECLARE_PER_CPU(u64, ia64_mca_pal_base); 163DECLARE_PER_CPU(u64, ia64_mca_pal_base);
diff --git a/include/asm-ia64/meminit.h b/include/asm-ia64/meminit.h
index f93308f54b61..7245a5781594 100644
--- a/include/asm-ia64/meminit.h
+++ b/include/asm-ia64/meminit.h
@@ -35,6 +35,7 @@ extern void find_memory (void);
35extern void reserve_memory (void); 35extern void reserve_memory (void);
36extern void find_initrd (void); 36extern void find_initrd (void);
37extern int filter_rsvd_memory (unsigned long start, unsigned long end, void *arg); 37extern int filter_rsvd_memory (unsigned long start, unsigned long end, void *arg);
38extern int filter_memory (unsigned long start, unsigned long end, void *arg);
38extern unsigned long efi_memmap_init(unsigned long *s, unsigned long *e); 39extern unsigned long efi_memmap_init(unsigned long *s, unsigned long *e);
39extern int find_max_min_low_pfn (unsigned long , unsigned long, void *); 40extern int find_max_min_low_pfn (unsigned long , unsigned long, void *);
40 41
@@ -56,7 +57,7 @@ extern int reserve_elfcorehdr(unsigned long *start, unsigned long *end);
56 57
57#define IGNORE_PFN0 1 /* XXX fix me: ignore pfn 0 until TLB miss handler is updated... */ 58#define IGNORE_PFN0 1 /* XXX fix me: ignore pfn 0 until TLB miss handler is updated... */
58 59
59extern int register_active_ranges(u64 start, u64 end, void *arg); 60extern int register_active_ranges(u64 start, u64 len, int nid);
60 61
61#ifdef CONFIG_VIRTUAL_MEM_MAP 62#ifdef CONFIG_VIRTUAL_MEM_MAP
62# define LARGE_GAP 0x40000000 /* Use virtual mem map if hole is > than this */ 63# define LARGE_GAP 0x40000000 /* Use virtual mem map if hole is > than this */
diff --git a/include/asm-ia64/numa.h b/include/asm-ia64/numa.h
index 6a8a27cfae3e..3499ff57bf42 100644
--- a/include/asm-ia64/numa.h
+++ b/include/asm-ia64/numa.h
@@ -22,6 +22,8 @@
22 22
23#include <asm/mmzone.h> 23#include <asm/mmzone.h>
24 24
25#define NUMA_NO_NODE -1
26
25extern u16 cpu_to_node_map[NR_CPUS] __cacheline_aligned; 27extern u16 cpu_to_node_map[NR_CPUS] __cacheline_aligned;
26extern cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned; 28extern cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
27extern pg_data_t *pgdat_list[MAX_NUMNODES]; 29extern pg_data_t *pgdat_list[MAX_NUMNODES];
diff --git a/include/asm-ia64/page.h b/include/asm-ia64/page.h
index 4999a6c63775..36f39321b768 100644
--- a/include/asm-ia64/page.h
+++ b/include/asm-ia64/page.h
@@ -54,9 +54,6 @@
54# define HPAGE_MASK (~(HPAGE_SIZE - 1)) 54# define HPAGE_MASK (~(HPAGE_SIZE - 1))
55 55
56# define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 56# define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
57# define ARCH_HAS_HUGEPAGE_ONLY_RANGE
58# define ARCH_HAS_PREPARE_HUGEPAGE_RANGE
59# define ARCH_HAS_HUGETLB_FREE_PGD_RANGE
60#endif /* CONFIG_HUGETLB_PAGE */ 57#endif /* CONFIG_HUGETLB_PAGE */
61 58
62#ifdef __ASSEMBLY__ 59#ifdef __ASSEMBLY__
@@ -153,9 +150,6 @@ typedef union ia64_va {
153# define htlbpage_to_page(x) (((unsigned long) REGION_NUMBER(x) << 61) \ 150# define htlbpage_to_page(x) (((unsigned long) REGION_NUMBER(x) << 61) \
154 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT))) 151 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
155# define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) 152# define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
156# define is_hugepage_only_range(mm, addr, len) \
157 (REGION_NUMBER(addr) == RGN_HPAGE || \
158 REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
159extern unsigned int hpage_shift; 153extern unsigned int hpage_shift;
160#endif 154#endif
161 155
diff --git a/include/asm-ia64/pal.h b/include/asm-ia64/pal.h
index 8a695d3407d2..67b02901ead4 100644
--- a/include/asm-ia64/pal.h
+++ b/include/asm-ia64/pal.h
@@ -13,6 +13,7 @@
13 * Copyright (C) 1999 VA Linux Systems 13 * Copyright (C) 1999 VA Linux Systems
14 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> 14 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
15 * Copyright (C) 1999 Srinivasa Prasad Thirumalachar <sprasad@sprasad.engr.sgi.com> 15 * Copyright (C) 1999 Srinivasa Prasad Thirumalachar <sprasad@sprasad.engr.sgi.com>
16 * Copyright (C) 2008 Silicon Graphics, Inc. (SGI)
16 * 17 *
17 * 99/10/01 davidm Make sure we pass zero for reserved parameters. 18 * 99/10/01 davidm Make sure we pass zero for reserved parameters.
18 * 00/03/07 davidm Updated pal_cache_flush() to be in sync with PAL v2.6. 19 * 00/03/07 davidm Updated pal_cache_flush() to be in sync with PAL v2.6.
@@ -73,6 +74,8 @@
73#define PAL_CACHE_SHARED_INFO 43 /* returns information on caches shared by logical processor */ 74#define PAL_CACHE_SHARED_INFO 43 /* returns information on caches shared by logical processor */
74#define PAL_GET_HW_POLICY 48 /* Get current hardware resource sharing policy */ 75#define PAL_GET_HW_POLICY 48 /* Get current hardware resource sharing policy */
75#define PAL_SET_HW_POLICY 49 /* Set current hardware resource sharing policy */ 76#define PAL_SET_HW_POLICY 49 /* Set current hardware resource sharing policy */
77#define PAL_VP_INFO 50 /* Information about virtual processor features */
78#define PAL_MC_HW_TRACKING 51 /* Hardware tracking status */
76 79
77#define PAL_COPY_PAL 256 /* relocate PAL procedures and PAL PMI */ 80#define PAL_COPY_PAL 256 /* relocate PAL procedures and PAL PMI */
78#define PAL_HALT_INFO 257 /* return the low power capabilities of processor */ 81#define PAL_HALT_INFO 257 /* return the low power capabilities of processor */
@@ -504,7 +507,8 @@ typedef struct pal_cache_check_info_s {
504 wiv : 1, /* Way field valid */ 507 wiv : 1, /* Way field valid */
505 reserved2 : 1, 508 reserved2 : 1,
506 dp : 1, /* Data poisoned on MBE */ 509 dp : 1, /* Data poisoned on MBE */
507 reserved3 : 8, 510 reserved3 : 6,
511 hlth : 2, /* Health indicator */
508 512
509 index : 20, /* Cache line index */ 513 index : 20, /* Cache line index */
510 reserved4 : 2, 514 reserved4 : 2,
@@ -542,7 +546,9 @@ typedef struct pal_tlb_check_info_s {
542 dtc : 1, /* Fail in data TC */ 546 dtc : 1, /* Fail in data TC */
543 itc : 1, /* Fail in inst. TC */ 547 itc : 1, /* Fail in inst. TC */
544 op : 4, /* Cache operation */ 548 op : 4, /* Cache operation */
545 reserved3 : 30, 549 reserved3 : 6,
550 hlth : 2, /* Health indicator */
551 reserved4 : 22,
546 552
547 is : 1, /* instruction set (1 == ia32) */ 553 is : 1, /* instruction set (1 == ia32) */
548 iv : 1, /* instruction set field valid */ 554 iv : 1, /* instruction set field valid */
@@ -633,7 +639,8 @@ typedef struct pal_uarch_check_info_s {
633 way : 6, /* Way of structure */ 639 way : 6, /* Way of structure */
634 wv : 1, /* way valid */ 640 wv : 1, /* way valid */
635 xv : 1, /* index valid */ 641 xv : 1, /* index valid */
636 reserved1 : 8, 642 reserved1 : 6,
643 hlth : 2, /* Health indicator */
637 index : 8, /* Index or set of the uarch 644 index : 8, /* Index or set of the uarch
638 * structure that failed. 645 * structure that failed.
639 */ 646 */
@@ -1213,14 +1220,12 @@ ia64_pal_mc_drain (void)
1213 1220
1214/* Return the machine check dynamic processor state */ 1221/* Return the machine check dynamic processor state */
1215static inline s64 1222static inline s64
1216ia64_pal_mc_dynamic_state (u64 offset, u64 *size, u64 *pds) 1223ia64_pal_mc_dynamic_state (u64 info_type, u64 dy_buffer, u64 *size)
1217{ 1224{
1218 struct ia64_pal_retval iprv; 1225 struct ia64_pal_retval iprv;
1219 PAL_CALL(iprv, PAL_MC_DYNAMIC_STATE, offset, 0, 0); 1226 PAL_CALL(iprv, PAL_MC_DYNAMIC_STATE, info_type, dy_buffer, 0);
1220 if (size) 1227 if (size)
1221 *size = iprv.v0; 1228 *size = iprv.v0;
1222 if (pds)
1223 *pds = iprv.v1;
1224 return iprv.status; 1229 return iprv.status;
1225} 1230}
1226 1231
@@ -1281,15 +1286,41 @@ ia64_pal_mc_expected (u64 expected, u64 *previous)
1281 return iprv.status; 1286 return iprv.status;
1282} 1287}
1283 1288
1289typedef union pal_hw_tracking_u {
1290 u64 pht_data;
1291 struct {
1292 u64 itc :4, /* Instruction cache tracking */
1293 dct :4, /* Date cache tracking */
1294 itt :4, /* Instruction TLB tracking */
1295 ddt :4, /* Data TLB tracking */
1296 reserved:48;
1297 } pal_hw_tracking_s;
1298} pal_hw_tracking_u_t;
1299
1300/*
1301 * Hardware tracking status.
1302 */
1303static inline s64
1304ia64_pal_mc_hw_tracking (u64 *status)
1305{
1306 struct ia64_pal_retval iprv;
1307 PAL_CALL(iprv, PAL_MC_HW_TRACKING, 0, 0, 0);
1308 if (status)
1309 *status = iprv.v0;
1310 return iprv.status;
1311}
1312
1284/* Register a platform dependent location with PAL to which it can save 1313/* Register a platform dependent location with PAL to which it can save
1285 * minimal processor state in the event of a machine check or initialization 1314 * minimal processor state in the event of a machine check or initialization
1286 * event. 1315 * event.
1287 */ 1316 */
1288static inline s64 1317static inline s64
1289ia64_pal_mc_register_mem (u64 physical_addr) 1318ia64_pal_mc_register_mem (u64 physical_addr, u64 size, u64 *req_size)
1290{ 1319{
1291 struct ia64_pal_retval iprv; 1320 struct ia64_pal_retval iprv;
1292 PAL_CALL(iprv, PAL_MC_REGISTER_MEM, physical_addr, 0, 0); 1321 PAL_CALL(iprv, PAL_MC_REGISTER_MEM, physical_addr, size, 0);
1322 if (req_size)
1323 *req_size = iprv.v0;
1293 return iprv.status; 1324 return iprv.status;
1294} 1325}
1295 1326
@@ -1631,6 +1662,29 @@ ia64_pal_vm_summary (pal_vm_info_1_u_t *vm_info_1, pal_vm_info_2_u_t *vm_info_2)
1631 return iprv.status; 1662 return iprv.status;
1632} 1663}
1633 1664
1665typedef union pal_vp_info_u {
1666 u64 pvi_val;
1667 struct {
1668 u64 index: 48, /* virtual feature set info */
1669 vmm_id: 16; /* feature set id */
1670 } pal_vp_info_s;
1671} pal_vp_info_u_t;
1672
1673/*
1674 * Returns infomation about virtual processor features
1675 */
1676static inline s64
1677ia64_pal_vp_info (u64 feature_set, u64 vp_buffer, u64 *vp_info, u64 *vmm_id)
1678{
1679 struct ia64_pal_retval iprv;
1680 PAL_CALL(iprv, PAL_VP_INFO, feature_set, vp_buffer, 0);
1681 if (vp_info)
1682 *vp_info = iprv.v0;
1683 if (vmm_id)
1684 *vmm_id = iprv.v1;
1685 return iprv.status;
1686}
1687
1634typedef union pal_itr_valid_u { 1688typedef union pal_itr_valid_u {
1635 u64 piv_val; 1689 u64 piv_val;
1636 struct { 1690 struct {
diff --git a/include/asm-ia64/pgtable.h b/include/asm-ia64/pgtable.h
index e6204f14f614..7a9bff47564f 100644
--- a/include/asm-ia64/pgtable.h
+++ b/include/asm-ia64/pgtable.h
@@ -302,6 +302,8 @@ ia64_phys_addr_valid (unsigned long addr)
302#define pte_dirty(pte) ((pte_val(pte) & _PAGE_D) != 0) 302#define pte_dirty(pte) ((pte_val(pte) & _PAGE_D) != 0)
303#define pte_young(pte) ((pte_val(pte) & _PAGE_A) != 0) 303#define pte_young(pte) ((pte_val(pte) & _PAGE_A) != 0)
304#define pte_file(pte) ((pte_val(pte) & _PAGE_FILE) != 0) 304#define pte_file(pte) ((pte_val(pte) & _PAGE_FILE) != 0)
305#define pte_special(pte) 0
306
305/* 307/*
306 * Note: we convert AR_RWX to AR_RX and AR_RW to AR_R by clearing the 2nd bit in the 308 * Note: we convert AR_RWX to AR_RX and AR_RW to AR_R by clearing the 2nd bit in the
307 * access rights: 309 * access rights:
@@ -313,6 +315,7 @@ ia64_phys_addr_valid (unsigned long addr)
313#define pte_mkclean(pte) (__pte(pte_val(pte) & ~_PAGE_D)) 315#define pte_mkclean(pte) (__pte(pte_val(pte) & ~_PAGE_D))
314#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_D)) 316#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_D))
315#define pte_mkhuge(pte) (__pte(pte_val(pte))) 317#define pte_mkhuge(pte) (__pte(pte_val(pte)))
318#define pte_mkspecial(pte) (pte)
316 319
317/* 320/*
318 * Because ia64's Icache and Dcache is not coherent (on a cpu), we need to 321 * Because ia64's Icache and Dcache is not coherent (on a cpu), we need to
@@ -371,7 +374,7 @@ pgd_index (unsigned long address)
371/* The offset in the 1-level directory is given by the 3 region bits 374/* The offset in the 1-level directory is given by the 3 region bits
372 (61..63) and the level-1 bits. */ 375 (61..63) and the level-1 bits. */
373static inline pgd_t* 376static inline pgd_t*
374pgd_offset (struct mm_struct *mm, unsigned long address) 377pgd_offset (const struct mm_struct *mm, unsigned long address)
375{ 378{
376 return mm->pgd + pgd_index(address); 379 return mm->pgd + pgd_index(address);
377} 380}
diff --git a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
index 741f7ecb986a..6aff126fc07e 100644
--- a/include/asm-ia64/processor.h
+++ b/include/asm-ia64/processor.h
@@ -119,6 +119,69 @@ struct ia64_psr {
119 __u64 reserved4 : 19; 119 __u64 reserved4 : 19;
120}; 120};
121 121
122union ia64_isr {
123 __u64 val;
124 struct {
125 __u64 code : 16;
126 __u64 vector : 8;
127 __u64 reserved1 : 8;
128 __u64 x : 1;
129 __u64 w : 1;
130 __u64 r : 1;
131 __u64 na : 1;
132 __u64 sp : 1;
133 __u64 rs : 1;
134 __u64 ir : 1;
135 __u64 ni : 1;
136 __u64 so : 1;
137 __u64 ei : 2;
138 __u64 ed : 1;
139 __u64 reserved2 : 20;
140 };
141};
142
143union ia64_lid {
144 __u64 val;
145 struct {
146 __u64 rv : 16;
147 __u64 eid : 8;
148 __u64 id : 8;
149 __u64 ig : 32;
150 };
151};
152
153union ia64_tpr {
154 __u64 val;
155 struct {
156 __u64 ig0 : 4;
157 __u64 mic : 4;
158 __u64 rsv : 8;
159 __u64 mmi : 1;
160 __u64 ig1 : 47;
161 };
162};
163
164union ia64_itir {
165 __u64 val;
166 struct {
167 __u64 rv3 : 2; /* 0-1 */
168 __u64 ps : 6; /* 2-7 */
169 __u64 key : 24; /* 8-31 */
170 __u64 rv4 : 32; /* 32-63 */
171 };
172};
173
174union ia64_rr {
175 __u64 val;
176 struct {
177 __u64 ve : 1; /* enable hw walker */
178 __u64 reserved0: 1; /* reserved */
179 __u64 ps : 6; /* log page size */
180 __u64 rid : 24; /* region id */
181 __u64 reserved1: 32; /* reserved */
182 };
183};
184
122/* 185/*
123 * CPU type, hardware bug flags, and per-CPU state. Frequently used 186 * CPU type, hardware bug flags, and per-CPU state. Frequently used
124 * state comes earlier: 187 * state comes earlier:
diff --git a/include/asm-ia64/sal.h b/include/asm-ia64/sal.h
index f4904db3b057..89594b442f83 100644
--- a/include/asm-ia64/sal.h
+++ b/include/asm-ia64/sal.h
@@ -296,6 +296,9 @@ enum {
296 EFI_GUID(0xe429faf8, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81) 296 EFI_GUID(0xe429faf8, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
297#define SAL_PLAT_BUS_ERR_SECT_GUID \ 297#define SAL_PLAT_BUS_ERR_SECT_GUID \
298 EFI_GUID(0xe429faf9, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81) 298 EFI_GUID(0xe429faf9, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
299#define PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID \
300 EFI_GUID(0x6cb0a200, 0x893a, 0x11da, 0x96, 0xd2, 0x0, 0x10, 0x83, 0xff, \
301 0xca, 0x4d)
299 302
300#define MAX_CACHE_ERRORS 6 303#define MAX_CACHE_ERRORS 6
301#define MAX_TLB_ERRORS 6 304#define MAX_TLB_ERRORS 6
@@ -879,6 +882,24 @@ extern void ia64_jump_to_sal(struct sal_to_os_boot *);
879 882
880extern void ia64_sal_handler_init(void *entry_point, void *gpval); 883extern void ia64_sal_handler_init(void *entry_point, void *gpval);
881 884
885#define PALO_MAX_TLB_PURGES 0xFFFF
886#define PALO_SIG "PALO"
887
888struct palo_table {
889 u8 signature[4]; /* Should be "PALO" */
890 u32 length;
891 u8 minor_revision;
892 u8 major_revision;
893 u8 checksum;
894 u8 reserved1[5];
895 u16 max_tlb_purges;
896 u8 reserved2[6];
897};
898
899#define NPTCG_FROM_PAL 0
900#define NPTCG_FROM_PALO 1
901#define NPTCG_FROM_KERNEL_PARAMETER 2
902
882#endif /* __ASSEMBLY__ */ 903#endif /* __ASSEMBLY__ */
883 904
884#endif /* _ASM_IA64_SAL_H */ 905#endif /* _ASM_IA64_SAL_H */
diff --git a/include/asm-ia64/semaphore.h b/include/asm-ia64/semaphore.h
index d8393d11288d..d9b2034ed1d2 100644
--- a/include/asm-ia64/semaphore.h
+++ b/include/asm-ia64/semaphore.h
@@ -1,99 +1 @@
1#ifndef _ASM_IA64_SEMAPHORE_H #include <linux/semaphore.h>
2#define _ASM_IA64_SEMAPHORE_H
3
4/*
5 * Copyright (C) 1998-2000 Hewlett-Packard Co
6 * Copyright (C) 1998-2000 David Mosberger-Tang <davidm@hpl.hp.com>
7 */
8
9#include <linux/wait.h>
10#include <linux/rwsem.h>
11
12#include <asm/atomic.h>
13
14struct semaphore {
15 atomic_t count;
16 int sleepers;
17 wait_queue_head_t wait;
18};
19
20#define __SEMAPHORE_INITIALIZER(name, n) \
21{ \
22 .count = ATOMIC_INIT(n), \
23 .sleepers = 0, \
24 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
25}
26
27#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
28 struct semaphore name = __SEMAPHORE_INITIALIZER(name, count)
29
30#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
31
32static inline void
33sema_init (struct semaphore *sem, int val)
34{
35 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
36}
37
38static inline void
39init_MUTEX (struct semaphore *sem)
40{
41 sema_init(sem, 1);
42}
43
44static inline void
45init_MUTEX_LOCKED (struct semaphore *sem)
46{
47 sema_init(sem, 0);
48}
49
50extern void __down (struct semaphore * sem);
51extern int __down_interruptible (struct semaphore * sem);
52extern int __down_trylock (struct semaphore * sem);
53extern void __up (struct semaphore * sem);
54
55/*
56 * Atomically decrement the semaphore's count. If it goes negative,
57 * block the calling thread in the TASK_UNINTERRUPTIBLE state.
58 */
59static inline void
60down (struct semaphore *sem)
61{
62 might_sleep();
63 if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
64 __down(sem);
65}
66
67/*
68 * Atomically decrement the semaphore's count. If it goes negative,
69 * block the calling thread in the TASK_INTERRUPTIBLE state.
70 */
71static inline int
72down_interruptible (struct semaphore * sem)
73{
74 int ret = 0;
75
76 might_sleep();
77 if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
78 ret = __down_interruptible(sem);
79 return ret;
80}
81
82static inline int
83down_trylock (struct semaphore *sem)
84{
85 int ret = 0;
86
87 if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
88 ret = __down_trylock(sem);
89 return ret;
90}
91
92static inline void
93up (struct semaphore * sem)
94{
95 if (ia64_fetchadd(1, &sem->count.counter, rel) <= -1)
96 __up(sem);
97}
98
99#endif /* _ASM_IA64_SEMAPHORE_H */
diff --git a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
index 4fa733dd417a..ec5f355fb7e3 100644
--- a/include/asm-ia64/smp.h
+++ b/include/asm-ia64/smp.h
@@ -38,6 +38,9 @@ ia64_get_lid (void)
38 return lid.f.id << 8 | lid.f.eid; 38 return lid.f.id << 8 | lid.f.eid;
39} 39}
40 40
41extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
42 void *info, int wait);
43
41#define hard_smp_processor_id() ia64_get_lid() 44#define hard_smp_processor_id() ia64_get_lid()
42 45
43#ifdef CONFIG_SMP 46#ifdef CONFIG_SMP
diff --git a/include/asm-ia64/sn/nodepda.h b/include/asm-ia64/sn/nodepda.h
index 6f6d69e39ff5..ee118b901de4 100644
--- a/include/asm-ia64/sn/nodepda.h
+++ b/include/asm-ia64/sn/nodepda.h
@@ -9,7 +9,6 @@
9#define _ASM_IA64_SN_NODEPDA_H 9#define _ASM_IA64_SN_NODEPDA_H
10 10
11 11
12#include <asm/semaphore.h>
13#include <asm/irq.h> 12#include <asm/irq.h>
14#include <asm/sn/arch.h> 13#include <asm/sn/arch.h>
15#include <asm/sn/intr.h> 14#include <asm/sn/intr.h>
diff --git a/include/asm-ia64/sn/xp.h b/include/asm-ia64/sn/xp.h
deleted file mode 100644
index f7711b308e48..000000000000
--- a/include/asm-ia64/sn/xp.h
+++ /dev/null
@@ -1,485 +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) 2004-2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9
10/*
11 * External Cross Partition (XP) structures and defines.
12 */
13
14
15#ifndef _ASM_IA64_SN_XP_H
16#define _ASM_IA64_SN_XP_H
17
18
19#include <linux/cache.h>
20#include <linux/hardirq.h>
21#include <linux/mutex.h>
22#include <asm/sn/types.h>
23#include <asm/sn/bte.h>
24
25
26#ifdef USE_DBUG_ON
27#define DBUG_ON(condition) BUG_ON(condition)
28#else
29#define DBUG_ON(condition)
30#endif
31
32
33/*
34 * Define the maximum number of logically defined partitions the system
35 * can support. It is constrained by the maximum number of hardware
36 * partitionable regions. The term 'region' in this context refers to the
37 * minimum number of nodes that can comprise an access protection grouping.
38 * The access protection is in regards to memory, IPI and IOI.
39 *
40 * The maximum number of hardware partitionable regions is equal to the
41 * maximum number of nodes in the entire system divided by the minimum number
42 * of nodes that comprise an access protection grouping.
43 */
44#define XP_MAX_PARTITIONS 64
45
46
47/*
48 * Define the number of u64s required to represent all the C-brick nasids
49 * as a bitmap. The cross-partition kernel modules deal only with
50 * C-brick nasids, thus the need for bitmaps which don't account for
51 * odd-numbered (non C-brick) nasids.
52 */
53#define XP_MAX_PHYSNODE_ID (MAX_NUMALINK_NODES / 2)
54#define XP_NASID_MASK_BYTES ((XP_MAX_PHYSNODE_ID + 7) / 8)
55#define XP_NASID_MASK_WORDS ((XP_MAX_PHYSNODE_ID + 63) / 64)
56
57
58/*
59 * Wrapper for bte_copy() that should it return a failure status will retry
60 * the bte_copy() once in the hope that the failure was due to a temporary
61 * aberration (i.e., the link going down temporarily).
62 *
63 * src - physical address of the source of the transfer.
64 * vdst - virtual address of the destination of the transfer.
65 * len - number of bytes to transfer from source to destination.
66 * mode - see bte_copy() for definition.
67 * notification - see bte_copy() for definition.
68 *
69 * Note: xp_bte_copy() should never be called while holding a spinlock.
70 */
71static inline bte_result_t
72xp_bte_copy(u64 src, u64 vdst, u64 len, u64 mode, void *notification)
73{
74 bte_result_t ret;
75 u64 pdst = ia64_tpa(vdst);
76
77
78 /*
79 * Ensure that the physically mapped memory is contiguous.
80 *
81 * We do this by ensuring that the memory is from region 7 only.
82 * If the need should arise to use memory from one of the other
83 * regions, then modify the BUG_ON() statement to ensure that the
84 * memory from that region is always physically contiguous.
85 */
86 BUG_ON(REGION_NUMBER(vdst) != RGN_KERNEL);
87
88 ret = bte_copy(src, pdst, len, mode, notification);
89 if ((ret != BTE_SUCCESS) && BTE_ERROR_RETRY(ret)) {
90 if (!in_interrupt()) {
91 cond_resched();
92 }
93 ret = bte_copy(src, pdst, len, mode, notification);
94 }
95
96 return ret;
97}
98
99
100/*
101 * XPC establishes channel connections between the local partition and any
102 * other partition that is currently up. Over these channels, kernel-level
103 * `users' can communicate with their counterparts on the other partitions.
104 *
105 * The maxinum number of channels is limited to eight. For performance reasons,
106 * the internal cross partition structures require sixteen bytes per channel,
107 * and eight allows all of this interface-shared info to fit in one cache line.
108 *
109 * XPC_NCHANNELS reflects the total number of channels currently defined.
110 * If the need for additional channels arises, one can simply increase
111 * XPC_NCHANNELS accordingly. If the day should come where that number
112 * exceeds the MAXIMUM number of channels allowed (eight), then one will need
113 * to make changes to the XPC code to allow for this.
114 */
115#define XPC_MEM_CHANNEL 0 /* memory channel number */
116#define XPC_NET_CHANNEL 1 /* network channel number */
117
118#define XPC_NCHANNELS 2 /* #of defined channels */
119#define XPC_MAX_NCHANNELS 8 /* max #of channels allowed */
120
121#if XPC_NCHANNELS > XPC_MAX_NCHANNELS
122#error XPC_NCHANNELS exceeds MAXIMUM allowed.
123#endif
124
125
126/*
127 * The format of an XPC message is as follows:
128 *
129 * +-------+--------------------------------+
130 * | flags |////////////////////////////////|
131 * +-------+--------------------------------+
132 * | message # |
133 * +----------------------------------------+
134 * | payload (user-defined message) |
135 * | |
136 * :
137 * | |
138 * +----------------------------------------+
139 *
140 * The size of the payload is defined by the user via xpc_connect(). A user-
141 * defined message resides in the payload area.
142 *
143 * The user should have no dealings with the message header, but only the
144 * message's payload. When a message entry is allocated (via xpc_allocate())
145 * a pointer to the payload area is returned and not the actual beginning of
146 * the XPC message. The user then constructs a message in the payload area
147 * and passes that pointer as an argument on xpc_send() or xpc_send_notify().
148 *
149 * The size of a message entry (within a message queue) must be a cacheline
150 * sized multiple in order to facilitate the BTE transfer of messages from one
151 * message queue to another. A macro, XPC_MSG_SIZE(), is provided for the user
152 * that wants to fit as many msg entries as possible in a given memory size
153 * (e.g. a memory page).
154 */
155struct xpc_msg {
156 u8 flags; /* FOR XPC INTERNAL USE ONLY */
157 u8 reserved[7]; /* FOR XPC INTERNAL USE ONLY */
158 s64 number; /* FOR XPC INTERNAL USE ONLY */
159
160 u64 payload; /* user defined portion of message */
161};
162
163
164#define XPC_MSG_PAYLOAD_OFFSET (u64) (&((struct xpc_msg *)0)->payload)
165#define XPC_MSG_SIZE(_payload_size) \
166 L1_CACHE_ALIGN(XPC_MSG_PAYLOAD_OFFSET + (_payload_size))
167
168
169/*
170 * Define the return values and values passed to user's callout functions.
171 * (It is important to add new value codes at the end just preceding
172 * xpcUnknownReason, which must have the highest numerical value.)
173 */
174enum xpc_retval {
175 xpcSuccess = 0,
176
177 xpcNotConnected, /* 1: channel is not connected */
178 xpcConnected, /* 2: channel connected (opened) */
179 xpcRETIRED1, /* 3: (formerly xpcDisconnected) */
180
181 xpcMsgReceived, /* 4: message received */
182 xpcMsgDelivered, /* 5: message delivered and acknowledged */
183
184 xpcRETIRED2, /* 6: (formerly xpcTransferFailed) */
185
186 xpcNoWait, /* 7: operation would require wait */
187 xpcRetry, /* 8: retry operation */
188 xpcTimeout, /* 9: timeout in xpc_allocate_msg_wait() */
189 xpcInterrupted, /* 10: interrupted wait */
190
191 xpcUnequalMsgSizes, /* 11: message size disparity between sides */
192 xpcInvalidAddress, /* 12: invalid address */
193
194 xpcNoMemory, /* 13: no memory available for XPC structures */
195 xpcLackOfResources, /* 14: insufficient resources for operation */
196 xpcUnregistered, /* 15: channel is not registered */
197 xpcAlreadyRegistered, /* 16: channel is already registered */
198
199 xpcPartitionDown, /* 17: remote partition is down */
200 xpcNotLoaded, /* 18: XPC module is not loaded */
201 xpcUnloading, /* 19: this side is unloading XPC module */
202
203 xpcBadMagic, /* 20: XPC MAGIC string not found */
204
205 xpcReactivating, /* 21: remote partition was reactivated */
206
207 xpcUnregistering, /* 22: this side is unregistering channel */
208 xpcOtherUnregistering, /* 23: other side is unregistering channel */
209
210 xpcCloneKThread, /* 24: cloning kernel thread */
211 xpcCloneKThreadFailed, /* 25: cloning kernel thread failed */
212
213 xpcNoHeartbeat, /* 26: remote partition has no heartbeat */
214
215 xpcPioReadError, /* 27: PIO read error */
216 xpcPhysAddrRegFailed, /* 28: registration of phys addr range failed */
217
218 xpcBteDirectoryError, /* 29: maps to BTEFAIL_DIR */
219 xpcBtePoisonError, /* 30: maps to BTEFAIL_POISON */
220 xpcBteWriteError, /* 31: maps to BTEFAIL_WERR */
221 xpcBteAccessError, /* 32: maps to BTEFAIL_ACCESS */
222 xpcBtePWriteError, /* 33: maps to BTEFAIL_PWERR */
223 xpcBtePReadError, /* 34: maps to BTEFAIL_PRERR */
224 xpcBteTimeOutError, /* 35: maps to BTEFAIL_TOUT */
225 xpcBteXtalkError, /* 36: maps to BTEFAIL_XTERR */
226 xpcBteNotAvailable, /* 37: maps to BTEFAIL_NOTAVAIL */
227 xpcBteUnmappedError, /* 38: unmapped BTEFAIL_ error */
228
229 xpcBadVersion, /* 39: bad version number */
230 xpcVarsNotSet, /* 40: the XPC variables are not set up */
231 xpcNoRsvdPageAddr, /* 41: unable to get rsvd page's phys addr */
232 xpcInvalidPartid, /* 42: invalid partition ID */
233 xpcLocalPartid, /* 43: local partition ID */
234
235 xpcOtherGoingDown, /* 44: other side going down, reason unknown */
236 xpcSystemGoingDown, /* 45: system is going down, reason unknown */
237 xpcSystemHalt, /* 46: system is being halted */
238 xpcSystemReboot, /* 47: system is being rebooted */
239 xpcSystemPoweroff, /* 48: system is being powered off */
240
241 xpcDisconnecting, /* 49: channel disconnecting (closing) */
242
243 xpcOpenCloseError, /* 50: channel open/close protocol error */
244
245 xpcDisconnected, /* 51: channel disconnected (closed) */
246
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 */
271};
272
273
274/*
275 * Define the callout function types used by XPC to update the user on
276 * connection activity and state changes (via the user function registered by
277 * xpc_connect()) and to notify them of messages received and delivered (via
278 * the user function registered by xpc_send_notify()).
279 *
280 * The two function types are xpc_channel_func and xpc_notify_func and
281 * both share the following arguments, with the exception of "data", which
282 * only xpc_channel_func has.
283 *
284 * Arguments:
285 *
286 * reason - reason code. (See following table.)
287 * partid - partition ID associated with condition.
288 * ch_number - channel # associated with condition.
289 * data - pointer to optional data. (See following table.)
290 * key - pointer to optional user-defined value provided as the "key"
291 * argument to xpc_connect() or xpc_send_notify().
292 *
293 * In the following table the "Optional Data" column applies to callouts made
294 * to functions registered by xpc_connect(). A "NA" in that column indicates
295 * that this reason code can be passed to functions registered by
296 * xpc_send_notify() (i.e. they don't have data arguments).
297 *
298 * Also, the first three reason codes in the following table indicate
299 * success, whereas the others indicate failure. When a failure reason code
300 * is received, one can assume that the channel is not connected.
301 *
302 *
303 * Reason Code | Cause | Optional Data
304 * =====================+================================+=====================
305 * xpcConnected | connection has been established| max #of entries
306 * | to the specified partition on | allowed in message
307 * | the specified channel | queue
308 * ---------------------+--------------------------------+---------------------
309 * xpcMsgReceived | an XPC message arrived from | address of payload
310 * | the specified partition on the |
311 * | specified channel | [the user must call
312 * | | xpc_received() when
313 * | | finished with the
314 * | | payload]
315 * ---------------------+--------------------------------+---------------------
316 * xpcMsgDelivered | notification that the message | NA
317 * | was delivered to the intended |
318 * | recipient and that they have |
319 * | acknowledged its receipt by |
320 * | calling xpc_received() |
321 * =====================+================================+=====================
322 * xpcUnequalMsgSizes | can't connect to the specified | NULL
323 * | partition on the specified |
324 * | channel because of mismatched |
325 * | message sizes |
326 * ---------------------+--------------------------------+---------------------
327 * xpcNoMemory | insufficient memory avaiable | NULL
328 * | to allocate message queue |
329 * ---------------------+--------------------------------+---------------------
330 * xpcLackOfResources | lack of resources to create | NULL
331 * | the necessary kthreads to |
332 * | support the channel |
333 * ---------------------+--------------------------------+---------------------
334 * xpcUnregistering | this side's user has | NULL or NA
335 * | unregistered by calling |
336 * | xpc_disconnect() |
337 * ---------------------+--------------------------------+---------------------
338 * xpcOtherUnregistering| the other side's user has | NULL or NA
339 * | unregistered by calling |
340 * | xpc_disconnect() |
341 * ---------------------+--------------------------------+---------------------
342 * xpcNoHeartbeat | the other side's XPC is no | NULL or NA
343 * | longer heartbeating |
344 * | |
345 * ---------------------+--------------------------------+---------------------
346 * xpcUnloading | this side's XPC module is | NULL or NA
347 * | being unloaded |
348 * | |
349 * ---------------------+--------------------------------+---------------------
350 * xpcOtherUnloading | the other side's XPC module is | NULL or NA
351 * | is being unloaded |
352 * | |
353 * ---------------------+--------------------------------+---------------------
354 * xpcPioReadError | xp_nofault_PIOR() returned an | NULL or NA
355 * | error while sending an IPI |
356 * | |
357 * ---------------------+--------------------------------+---------------------
358 * xpcInvalidAddress | the address either received or | NULL or NA
359 * | sent by the specified partition|
360 * | is invalid |
361 * ---------------------+--------------------------------+---------------------
362 * xpcBteNotAvailable | attempt to pull data from the | NULL or NA
363 * xpcBtePoisonError | specified partition over the |
364 * xpcBteWriteError | specified channel via a |
365 * xpcBteAccessError | bte_copy() failed |
366 * xpcBteTimeOutError | |
367 * xpcBteXtalkError | |
368 * xpcBteDirectoryError | |
369 * xpcBteGenericError | |
370 * xpcBteUnmappedError | |
371 * ---------------------+--------------------------------+---------------------
372 * xpcUnknownReason | the specified channel to the | NULL or NA
373 * | specified partition was |
374 * | unavailable for unknown reasons|
375 * =====================+================================+=====================
376 */
377
378typedef void (*xpc_channel_func)(enum xpc_retval reason, partid_t partid,
379 int ch_number, void *data, void *key);
380
381typedef void (*xpc_notify_func)(enum xpc_retval reason, partid_t partid,
382 int ch_number, void *key);
383
384
385/*
386 * The following is a registration entry. There is a global array of these,
387 * one per channel. It is used to record the connection registration made
388 * by the users of XPC. As long as a registration entry exists, for any
389 * partition that comes up, XPC will attempt to establish a connection on
390 * that channel. Notification that a connection has been made will occur via
391 * the xpc_channel_func function.
392 *
393 * The 'func' field points to the function to call when aynchronous
394 * notification is required for such events as: a connection established/lost,
395 * or an incoming message received, or an error condition encountered. A
396 * non-NULL 'func' field indicates that there is an active registration for
397 * the channel.
398 */
399struct xpc_registration {
400 struct mutex mutex;
401 xpc_channel_func func; /* function to call */
402 void *key; /* pointer to user's key */
403 u16 nentries; /* #of msg entries in local msg queue */
404 u16 msg_size; /* message queue's message size */
405 u32 assigned_limit; /* limit on #of assigned kthreads */
406 u32 idle_limit; /* limit on #of idle kthreads */
407} ____cacheline_aligned;
408
409
410#define XPC_CHANNEL_REGISTERED(_c) (xpc_registrations[_c].func != NULL)
411
412
413/* the following are valid xpc_allocate() flags */
414#define XPC_WAIT 0 /* wait flag */
415#define XPC_NOWAIT 1 /* no wait flag */
416
417
418struct xpc_interface {
419 void (*connect)(int);
420 void (*disconnect)(int);
421 enum xpc_retval (*allocate)(partid_t, int, u32, void **);
422 enum xpc_retval (*send)(partid_t, int, void *);
423 enum xpc_retval (*send_notify)(partid_t, int, void *,
424 xpc_notify_func, void *);
425 void (*received)(partid_t, int, void *);
426 enum xpc_retval (*partid_to_nasids)(partid_t, void *);
427};
428
429
430extern struct xpc_interface xpc_interface;
431
432extern void xpc_set_interface(void (*)(int),
433 void (*)(int),
434 enum xpc_retval (*)(partid_t, int, u32, void **),
435 enum xpc_retval (*)(partid_t, int, void *),
436 enum xpc_retval (*)(partid_t, int, void *, xpc_notify_func,
437 void *),
438 void (*)(partid_t, int, void *),
439 enum xpc_retval (*)(partid_t, void *));
440extern void xpc_clear_interface(void);
441
442
443extern enum xpc_retval xpc_connect(int, xpc_channel_func, void *, u16,
444 u16, u32, u32);
445extern void xpc_disconnect(int);
446
447static inline enum xpc_retval
448xpc_allocate(partid_t partid, int ch_number, u32 flags, void **payload)
449{
450 return xpc_interface.allocate(partid, ch_number, flags, payload);
451}
452
453static inline enum xpc_retval
454xpc_send(partid_t partid, int ch_number, void *payload)
455{
456 return xpc_interface.send(partid, ch_number, payload);
457}
458
459static inline enum xpc_retval
460xpc_send_notify(partid_t partid, int ch_number, void *payload,
461 xpc_notify_func func, void *key)
462{
463 return xpc_interface.send_notify(partid, ch_number, payload, func, key);
464}
465
466static inline void
467xpc_received(partid_t partid, int ch_number, void *payload)
468{
469 return xpc_interface.received(partid, ch_number, payload);
470}
471
472static inline enum xpc_retval
473xpc_partid_to_nasids(partid_t partid, void *nasids)
474{
475 return xpc_interface.partid_to_nasids(partid, nasids);
476}
477
478
479extern u64 xp_nofault_PIOR_target;
480extern int xp_nofault_PIOR(void *);
481extern int xp_error_PIOR(void);
482
483
484#endif /* _ASM_IA64_SN_XP_H */
485
diff --git a/include/asm-ia64/sn/xpc.h b/include/asm-ia64/sn/xpc.h
deleted file mode 100644
index 3c0900ab8003..000000000000
--- a/include/asm-ia64/sn/xpc.h
+++ /dev/null
@@ -1,1267 +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) 2004-2007 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9
10/*
11 * Cross Partition Communication (XPC) structures and macros.
12 */
13
14#ifndef _ASM_IA64_SN_XPC_H
15#define _ASM_IA64_SN_XPC_H
16
17
18#include <linux/interrupt.h>
19#include <linux/sysctl.h>
20#include <linux/device.h>
21#include <linux/mutex.h>
22#include <linux/completion.h>
23#include <asm/pgtable.h>
24#include <asm/processor.h>
25#include <asm/sn/bte.h>
26#include <asm/sn/clksupport.h>
27#include <asm/sn/addrs.h>
28#include <asm/sn/mspec.h>
29#include <asm/sn/shub_mmr.h>
30#include <asm/sn/xp.h>
31
32
33/*
34 * XPC Version numbers consist of a major and minor number. XPC can always
35 * talk to versions with same major #, and never talk to versions with a
36 * different major #.
37 */
38#define _XPC_VERSION(_maj, _min) (((_maj) << 4) | ((_min) & 0xf))
39#define XPC_VERSION_MAJOR(_v) ((_v) >> 4)
40#define XPC_VERSION_MINOR(_v) ((_v) & 0xf)
41
42
43/*
44 * The next macros define word or bit representations for given
45 * C-brick nasid in either the SAL provided bit array representing
46 * nasids in the partition/machine or the AMO_t array used for
47 * inter-partition initiation communications.
48 *
49 * For SN2 machines, C-Bricks are alway even numbered NASIDs. As
50 * such, some space will be saved by insisting that nasid information
51 * passed from SAL always be packed for C-Bricks and the
52 * cross-partition interrupts use the same packing scheme.
53 */
54#define XPC_NASID_W_INDEX(_n) (((_n) / 64) / 2)
55#define XPC_NASID_B_INDEX(_n) (((_n) / 2) & (64 - 1))
56#define XPC_NASID_IN_ARRAY(_n, _p) ((_p)[XPC_NASID_W_INDEX(_n)] & \
57 (1UL << XPC_NASID_B_INDEX(_n)))
58#define XPC_NASID_FROM_W_B(_w, _b) (((_w) * 64 + (_b)) * 2)
59
60#define XPC_HB_DEFAULT_INTERVAL 5 /* incr HB every x secs */
61#define XPC_HB_CHECK_DEFAULT_INTERVAL 20 /* check HB every x secs */
62
63/* define the process name of HB checker and the CPU it is pinned to */
64#define XPC_HB_CHECK_THREAD_NAME "xpc_hb"
65#define XPC_HB_CHECK_CPU 0
66
67/* define the process name of the discovery thread */
68#define XPC_DISCOVERY_THREAD_NAME "xpc_discovery"
69
70
71/*
72 * the reserved page
73 *
74 * SAL reserves one page of memory per partition for XPC. Though a full page
75 * in length (16384 bytes), its starting address is not page aligned, but it
76 * is cacheline aligned. The reserved page consists of the following:
77 *
78 * reserved page header
79 *
80 * The first cacheline of the reserved page contains the header
81 * (struct xpc_rsvd_page). Before SAL initialization has completed,
82 * SAL has set up the following fields of the reserved page header:
83 * SAL_signature, SAL_version, partid, and nasids_size. The other
84 * fields are set up by XPC. (xpc_rsvd_page points to the local
85 * partition's reserved page.)
86 *
87 * part_nasids mask
88 * mach_nasids mask
89 *
90 * SAL also sets up two bitmaps (or masks), one that reflects the actual
91 * nasids in this partition (part_nasids), and the other that reflects
92 * the actual nasids in the entire machine (mach_nasids). We're only
93 * interested in the even numbered nasids (which contain the processors
94 * and/or memory), so we only need half as many bits to represent the
95 * nasids. The part_nasids mask is located starting at the first cacheline
96 * following the reserved page header. The mach_nasids mask follows right
97 * after the part_nasids mask. The size in bytes of each mask is reflected
98 * by the reserved page header field 'nasids_size'. (Local partition's
99 * mask pointers are xpc_part_nasids and xpc_mach_nasids.)
100 *
101 * vars
102 * vars part
103 *
104 * Immediately following the mach_nasids mask are the XPC variables
105 * required by other partitions. First are those that are generic to all
106 * partitions (vars), followed on the next available cacheline by those
107 * which are partition specific (vars part). These are setup by XPC.
108 * (Local partition's vars pointers are xpc_vars and xpc_vars_part.)
109 *
110 * Note: Until vars_pa is set, the partition XPC code has not been initialized.
111 */
112struct xpc_rsvd_page {
113 u64 SAL_signature; /* SAL: unique signature */
114 u64 SAL_version; /* SAL: version */
115 u8 partid; /* SAL: partition ID */
116 u8 version;
117 u8 pad1[6]; /* align to next u64 in cacheline */
118 volatile u64 vars_pa;
119 struct timespec stamp; /* time when reserved page was setup by XPC */
120 u64 pad2[9]; /* align to last u64 in cacheline */
121 u64 nasids_size; /* SAL: size of each nasid mask in bytes */
122};
123
124#define XPC_RP_VERSION _XPC_VERSION(1,1) /* version 1.1 of the reserved page */
125
126#define XPC_SUPPORTS_RP_STAMP(_version) \
127 (_version >= _XPC_VERSION(1,1))
128
129/*
130 * compare stamps - the return value is:
131 *
132 * < 0, if stamp1 < stamp2
133 * = 0, if stamp1 == stamp2
134 * > 0, if stamp1 > stamp2
135 */
136static inline int
137xpc_compare_stamps(struct timespec *stamp1, struct timespec *stamp2)
138{
139 int ret;
140
141
142 if ((ret = stamp1->tv_sec - stamp2->tv_sec) == 0) {
143 ret = stamp1->tv_nsec - stamp2->tv_nsec;
144 }
145 return ret;
146}
147
148
149/*
150 * Define the structures by which XPC variables can be exported to other
151 * partitions. (There are two: struct xpc_vars and struct xpc_vars_part)
152 */
153
154/*
155 * The following structure describes the partition generic variables
156 * needed by other partitions in order to properly initialize.
157 *
158 * struct xpc_vars version number also applies to struct xpc_vars_part.
159 * Changes to either structure and/or related functionality should be
160 * reflected by incrementing either the major or minor version numbers
161 * of struct xpc_vars.
162 */
163struct xpc_vars {
164 u8 version;
165 u64 heartbeat;
166 u64 heartbeating_to_mask;
167 u64 heartbeat_offline; /* if 0, heartbeat should be changing */
168 int act_nasid;
169 int act_phys_cpuid;
170 u64 vars_part_pa;
171 u64 amos_page_pa; /* paddr of page of AMOs from MSPEC driver */
172 AMO_t *amos_page; /* vaddr of page of AMOs from MSPEC driver */
173};
174
175#define XPC_V_VERSION _XPC_VERSION(3,1) /* version 3.1 of the cross vars */
176
177#define XPC_SUPPORTS_DISENGAGE_REQUEST(_version) \
178 (_version >= _XPC_VERSION(3,1))
179
180
181static inline int
182xpc_hb_allowed(partid_t partid, struct xpc_vars *vars)
183{
184 return ((vars->heartbeating_to_mask & (1UL << partid)) != 0);
185}
186
187static inline void
188xpc_allow_hb(partid_t partid, struct xpc_vars *vars)
189{
190 u64 old_mask, new_mask;
191
192 do {
193 old_mask = vars->heartbeating_to_mask;
194 new_mask = (old_mask | (1UL << partid));
195 } while (cmpxchg(&vars->heartbeating_to_mask, old_mask, new_mask) !=
196 old_mask);
197}
198
199static inline void
200xpc_disallow_hb(partid_t partid, struct xpc_vars *vars)
201{
202 u64 old_mask, new_mask;
203
204 do {
205 old_mask = vars->heartbeating_to_mask;
206 new_mask = (old_mask & ~(1UL << partid));
207 } while (cmpxchg(&vars->heartbeating_to_mask, old_mask, new_mask) !=
208 old_mask);
209}
210
211
212/*
213 * The AMOs page consists of a number of AMO variables which are divided into
214 * four groups, The first two groups are used to identify an IRQ's sender.
215 * These two groups consist of 64 and 128 AMO variables respectively. The last
216 * two groups, consisting of just one AMO variable each, are used to identify
217 * the remote partitions that are currently engaged (from the viewpoint of
218 * the XPC running on the remote partition).
219 */
220#define XPC_NOTIFY_IRQ_AMOS 0
221#define XPC_ACTIVATE_IRQ_AMOS (XPC_NOTIFY_IRQ_AMOS + XP_MAX_PARTITIONS)
222#define XPC_ENGAGED_PARTITIONS_AMO (XPC_ACTIVATE_IRQ_AMOS + XP_NASID_MASK_WORDS)
223#define XPC_DISENGAGE_REQUEST_AMO (XPC_ENGAGED_PARTITIONS_AMO + 1)
224
225
226/*
227 * The following structure describes the per partition specific variables.
228 *
229 * An array of these structures, one per partition, will be defined. As a
230 * partition becomes active XPC will copy the array entry corresponding to
231 * itself from that partition. It is desirable that the size of this
232 * structure evenly divide into a cacheline, such that none of the entries
233 * in this array crosses a cacheline boundary. As it is now, each entry
234 * occupies half a cacheline.
235 */
236struct xpc_vars_part {
237 volatile u64 magic;
238
239 u64 openclose_args_pa; /* physical address of open and close args */
240 u64 GPs_pa; /* physical address of Get/Put values */
241
242 u64 IPI_amo_pa; /* physical address of IPI AMO_t structure */
243 int IPI_nasid; /* nasid of where to send IPIs */
244 int IPI_phys_cpuid; /* physical CPU ID of where to send IPIs */
245
246 u8 nchannels; /* #of defined channels supported */
247
248 u8 reserved[23]; /* pad to a full 64 bytes */
249};
250
251/*
252 * The vars_part MAGIC numbers play a part in the first contact protocol.
253 *
254 * MAGIC1 indicates that the per partition specific variables for a remote
255 * partition have been initialized by this partition.
256 *
257 * MAGIC2 indicates that this partition has pulled the remote partititions
258 * per partition variables that pertain to this partition.
259 */
260#define XPC_VP_MAGIC1 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */
261#define XPC_VP_MAGIC2 0x0073726176435058L /* 'XPCvars\0'L (little endian) */
262
263
264/* the reserved page sizes and offsets */
265
266#define XPC_RP_HEADER_SIZE L1_CACHE_ALIGN(sizeof(struct xpc_rsvd_page))
267#define XPC_RP_VARS_SIZE L1_CACHE_ALIGN(sizeof(struct xpc_vars))
268
269#define XPC_RP_PART_NASIDS(_rp) (u64 *) ((u8 *) _rp + XPC_RP_HEADER_SIZE)
270#define XPC_RP_MACH_NASIDS(_rp) (XPC_RP_PART_NASIDS(_rp) + xp_nasid_mask_words)
271#define XPC_RP_VARS(_rp) ((struct xpc_vars *) XPC_RP_MACH_NASIDS(_rp) + xp_nasid_mask_words)
272#define XPC_RP_VARS_PART(_rp) (struct xpc_vars_part *) ((u8 *) XPC_RP_VARS(rp) + XPC_RP_VARS_SIZE)
273
274
275/*
276 * Functions registered by add_timer() or called by kernel_thread() only
277 * allow for a single 64-bit argument. The following macros can be used to
278 * pack and unpack two (32-bit, 16-bit or 8-bit) arguments into or out from
279 * the passed argument.
280 */
281#define XPC_PACK_ARGS(_arg1, _arg2) \
282 ((((u64) _arg1) & 0xffffffff) | \
283 ((((u64) _arg2) & 0xffffffff) << 32))
284
285#define XPC_UNPACK_ARG1(_args) (((u64) _args) & 0xffffffff)
286#define XPC_UNPACK_ARG2(_args) ((((u64) _args) >> 32) & 0xffffffff)
287
288
289
290/*
291 * Define a Get/Put value pair (pointers) used with a message queue.
292 */
293struct xpc_gp {
294 volatile s64 get; /* Get value */
295 volatile s64 put; /* Put value */
296};
297
298#define XPC_GP_SIZE \
299 L1_CACHE_ALIGN(sizeof(struct xpc_gp) * XPC_NCHANNELS)
300
301
302
303/*
304 * Define a structure that contains arguments associated with opening and
305 * closing a channel.
306 */
307struct xpc_openclose_args {
308 u16 reason; /* reason why channel is closing */
309 u16 msg_size; /* sizeof each message entry */
310 u16 remote_nentries; /* #of message entries in remote msg queue */
311 u16 local_nentries; /* #of message entries in local msg queue */
312 u64 local_msgqueue_pa; /* physical address of local message queue */
313};
314
315#define XPC_OPENCLOSE_ARGS_SIZE \
316 L1_CACHE_ALIGN(sizeof(struct xpc_openclose_args) * XPC_NCHANNELS)
317
318
319
320/* struct xpc_msg flags */
321
322#define XPC_M_DONE 0x01 /* msg has been received/consumed */
323#define XPC_M_READY 0x02 /* msg is ready to be sent */
324#define XPC_M_INTERRUPT 0x04 /* send interrupt when msg consumed */
325
326
327#define XPC_MSG_ADDRESS(_payload) \
328 ((struct xpc_msg *)((u8 *)(_payload) - XPC_MSG_PAYLOAD_OFFSET))
329
330
331
332/*
333 * Defines notify entry.
334 *
335 * This is used to notify a message's sender that their message was received
336 * and consumed by the intended recipient.
337 */
338struct xpc_notify {
339 volatile u8 type; /* type of notification */
340
341 /* the following two fields are only used if type == XPC_N_CALL */
342 xpc_notify_func func; /* user's notify function */
343 void *key; /* pointer to user's key */
344};
345
346/* struct xpc_notify type of notification */
347
348#define XPC_N_CALL 0x01 /* notify function provided by user */
349
350
351
352/*
353 * Define the structure that manages all the stuff required by a channel. In
354 * particular, they are used to manage the messages sent across the channel.
355 *
356 * This structure is private to a partition, and is NOT shared across the
357 * partition boundary.
358 *
359 * There is an array of these structures for each remote partition. It is
360 * allocated at the time a partition becomes active. The array contains one
361 * of these structures for each potential channel connection to that partition.
362 *
363 * Each of these structures manages two message queues (circular buffers).
364 * They are allocated at the time a channel connection is made. One of
365 * these message queues (local_msgqueue) holds the locally created messages
366 * that are destined for the remote partition. The other of these message
367 * queues (remote_msgqueue) is a locally cached copy of the remote partition's
368 * own local_msgqueue.
369 *
370 * The following is a description of the Get/Put pointers used to manage these
371 * two message queues. Consider the local_msgqueue to be on one partition
372 * and the remote_msgqueue to be its cached copy on another partition. A
373 * description of what each of the lettered areas contains is included.
374 *
375 *
376 * local_msgqueue remote_msgqueue
377 *
378 * |/////////| |/////////|
379 * w_remote_GP.get --> +---------+ |/////////|
380 * | F | |/////////|
381 * remote_GP.get --> +---------+ +---------+ <-- local_GP->get
382 * | | | |
383 * | | | E |
384 * | | | |
385 * | | +---------+ <-- w_local_GP.get
386 * | B | |/////////|
387 * | | |////D////|
388 * | | |/////////|
389 * | | +---------+ <-- w_remote_GP.put
390 * | | |////C////|
391 * local_GP->put --> +---------+ +---------+ <-- remote_GP.put
392 * | | |/////////|
393 * | A | |/////////|
394 * | | |/////////|
395 * w_local_GP.put --> +---------+ |/////////|
396 * |/////////| |/////////|
397 *
398 *
399 * ( remote_GP.[get|put] are cached copies of the remote
400 * partition's local_GP->[get|put], and thus their values can
401 * lag behind their counterparts on the remote partition. )
402 *
403 *
404 * A - Messages that have been allocated, but have not yet been sent to the
405 * remote partition.
406 *
407 * B - Messages that have been sent, but have not yet been acknowledged by the
408 * remote partition as having been received.
409 *
410 * C - Area that needs to be prepared for the copying of sent messages, by
411 * the clearing of the message flags of any previously received messages.
412 *
413 * D - Area into which sent messages are to be copied from the remote
414 * partition's local_msgqueue and then delivered to their intended
415 * recipients. [ To allow for a multi-message copy, another pointer
416 * (next_msg_to_pull) has been added to keep track of the next message
417 * number needing to be copied (pulled). It chases after w_remote_GP.put.
418 * Any messages lying between w_local_GP.get and next_msg_to_pull have
419 * been copied and are ready to be delivered. ]
420 *
421 * E - Messages that have been copied and delivered, but have not yet been
422 * acknowledged by the recipient as having been received.
423 *
424 * F - Messages that have been acknowledged, but XPC has not yet notified the
425 * sender that the message was received by its intended recipient.
426 * This is also an area that needs to be prepared for the allocating of
427 * new messages, by the clearing of the message flags of the acknowledged
428 * messages.
429 */
430struct xpc_channel {
431 partid_t partid; /* ID of remote partition connected */
432 spinlock_t lock; /* lock for updating this structure */
433 u32 flags; /* general flags */
434
435 enum xpc_retval reason; /* reason why channel is disconnect'g */
436 int reason_line; /* line# disconnect initiated from */
437
438 u16 number; /* channel # */
439
440 u16 msg_size; /* sizeof each msg entry */
441 u16 local_nentries; /* #of msg entries in local msg queue */
442 u16 remote_nentries; /* #of msg entries in remote msg queue*/
443
444 void *local_msgqueue_base; /* base address of kmalloc'd space */
445 struct xpc_msg *local_msgqueue; /* local message queue */
446 void *remote_msgqueue_base; /* base address of kmalloc'd space */
447 struct xpc_msg *remote_msgqueue;/* cached copy of remote partition's */
448 /* local message queue */
449 u64 remote_msgqueue_pa; /* phys addr of remote partition's */
450 /* local message queue */
451
452 atomic_t references; /* #of external references to queues */
453
454 atomic_t n_on_msg_allocate_wq; /* #on msg allocation wait queue */
455 wait_queue_head_t msg_allocate_wq; /* msg allocation wait queue */
456
457 u8 delayed_IPI_flags; /* IPI flags received, but delayed */
458 /* action until channel disconnected */
459
460 /* queue of msg senders who want to be notified when msg received */
461
462 atomic_t n_to_notify; /* #of msg senders to notify */
463 struct xpc_notify *notify_queue;/* notify queue for messages sent */
464
465 xpc_channel_func func; /* user's channel function */
466 void *key; /* pointer to user's key */
467
468 struct mutex msg_to_pull_mutex; /* next msg to pull serialization */
469 struct completion wdisconnect_wait; /* wait for channel disconnect */
470
471 struct xpc_openclose_args *local_openclose_args; /* args passed on */
472 /* opening or closing of channel */
473
474 /* various flavors of local and remote Get/Put values */
475
476 struct xpc_gp *local_GP; /* local Get/Put values */
477 struct xpc_gp remote_GP; /* remote Get/Put values */
478 struct xpc_gp w_local_GP; /* working local Get/Put values */
479 struct xpc_gp w_remote_GP; /* working remote Get/Put values */
480 s64 next_msg_to_pull; /* Put value of next msg to pull */
481
482 /* kthread management related fields */
483
484// >>> rethink having kthreads_assigned_limit and kthreads_idle_limit; perhaps
485// >>> allow the assigned limit be unbounded and let the idle limit be dynamic
486// >>> dependent on activity over the last interval of time
487 atomic_t kthreads_assigned; /* #of kthreads assigned to channel */
488 u32 kthreads_assigned_limit; /* limit on #of kthreads assigned */
489 atomic_t kthreads_idle; /* #of kthreads idle waiting for work */
490 u32 kthreads_idle_limit; /* limit on #of kthreads idle */
491 atomic_t kthreads_active; /* #of kthreads actively working */
492 // >>> following field is temporary
493 u32 kthreads_created; /* total #of kthreads created */
494
495 wait_queue_head_t idle_wq; /* idle kthread wait queue */
496
497} ____cacheline_aligned;
498
499
500/* struct xpc_channel flags */
501
502#define XPC_C_WASCONNECTED 0x00000001 /* channel was connected */
503
504#define XPC_C_ROPENREPLY 0x00000002 /* remote open channel reply */
505#define XPC_C_OPENREPLY 0x00000004 /* local open channel reply */
506#define XPC_C_ROPENREQUEST 0x00000008 /* remote open channel request */
507#define XPC_C_OPENREQUEST 0x00000010 /* local open channel request */
508
509#define XPC_C_SETUP 0x00000020 /* channel's msgqueues are alloc'd */
510#define XPC_C_CONNECTEDCALLOUT 0x00000040 /* connected callout initiated */
511#define XPC_C_CONNECTEDCALLOUT_MADE \
512 0x00000080 /* connected callout completed */
513#define XPC_C_CONNECTED 0x00000100 /* local channel is connected */
514#define XPC_C_CONNECTING 0x00000200 /* channel is being connected */
515
516#define XPC_C_RCLOSEREPLY 0x00000400 /* remote close channel reply */
517#define XPC_C_CLOSEREPLY 0x00000800 /* local close channel reply */
518#define XPC_C_RCLOSEREQUEST 0x00001000 /* remote close channel request */
519#define XPC_C_CLOSEREQUEST 0x00002000 /* local close channel request */
520
521#define XPC_C_DISCONNECTED 0x00004000 /* channel is disconnected */
522#define XPC_C_DISCONNECTING 0x00008000 /* channel is being disconnected */
523#define XPC_C_DISCONNECTINGCALLOUT \
524 0x00010000 /* disconnecting callout initiated */
525#define XPC_C_DISCONNECTINGCALLOUT_MADE \
526 0x00020000 /* disconnecting callout completed */
527#define XPC_C_WDISCONNECT 0x00040000 /* waiting for channel disconnect */
528
529
530
531/*
532 * Manages channels on a partition basis. There is one of these structures
533 * for each partition (a partition will never utilize the structure that
534 * represents itself).
535 */
536struct xpc_partition {
537
538 /* XPC HB infrastructure */
539
540 u8 remote_rp_version; /* version# of partition's rsvd pg */
541 struct timespec remote_rp_stamp;/* time when rsvd pg was initialized */
542 u64 remote_rp_pa; /* phys addr of partition's rsvd pg */
543 u64 remote_vars_pa; /* phys addr of partition's vars */
544 u64 remote_vars_part_pa; /* phys addr of partition's vars part */
545 u64 last_heartbeat; /* HB at last read */
546 u64 remote_amos_page_pa; /* phys addr of partition's amos page */
547 int remote_act_nasid; /* active part's act/deact nasid */
548 int remote_act_phys_cpuid; /* active part's act/deact phys cpuid */
549 u32 act_IRQ_rcvd; /* IRQs since activation */
550 spinlock_t act_lock; /* protect updating of act_state */
551 u8 act_state; /* from XPC HB viewpoint */
552 u8 remote_vars_version; /* version# of partition's vars */
553 enum xpc_retval reason; /* reason partition is deactivating */
554 int reason_line; /* line# deactivation initiated from */
555 int reactivate_nasid; /* nasid in partition to reactivate */
556
557 unsigned long disengage_request_timeout; /* timeout in jiffies */
558 struct timer_list disengage_request_timer;
559
560
561 /* XPC infrastructure referencing and teardown control */
562
563 volatile u8 setup_state; /* infrastructure setup state */
564 wait_queue_head_t teardown_wq; /* kthread waiting to teardown infra */
565 atomic_t references; /* #of references to infrastructure */
566
567
568 /*
569 * NONE OF THE PRECEDING FIELDS OF THIS STRUCTURE WILL BE CLEARED WHEN
570 * XPC SETS UP THE NECESSARY INFRASTRUCTURE TO SUPPORT CROSS PARTITION
571 * COMMUNICATION. ALL OF THE FOLLOWING FIELDS WILL BE CLEARED. (THE
572 * 'nchannels' FIELD MUST BE THE FIRST OF THE FIELDS TO BE CLEARED.)
573 */
574
575
576 u8 nchannels; /* #of defined channels supported */
577 atomic_t nchannels_active; /* #of channels that are not DISCONNECTED */
578 atomic_t nchannels_engaged;/* #of channels engaged with remote part */
579 struct xpc_channel *channels;/* array of channel structures */
580
581 void *local_GPs_base; /* base address of kmalloc'd space */
582 struct xpc_gp *local_GPs; /* local Get/Put values */
583 void *remote_GPs_base; /* base address of kmalloc'd space */
584 struct xpc_gp *remote_GPs;/* copy of remote partition's local Get/Put */
585 /* values */
586 u64 remote_GPs_pa; /* phys address of remote partition's local */
587 /* Get/Put values */
588
589
590 /* fields used to pass args when opening or closing a channel */
591
592 void *local_openclose_args_base; /* base address of kmalloc'd space */
593 struct xpc_openclose_args *local_openclose_args; /* local's args */
594 void *remote_openclose_args_base; /* base address of kmalloc'd space */
595 struct xpc_openclose_args *remote_openclose_args; /* copy of remote's */
596 /* args */
597 u64 remote_openclose_args_pa; /* phys addr of remote's args */
598
599
600 /* IPI sending, receiving and handling related fields */
601
602 int remote_IPI_nasid; /* nasid of where to send IPIs */
603 int remote_IPI_phys_cpuid; /* phys CPU ID of where to send IPIs */
604 AMO_t *remote_IPI_amo_va; /* address of remote IPI AMO_t structure */
605
606 AMO_t *local_IPI_amo_va; /* address of IPI AMO_t structure */
607 u64 local_IPI_amo; /* IPI amo flags yet to be handled */
608 char IPI_owner[8]; /* IPI owner's name */
609 struct timer_list dropped_IPI_timer; /* dropped IPI timer */
610
611 spinlock_t IPI_lock; /* IPI handler lock */
612
613
614 /* channel manager related fields */
615
616 atomic_t channel_mgr_requests; /* #of requests to activate chan mgr */
617 wait_queue_head_t channel_mgr_wq; /* channel mgr's wait queue */
618
619} ____cacheline_aligned;
620
621
622/* struct xpc_partition act_state values (for XPC HB) */
623
624#define XPC_P_INACTIVE 0x00 /* partition is not active */
625#define XPC_P_ACTIVATION_REQ 0x01 /* created thread to activate */
626#define XPC_P_ACTIVATING 0x02 /* activation thread started */
627#define XPC_P_ACTIVE 0x03 /* xpc_partition_up() was called */
628#define XPC_P_DEACTIVATING 0x04 /* partition deactivation initiated */
629
630
631#define XPC_DEACTIVATE_PARTITION(_p, _reason) \
632 xpc_deactivate_partition(__LINE__, (_p), (_reason))
633
634
635/* struct xpc_partition setup_state values */
636
637#define XPC_P_UNSET 0x00 /* infrastructure was never setup */
638#define XPC_P_SETUP 0x01 /* infrastructure is setup */
639#define XPC_P_WTEARDOWN 0x02 /* waiting to teardown infrastructure */
640#define XPC_P_TORNDOWN 0x03 /* infrastructure is torndown */
641
642
643
644/*
645 * struct xpc_partition IPI_timer #of seconds to wait before checking for
646 * dropped IPIs. These occur whenever an IPI amo write doesn't complete until
647 * after the IPI was received.
648 */
649#define XPC_P_DROPPED_IPI_WAIT (0.25 * HZ)
650
651
652/* number of seconds to wait for other partitions to disengage */
653#define XPC_DISENGAGE_REQUEST_DEFAULT_TIMELIMIT 90
654
655/* interval in seconds to print 'waiting disengagement' messages */
656#define XPC_DISENGAGE_PRINTMSG_INTERVAL 10
657
658
659#define XPC_PARTID(_p) ((partid_t) ((_p) - &xpc_partitions[0]))
660
661
662
663/* found in xp_main.c */
664extern struct xpc_registration xpc_registrations[];
665
666
667/* found in xpc_main.c */
668extern struct device *xpc_part;
669extern struct device *xpc_chan;
670extern int xpc_disengage_request_timelimit;
671extern int xpc_disengage_request_timedout;
672extern irqreturn_t xpc_notify_IRQ_handler(int, void *);
673extern void xpc_dropped_IPI_check(struct xpc_partition *);
674extern void xpc_activate_partition(struct xpc_partition *);
675extern void xpc_activate_kthreads(struct xpc_channel *, int);
676extern void xpc_create_kthreads(struct xpc_channel *, int, int);
677extern void xpc_disconnect_wait(int);
678
679
680/* found in xpc_partition.c */
681extern int xpc_exiting;
682extern struct xpc_vars *xpc_vars;
683extern struct xpc_rsvd_page *xpc_rsvd_page;
684extern struct xpc_vars_part *xpc_vars_part;
685extern struct xpc_partition xpc_partitions[XP_MAX_PARTITIONS + 1];
686extern char *xpc_remote_copy_buffer;
687extern void *xpc_remote_copy_buffer_base;
688extern void *xpc_kmalloc_cacheline_aligned(size_t, gfp_t, void **);
689extern struct xpc_rsvd_page *xpc_rsvd_page_init(void);
690extern void xpc_allow_IPI_ops(void);
691extern void xpc_restrict_IPI_ops(void);
692extern int xpc_identify_act_IRQ_sender(void);
693extern int xpc_partition_disengaged(struct xpc_partition *);
694extern enum xpc_retval xpc_mark_partition_active(struct xpc_partition *);
695extern void xpc_mark_partition_inactive(struct xpc_partition *);
696extern void xpc_discovery(void);
697extern void xpc_check_remote_hb(void);
698extern void xpc_deactivate_partition(const int, struct xpc_partition *,
699 enum xpc_retval);
700extern enum xpc_retval xpc_initiate_partid_to_nasids(partid_t, void *);
701
702
703/* found in xpc_channel.c */
704extern void xpc_initiate_connect(int);
705extern void xpc_initiate_disconnect(int);
706extern enum xpc_retval xpc_initiate_allocate(partid_t, int, u32, void **);
707extern enum xpc_retval xpc_initiate_send(partid_t, int, void *);
708extern enum xpc_retval xpc_initiate_send_notify(partid_t, int, void *,
709 xpc_notify_func, void *);
710extern void xpc_initiate_received(partid_t, int, void *);
711extern enum xpc_retval xpc_setup_infrastructure(struct xpc_partition *);
712extern enum xpc_retval xpc_pull_remote_vars_part(struct xpc_partition *);
713extern void xpc_process_channel_activity(struct xpc_partition *);
714extern void xpc_connected_callout(struct xpc_channel *);
715extern void xpc_deliver_msg(struct xpc_channel *);
716extern void xpc_disconnect_channel(const int, struct xpc_channel *,
717 enum xpc_retval, unsigned long *);
718extern void xpc_disconnect_callout(struct xpc_channel *, enum xpc_retval);
719extern void xpc_partition_going_down(struct xpc_partition *, enum xpc_retval);
720extern void xpc_teardown_infrastructure(struct xpc_partition *);
721
722
723
724static inline void
725xpc_wakeup_channel_mgr(struct xpc_partition *part)
726{
727 if (atomic_inc_return(&part->channel_mgr_requests) == 1) {
728 wake_up(&part->channel_mgr_wq);
729 }
730}
731
732
733
734/*
735 * These next two inlines are used to keep us from tearing down a channel's
736 * msg queues while a thread may be referencing them.
737 */
738static inline void
739xpc_msgqueue_ref(struct xpc_channel *ch)
740{
741 atomic_inc(&ch->references);
742}
743
744static inline void
745xpc_msgqueue_deref(struct xpc_channel *ch)
746{
747 s32 refs = atomic_dec_return(&ch->references);
748
749 DBUG_ON(refs < 0);
750 if (refs == 0) {
751 xpc_wakeup_channel_mgr(&xpc_partitions[ch->partid]);
752 }
753}
754
755
756
757#define XPC_DISCONNECT_CHANNEL(_ch, _reason, _irqflgs) \
758 xpc_disconnect_channel(__LINE__, _ch, _reason, _irqflgs)
759
760
761/*
762 * These two inlines are used to keep us from tearing down a partition's
763 * setup infrastructure while a thread may be referencing it.
764 */
765static inline void
766xpc_part_deref(struct xpc_partition *part)
767{
768 s32 refs = atomic_dec_return(&part->references);
769
770
771 DBUG_ON(refs < 0);
772 if (refs == 0 && part->setup_state == XPC_P_WTEARDOWN) {
773 wake_up(&part->teardown_wq);
774 }
775}
776
777static inline int
778xpc_part_ref(struct xpc_partition *part)
779{
780 int setup;
781
782
783 atomic_inc(&part->references);
784 setup = (part->setup_state == XPC_P_SETUP);
785 if (!setup) {
786 xpc_part_deref(part);
787 }
788 return setup;
789}
790
791
792
793/*
794 * The following macro is to be used for the setting of the reason and
795 * reason_line fields in both the struct xpc_channel and struct xpc_partition
796 * structures.
797 */
798#define XPC_SET_REASON(_p, _reason, _line) \
799 { \
800 (_p)->reason = _reason; \
801 (_p)->reason_line = _line; \
802 }
803
804
805
806/*
807 * This next set of inlines are used to keep track of when a partition is
808 * potentially engaged in accessing memory belonging to another partition.
809 */
810
811static inline void
812xpc_mark_partition_engaged(struct xpc_partition *part)
813{
814 unsigned long irq_flags;
815 AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa +
816 (XPC_ENGAGED_PARTITIONS_AMO * sizeof(AMO_t)));
817
818
819 local_irq_save(irq_flags);
820
821 /* set bit corresponding to our partid in remote partition's AMO */
822 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR,
823 (1UL << sn_partition_id));
824 /*
825 * We must always use the nofault function regardless of whether we
826 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
827 * didn't, we'd never know that the other partition is down and would
828 * keep sending IPIs and AMOs to it until the heartbeat times out.
829 */
830 (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->
831 variable), xp_nofault_PIOR_target));
832
833 local_irq_restore(irq_flags);
834}
835
836static inline void
837xpc_mark_partition_disengaged(struct xpc_partition *part)
838{
839 unsigned long irq_flags;
840 AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa +
841 (XPC_ENGAGED_PARTITIONS_AMO * sizeof(AMO_t)));
842
843
844 local_irq_save(irq_flags);
845
846 /* clear bit corresponding to our partid in remote partition's AMO */
847 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND,
848 ~(1UL << sn_partition_id));
849 /*
850 * We must always use the nofault function regardless of whether we
851 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
852 * didn't, we'd never know that the other partition is down and would
853 * keep sending IPIs and AMOs to it until the heartbeat times out.
854 */
855 (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->
856 variable), xp_nofault_PIOR_target));
857
858 local_irq_restore(irq_flags);
859}
860
861static inline void
862xpc_request_partition_disengage(struct xpc_partition *part)
863{
864 unsigned long irq_flags;
865 AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa +
866 (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t)));
867
868
869 local_irq_save(irq_flags);
870
871 /* set bit corresponding to our partid in remote partition's AMO */
872 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR,
873 (1UL << sn_partition_id));
874 /*
875 * We must always use the nofault function regardless of whether we
876 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
877 * didn't, we'd never know that the other partition is down and would
878 * keep sending IPIs and AMOs to it until the heartbeat times out.
879 */
880 (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->
881 variable), xp_nofault_PIOR_target));
882
883 local_irq_restore(irq_flags);
884}
885
886static inline void
887xpc_cancel_partition_disengage_request(struct xpc_partition *part)
888{
889 unsigned long irq_flags;
890 AMO_t *amo = (AMO_t *) __va(part->remote_amos_page_pa +
891 (XPC_DISENGAGE_REQUEST_AMO * sizeof(AMO_t)));
892
893
894 local_irq_save(irq_flags);
895
896 /* clear bit corresponding to our partid in remote partition's AMO */
897 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND,
898 ~(1UL << sn_partition_id));
899 /*
900 * We must always use the nofault function regardless of whether we
901 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
902 * didn't, we'd never know that the other partition is down and would
903 * keep sending IPIs and AMOs to it until the heartbeat times out.
904 */
905 (void) xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->
906 variable), xp_nofault_PIOR_target));
907
908 local_irq_restore(irq_flags);
909}
910
911static inline u64
912xpc_partition_engaged(u64 partid_mask)
913{
914 AMO_t *amo = xpc_vars->amos_page + XPC_ENGAGED_PARTITIONS_AMO;
915
916
917 /* return our partition's AMO variable ANDed with partid_mask */
918 return (FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_LOAD) &
919 partid_mask);
920}
921
922static inline u64
923xpc_partition_disengage_requested(u64 partid_mask)
924{
925 AMO_t *amo = xpc_vars->amos_page + XPC_DISENGAGE_REQUEST_AMO;
926
927
928 /* return our partition's AMO variable ANDed with partid_mask */
929 return (FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_LOAD) &
930 partid_mask);
931}
932
933static inline void
934xpc_clear_partition_engaged(u64 partid_mask)
935{
936 AMO_t *amo = xpc_vars->amos_page + XPC_ENGAGED_PARTITIONS_AMO;
937
938
939 /* clear bit(s) based on partid_mask in our partition's AMO */
940 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND,
941 ~partid_mask);
942}
943
944static inline void
945xpc_clear_partition_disengage_request(u64 partid_mask)
946{
947 AMO_t *amo = xpc_vars->amos_page + XPC_DISENGAGE_REQUEST_AMO;
948
949
950 /* clear bit(s) based on partid_mask in our partition's AMO */
951 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_AND,
952 ~partid_mask);
953}
954
955
956
957/*
958 * The following set of macros and inlines are used for the sending and
959 * receiving of IPIs (also known as IRQs). There are two flavors of IPIs,
960 * one that is associated with partition activity (SGI_XPC_ACTIVATE) and
961 * the other that is associated with channel activity (SGI_XPC_NOTIFY).
962 */
963
964static inline u64
965xpc_IPI_receive(AMO_t *amo)
966{
967 return FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_CLEAR);
968}
969
970
971static inline enum xpc_retval
972xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
973{
974 int ret = 0;
975 unsigned long irq_flags;
976
977
978 local_irq_save(irq_flags);
979
980 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR, flag);
981 sn_send_IPI_phys(nasid, phys_cpuid, vector, 0);
982
983 /*
984 * We must always use the nofault function regardless of whether we
985 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
986 * didn't, we'd never know that the other partition is down and would
987 * keep sending IPIs and AMOs to it until the heartbeat times out.
988 */
989 ret = xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->variable),
990 xp_nofault_PIOR_target));
991
992 local_irq_restore(irq_flags);
993
994 return ((ret == 0) ? xpcSuccess : xpcPioReadError);
995}
996
997
998/*
999 * IPIs associated with SGI_XPC_ACTIVATE IRQ.
1000 */
1001
1002/*
1003 * Flag the appropriate AMO variable and send an IPI to the specified node.
1004 */
1005static inline void
1006xpc_activate_IRQ_send(u64 amos_page_pa, int from_nasid, int to_nasid,
1007 int to_phys_cpuid)
1008{
1009 int w_index = XPC_NASID_W_INDEX(from_nasid);
1010 int b_index = XPC_NASID_B_INDEX(from_nasid);
1011 AMO_t *amos = (AMO_t *) __va(amos_page_pa +
1012 (XPC_ACTIVATE_IRQ_AMOS * sizeof(AMO_t)));
1013
1014
1015 (void) xpc_IPI_send(&amos[w_index], (1UL << b_index), to_nasid,
1016 to_phys_cpuid, SGI_XPC_ACTIVATE);
1017}
1018
1019static inline void
1020xpc_IPI_send_activate(struct xpc_vars *vars)
1021{
1022 xpc_activate_IRQ_send(vars->amos_page_pa, cnodeid_to_nasid(0),
1023 vars->act_nasid, vars->act_phys_cpuid);
1024}
1025
1026static inline void
1027xpc_IPI_send_activated(struct xpc_partition *part)
1028{
1029 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0),
1030 part->remote_act_nasid, part->remote_act_phys_cpuid);
1031}
1032
1033static inline void
1034xpc_IPI_send_reactivate(struct xpc_partition *part)
1035{
1036 xpc_activate_IRQ_send(xpc_vars->amos_page_pa, part->reactivate_nasid,
1037 xpc_vars->act_nasid, xpc_vars->act_phys_cpuid);
1038}
1039
1040static inline void
1041xpc_IPI_send_disengage(struct xpc_partition *part)
1042{
1043 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0),
1044 part->remote_act_nasid, part->remote_act_phys_cpuid);
1045}
1046
1047
1048/*
1049 * IPIs associated with SGI_XPC_NOTIFY IRQ.
1050 */
1051
1052/*
1053 * Send an IPI to the remote partition that is associated with the
1054 * specified channel.
1055 */
1056#define XPC_NOTIFY_IRQ_SEND(_ch, _ipi_f, _irq_f) \
1057 xpc_notify_IRQ_send(_ch, _ipi_f, #_ipi_f, _irq_f)
1058
1059static inline void
1060xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
1061 unsigned long *irq_flags)
1062{
1063 struct xpc_partition *part = &xpc_partitions[ch->partid];
1064 enum xpc_retval ret;
1065
1066
1067 if (likely(part->act_state != XPC_P_DEACTIVATING)) {
1068 ret = xpc_IPI_send(part->remote_IPI_amo_va,
1069 (u64) ipi_flag << (ch->number * 8),
1070 part->remote_IPI_nasid,
1071 part->remote_IPI_phys_cpuid,
1072 SGI_XPC_NOTIFY);
1073 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n",
1074 ipi_flag_string, ch->partid, ch->number, ret);
1075 if (unlikely(ret != xpcSuccess)) {
1076 if (irq_flags != NULL) {
1077 spin_unlock_irqrestore(&ch->lock, *irq_flags);
1078 }
1079 XPC_DEACTIVATE_PARTITION(part, ret);
1080 if (irq_flags != NULL) {
1081 spin_lock_irqsave(&ch->lock, *irq_flags);
1082 }
1083 }
1084 }
1085}
1086
1087
1088/*
1089 * Make it look like the remote partition, which is associated with the
1090 * specified channel, sent us an IPI. This faked IPI will be handled
1091 * by xpc_dropped_IPI_check().
1092 */
1093#define XPC_NOTIFY_IRQ_SEND_LOCAL(_ch, _ipi_f) \
1094 xpc_notify_IRQ_send_local(_ch, _ipi_f, #_ipi_f)
1095
1096static inline void
1097xpc_notify_IRQ_send_local(struct xpc_channel *ch, u8 ipi_flag,
1098 char *ipi_flag_string)
1099{
1100 struct xpc_partition *part = &xpc_partitions[ch->partid];
1101
1102
1103 FETCHOP_STORE_OP(TO_AMO((u64) &part->local_IPI_amo_va->variable),
1104 FETCHOP_OR, ((u64) ipi_flag << (ch->number * 8)));
1105 dev_dbg(xpc_chan, "%s sent local from partid=%d, channel=%d\n",
1106 ipi_flag_string, ch->partid, ch->number);
1107}
1108
1109
1110/*
1111 * The sending and receiving of IPIs includes the setting of an AMO variable
1112 * to indicate the reason the IPI was sent. The 64-bit variable is divided
1113 * up into eight bytes, ordered from right to left. Byte zero pertains to
1114 * channel 0, byte one to channel 1, and so on. Each byte is described by
1115 * the following IPI flags.
1116 */
1117
1118#define XPC_IPI_CLOSEREQUEST 0x01
1119#define XPC_IPI_CLOSEREPLY 0x02
1120#define XPC_IPI_OPENREQUEST 0x04
1121#define XPC_IPI_OPENREPLY 0x08
1122#define XPC_IPI_MSGREQUEST 0x10
1123
1124
1125/* given an AMO variable and a channel#, get its associated IPI flags */
1126#define XPC_GET_IPI_FLAGS(_amo, _c) ((u8) (((_amo) >> ((_c) * 8)) & 0xff))
1127#define XPC_SET_IPI_FLAGS(_amo, _c, _f) (_amo) |= ((u64) (_f) << ((_c) * 8))
1128
1129#define XPC_ANY_OPENCLOSE_IPI_FLAGS_SET(_amo) ((_amo) & __IA64_UL_CONST(0x0f0f0f0f0f0f0f0f))
1130#define XPC_ANY_MSG_IPI_FLAGS_SET(_amo) ((_amo) & __IA64_UL_CONST(0x1010101010101010))
1131
1132
1133static inline void
1134xpc_IPI_send_closerequest(struct xpc_channel *ch, unsigned long *irq_flags)
1135{
1136 struct xpc_openclose_args *args = ch->local_openclose_args;
1137
1138
1139 args->reason = ch->reason;
1140
1141 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_CLOSEREQUEST, irq_flags);
1142}
1143
1144static inline void
1145xpc_IPI_send_closereply(struct xpc_channel *ch, unsigned long *irq_flags)
1146{
1147 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_CLOSEREPLY, irq_flags);
1148}
1149
1150static inline void
1151xpc_IPI_send_openrequest(struct xpc_channel *ch, unsigned long *irq_flags)
1152{
1153 struct xpc_openclose_args *args = ch->local_openclose_args;
1154
1155
1156 args->msg_size = ch->msg_size;
1157 args->local_nentries = ch->local_nentries;
1158
1159 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_OPENREQUEST, irq_flags);
1160}
1161
1162static inline void
1163xpc_IPI_send_openreply(struct xpc_channel *ch, unsigned long *irq_flags)
1164{
1165 struct xpc_openclose_args *args = ch->local_openclose_args;
1166
1167
1168 args->remote_nentries = ch->remote_nentries;
1169 args->local_nentries = ch->local_nentries;
1170 args->local_msgqueue_pa = __pa(ch->local_msgqueue);
1171
1172 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_OPENREPLY, irq_flags);
1173}
1174
1175static inline void
1176xpc_IPI_send_msgrequest(struct xpc_channel *ch)
1177{
1178 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_MSGREQUEST, NULL);
1179}
1180
1181static inline void
1182xpc_IPI_send_local_msgrequest(struct xpc_channel *ch)
1183{
1184 XPC_NOTIFY_IRQ_SEND_LOCAL(ch, XPC_IPI_MSGREQUEST);
1185}
1186
1187
1188/*
1189 * Memory for XPC's AMO variables is allocated by the MSPEC driver. These
1190 * pages are located in the lowest granule. The lowest granule uses 4k pages
1191 * for cached references and an alternate TLB handler to never provide a
1192 * cacheable mapping for the entire region. This will prevent speculative
1193 * reading of cached copies of our lines from being issued which will cause
1194 * a PI FSB Protocol error to be generated by the SHUB. For XPC, we need 64
1195 * AMO variables (based on XP_MAX_PARTITIONS) for message notification and an
1196 * additional 128 AMO variables (based on XP_NASID_MASK_WORDS) for partition
1197 * activation and 2 AMO variables for partition deactivation.
1198 */
1199static inline AMO_t *
1200xpc_IPI_init(int index)
1201{
1202 AMO_t *amo = xpc_vars->amos_page + index;
1203
1204
1205 (void) xpc_IPI_receive(amo); /* clear AMO variable */
1206 return amo;
1207}
1208
1209
1210
1211static inline enum xpc_retval
1212xpc_map_bte_errors(bte_result_t error)
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 }
1222 switch (error) {
1223 case BTE_SUCCESS: return xpcSuccess;
1224 case BTEFAIL_DIR: return xpcBteDirectoryError;
1225 case BTEFAIL_POISON: return xpcBtePoisonError;
1226 case BTEFAIL_WERR: return xpcBteWriteError;
1227 case BTEFAIL_ACCESS: return xpcBteAccessError;
1228 case BTEFAIL_PWERR: return xpcBtePWriteError;
1229 case BTEFAIL_PRERR: return xpcBtePReadError;
1230 case BTEFAIL_TOUT: return xpcBteTimeOutError;
1231 case BTEFAIL_XTERR: return xpcBteXtalkError;
1232 case BTEFAIL_NOTAVAIL: return xpcBteNotAvailable;
1233 default: return xpcBteUnmappedError;
1234 }
1235}
1236
1237
1238
1239/*
1240 * Check to see if there is any channel activity to/from the specified
1241 * partition.
1242 */
1243static inline void
1244xpc_check_for_channel_activity(struct xpc_partition *part)
1245{
1246 u64 IPI_amo;
1247 unsigned long irq_flags;
1248
1249
1250 IPI_amo = xpc_IPI_receive(part->local_IPI_amo_va);
1251 if (IPI_amo == 0) {
1252 return;
1253 }
1254
1255 spin_lock_irqsave(&part->IPI_lock, irq_flags);
1256 part->local_IPI_amo |= IPI_amo;
1257 spin_unlock_irqrestore(&part->IPI_lock, irq_flags);
1258
1259 dev_dbg(xpc_chan, "received IPI from partid=%d, IPI_amo=0x%lx\n",
1260 XPC_PARTID(part), IPI_amo);
1261
1262 xpc_wakeup_channel_mgr(part);
1263}
1264
1265
1266#endif /* _ASM_IA64_SN_XPC_H */
1267
diff --git a/include/asm-ia64/system.h b/include/asm-ia64/system.h
index 595112bca3cc..26e250bfb912 100644
--- a/include/asm-ia64/system.h
+++ b/include/asm-ia64/system.h
@@ -146,23 +146,23 @@ do { \
146 146
147# define local_irq_save(x) \ 147# define local_irq_save(x) \
148do { \ 148do { \
149 unsigned long psr; \ 149 unsigned long __psr; \
150 \ 150 \
151 __local_irq_save(psr); \ 151 __local_irq_save(__psr); \
152 if (psr & IA64_PSR_I) \ 152 if (__psr & IA64_PSR_I) \
153 __save_ip(); \ 153 __save_ip(); \
154 (x) = psr; \ 154 (x) = __psr; \
155} while (0) 155} while (0)
156 156
157# define local_irq_disable() do { unsigned long x; local_irq_save(x); } while (0) 157# define local_irq_disable() do { unsigned long __x; local_irq_save(__x); } while (0)
158 158
159# define local_irq_restore(x) \ 159# define local_irq_restore(x) \
160do { \ 160do { \
161 unsigned long old_psr, psr = (x); \ 161 unsigned long __old_psr, __psr = (x); \
162 \ 162 \
163 local_save_flags(old_psr); \ 163 local_save_flags(__old_psr); \
164 __local_irq_restore(psr); \ 164 __local_irq_restore(__psr); \
165 if ((old_psr & IA64_PSR_I) && !(psr & IA64_PSR_I)) \ 165 if ((__old_psr & IA64_PSR_I) && !(__psr & IA64_PSR_I)) \
166 __save_ip(); \ 166 __save_ip(); \
167} while (0) 167} while (0)
168 168
@@ -210,6 +210,13 @@ struct task_struct;
210extern void ia64_save_extra (struct task_struct *task); 210extern void ia64_save_extra (struct task_struct *task);
211extern void ia64_load_extra (struct task_struct *task); 211extern void ia64_load_extra (struct task_struct *task);
212 212
213#ifdef CONFIG_VIRT_CPU_ACCOUNTING
214extern void ia64_account_on_switch (struct task_struct *prev, struct task_struct *next);
215# define IA64_ACCOUNT_ON_SWITCH(p,n) ia64_account_on_switch(p,n)
216#else
217# define IA64_ACCOUNT_ON_SWITCH(p,n)
218#endif
219
213#ifdef CONFIG_PERFMON 220#ifdef CONFIG_PERFMON
214 DECLARE_PER_CPU(unsigned long, pfm_syst_info); 221 DECLARE_PER_CPU(unsigned long, pfm_syst_info);
215# define PERFMON_IS_SYSWIDE() (__get_cpu_var(pfm_syst_info) & 0x1) 222# define PERFMON_IS_SYSWIDE() (__get_cpu_var(pfm_syst_info) & 0x1)
@@ -222,6 +229,7 @@ extern void ia64_load_extra (struct task_struct *task);
222 || IS_IA32_PROCESS(task_pt_regs(t)) || PERFMON_IS_SYSWIDE()) 229 || IS_IA32_PROCESS(task_pt_regs(t)) || PERFMON_IS_SYSWIDE())
223 230
224#define __switch_to(prev,next,last) do { \ 231#define __switch_to(prev,next,last) do { \
232 IA64_ACCOUNT_ON_SWITCH(prev, next); \
225 if (IA64_HAS_EXTRA_STATE(prev)) \ 233 if (IA64_HAS_EXTRA_STATE(prev)) \
226 ia64_save_extra(prev); \ 234 ia64_save_extra(prev); \
227 if (IA64_HAS_EXTRA_STATE(next)) \ 235 if (IA64_HAS_EXTRA_STATE(next)) \
@@ -266,6 +274,10 @@ void cpu_idle_wait(void);
266 274
267void default_idle(void); 275void default_idle(void);
268 276
277#ifdef CONFIG_VIRT_CPU_ACCOUNTING
278extern void account_system_vtime(struct task_struct *);
279#endif
280
269#endif /* __KERNEL__ */ 281#endif /* __KERNEL__ */
270 282
271#endif /* __ASSEMBLY__ */ 283#endif /* __ASSEMBLY__ */
diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h
index 93d83cbe0c8c..f30e05583869 100644
--- a/include/asm-ia64/thread_info.h
+++ b/include/asm-ia64/thread_info.h
@@ -31,6 +31,12 @@ struct thread_info {
31 mm_segment_t addr_limit; /* user-level address space limit */ 31 mm_segment_t addr_limit; /* user-level address space limit */
32 int preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */ 32 int preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */
33 struct restart_block restart_block; 33 struct restart_block restart_block;
34#ifdef CONFIG_VIRT_CPU_ACCOUNTING
35 __u64 ac_stamp;
36 __u64 ac_leave;
37 __u64 ac_stime;
38 __u64 ac_utime;
39#endif
34}; 40};
35 41
36#define THREAD_SIZE KERNEL_STACK_SIZE 42#define THREAD_SIZE KERNEL_STACK_SIZE
@@ -62,9 +68,17 @@ struct thread_info {
62#define task_stack_page(tsk) ((void *)(tsk)) 68#define task_stack_page(tsk) ((void *)(tsk))
63 69
64#define __HAVE_THREAD_FUNCTIONS 70#define __HAVE_THREAD_FUNCTIONS
71#ifdef CONFIG_VIRT_CPU_ACCOUNTING
72#define setup_thread_stack(p, org) \
73 *task_thread_info(p) = *task_thread_info(org); \
74 task_thread_info(p)->ac_stime = 0; \
75 task_thread_info(p)->ac_utime = 0; \
76 task_thread_info(p)->task = (p);
77#else
65#define setup_thread_stack(p, org) \ 78#define setup_thread_stack(p, org) \
66 *task_thread_info(p) = *task_thread_info(org); \ 79 *task_thread_info(p) = *task_thread_info(org); \
67 task_thread_info(p)->task = (p); 80 task_thread_info(p)->task = (p);
81#endif
68#define end_of_stack(p) (unsigned long *)((void *)(p) + IA64_RBS_OFFSET) 82#define end_of_stack(p) (unsigned long *)((void *)(p) + IA64_RBS_OFFSET)
69 83
70#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR 84#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
@@ -87,7 +101,6 @@ extern void tsk_clear_notify_resume(struct task_struct *tsk);
87#define TIF_SYSCALL_TRACE 2 /* syscall trace active */ 101#define TIF_SYSCALL_TRACE 2 /* syscall trace active */
88#define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */ 102#define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
89#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ 103#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
90#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
91#define TIF_NOTIFY_RESUME 6 /* resumption notification requested */ 104#define TIF_NOTIFY_RESUME 6 /* resumption notification requested */
92#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 105#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
93#define TIF_MEMDIE 17 106#define TIF_MEMDIE 17
@@ -95,6 +108,7 @@ extern void tsk_clear_notify_resume(struct task_struct *tsk);
95#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */ 108#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */
96#define TIF_FREEZE 20 /* is freezing for suspend */ 109#define TIF_FREEZE 20 /* is freezing for suspend */
97#define TIF_RESTORE_RSE 21 /* user RBS is newer than kernel RBS */ 110#define TIF_RESTORE_RSE 21 /* user RBS is newer than kernel RBS */
111#define TIF_RESTORE_SIGMASK 22 /* restore signal mask in do_signal() */
98 112
99#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 113#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
100#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 114#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
@@ -112,8 +126,7 @@ extern void tsk_clear_notify_resume(struct task_struct *tsk);
112 126
113/* "work to do on user-return" bits */ 127/* "work to do on user-return" bits */
114#define TIF_ALLWORK_MASK (_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SYSCALL_AUDIT|\ 128#define TIF_ALLWORK_MASK (_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SYSCALL_AUDIT|\
115 _TIF_NEED_RESCHED| _TIF_SYSCALL_TRACE|\ 129 _TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE)
116 _TIF_RESTORE_SIGMASK)
117/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */ 130/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */
118#define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)) 131#define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT))
119 132
diff --git a/include/asm-ia64/tlb.h b/include/asm-ia64/tlb.h
index 26edcb750f9f..20d8a39680c2 100644
--- a/include/asm-ia64/tlb.h
+++ b/include/asm-ia64/tlb.h
@@ -64,6 +64,32 @@ struct mmu_gather {
64 struct page *pages[FREE_PTE_NR]; 64 struct page *pages[FREE_PTE_NR];
65}; 65};
66 66
67struct ia64_tr_entry {
68 u64 ifa;
69 u64 itir;
70 u64 pte;
71 u64 rr;
72}; /*Record for tr entry!*/
73
74extern int ia64_itr_entry(u64 target_mask, u64 va, u64 pte, u64 log_size);
75extern void ia64_ptr_entry(u64 target_mask, int slot);
76
77extern struct ia64_tr_entry __per_cpu_idtrs[NR_CPUS][2][IA64_TR_ALLOC_MAX];
78
79/*
80 region register macros
81*/
82#define RR_TO_VE(val) (((val) >> 0) & 0x0000000000000001)
83#define RR_VE(val) (((val) & 0x0000000000000001) << 0)
84#define RR_VE_MASK 0x0000000000000001L
85#define RR_VE_SHIFT 0
86#define RR_TO_PS(val) (((val) >> 2) & 0x000000000000003f)
87#define RR_PS(val) (((val) & 0x000000000000003f) << 2)
88#define RR_PS_MASK 0x00000000000000fcL
89#define RR_PS_SHIFT 2
90#define RR_RID_MASK 0x00000000ffffff00L
91#define RR_TO_RID(val) ((val >> 8) & 0xffffff)
92
67/* Users of the generic TLB shootdown code must declare this storage space. */ 93/* Users of the generic TLB shootdown code must declare this storage space. */
68DECLARE_PER_CPU(struct mmu_gather, mmu_gathers); 94DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
69 95
diff --git a/include/asm-ia64/tlbflush.h b/include/asm-ia64/tlbflush.h
index 7774a1cac0cc..3be25dfed164 100644
--- a/include/asm-ia64/tlbflush.h
+++ b/include/asm-ia64/tlbflush.h
@@ -17,6 +17,7 @@
17 * Now for some TLB flushing routines. This is the kind of stuff that 17 * Now for some TLB flushing routines. This is the kind of stuff that
18 * can be very expensive, so try to avoid them whenever possible. 18 * can be very expensive, so try to avoid them whenever possible.
19 */ 19 */
20extern void setup_ptcg_sem(int max_purges, int from_palo);
20 21
21/* 22/*
22 * Flush everything (kernel mapping may also have changed due to 23 * Flush everything (kernel mapping may also have changed due to
diff --git a/include/asm-ia64/topology.h b/include/asm-ia64/topology.h
index 2d67b72b18d0..32863b3bb1d3 100644
--- a/include/asm-ia64/topology.h
+++ b/include/asm-ia64/topology.h
@@ -93,7 +93,7 @@ void build_cpu_to_node_map(void);
93 .cache_nice_tries = 2, \ 93 .cache_nice_tries = 2, \
94 .busy_idx = 3, \ 94 .busy_idx = 3, \
95 .idle_idx = 2, \ 95 .idle_idx = 2, \
96 .newidle_idx = 0, /* unused */ \ 96 .newidle_idx = 2, \
97 .wake_idx = 1, \ 97 .wake_idx = 1, \
98 .forkexec_idx = 1, \ 98 .forkexec_idx = 1, \
99 .flags = SD_LOAD_BALANCE \ 99 .flags = SD_LOAD_BALANCE \
@@ -116,6 +116,13 @@ void build_cpu_to_node_map(void);
116#define smt_capable() (smp_num_siblings > 1) 116#define smt_capable() (smp_num_siblings > 1)
117#endif 117#endif
118 118
119extern void arch_fix_phys_package_id(int num, u32 slot);
120
121#define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \
122 CPU_MASK_ALL : \
123 node_to_cpumask(pcibus_to_node(bus)) \
124 )
125
119#include <asm-generic/topology.h> 126#include <asm-generic/topology.h>
120 127
121#endif /* _ASM_IA64_TOPOLOGY_H */ 128#endif /* _ASM_IA64_TOPOLOGY_H */
diff --git a/include/asm-ia64/unaligned.h b/include/asm-ia64/unaligned.h
index bb8559888103..7bddc7f58584 100644
--- a/include/asm-ia64/unaligned.h
+++ b/include/asm-ia64/unaligned.h
@@ -1,6 +1,11 @@
1#ifndef _ASM_IA64_UNALIGNED_H 1#ifndef _ASM_IA64_UNALIGNED_H
2#define _ASM_IA64_UNALIGNED_H 2#define _ASM_IA64_UNALIGNED_H
3 3
4#include <asm-generic/unaligned.h> 4#include <linux/unaligned/le_struct.h>
5#include <linux/unaligned/be_byteshift.h>
6#include <linux/unaligned/generic.h>
7
8#define get_unaligned __get_unaligned_le
9#define put_unaligned __put_unaligned_le
5 10
6#endif /* _ASM_IA64_UNALIGNED_H */ 11#endif /* _ASM_IA64_UNALIGNED_H */
diff --git a/include/asm-ia64/uncached.h b/include/asm-ia64/uncached.h
index b82d923b73c1..13d7e65ca3cc 100644
--- a/include/asm-ia64/uncached.h
+++ b/include/asm-ia64/uncached.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2001-2005 Silicon Graphics, Inc. All rights reserved. 2 * Copyright (C) 2001-2008 Silicon Graphics, Inc. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License 5 * under the terms of version 2 of the GNU General Public License
@@ -8,5 +8,5 @@
8 * Prototypes for the uncached page allocator 8 * Prototypes for the uncached page allocator
9 */ 9 */
10 10
11extern unsigned long uncached_alloc_page(int nid); 11extern unsigned long uncached_alloc_page(int starting_nid, int n_pages);
12extern void uncached_free_page(unsigned long); 12extern void uncached_free_page(unsigned long uc_addr, int n_pages);
diff --git a/include/asm-m32r/ide.h b/include/asm-m32r/ide.h
index 5d2044e529ab..1e7f6474d130 100644
--- a/include/asm-m32r/ide.h
+++ b/include/asm-m32r/ide.h
@@ -23,8 +23,6 @@
23# endif 23# endif
24#endif 24#endif
25 25
26#define IDE_ARCH_OBSOLETE_DEFAULTS
27
28static __inline__ int ide_default_irq(unsigned long base) 26static __inline__ int ide_default_irq(unsigned long base)
29{ 27{
30 switch (base) { 28 switch (base) {
@@ -65,14 +63,6 @@ static __inline__ unsigned long ide_default_io_base(int index)
65 } 63 }
66} 64}
67 65
68#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
69
70#ifdef CONFIG_BLK_DEV_IDEPCI
71#define ide_init_default_irq(base) (0)
72#else
73#define ide_init_default_irq(base) ide_default_irq(base)
74#endif
75
76#include <asm-generic/ide_iops.h> 66#include <asm-generic/ide_iops.h>
77 67
78#endif /* __KERNEL__ */ 68#endif /* __KERNEL__ */
diff --git a/include/asm-m32r/pgtable.h b/include/asm-m32r/pgtable.h
index 86505387be08..e6359c566b50 100644
--- a/include/asm-m32r/pgtable.h
+++ b/include/asm-m32r/pgtable.h
@@ -214,6 +214,11 @@ static inline int pte_file(pte_t pte)
214 return pte_val(pte) & _PAGE_FILE; 214 return pte_val(pte) & _PAGE_FILE;
215} 215}
216 216
217static inline int pte_special(pte_t pte)
218{
219 return 0;
220}
221
217static inline pte_t pte_mkclean(pte_t pte) 222static inline pte_t pte_mkclean(pte_t pte)
218{ 223{
219 pte_val(pte) &= ~_PAGE_DIRTY; 224 pte_val(pte) &= ~_PAGE_DIRTY;
@@ -250,6 +255,11 @@ static inline pte_t pte_mkwrite(pte_t pte)
250 return pte; 255 return pte;
251} 256}
252 257
258static inline pte_t pte_mkspecial(pte_t pte)
259{
260 return pte;
261}
262
253static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) 263static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
254{ 264{
255 return test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep); 265 return test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep);
diff --git a/include/asm-m32r/semaphore.h b/include/asm-m32r/semaphore.h
index b5bf95a6f2b4..d9b2034ed1d2 100644
--- a/include/asm-m32r/semaphore.h
+++ b/include/asm-m32r/semaphore.h
@@ -1,144 +1 @@
1#ifndef _ASM_M32R_SEMAPHORE_H #include <linux/semaphore.h>
2#define _ASM_M32R_SEMAPHORE_H
3
4#include <linux/linkage.h>
5
6#ifdef __KERNEL__
7
8/*
9 * SMP- and interrupt-safe semaphores..
10 *
11 * Copyright (C) 1996 Linus Torvalds
12 * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
13 */
14
15#include <linux/wait.h>
16#include <linux/rwsem.h>
17#include <asm/assembler.h>
18#include <asm/system.h>
19#include <asm/atomic.h>
20
21struct semaphore {
22 atomic_t count;
23 int sleepers;
24 wait_queue_head_t wait;
25};
26
27#define __SEMAPHORE_INITIALIZER(name, n) \
28{ \
29 .count = ATOMIC_INIT(n), \
30 .sleepers = 0, \
31 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
32}
33
34#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
35 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
36
37#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
38
39static inline void sema_init (struct semaphore *sem, int val)
40{
41/*
42 * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
43 *
44 * i'd rather use the more flexible initialization above, but sadly
45 * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well.
46 */
47 atomic_set(&sem->count, val);
48 sem->sleepers = 0;
49 init_waitqueue_head(&sem->wait);
50}
51
52static inline void init_MUTEX (struct semaphore *sem)
53{
54 sema_init(sem, 1);
55}
56
57static inline void init_MUTEX_LOCKED (struct semaphore *sem)
58{
59 sema_init(sem, 0);
60}
61
62asmlinkage void __down_failed(void /* special register calling convention */);
63asmlinkage int __down_failed_interruptible(void /* params in registers */);
64asmlinkage int __down_failed_trylock(void /* params in registers */);
65asmlinkage void __up_wakeup(void /* special register calling convention */);
66
67asmlinkage void __down(struct semaphore * sem);
68asmlinkage int __down_interruptible(struct semaphore * sem);
69asmlinkage int __down_trylock(struct semaphore * sem);
70asmlinkage void __up(struct semaphore * sem);
71
72/*
73 * Atomically decrement the semaphore's count. If it goes negative,
74 * block the calling thread in the TASK_UNINTERRUPTIBLE state.
75 */
76static inline void down(struct semaphore * sem)
77{
78 might_sleep();
79 if (unlikely(atomic_dec_return(&sem->count) < 0))
80 __down(sem);
81}
82
83/*
84 * Interruptible try to acquire a semaphore. If we obtained
85 * it, return zero. If we were interrupted, returns -EINTR
86 */
87static inline int down_interruptible(struct semaphore * sem)
88{
89 int result = 0;
90
91 might_sleep();
92 if (unlikely(atomic_dec_return(&sem->count) < 0))
93 result = __down_interruptible(sem);
94
95 return result;
96}
97
98/*
99 * Non-blockingly attempt to down() a semaphore.
100 * Returns zero if we acquired it
101 */
102static inline int down_trylock(struct semaphore * sem)
103{
104 unsigned long flags;
105 long count;
106 int result = 0;
107
108 local_irq_save(flags);
109 __asm__ __volatile__ (
110 "# down_trylock \n\t"
111 DCACHE_CLEAR("%0", "r4", "%1")
112 M32R_LOCK" %0, @%1; \n\t"
113 "addi %0, #-1; \n\t"
114 M32R_UNLOCK" %0, @%1; \n\t"
115 : "=&r" (count)
116 : "r" (&sem->count)
117 : "memory"
118#ifdef CONFIG_CHIP_M32700_TS1
119 , "r4"
120#endif /* CONFIG_CHIP_M32700_TS1 */
121 );
122 local_irq_restore(flags);
123
124 if (unlikely(count < 0))
125 result = __down_trylock(sem);
126
127 return result;
128}
129
130/*
131 * Note! This is subtle. We jump to wake people up only if
132 * the semaphore was negative (== somebody was waiting on it).
133 * The default case (no contention) will result in NO
134 * jumps for both down() and up().
135 */
136static inline void up(struct semaphore * sem)
137{
138 if (unlikely(atomic_inc_return(&sem->count) <= 0))
139 __up(sem);
140}
141
142#endif /* __KERNEL__ */
143
144#endif /* _ASM_M32R_SEMAPHORE_H */
diff --git a/include/asm-m32r/unaligned.h b/include/asm-m32r/unaligned.h
index fccc180c3913..377eb20d1ec6 100644
--- a/include/asm-m32r/unaligned.h
+++ b/include/asm-m32r/unaligned.h
@@ -1,19 +1,18 @@
1#ifndef _ASM_M32R_UNALIGNED_H 1#ifndef _ASM_M32R_UNALIGNED_H
2#define _ASM_M32R_UNALIGNED_H 2#define _ASM_M32R_UNALIGNED_H
3 3
4/* 4#if defined(__LITTLE_ENDIAN__)
5 * For the benefit of those who are trying to port Linux to another 5# include <linux/unaligned/le_memmove.h>
6 * architecture, here are some C-language equivalents. 6# include <linux/unaligned/be_byteshift.h>
7 */ 7# include <linux/unaligned/generic.h>
8 8# define get_unaligned __get_unaligned_le
9#include <asm/string.h> 9# define put_unaligned __put_unaligned_le
10 10#else
11#define get_unaligned(ptr) \ 11# include <linux/unaligned/be_memmove.h>
12 ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) 12# include <linux/unaligned/le_byteshift.h>
13 13# include <linux/unaligned/generic.h>
14#define put_unaligned(val, ptr) \ 14# define get_unaligned __get_unaligned_be
15 ({ __typeof__(*(ptr)) __tmp = (val); \ 15# define put_unaligned __put_unaligned_be
16 memmove((ptr), &__tmp, sizeof(*(ptr))); \ 16#endif
17 (void)0; })
18 17
19#endif /* _ASM_M32R_UNALIGNED_H */ 18#endif /* _ASM_M32R_UNALIGNED_H */
diff --git a/include/asm-m68k/div64.h b/include/asm-m68k/div64.h
index 33caad1628d4..8243c931b5c0 100644
--- a/include/asm-m68k/div64.h
+++ b/include/asm-m68k/div64.h
@@ -25,5 +25,4 @@
25 __rem; \ 25 __rem; \
26}) 26})
27 27
28extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
29#endif /* _M68K_DIV64_H */ 28#endif /* _M68K_DIV64_H */
diff --git a/include/asm-m68k/motorola_pgtable.h b/include/asm-m68k/motorola_pgtable.h
index 13135d4821d8..8e9a8a754dde 100644
--- a/include/asm-m68k/motorola_pgtable.h
+++ b/include/asm-m68k/motorola_pgtable.h
@@ -168,6 +168,7 @@ static inline int pte_write(pte_t pte) { return !(pte_val(pte) & _PAGE_RONLY);
168static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 168static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
169static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 169static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
170static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 170static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
171static inline int pte_special(pte_t pte) { return 0; }
171 172
172static inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_RONLY; return pte; } 173static inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_RONLY; return pte; }
173static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~_PAGE_DIRTY; return pte; } 174static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
@@ -185,6 +186,7 @@ static inline pte_t pte_mkcache(pte_t pte)
185 pte_val(pte) = (pte_val(pte) & _CACHEMASK040) | m68k_supervisor_cachemode; 186 pte_val(pte) = (pte_val(pte) & _CACHEMASK040) | m68k_supervisor_cachemode;
186 return pte; 187 return pte;
187} 188}
189static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
188 190
189#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address)) 191#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
190 192
diff --git a/include/asm-m68k/semaphore-helper.h b/include/asm-m68k/semaphore-helper.h
deleted file mode 100644
index eef30ba0b499..000000000000
--- a/include/asm-m68k/semaphore-helper.h
+++ /dev/null
@@ -1,142 +0,0 @@
1#ifndef _M68K_SEMAPHORE_HELPER_H
2#define _M68K_SEMAPHORE_HELPER_H
3
4/*
5 * SMP- and interrupt-safe semaphores helper functions.
6 *
7 * (C) Copyright 1996 Linus Torvalds
8 *
9 * m68k version by Andreas Schwab
10 */
11
12#include <linux/errno.h>
13
14/*
15 * These two _must_ execute atomically wrt each other.
16 */
17static inline void wake_one_more(struct semaphore * sem)
18{
19 atomic_inc(&sem->waking);
20}
21
22#ifndef CONFIG_RMW_INSNS
23extern spinlock_t semaphore_wake_lock;
24#endif
25
26static inline int waking_non_zero(struct semaphore *sem)
27{
28 int ret;
29#ifndef CONFIG_RMW_INSNS
30 unsigned long flags;
31
32 spin_lock_irqsave(&semaphore_wake_lock, flags);
33 ret = 0;
34 if (atomic_read(&sem->waking) > 0) {
35 atomic_dec(&sem->waking);
36 ret = 1;
37 }
38 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
39#else
40 int tmp1, tmp2;
41
42 __asm__ __volatile__
43 ("1: movel %1,%2\n"
44 " jle 2f\n"
45 " subql #1,%2\n"
46 " casl %1,%2,%3\n"
47 " jne 1b\n"
48 " moveq #1,%0\n"
49 "2:"
50 : "=d" (ret), "=d" (tmp1), "=d" (tmp2)
51 : "m" (sem->waking), "0" (0), "1" (sem->waking));
52#endif
53
54 return ret;
55}
56
57/*
58 * waking_non_zero_interruptible:
59 * 1 got the lock
60 * 0 go to sleep
61 * -EINTR interrupted
62 */
63static inline int waking_non_zero_interruptible(struct semaphore *sem,
64 struct task_struct *tsk)
65{
66 int ret;
67#ifndef CONFIG_RMW_INSNS
68 unsigned long flags;
69
70 spin_lock_irqsave(&semaphore_wake_lock, flags);
71 ret = 0;
72 if (atomic_read(&sem->waking) > 0) {
73 atomic_dec(&sem->waking);
74 ret = 1;
75 } else if (signal_pending(tsk)) {
76 atomic_inc(&sem->count);
77 ret = -EINTR;
78 }
79 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
80#else
81 int tmp1, tmp2;
82
83 __asm__ __volatile__
84 ("1: movel %1,%2\n"
85 " jle 2f\n"
86 " subql #1,%2\n"
87 " casl %1,%2,%3\n"
88 " jne 1b\n"
89 " moveq #1,%0\n"
90 " jra %a4\n"
91 "2:"
92 : "=d" (ret), "=d" (tmp1), "=d" (tmp2)
93 : "m" (sem->waking), "i" (&&next), "0" (0), "1" (sem->waking));
94 if (signal_pending(tsk)) {
95 atomic_inc(&sem->count);
96 ret = -EINTR;
97 }
98next:
99#endif
100
101 return ret;
102}
103
104/*
105 * waking_non_zero_trylock:
106 * 1 failed to lock
107 * 0 got the lock
108 */
109static inline int waking_non_zero_trylock(struct semaphore *sem)
110{
111 int ret;
112#ifndef CONFIG_RMW_INSNS
113 unsigned long flags;
114
115 spin_lock_irqsave(&semaphore_wake_lock, flags);
116 ret = 1;
117 if (atomic_read(&sem->waking) > 0) {
118 atomic_dec(&sem->waking);
119 ret = 0;
120 } else
121 atomic_inc(&sem->count);
122 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
123#else
124 int tmp1, tmp2;
125
126 __asm__ __volatile__
127 ("1: movel %1,%2\n"
128 " jle 2f\n"
129 " subql #1,%2\n"
130 " casl %1,%2,%3\n"
131 " jne 1b\n"
132 " moveq #0,%0\n"
133 "2:"
134 : "=d" (ret), "=d" (tmp1), "=d" (tmp2)
135 : "m" (sem->waking), "0" (1), "1" (sem->waking));
136 if (ret)
137 atomic_inc(&sem->count);
138#endif
139 return ret;
140}
141
142#endif
diff --git a/include/asm-m68k/semaphore.h b/include/asm-m68k/semaphore.h
index 64d6b119bb0a..d9b2034ed1d2 100644
--- a/include/asm-m68k/semaphore.h
+++ b/include/asm-m68k/semaphore.h
@@ -1,163 +1 @@
1#ifndef _M68K_SEMAPHORE_H #include <linux/semaphore.h>
2#define _M68K_SEMAPHORE_H
3
4#define RW_LOCK_BIAS 0x01000000
5
6#ifndef __ASSEMBLY__
7
8#include <linux/linkage.h>
9#include <linux/wait.h>
10#include <linux/spinlock.h>
11#include <linux/rwsem.h>
12#include <linux/stringify.h>
13
14#include <asm/system.h>
15#include <asm/atomic.h>
16
17/*
18 * Interrupt-safe semaphores..
19 *
20 * (C) Copyright 1996 Linus Torvalds
21 *
22 * m68k version by Andreas Schwab
23 */
24
25
26struct semaphore {
27 atomic_t count;
28 atomic_t waking;
29 wait_queue_head_t wait;
30};
31
32#define __SEMAPHORE_INITIALIZER(name, n) \
33{ \
34 .count = ATOMIC_INIT(n), \
35 .waking = ATOMIC_INIT(0), \
36 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
37}
38
39#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
40 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
41
42#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
43
44static inline void sema_init(struct semaphore *sem, int val)
45{
46 *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
47}
48
49static inline void init_MUTEX (struct semaphore *sem)
50{
51 sema_init(sem, 1);
52}
53
54static inline void init_MUTEX_LOCKED (struct semaphore *sem)
55{
56 sema_init(sem, 0);
57}
58
59asmlinkage void __down_failed(void /* special register calling convention */);
60asmlinkage int __down_failed_interruptible(void /* params in registers */);
61asmlinkage int __down_failed_trylock(void /* params in registers */);
62asmlinkage void __up_wakeup(void /* special register calling convention */);
63
64asmlinkage void __down(struct semaphore * sem);
65asmlinkage int __down_interruptible(struct semaphore * sem);
66asmlinkage int __down_trylock(struct semaphore * sem);
67asmlinkage void __up(struct semaphore * sem);
68
69/*
70 * This is ugly, but we want the default case to fall through.
71 * "down_failed" is a special asm handler that calls the C
72 * routine that actually waits. See arch/m68k/lib/semaphore.S
73 */
74static inline void down(struct semaphore *sem)
75{
76 register struct semaphore *sem1 __asm__ ("%a1") = sem;
77
78 might_sleep();
79 __asm__ __volatile__(
80 "| atomic down operation\n\t"
81 "subql #1,%0@\n\t"
82 "jmi 2f\n\t"
83 "1:\n"
84 LOCK_SECTION_START(".even\n\t")
85 "2:\tpea 1b\n\t"
86 "jbra __down_failed\n"
87 LOCK_SECTION_END
88 : /* no outputs */
89 : "a" (sem1)
90 : "memory");
91}
92
93static inline int down_interruptible(struct semaphore *sem)
94{
95 register struct semaphore *sem1 __asm__ ("%a1") = sem;
96 register int result __asm__ ("%d0");
97
98 might_sleep();
99 __asm__ __volatile__(
100 "| atomic interruptible down operation\n\t"
101 "subql #1,%1@\n\t"
102 "jmi 2f\n\t"
103 "clrl %0\n"
104 "1:\n"
105 LOCK_SECTION_START(".even\n\t")
106 "2:\tpea 1b\n\t"
107 "jbra __down_failed_interruptible\n"
108 LOCK_SECTION_END
109 : "=d" (result)
110 : "a" (sem1)
111 : "memory");
112 return result;
113}
114
115static inline int down_trylock(struct semaphore *sem)
116{
117 register struct semaphore *sem1 __asm__ ("%a1") = sem;
118 register int result __asm__ ("%d0");
119
120 __asm__ __volatile__(
121 "| atomic down trylock operation\n\t"
122 "subql #1,%1@\n\t"
123 "jmi 2f\n\t"
124 "clrl %0\n"
125 "1:\n"
126 LOCK_SECTION_START(".even\n\t")
127 "2:\tpea 1b\n\t"
128 "jbra __down_failed_trylock\n"
129 LOCK_SECTION_END
130 : "=d" (result)
131 : "a" (sem1)
132 : "memory");
133 return result;
134}
135
136/*
137 * Note! This is subtle. We jump to wake people up only if
138 * the semaphore was negative (== somebody was waiting on it).
139 * The default case (no contention) will result in NO
140 * jumps for both down() and up().
141 */
142static inline void up(struct semaphore *sem)
143{
144 register struct semaphore *sem1 __asm__ ("%a1") = sem;
145
146 __asm__ __volatile__(
147 "| atomic up operation\n\t"
148 "addql #1,%0@\n\t"
149 "jle 2f\n"
150 "1:\n"
151 LOCK_SECTION_START(".even\n\t")
152 "2:\t"
153 "pea 1b\n\t"
154 "jbra __up_wakeup\n"
155 LOCK_SECTION_END
156 : /* no outputs */
157 : "a" (sem1)
158 : "memory");
159}
160
161#endif /* __ASSEMBLY__ */
162
163#endif
diff --git a/include/asm-m68k/sun3_pgtable.h b/include/asm-m68k/sun3_pgtable.h
index b766fc261bde..f847ec732d62 100644
--- a/include/asm-m68k/sun3_pgtable.h
+++ b/include/asm-m68k/sun3_pgtable.h
@@ -169,6 +169,7 @@ static inline int pte_write(pte_t pte) { return pte_val(pte) & SUN3_PAGE_WRITEA
169static inline int pte_dirty(pte_t pte) { return pte_val(pte) & SUN3_PAGE_MODIFIED; } 169static inline int pte_dirty(pte_t pte) { return pte_val(pte) & SUN3_PAGE_MODIFIED; }
170static inline int pte_young(pte_t pte) { return pte_val(pte) & SUN3_PAGE_ACCESSED; } 170static inline int pte_young(pte_t pte) { return pte_val(pte) & SUN3_PAGE_ACCESSED; }
171static inline int pte_file(pte_t pte) { return pte_val(pte) & SUN3_PAGE_ACCESSED; } 171static inline int pte_file(pte_t pte) { return pte_val(pte) & SUN3_PAGE_ACCESSED; }
172static inline int pte_special(pte_t pte) { return 0; }
172 173
173static inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) &= ~SUN3_PAGE_WRITEABLE; return pte; } 174static inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) &= ~SUN3_PAGE_WRITEABLE; return pte; }
174static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~SUN3_PAGE_MODIFIED; return pte; } 175static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~SUN3_PAGE_MODIFIED; return pte; }
@@ -181,6 +182,7 @@ static inline pte_t pte_mknocache(pte_t pte) { pte_val(pte) |= SUN3_PAGE_NOCACHE
181//static inline pte_t pte_mkcache(pte_t pte) { pte_val(pte) &= SUN3_PAGE_NOCACHE; return pte; } 182//static inline pte_t pte_mkcache(pte_t pte) { pte_val(pte) &= SUN3_PAGE_NOCACHE; return pte; }
182// until then, use: 183// until then, use:
183static inline pte_t pte_mkcache(pte_t pte) { return pte; } 184static inline pte_t pte_mkcache(pte_t pte) { return pte; }
185static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
184 186
185extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 187extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
186extern pgd_t kernel_pg_dir[PTRS_PER_PGD]; 188extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
diff --git a/include/asm-m68k/unaligned.h b/include/asm-m68k/unaligned.h
index 804cb3f888fe..77698f2dc33c 100644
--- a/include/asm-m68k/unaligned.h
+++ b/include/asm-m68k/unaligned.h
@@ -1,16 +1,13 @@
1#ifndef __M68K_UNALIGNED_H 1#ifndef _ASM_M68K_UNALIGNED_H
2#define __M68K_UNALIGNED_H 2#define _ASM_M68K_UNALIGNED_H
3 3
4/* 4/*
5 * The m68k can do unaligned accesses itself. 5 * The m68k can do unaligned accesses itself.
6 *
7 * The strange macros are there to make sure these can't
8 * be misused in a way that makes them not work on other
9 * architectures where unaligned accesses aren't as simple.
10 */ 6 */
7#include <linux/unaligned/access_ok.h>
8#include <linux/unaligned/generic.h>
11 9
12#define get_unaligned(ptr) (*(ptr)) 10#define get_unaligned __get_unaligned_be
11#define put_unaligned __put_unaligned_be
13 12
14#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) 13#endif /* _ASM_M68K_UNALIGNED_H */
15
16#endif
diff --git a/include/asm-m68knommu/dma.h b/include/asm-m68knommu/dma.h
index 3f20419c633a..939a02056217 100644
--- a/include/asm-m68knommu/dma.h
+++ b/include/asm-m68knommu/dma.h
@@ -35,7 +35,8 @@
35/* 35/*
36 * Set number of channels of DMA on ColdFire for different implementations. 36 * Set number of channels of DMA on ColdFire for different implementations.
37 */ 37 */
38#if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) 38#if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) || \
39 defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x)
39#define MAX_M68K_DMA_CHANNELS 4 40#define MAX_M68K_DMA_CHANNELS 4
40#elif defined(CONFIG_M5272) 41#elif defined(CONFIG_M5272)
41#define MAX_M68K_DMA_CHANNELS 1 42#define MAX_M68K_DMA_CHANNELS 1
diff --git a/include/asm-m68knommu/param.h b/include/asm-m68knommu/param.h
index 96c451018324..6044397adb64 100644
--- a/include/asm-m68knommu/param.h
+++ b/include/asm-m68knommu/param.h
@@ -1,13 +1,16 @@
1#ifndef _M68KNOMMU_PARAM_H 1#ifndef _M68KNOMMU_PARAM_H
2#define _M68KNOMMU_PARAM_H 2#define _M68KNOMMU_PARAM_H
3 3
4#define HZ CONFIG_HZ
5
6#ifdef __KERNEL__ 4#ifdef __KERNEL__
5#define HZ CONFIG_HZ
7#define USER_HZ HZ 6#define USER_HZ HZ
8#define CLOCKS_PER_SEC (USER_HZ) 7#define CLOCKS_PER_SEC (USER_HZ)
9#endif 8#endif
10 9
10#ifndef HZ
11#define HZ 100
12#endif
13
11#define EXEC_PAGESIZE 4096 14#define EXEC_PAGESIZE 4096
12 15
13#ifndef NOGROUP 16#ifndef NOGROUP
diff --git a/include/asm-m68knommu/semaphore-helper.h b/include/asm-m68knommu/semaphore-helper.h
deleted file mode 100644
index 43da7bc483c7..000000000000
--- a/include/asm-m68knommu/semaphore-helper.h
+++ /dev/null
@@ -1,82 +0,0 @@
1#ifndef _M68K_SEMAPHORE_HELPER_H
2#define _M68K_SEMAPHORE_HELPER_H
3
4/*
5 * SMP- and interrupt-safe semaphores helper functions.
6 *
7 * (C) Copyright 1996 Linus Torvalds
8 *
9 * m68k version by Andreas Schwab
10 */
11
12
13/*
14 * These two _must_ execute atomically wrt each other.
15 */
16static inline void wake_one_more(struct semaphore * sem)
17{
18 atomic_inc(&sem->waking);
19}
20
21static inline int waking_non_zero(struct semaphore *sem)
22{
23 int ret;
24 unsigned long flags;
25
26 spin_lock_irqsave(&semaphore_wake_lock, flags);
27 ret = 0;
28 if (atomic_read(&sem->waking) > 0) {
29 atomic_dec(&sem->waking);
30 ret = 1;
31 }
32 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
33 return ret;
34}
35
36/*
37 * waking_non_zero_interruptible:
38 * 1 got the lock
39 * 0 go to sleep
40 * -EINTR interrupted
41 */
42static inline int waking_non_zero_interruptible(struct semaphore *sem,
43 struct task_struct *tsk)
44{
45 int ret;
46 unsigned long flags;
47
48 spin_lock_irqsave(&semaphore_wake_lock, flags);
49 ret = 0;
50 if (atomic_read(&sem->waking) > 0) {
51 atomic_dec(&sem->waking);
52 ret = 1;
53 } else if (signal_pending(tsk)) {
54 atomic_inc(&sem->count);
55 ret = -EINTR;
56 }
57 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
58 return ret;
59}
60
61/*
62 * waking_non_zero_trylock:
63 * 1 failed to lock
64 * 0 got the lock
65 */
66static inline int waking_non_zero_trylock(struct semaphore *sem)
67{
68 int ret;
69 unsigned long flags;
70
71 spin_lock_irqsave(&semaphore_wake_lock, flags);
72 ret = 1;
73 if (atomic_read(&sem->waking) > 0) {
74 atomic_dec(&sem->waking);
75 ret = 0;
76 } else
77 atomic_inc(&sem->count);
78 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
79 return ret;
80}
81
82#endif
diff --git a/include/asm-m68knommu/semaphore.h b/include/asm-m68knommu/semaphore.h
index 5779eb6c0689..d9b2034ed1d2 100644
--- a/include/asm-m68knommu/semaphore.h
+++ b/include/asm-m68knommu/semaphore.h
@@ -1,153 +1 @@
1#ifndef _M68K_SEMAPHORE_H #include <linux/semaphore.h>
2#define _M68K_SEMAPHORE_H
3
4#define RW_LOCK_BIAS 0x01000000
5
6#ifndef __ASSEMBLY__
7
8#include <linux/linkage.h>
9#include <linux/wait.h>
10#include <linux/spinlock.h>
11#include <linux/rwsem.h>
12
13#include <asm/system.h>
14#include <asm/atomic.h>
15
16/*
17 * Interrupt-safe semaphores..
18 *
19 * (C) Copyright 1996 Linus Torvalds
20 *
21 * m68k version by Andreas Schwab
22 */
23
24
25struct semaphore {
26 atomic_t count;
27 atomic_t waking;
28 wait_queue_head_t wait;
29};
30
31#define __SEMAPHORE_INITIALIZER(name, n) \
32{ \
33 .count = ATOMIC_INIT(n), \
34 .waking = ATOMIC_INIT(0), \
35 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
36}
37
38#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
39 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
40
41#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
42
43static inline void sema_init (struct semaphore *sem, int val)
44{
45 *sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
46}
47
48static inline void init_MUTEX (struct semaphore *sem)
49{
50 sema_init(sem, 1);
51}
52
53static inline void init_MUTEX_LOCKED (struct semaphore *sem)
54{
55 sema_init(sem, 0);
56}
57
58asmlinkage void __down_failed(void /* special register calling convention */);
59asmlinkage int __down_failed_interruptible(void /* params in registers */);
60asmlinkage int __down_failed_trylock(void /* params in registers */);
61asmlinkage void __up_wakeup(void /* special register calling convention */);
62
63asmlinkage void __down(struct semaphore * sem);
64asmlinkage int __down_interruptible(struct semaphore * sem);
65asmlinkage int __down_trylock(struct semaphore * sem);
66asmlinkage void __up(struct semaphore * sem);
67
68extern spinlock_t semaphore_wake_lock;
69
70/*
71 * This is ugly, but we want the default case to fall through.
72 * "down_failed" is a special asm handler that calls the C
73 * routine that actually waits. See arch/m68k/lib/semaphore.S
74 */
75static inline void down(struct semaphore * sem)
76{
77 might_sleep();
78 __asm__ __volatile__(
79 "| atomic down operation\n\t"
80 "movel %0, %%a1\n\t"
81 "lea %%pc@(1f), %%a0\n\t"
82 "subql #1, %%a1@\n\t"
83 "jmi __down_failed\n"
84 "1:"
85 : /* no outputs */
86 : "g" (sem)
87 : "cc", "%a0", "%a1", "memory");
88}
89
90static inline int down_interruptible(struct semaphore * sem)
91{
92 int ret;
93
94 might_sleep();
95 __asm__ __volatile__(
96 "| atomic down operation\n\t"
97 "movel %1, %%a1\n\t"
98 "lea %%pc@(1f), %%a0\n\t"
99 "subql #1, %%a1@\n\t"
100 "jmi __down_failed_interruptible\n\t"
101 "clrl %%d0\n"
102 "1: movel %%d0, %0\n"
103 : "=d" (ret)
104 : "g" (sem)
105 : "cc", "%d0", "%a0", "%a1", "memory");
106 return(ret);
107}
108
109static inline int down_trylock(struct semaphore * sem)
110{
111 register struct semaphore *sem1 __asm__ ("%a1") = sem;
112 register int result __asm__ ("%d0");
113
114 __asm__ __volatile__(
115 "| atomic down trylock operation\n\t"
116 "subql #1,%1@\n\t"
117 "jmi 2f\n\t"
118 "clrl %0\n"
119 "1:\n"
120 ".section .text.lock,\"ax\"\n"
121 ".even\n"
122 "2:\tpea 1b\n\t"
123 "jbra __down_failed_trylock\n"
124 ".previous"
125 : "=d" (result)
126 : "a" (sem1)
127 : "memory");
128 return result;
129}
130
131/*
132 * Note! This is subtle. We jump to wake people up only if
133 * the semaphore was negative (== somebody was waiting on it).
134 * The default case (no contention) will result in NO
135 * jumps for both down() and up().
136 */
137static inline void up(struct semaphore * sem)
138{
139 __asm__ __volatile__(
140 "| atomic up operation\n\t"
141 "movel %0, %%a1\n\t"
142 "lea %%pc@(1f), %%a0\n\t"
143 "addql #1, %%a1@\n\t"
144 "jle __up_wakeup\n"
145 "1:"
146 : /* no outputs */
147 : "g" (sem)
148 : "cc", "%a0", "%a1", "memory");
149}
150
151#endif /* __ASSEMBLY__ */
152
153#endif
diff --git a/include/asm-m68knommu/unaligned.h b/include/asm-m68knommu/unaligned.h
index 869e9dd24f54..eb1ea4cb9a59 100644
--- a/include/asm-m68knommu/unaligned.h
+++ b/include/asm-m68knommu/unaligned.h
@@ -1,23 +1,25 @@
1#ifndef __M68K_UNALIGNED_H 1#ifndef _ASM_M68KNOMMU_UNALIGNED_H
2#define __M68K_UNALIGNED_H 2#define _ASM_M68KNOMMU_UNALIGNED_H
3 3
4 4
5#ifdef CONFIG_COLDFIRE 5#ifdef CONFIG_COLDFIRE
6#include <linux/unaligned/be_struct.h>
7#include <linux/unaligned/le_byteshift.h>
8#include <linux/unaligned/generic.h>
6 9
7#include <asm-generic/unaligned.h> 10#define get_unaligned __get_unaligned_be
11#define put_unaligned __put_unaligned_be
8 12
9#else 13#else
10/* 14/*
11 * The m68k can do unaligned accesses itself. 15 * The m68k can do unaligned accesses itself.
12 *
13 * The strange macros are there to make sure these can't
14 * be misused in a way that makes them not work on other
15 * architectures where unaligned accesses aren't as simple.
16 */ 16 */
17#include <linux/unaligned/access_ok.h>
18#include <linux/unaligned/generic.h>
17 19
18#define get_unaligned(ptr) (*(ptr)) 20#define get_unaligned __get_unaligned_be
19#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) 21#define put_unaligned __put_unaligned_be
20 22
21#endif 23#endif
22 24
23#endif 25#endif /* _ASM_M68KNOMMU_UNALIGNED_H */
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index ec75ce4cdb8c..c2bd126c3b4e 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -591,6 +591,11 @@ static inline int __ilog2(unsigned long x)
591 return 63 - lz; 591 return 63 - lz;
592} 592}
593 593
594static inline unsigned long __fls(unsigned long x)
595{
596 return __ilog2(x);
597}
598
594#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) 599#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
595 600
596/* 601/*
diff --git a/include/asm-mips/cmp.h b/include/asm-mips/cmp.h
new file mode 100644
index 000000000000..89a73fb93ae6
--- /dev/null
+++ b/include/asm-mips/cmp.h
@@ -0,0 +1,18 @@
1#ifndef _ASM_CMP_H
2#define _ASM_CMP_H
3
4/*
5 * Definitions for CMP multitasking on MIPS cores
6 */
7struct task_struct;
8
9extern void cmp_smp_setup(void);
10extern void cmp_smp_finish(void);
11extern void cmp_boot_secondary(int cpu, struct task_struct *t);
12extern void cmp_init_secondary(void);
13extern void cmp_cpus_done(void);
14extern void cmp_prepare_cpus(unsigned int max_cpus);
15
16/* This is platform specific */
17extern void cmp_send_ipi(int cpu, unsigned int action);
18#endif /* _ASM_CMP_H */
diff --git a/include/asm-mips/cpu.h b/include/asm-mips/cpu.h
index bf5bbc78a9f7..1c35cac6f35b 100644
--- a/include/asm-mips/cpu.h
+++ b/include/asm-mips/cpu.h
@@ -29,7 +29,7 @@
29#define PRID_COMP_ALCHEMY 0x030000 29#define PRID_COMP_ALCHEMY 0x030000
30#define PRID_COMP_SIBYTE 0x040000 30#define PRID_COMP_SIBYTE 0x040000
31#define PRID_COMP_SANDCRAFT 0x050000 31#define PRID_COMP_SANDCRAFT 0x050000
32#define PRID_COMP_PHILIPS 0x060000 32#define PRID_COMP_NXP 0x060000
33#define PRID_COMP_TOSHIBA 0x070000 33#define PRID_COMP_TOSHIBA 0x070000
34#define PRID_COMP_LSI 0x080000 34#define PRID_COMP_LSI 0x080000
35#define PRID_COMP_LEXRA 0x0b0000 35#define PRID_COMP_LEXRA 0x0b0000
@@ -89,6 +89,7 @@
89#define PRID_IMP_34K 0x9500 89#define PRID_IMP_34K 0x9500
90#define PRID_IMP_24KE 0x9600 90#define PRID_IMP_24KE 0x9600
91#define PRID_IMP_74K 0x9700 91#define PRID_IMP_74K 0x9700
92#define PRID_IMP_1004K 0x9900
92#define PRID_IMP_LOONGSON1 0x4200 93#define PRID_IMP_LOONGSON1 0x4200
93#define PRID_IMP_LOONGSON2 0x6300 94#define PRID_IMP_LOONGSON2 0x6300
94 95
@@ -194,9 +195,9 @@ enum cpu_type_enum {
194 /* 195 /*
195 * MIPS32 class processors 196 * MIPS32 class processors
196 */ 197 */
197 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_74K, CPU_AU1000, 198 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K,
198 CPU_AU1100, CPU_AU1200, CPU_AU1210, CPU_AU1250, CPU_AU1500, CPU_AU1550, 199 CPU_AU1000, CPU_AU1100, CPU_AU1200, CPU_AU1210, CPU_AU1250, CPU_AU1500,
199 CPU_PR4450, CPU_BCM3302, CPU_BCM4710, 200 CPU_AU1550, CPU_PR4450, CPU_BCM3302, CPU_BCM4710,
200 201
201 /* 202 /*
202 * MIPS64 class processors 203 * MIPS64 class processors
diff --git a/include/asm-mips/dec/ioasic.h b/include/asm-mips/dec/ioasic.h
index 486a5b0a1302..98badd6bf22d 100644
--- a/include/asm-mips/dec/ioasic.h
+++ b/include/asm-mips/dec/ioasic.h
@@ -33,4 +33,6 @@ static inline u32 ioasic_read(unsigned int reg)
33 33
34extern void init_ioasic_irqs(int base); 34extern void init_ioasic_irqs(int base);
35 35
36extern void dec_ioasic_clocksource_init(void);
37
36#endif /* __ASM_DEC_IOASIC_H */ 38#endif /* __ASM_DEC_IOASIC_H */
diff --git a/include/asm-mips/div64.h b/include/asm-mips/div64.h
index 716371bd0980..d1d699105c11 100644
--- a/include/asm-mips/div64.h
+++ b/include/asm-mips/div64.h
@@ -82,7 +82,6 @@
82 (n) = __quot; \ 82 (n) = __quot; \
83 __mod; }) 83 __mod; })
84 84
85extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
86#endif /* (_MIPS_SZLONG == 32) */ 85#endif /* (_MIPS_SZLONG == 32) */
87 86
88#if (_MIPS_SZLONG == 64) 87#if (_MIPS_SZLONG == 64)
@@ -106,11 +105,6 @@ extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
106 (n) = __quot; \ 105 (n) = __quot; \
107 __mod; }) 106 __mod; })
108 107
109static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
110{
111 return dividend / divisor;
112}
113
114#endif /* (_MIPS_SZLONG == 64) */ 108#endif /* (_MIPS_SZLONG == 64) */
115 109
116#endif /* _ASM_DIV64_H */ 110#endif /* _ASM_DIV64_H */
diff --git a/include/asm-mips/ds1287.h b/include/asm-mips/ds1287.h
new file mode 100644
index 000000000000..ba1702e86931
--- /dev/null
+++ b/include/asm-mips/ds1287.h
@@ -0,0 +1,27 @@
1/*
2 * DS1287 timer functions.
3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#ifndef __ASM_DS1287_H
21#define __ASM_DS1287_H
22
23extern int ds1287_timer_state(void);
24extern void ds1287_set_base_clock(unsigned int clock);
25extern int ds1287_clockevent_init(int irq);
26
27#endif
diff --git a/include/asm-mips/futex.h b/include/asm-mips/futex.h
index 17f082cfea85..b9cce90346cf 100644
--- a/include/asm-mips/futex.h
+++ b/include/asm-mips/futex.h
@@ -11,9 +11,9 @@
11#ifdef __KERNEL__ 11#ifdef __KERNEL__
12 12
13#include <linux/futex.h> 13#include <linux/futex.h>
14#include <linux/uaccess.h>
14#include <asm/barrier.h> 15#include <asm/barrier.h>
15#include <asm/errno.h> 16#include <asm/errno.h>
16#include <asm/uaccess.h>
17#include <asm/war.h> 17#include <asm/war.h>
18 18
19#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ 19#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
diff --git a/include/asm-mips/gcmpregs.h b/include/asm-mips/gcmpregs.h
new file mode 100644
index 000000000000..d74a8a4ca861
--- /dev/null
+++ b/include/asm-mips/gcmpregs.h
@@ -0,0 +1,117 @@
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) 2000, 07 MIPS Technologies, Inc.
7 *
8 * Multiprocessor Subsystem Register Definitions
9 *
10 */
11#ifndef _ASM_GCMPREGS_H
12#define _ASM_GCMPREGS_H
13
14
15/* Offsets to major blocks within GCMP from GCMP base */
16#define GCMP_GCB_OFS 0x0000 /* Global Control Block */
17#define GCMP_CLCB_OFS 0x2000 /* Core Local Control Block */
18#define GCMP_COCB_OFS 0x4000 /* Core Other Control Block */
19#define GCMP_GDB_OFS 0x8000 /* Global Debug Block */
20
21/* Offsets to individual GCMP registers from GCMP base */
22#define GCMPOFS(block, tag, reg) (GCMP_##block##_OFS + GCMP_##tag##_##reg##_OFS)
23
24#define GCMPGCBOFS(reg) GCMPOFS(GCB, GCB, reg)
25#define GCMPCLCBOFS(reg) GCMPOFS(CLCB, CCB, reg)
26#define GCMPCOCBOFS(reg) GCMPOFS(COCB, CCB, reg)
27#define GCMPGDBOFS(reg) GCMPOFS(GDB, GDB, reg)
28
29/* GCMP register access */
30#define GCMPGCB(reg) REGP(_gcmp_base, GCMPGCBOFS(reg))
31#define GCMPCLCB(reg) REGP(_gcmp_base, GCMPCLCBOFS(reg))
32#define GCMPCOCB(reg) REGP(_gcmp_base, GCMPCOCBOFS(reg))
33#define GCMPGDB(reg) REGP(_gcmp_base, GCMPGDBOFS(reg))
34
35/* Mask generation */
36#define GCMPMSK(block, reg, bits) (MSK(bits)<<GCMP_##block##_##reg##_SHF)
37#define GCMPGCBMSK(reg, bits) GCMPMSK(GCB, reg, bits)
38#define GCMPCCBMSK(reg, bits) GCMPMSK(CCB, reg, bits)
39#define GCMPGDBMSK(reg, bits) GCMPMSK(GDB, reg, bits)
40
41/* GCB registers */
42#define GCMP_GCB_GC_OFS 0x0000 /* Global Config Register */
43#define GCMP_GCB_GC_NUMIOCU_SHF 8
44#define GCMP_GCB_GC_NUMIOCU_MSK GCMPGCBMSK(GC_NUMIOCU, 4)
45#define GCMP_GCB_GC_NUMCORES_SHF 0
46#define GCMP_GCB_GC_NUMCORES_MSK GCMPGCBMSK(GC_NUMCORES, 8)
47#define GCMP_GCB_GCMPB_OFS 0x0008 /* Global GCMP Base */
48#define GCMP_GCB_GCMPB_GCMPBASE_SHF 15
49#define GCMP_GCB_GCMPB_GCMPBASE_MSK GCMPGCBMSK(GCMPB_GCMPBASE, 17)
50#define GCMP_GCB_GCMPB_CMDEFTGT_SHF 0
51#define GCMP_GCB_GCMPB_CMDEFTGT_MSK GCMPGCBMSK(GCMPB_CMDEFTGT, 2)
52#define GCMP_GCB_GCMPB_CMDEFTGT_MEM 0
53#define GCMP_GCB_GCMPB_CMDEFTGT_MEM1 1
54#define GCMP_GCB_GCMPB_CMDEFTGT_IOCU1 2
55#define GCMP_GCB_GCMPB_CMDEFTGT_IOCU2 3
56#define GCMP_GCB_CCMC_OFS 0x0010 /* Global CM Control */
57#define GCMP_GCB_GCSRAP_OFS 0x0020 /* Global CSR Access Privilege */
58#define GCMP_GCB_GCSRAP_CMACCESS_SHF 0
59#define GCMP_GCB_GCSRAP_CMACCESS_MSK GCMPGCBMSK(GCSRAP_CMACCESS, 8)
60#define GCMP_GCB_GCMPREV_OFS 0x0030 /* GCMP Revision Register */
61#define GCMP_GCB_GCMEM_OFS 0x0040 /* Global CM Error Mask */
62#define GCMP_GCB_GCMEC_OFS 0x0048 /* Global CM Error Cause */
63#define GCMP_GCB_GMEC_ERROR_TYPE_SHF 27
64#define GCMP_GCB_GMEC_ERROR_TYPE_MSK GCMPGCBMSK(GMEC_ERROR_TYPE, 5)
65#define GCMP_GCB_GMEC_ERROR_INFO_SHF 0
66#define GCMP_GCB_GMEC_ERROR_INFO_MSK GCMPGCBMSK(GMEC_ERROR_INFO, 27)
67#define GCMP_GCB_GCMEA_OFS 0x0050 /* Global CM Error Address */
68#define GCMP_GCB_GCMEO_OFS 0x0058 /* Global CM Error Multiple */
69#define GCMP_GCB_GMEO_ERROR_2ND_SHF 0
70#define GCMP_GCB_GMEO_ERROR_2ND_MSK GCMPGCBMSK(GMEO_ERROR_2ND, 5)
71#define GCMP_GCB_GICBA_OFS 0x0080 /* Global Interrupt Controller Base Address */
72#define GCMP_GCB_GICBA_BASE_SHF 17
73#define GCMP_GCB_GICBA_BASE_MSK GCMPGCBMSK(GICBA_BASE, 15)
74#define GCMP_GCB_GICBA_EN_SHF 0
75#define GCMP_GCB_GICBA_EN_MSK GCMPGCBMSK(GICBA_EN, 1)
76
77/* GCB Regions */
78#define GCMP_GCB_CMxBASE_OFS(n) (0x0090+16*(n)) /* Global Region[0-3] Base Address */
79#define GCMP_GCB_CMxBASE_BASE_SHF 16
80#define GCMP_GCB_CMxBASE_BASE_MSK GCMPGCBMSK(CMxBASE_BASE, 16)
81#define GCMP_GCB_CMxMASK_OFS(n) (0x0098+16*(n)) /* Global Region[0-3] Address Mask */
82#define GCMP_GCB_CMxMASK_MASK_SHF 16
83#define GCMP_GCB_CMxMASK_MASK_MSK GCMPGCBMSK(CMxMASK_MASK, 16)
84#define GCMP_GCB_CMxMASK_CMREGTGT_SHF 0
85#define GCMP_GCB_CMxMASK_CMREGTGT_MSK GCMPGCBMSK(CMxMASK_CMREGTGT, 2)
86#define GCMP_GCB_CMxMASK_CMREGTGT_MEM 0
87#define GCMP_GCB_CMxMASK_CMREGTGT_MEM1 1
88#define GCMP_GCB_CMxMASK_CMREGTGT_IOCU1 2
89#define GCMP_GCB_CMxMASK_CMREGTGT_IOCU2 3
90
91
92/* Core local/Core other control block registers */
93#define GCMP_CCB_RESETR_OFS 0x0000 /* Reset Release */
94#define GCMP_CCB_RESETR_INRESET_SHF 0
95#define GCMP_CCB_RESETR_INRESET_MSK GCMPCCBMSK(RESETR_INRESET, 16)
96#define GCMP_CCB_COHCTL_OFS 0x0008 /* Coherence Control */
97#define GCMP_CCB_COHCTL_DOMAIN_SHF 0
98#define GCMP_CCB_COHCTL_DOMAIN_MSK GCMPCCBMSK(COHCTL_DOMAIN, 8)
99#define GCMP_CCB_CFG_OFS 0x0010 /* Config */
100#define GCMP_CCB_CFG_IOCUTYPE_SHF 10
101#define GCMP_CCB_CFG_IOCUTYPE_MSK GCMPCCBMSK(CFG_IOCUTYPE, 2)
102#define GCMP_CCB_CFG_IOCUTYPE_CPU 0
103#define GCMP_CCB_CFG_IOCUTYPE_NCIOCU 1
104#define GCMP_CCB_CFG_IOCUTYPE_CIOCU 2
105#define GCMP_CCB_CFG_NUMVPE_SHF 0
106#define GCMP_CCB_CFG_NUMVPE_MSK GCMPCCBMSK(CFG_NUMVPE, 10)
107#define GCMP_CCB_OTHER_OFS 0x0018 /* Other Address */
108#define GCMP_CCB_OTHER_CORENUM_SHF 16
109#define GCMP_CCB_OTHER_CORENUM_MSK GCMPCCBMSK(OTHER_CORENUM, 16)
110#define GCMP_CCB_RESETBASE_OFS 0x0020 /* Reset Exception Base */
111#define GCMP_CCB_RESETBASE_BEV_SHF 12
112#define GCMP_CCB_RESETBASE_BEV_MSK GCMPCCBMSK(RESETBASE_BEV, 20)
113#define GCMP_CCB_ID_OFS 0x0028 /* Identification */
114#define GCMP_CCB_DINTGROUP_OFS 0x0030 /* DINT Group Participate */
115#define GCMP_CCB_DBGGROUP_OFS 0x0100 /* DebugBreak Group */
116
117#endif /* _ASM_GCMPREGS_H */
diff --git a/include/asm-mips/gic.h b/include/asm-mips/gic.h
new file mode 100644
index 000000000000..01b2f92dc33d
--- /dev/null
+++ b/include/asm-mips/gic.h
@@ -0,0 +1,487 @@
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) 2000, 07 MIPS Technologies, Inc.
7 *
8 * GIC Register Definitions
9 *
10 */
11#ifndef _ASM_GICREGS_H
12#define _ASM_GICREGS_H
13
14#undef GICISBYTELITTLEENDIAN
15#define GICISWORDLITTLEENDIAN
16
17/* Constants */
18#define GIC_POL_POS 1
19#define GIC_POL_NEG 0
20#define GIC_TRIG_EDGE 1
21#define GIC_TRIG_LEVEL 0
22
23#define GIC_NUM_INTRS 32
24
25#define MSK(n) ((1 << (n)) - 1)
26#define REG32(addr) (*(volatile unsigned int *) (addr))
27#define REG(base, offs) REG32((unsigned int)(base) + offs##_##OFS)
28#define REGP(base, phys) REG32((unsigned int)(base) + (phys))
29
30/* Accessors */
31#define GIC_REG(segment, offset) \
32 REG32(_gic_base + segment##_##SECTION_OFS + offset##_##OFS)
33#define GIC_REG_ADDR(segment, offset) \
34 REG32(_gic_base + segment##_##SECTION_OFS + offset)
35
36#define GIC_ABS_REG(segment, offset) \
37 (_gic_base + segment##_##SECTION_OFS + offset##_##OFS)
38#define GIC_REG_ABS_ADDR(segment, offset) \
39 (_gic_base + segment##_##SECTION_OFS + offset)
40
41#ifdef GICISBYTELITTLEENDIAN
42#define GICREAD(reg, data) (data) = (reg), (data) = le32_to_cpu(data)
43#define GICWRITE(reg, data) (reg) = cpu_to_le32(data)
44#define GICBIS(reg, bits) \
45 ({unsigned int data; \
46 GICREAD(reg, data); \
47 data |= bits; \
48 GICWRITE(reg, data); \
49 })
50
51#else
52#define GICREAD(reg, data) (data) = (reg)
53#define GICWRITE(reg, data) (reg) = (data)
54#define GICBIS(reg, bits) (reg) |= (bits)
55#endif
56
57
58/* GIC Address Space */
59#define SHARED_SECTION_OFS 0x0000
60#define SHARED_SECTION_SIZE 0x8000
61#define VPE_LOCAL_SECTION_OFS 0x8000
62#define VPE_LOCAL_SECTION_SIZE 0x4000
63#define VPE_OTHER_SECTION_OFS 0xc000
64#define VPE_OTHER_SECTION_SIZE 0x4000
65#define USM_VISIBLE_SECTION_OFS 0x10000
66#define USM_VISIBLE_SECTION_SIZE 0x10000
67
68/* Register Map for Shared Section */
69#if defined(CONFIG_CPU_LITTLE_ENDIAN) || defined(GICISWORDLITTLEENDIAN)
70
71#define GIC_SH_CONFIG_OFS 0x0000
72
73/* Shared Global Counter */
74#define GIC_SH_COUNTER_31_00_OFS 0x0010
75#define GIC_SH_COUNTER_63_32_OFS 0x0014
76
77/* Interrupt Polarity */
78#define GIC_SH_POL_31_0_OFS 0x0100
79#define GIC_SH_POL_63_32_OFS 0x0104
80#define GIC_SH_POL_95_64_OFS 0x0108
81#define GIC_SH_POL_127_96_OFS 0x010c
82#define GIC_SH_POL_159_128_OFS 0x0110
83#define GIC_SH_POL_191_160_OFS 0x0114
84#define GIC_SH_POL_223_192_OFS 0x0118
85#define GIC_SH_POL_255_224_OFS 0x011c
86
87/* Edge/Level Triggering */
88#define GIC_SH_TRIG_31_0_OFS 0x0180
89#define GIC_SH_TRIG_63_32_OFS 0x0184
90#define GIC_SH_TRIG_95_64_OFS 0x0188
91#define GIC_SH_TRIG_127_96_OFS 0x018c
92#define GIC_SH_TRIG_159_128_OFS 0x0190
93#define GIC_SH_TRIG_191_160_OFS 0x0194
94#define GIC_SH_TRIG_223_192_OFS 0x0198
95#define GIC_SH_TRIG_255_224_OFS 0x019c
96
97/* Dual Edge Triggering */
98#define GIC_SH_DUAL_31_0_OFS 0x0200
99#define GIC_SH_DUAL_63_32_OFS 0x0204
100#define GIC_SH_DUAL_95_64_OFS 0x0208
101#define GIC_SH_DUAL_127_96_OFS 0x020c
102#define GIC_SH_DUAL_159_128_OFS 0x0210
103#define GIC_SH_DUAL_191_160_OFS 0x0214
104#define GIC_SH_DUAL_223_192_OFS 0x0218
105#define GIC_SH_DUAL_255_224_OFS 0x021c
106
107/* Set/Clear corresponding bit in Edge Detect Register */
108#define GIC_SH_WEDGE_OFS 0x0280
109
110/* Reset Mask - Disables Interrupt */
111#define GIC_SH_RMASK_31_0_OFS 0x0300
112#define GIC_SH_RMASK_63_32_OFS 0x0304
113#define GIC_SH_RMASK_95_64_OFS 0x0308
114#define GIC_SH_RMASK_127_96_OFS 0x030c
115#define GIC_SH_RMASK_159_128_OFS 0x0310
116#define GIC_SH_RMASK_191_160_OFS 0x0314
117#define GIC_SH_RMASK_223_192_OFS 0x0318
118#define GIC_SH_RMASK_255_224_OFS 0x031c
119
120/* Set Mask (WO) - Enables Interrupt */
121#define GIC_SH_SMASK_31_0_OFS 0x0380
122#define GIC_SH_SMASK_63_32_OFS 0x0384
123#define GIC_SH_SMASK_95_64_OFS 0x0388
124#define GIC_SH_SMASK_127_96_OFS 0x038c
125#define GIC_SH_SMASK_159_128_OFS 0x0390
126#define GIC_SH_SMASK_191_160_OFS 0x0394
127#define GIC_SH_SMASK_223_192_OFS 0x0398
128#define GIC_SH_SMASK_255_224_OFS 0x039c
129
130/* Global Interrupt Mask Register (RO) - Bit Set == Interrupt enabled */
131#define GIC_SH_MASK_31_0_OFS 0x0400
132#define GIC_SH_MASK_63_32_OFS 0x0404
133#define GIC_SH_MASK_95_64_OFS 0x0408
134#define GIC_SH_MASK_127_96_OFS 0x040c
135#define GIC_SH_MASK_159_128_OFS 0x0410
136#define GIC_SH_MASK_191_160_OFS 0x0414
137#define GIC_SH_MASK_223_192_OFS 0x0418
138#define GIC_SH_MASK_255_224_OFS 0x041c
139
140/* Pending Global Interrupts (RO) */
141#define GIC_SH_PEND_31_0_OFS 0x0480
142#define GIC_SH_PEND_63_32_OFS 0x0484
143#define GIC_SH_PEND_95_64_OFS 0x0488
144#define GIC_SH_PEND_127_96_OFS 0x048c
145#define GIC_SH_PEND_159_128_OFS 0x0490
146#define GIC_SH_PEND_191_160_OFS 0x0494
147#define GIC_SH_PEND_223_192_OFS 0x0498
148#define GIC_SH_PEND_255_224_OFS 0x049c
149
150#define GIC_SH_INTR_MAP_TO_PIN_BASE_OFS 0x0500
151
152/* Maps Interrupt X to a Pin */
153#define GIC_SH_MAP_TO_PIN(intr) \
154 (GIC_SH_INTR_MAP_TO_PIN_BASE_OFS + (4 * intr))
155
156#define GIC_SH_INTR_MAP_TO_VPE_BASE_OFS 0x2000
157
158/* Maps Interrupt X to a VPE */
159#define GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe) \
160 (GIC_SH_INTR_MAP_TO_VPE_BASE_OFS + (32 * (intr)) + (((vpe) / 32) * 4))
161#define GIC_SH_MAP_TO_VPE_REG_BIT(vpe) (1 << ((vpe) % 32))
162
163/* Polarity : Reset Value is always 0 */
164#define GIC_SH_SET_POLARITY_OFS 0x0100
165#define GIC_SET_POLARITY(intr, pol) \
166 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + (((intr) / 32) * 4)), (pol) << ((intr) % 32))
167
168/* Triggering : Reset Value is always 0 */
169#define GIC_SH_SET_TRIGGER_OFS 0x0180
170#define GIC_SET_TRIGGER(intr, trig) \
171 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + (((intr) / 32) * 4)), (trig) << ((intr) % 32))
172
173/* Mask manipulation */
174#define GIC_SH_SMASK_OFS 0x0380
175#define GIC_SET_INTR_MASK(intr, val) \
176 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_SMASK_OFS + (((intr) / 32) * 4)), ((val) << ((intr) % 32)))
177
178#define GIC_SH_RMASK_OFS 0x0300
179#define GIC_CLR_INTR_MASK(intr, val) \
180 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_RMASK_OFS + (((intr) / 32) * 4)), ((val) << ((intr) % 32)))
181
182/* Register Map for Local Section */
183#define GIC_VPE_CTL_OFS 0x0000
184#define GIC_VPE_PEND_OFS 0x0004
185#define GIC_VPE_MASK_OFS 0x0008
186#define GIC_VPE_RMASK_OFS 0x000c
187#define GIC_VPE_SMASK_OFS 0x0010
188#define GIC_VPE_WD_MAP_OFS 0x0040
189#define GIC_VPE_COMPARE_MAP_OFS 0x0044
190#define GIC_VPE_TIMER_MAP_OFS 0x0048
191#define GIC_VPE_PERFCTR_MAP_OFS 0x0050
192#define GIC_VPE_SWINT0_MAP_OFS 0x0054
193#define GIC_VPE_SWINT1_MAP_OFS 0x0058
194#define GIC_VPE_OTHER_ADDR_OFS 0x0080
195#define GIC_VPE_WD_CONFIG0_OFS 0x0090
196#define GIC_VPE_WD_COUNT0_OFS 0x0094
197#define GIC_VPE_WD_INITIAL0_OFS 0x0098
198#define GIC_VPE_COMPARE_LO_OFS 0x00a0
199#define GIC_VPE_COMPARE_HI 0x00a4
200
201#define GIC_VPE_EIC_SHADOW_SET_BASE 0x0100
202#define GIC_VPE_EIC_SS(intr) \
203 (GIC_EIC_SHADOW_SET_BASE + (4 * intr))
204
205#define GIC_VPE_EIC_VEC_BASE 0x0800
206#define GIC_VPE_EIC_VEC(intr) \
207 (GIC_VPE_EIC_VEC_BASE + (4 * intr))
208
209#define GIC_VPE_TENABLE_NMI_OFS 0x1000
210#define GIC_VPE_TENABLE_YQ_OFS 0x1004
211#define GIC_VPE_TENABLE_INT_31_0_OFS 0x1080
212#define GIC_VPE_TENABLE_INT_63_32_OFS 0x1084
213
214/* User Mode Visible Section Register Map */
215#define GIC_UMV_SH_COUNTER_31_00_OFS 0x0000
216#define GIC_UMV_SH_COUNTER_63_32_OFS 0x0004
217
218#else /* CONFIG_CPU_BIG_ENDIAN */
219
220#define GIC_SH_CONFIG_OFS 0x0000
221
222/* Shared Global Counter */
223#define GIC_SH_COUNTER_31_00_OFS 0x0014
224#define GIC_SH_COUNTER_63_32_OFS 0x0010
225
226/* Interrupt Polarity */
227#define GIC_SH_POL_31_0_OFS 0x0104
228#define GIC_SH_POL_63_32_OFS 0x0100
229#define GIC_SH_POL_95_64_OFS 0x010c
230#define GIC_SH_POL_127_96_OFS 0x0108
231#define GIC_SH_POL_159_128_OFS 0x0114
232#define GIC_SH_POL_191_160_OFS 0x0110
233#define GIC_SH_POL_223_192_OFS 0x011c
234#define GIC_SH_POL_255_224_OFS 0x0118
235
236/* Edge/Level Triggering */
237#define GIC_SH_TRIG_31_0_OFS 0x0184
238#define GIC_SH_TRIG_63_32_OFS 0x0180
239#define GIC_SH_TRIG_95_64_OFS 0x018c
240#define GIC_SH_TRIG_127_96_OFS 0x0188
241#define GIC_SH_TRIG_159_128_OFS 0x0194
242#define GIC_SH_TRIG_191_160_OFS 0x0190
243#define GIC_SH_TRIG_223_192_OFS 0x019c
244#define GIC_SH_TRIG_255_224_OFS 0x0198
245
246/* Dual Edge Triggering */
247#define GIC_SH_DUAL_31_0_OFS 0x0204
248#define GIC_SH_DUAL_63_32_OFS 0x0200
249#define GIC_SH_DUAL_95_64_OFS 0x020c
250#define GIC_SH_DUAL_127_96_OFS 0x0208
251#define GIC_SH_DUAL_159_128_OFS 0x0214
252#define GIC_SH_DUAL_191_160_OFS 0x0210
253#define GIC_SH_DUAL_223_192_OFS 0x021c
254#define GIC_SH_DUAL_255_224_OFS 0x0218
255
256/* Set/Clear corresponding bit in Edge Detect Register */
257#define GIC_SH_WEDGE_OFS 0x0280
258
259/* Reset Mask - Disables Interrupt */
260#define GIC_SH_RMASK_31_0_OFS 0x0304
261#define GIC_SH_RMASK_63_32_OFS 0x0300
262#define GIC_SH_RMASK_95_64_OFS 0x030c
263#define GIC_SH_RMASK_127_96_OFS 0x0308
264#define GIC_SH_RMASK_159_128_OFS 0x0314
265#define GIC_SH_RMASK_191_160_OFS 0x0310
266#define GIC_SH_RMASK_223_192_OFS 0x031c
267#define GIC_SH_RMASK_255_224_OFS 0x0318
268
269/* Set Mask (WO) - Enables Interrupt */
270#define GIC_SH_SMASK_31_0_OFS 0x0384
271#define GIC_SH_SMASK_63_32_OFS 0x0380
272#define GIC_SH_SMASK_95_64_OFS 0x038c
273#define GIC_SH_SMASK_127_96_OFS 0x0388
274#define GIC_SH_SMASK_159_128_OFS 0x0394
275#define GIC_SH_SMASK_191_160_OFS 0x0390
276#define GIC_SH_SMASK_223_192_OFS 0x039c
277#define GIC_SH_SMASK_255_224_OFS 0x0398
278
279/* Global Interrupt Mask Register (RO) - Bit Set == Interrupt enabled */
280#define GIC_SH_MASK_31_0_OFS 0x0404
281#define GIC_SH_MASK_63_32_OFS 0x0400
282#define GIC_SH_MASK_95_64_OFS 0x040c
283#define GIC_SH_MASK_127_96_OFS 0x0408
284#define GIC_SH_MASK_159_128_OFS 0x0414
285#define GIC_SH_MASK_191_160_OFS 0x0410
286#define GIC_SH_MASK_223_192_OFS 0x041c
287#define GIC_SH_MASK_255_224_OFS 0x0418
288
289/* Pending Global Interrupts (RO) */
290#define GIC_SH_PEND_31_0_OFS 0x0484
291#define GIC_SH_PEND_63_32_OFS 0x0480
292#define GIC_SH_PEND_95_64_OFS 0x048c
293#define GIC_SH_PEND_127_96_OFS 0x0488
294#define GIC_SH_PEND_159_128_OFS 0x0494
295#define GIC_SH_PEND_191_160_OFS 0x0490
296#define GIC_SH_PEND_223_192_OFS 0x049c
297#define GIC_SH_PEND_255_224_OFS 0x0498
298
299#define GIC_SH_INTR_MAP_TO_PIN_BASE_OFS 0x0500
300
301/* Maps Interrupt X to a Pin */
302#define GIC_SH_MAP_TO_PIN(intr) \
303 (GIC_SH_INTR_MAP_TO_PIN_BASE_OFS + (4 * intr))
304
305#define GIC_SH_INTR_MAP_TO_VPE_BASE_OFS 0x2004
306
307/*
308 * Maps Interrupt X to a VPE. This is more complex than the LE case, as
309 * odd and even registers need to be transposed. It does work - trust me!
310 */
311#define GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe) \
312 (GIC_SH_INTR_MAP_TO_VPE_BASE_OFS + (32 * (intr)) + \
313 (((((vpe) / 32) ^ 1) - 1) * 4))
314#define GIC_SH_MAP_TO_VPE_REG_BIT(vpe) (1 << ((vpe) % 32))
315
316/* Polarity */
317#define GIC_SH_SET_POLARITY_OFS 0x0100
318#define GIC_SET_POLARITY(intr, pol) \
319 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), (pol) << ((intr) % 32))
320
321/* Triggering */
322#define GIC_SH_SET_TRIGGER_OFS 0x0180
323#define GIC_SET_TRIGGER(intr, trig) \
324 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), (trig) << ((intr) % 32))
325
326/* Mask manipulation */
327#define GIC_SH_SMASK_OFS 0x0380
328#define GIC_SET_INTR_MASK(intr, val) \
329 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_SMASK_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), ((val) << ((intr) % 32)))
330
331#define GIC_SH_RMASK_OFS 0x0300
332#define GIC_CLR_INTR_MASK(intr, val) \
333 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_RMASK_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), ((val) << ((intr) % 32))
334
335/* Register Map for Local Section */
336#define GIC_VPE_CTL_OFS 0x0000
337#define GIC_VPE_PEND_OFS 0x0004
338#define GIC_VPE_MASK_OFS 0x0008
339#define GIC_VPE_RMASK_OFS 0x000c
340#define GIC_VPE_SMASK_OFS 0x0010
341#define GIC_VPE_WD_MAP_OFS 0x0040
342#define GIC_VPE_COMPARE_MAP_OFS 0x0044
343#define GIC_VPE_TIMER_MAP_OFS 0x0048
344#define GIC_VPE_PERFCTR_MAP_OFS 0x0050
345#define GIC_VPE_SWINT0_MAP_OFS 0x0054
346#define GIC_VPE_SWINT1_MAP_OFS 0x0058
347#define GIC_VPE_OTHER_ADDR_OFS 0x0080
348#define GIC_VPE_WD_CONFIG0_OFS 0x0090
349#define GIC_VPE_WD_COUNT0_OFS 0x0094
350#define GIC_VPE_WD_INITIAL0_OFS 0x0098
351#define GIC_VPE_COMPARE_LO_OFS 0x00a4
352#define GIC_VPE_COMPARE_HI_OFS 0x00a0
353
354#define GIC_VPE_EIC_SHADOW_SET_BASE 0x0100
355#define GIC_VPE_EIC_SS(intr) \
356 (GIC_EIC_SHADOW_SET_BASE + (4 * intr))
357
358#define GIC_VPE_EIC_VEC_BASE 0x0800
359#define GIC_VPE_EIC_VEC(intr) \
360 (GIC_VPE_EIC_VEC_BASE + (4 * intr))
361
362#define GIC_VPE_TENABLE_NMI_OFS 0x1000
363#define GIC_VPE_TENABLE_YQ_OFS 0x1004
364#define GIC_VPE_TENABLE_INT_31_0_OFS 0x1080
365#define GIC_VPE_TENABLE_INT_63_32_OFS 0x1084
366
367/* User Mode Visible Section Register Map */
368#define GIC_UMV_SH_COUNTER_31_00_OFS 0x0004
369#define GIC_UMV_SH_COUNTER_63_32_OFS 0x0000
370
371#endif /* !LE */
372
373/* Masks */
374#define GIC_SH_CONFIG_COUNTSTOP_SHF 28
375#define GIC_SH_CONFIG_COUNTSTOP_MSK (MSK(1) << GIC_SH_CONFIG_COUNTSTOP_SHF)
376
377#define GIC_SH_CONFIG_COUNTBITS_SHF 24
378#define GIC_SH_CONFIG_COUNTBITS_MSK (MSK(4) << GIC_SH_CONFIG_COUNTBITS_SHF)
379
380#define GIC_SH_CONFIG_NUMINTRS_SHF 16
381#define GIC_SH_CONFIG_NUMINTRS_MSK (MSK(8) << GIC_SH_CONFIG_NUMINTRS_SHF)
382
383#define GIC_SH_CONFIG_NUMVPES_SHF 0
384#define GIC_SH_CONFIG_NUMVPES_MSK (MSK(8) << GIC_SH_CONFIG_NUMVPES_SHF)
385
386#define GIC_SH_WEDGE_SET(intr) (intr | (0x1 << 31))
387#define GIC_SH_WEDGE_CLR(intr) (intr & ~(0x1 << 31))
388
389#define GIC_MAP_TO_PIN_SHF 31
390#define GIC_MAP_TO_PIN_MSK (MSK(1) << GIC_MAP_TO_PIN_SHF)
391#define GIC_MAP_TO_NMI_SHF 30
392#define GIC_MAP_TO_NMI_MSK (MSK(1) << GIC_MAP_TO_NMI_SHF)
393#define GIC_MAP_TO_YQ_SHF 29
394#define GIC_MAP_TO_YQ_MSK (MSK(1) << GIC_MAP_TO_YQ_SHF)
395#define GIC_MAP_SHF 0
396#define GIC_MAP_MSK (MSK(6) << GIC_MAP_SHF)
397
398/* GIC_VPE_CTL Masks */
399#define GIC_VPE_CTL_PERFCNT_RTBL_SHF 2
400#define GIC_VPE_CTL_PERFCNT_RTBL_MSK (MSK(1) << GIC_VPE_CTL_PERFCNT_RTBL_SHF)
401#define GIC_VPE_CTL_TIMER_RTBL_SHF 1
402#define GIC_VPE_CTL_TIMER_RTBL_MSK (MSK(1) << GIC_VPE_CTL_TIMER_RTBL_SHF)
403#define GIC_VPE_CTL_EIC_MODE_SHF 0
404#define GIC_VPE_CTL_EIC_MODE_MSK (MSK(1) << GIC_VPE_CTL_EIC_MODE_SHF)
405
406/* GIC_VPE_PEND Masks */
407#define GIC_VPE_PEND_WD_SHF 0
408#define GIC_VPE_PEND_WD_MSK (MSK(1) << GIC_VPE_PEND_WD_SHF)
409#define GIC_VPE_PEND_CMP_SHF 1
410#define GIC_VPE_PEND_CMP_MSK (MSK(1) << GIC_VPE_PEND_CMP_SHF)
411#define GIC_VPE_PEND_TIMER_SHF 2
412#define GIC_VPE_PEND_TIMER_MSK (MSK(1) << GIC_VPE_PEND_TIMER_SHF)
413#define GIC_VPE_PEND_PERFCOUNT_SHF 3
414#define GIC_VPE_PEND_PERFCOUNT_MSK (MSK(1) << GIC_VPE_PEND_PERFCOUNT_SHF)
415#define GIC_VPE_PEND_SWINT0_SHF 4
416#define GIC_VPE_PEND_SWINT0_MSK (MSK(1) << GIC_VPE_PEND_SWINT0_SHF)
417#define GIC_VPE_PEND_SWINT1_SHF 5
418#define GIC_VPE_PEND_SWINT1_MSK (MSK(1) << GIC_VPE_PEND_SWINT1_SHF)
419
420/* GIC_VPE_RMASK Masks */
421#define GIC_VPE_RMASK_WD_SHF 0
422#define GIC_VPE_RMASK_WD_MSK (MSK(1) << GIC_VPE_RMASK_WD_SHF)
423#define GIC_VPE_RMASK_CMP_SHF 1
424#define GIC_VPE_RMASK_CMP_MSK (MSK(1) << GIC_VPE_RMASK_CMP_SHF)
425#define GIC_VPE_RMASK_TIMER_SHF 2
426#define GIC_VPE_RMASK_TIMER_MSK (MSK(1) << GIC_VPE_RMASK_TIMER_SHF)
427#define GIC_VPE_RMASK_PERFCNT_SHF 3
428#define GIC_VPE_RMASK_PERFCNT_MSK (MSK(1) << GIC_VPE_RMASK_PERFCNT_SHF)
429#define GIC_VPE_RMASK_SWINT0_SHF 4
430#define GIC_VPE_RMASK_SWINT0_MSK (MSK(1) << GIC_VPE_RMASK_SWINT0_SHF)
431#define GIC_VPE_RMASK_SWINT1_SHF 5
432#define GIC_VPE_RMASK_SWINT1_MSK (MSK(1) << GIC_VPE_RMASK_SWINT1_SHF)
433
434/* GIC_VPE_SMASK Masks */
435#define GIC_VPE_SMASK_WD_SHF 0
436#define GIC_VPE_SMASK_WD_MSK (MSK(1) << GIC_VPE_SMASK_WD_SHF)
437#define GIC_VPE_SMASK_CMP_SHF 1
438#define GIC_VPE_SMASK_CMP_MSK (MSK(1) << GIC_VPE_SMASK_CMP_SHF)
439#define GIC_VPE_SMASK_TIMER_SHF 2
440#define GIC_VPE_SMASK_TIMER_MSK (MSK(1) << GIC_VPE_SMASK_TIMER_SHF)
441#define GIC_VPE_SMASK_PERFCNT_SHF 3
442#define GIC_VPE_SMASK_PERFCNT_MSK (MSK(1) << GIC_VPE_SMASK_PERFCNT_SHF)
443#define GIC_VPE_SMASK_SWINT0_SHF 4
444#define GIC_VPE_SMASK_SWINT0_MSK (MSK(1) << GIC_VPE_SMASK_SWINT0_SHF)
445#define GIC_VPE_SMASK_SWINT1_SHF 5
446#define GIC_VPE_SMASK_SWINT1_MSK (MSK(1) << GIC_VPE_SMASK_SWINT1_SHF)
447
448/*
449 * Set the Mapping of Interrupt X to a VPE.
450 */
451#define GIC_SH_MAP_TO_VPE_SMASK(intr, vpe) \
452 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe)), \
453 GIC_SH_MAP_TO_VPE_REG_BIT(vpe))
454
455struct gic_pcpu_mask {
456 DECLARE_BITMAP(pcpu_mask, GIC_NUM_INTRS);
457};
458
459struct gic_pending_regs {
460 DECLARE_BITMAP(pending, GIC_NUM_INTRS);
461};
462
463struct gic_intrmask_regs {
464 DECLARE_BITMAP(intrmask, GIC_NUM_INTRS);
465};
466
467/*
468 * Interrupt Meta-data specification. The ipiflag helps
469 * in building ipi_map.
470 */
471struct gic_intr_map {
472 unsigned int intrnum; /* Ext Intr Num */
473 unsigned int cpunum; /* Directed to this CPU */
474 unsigned int pin; /* Directed to this Pin */
475 unsigned int polarity; /* Polarity : +/- */
476 unsigned int trigtype; /* Trigger : Edge/Levl */
477 unsigned int ipiflag; /* Is used for IPI ? */
478};
479
480extern void gic_init(unsigned long gic_base_addr,
481 unsigned long gic_addrspace_size, struct gic_intr_map *intrmap,
482 unsigned int intrmap_size, unsigned int irqbase);
483
484extern unsigned int gic_get_int(void);
485extern void gic_send_ipi(unsigned int intr);
486
487#endif /* _ASM_GICREGS_H */
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index e62058b0d28c..f18d2816cbec 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -273,7 +273,7 @@ static inline void __iomem * __ioremap_mode(phys_t offset, unsigned long size,
273 * memory-like regions on I/O busses. 273 * memory-like regions on I/O busses.
274 */ 274 */
275#define ioremap_cachable(offset, size) \ 275#define ioremap_cachable(offset, size) \
276 __ioremap_mode((offset), (size), PAGE_CACHABLE_DEFAULT) 276 __ioremap_mode((offset), (size), _page_cachable_default)
277 277
278/* 278/*
279 * These two are MIPS specific ioremap variant. ioremap_cacheable_cow 279 * These two are MIPS specific ioremap variant. ioremap_cacheable_cow
diff --git a/include/asm-mips/jmr3927/jmr3927.h b/include/asm-mips/jmr3927/jmr3927.h
index 81602c8047eb..a162268f17df 100644
--- a/include/asm-mips/jmr3927/jmr3927.h
+++ b/include/asm-mips/jmr3927/jmr3927.h
@@ -99,8 +99,8 @@
99#define jmr3927_led_and_set(n/*0-16*/) jmr3927_ioc_reg_out((~(n)) & jmr3927_ioc_reg_in(JMR3927_IOC_LED_ADDR), JMR3927_IOC_LED_ADDR) 99#define jmr3927_led_and_set(n/*0-16*/) jmr3927_ioc_reg_out((~(n)) & jmr3927_ioc_reg_in(JMR3927_IOC_LED_ADDR), JMR3927_IOC_LED_ADDR)
100 100
101/* DIPSW4 macro */ 101/* DIPSW4 macro */
102#define jmr3927_dipsw1() ((tx3927_pioptr->din & (1 << 11)) == 0) 102#define jmr3927_dipsw1() (gpio_get_value(11) == 0)
103#define jmr3927_dipsw2() ((tx3927_pioptr->din & (1 << 10)) == 0) 103#define jmr3927_dipsw2() (gpio_get_value(10) == 0)
104#define jmr3927_dipsw3() ((jmr3927_ioc_reg_in(JMR3927_IOC_DIPSW_ADDR) & 2) == 0) 104#define jmr3927_dipsw3() ((jmr3927_ioc_reg_in(JMR3927_IOC_DIPSW_ADDR) & 2) == 0)
105#define jmr3927_dipsw4() ((jmr3927_ioc_reg_in(JMR3927_IOC_DIPSW_ADDR) & 1) == 0) 105#define jmr3927_dipsw4() ((jmr3927_ioc_reg_in(JMR3927_IOC_DIPSW_ADDR) & 1) == 0)
106 106
diff --git a/include/asm-mips/jmr3927/tx3927.h b/include/asm-mips/jmr3927/tx3927.h
index 338f99882a39..fb580333c102 100644
--- a/include/asm-mips/jmr3927/tx3927.h
+++ b/include/asm-mips/jmr3927/tx3927.h
@@ -314,6 +314,6 @@ struct tx3927_ccfg_reg {
314#define tx3927_ccfgptr ((struct tx3927_ccfg_reg *)TX3927_CCFG_REG) 314#define tx3927_ccfgptr ((struct tx3927_ccfg_reg *)TX3927_CCFG_REG)
315#define tx3927_tmrptr(ch) ((struct txx927_tmr_reg *)TX3927_TMR_REG(ch)) 315#define tx3927_tmrptr(ch) ((struct txx927_tmr_reg *)TX3927_TMR_REG(ch))
316#define tx3927_sioptr(ch) ((struct txx927_sio_reg *)TX3927_SIO_REG(ch)) 316#define tx3927_sioptr(ch) ((struct txx927_sio_reg *)TX3927_SIO_REG(ch))
317#define tx3927_pioptr ((struct txx927_pio_reg *)TX3927_PIO_REG) 317#define tx3927_pioptr ((struct txx9_pio_reg __iomem *)TX3927_PIO_REG)
318 318
319#endif /* __ASM_TX3927_H */ 319#endif /* __ASM_TX3927_H */
diff --git a/include/asm-mips/jmr3927/txx927.h b/include/asm-mips/jmr3927/txx927.h
index 0474fe8dac3f..25dcf2feb095 100644
--- a/include/asm-mips/jmr3927/txx927.h
+++ b/include/asm-mips/jmr3927/txx927.h
@@ -22,18 +22,6 @@ struct txx927_sio_reg {
22 volatile unsigned long rfifo; 22 volatile unsigned long rfifo;
23}; 23};
24 24
25struct txx927_pio_reg {
26 volatile unsigned long dout;
27 volatile unsigned long din;
28 volatile unsigned long dir;
29 volatile unsigned long od;
30 volatile unsigned long flag[2];
31 volatile unsigned long pol;
32 volatile unsigned long intc;
33 volatile unsigned long maskcpu;
34 volatile unsigned long maskext;
35};
36
37/* 25/*
38 * SIO 26 * SIO
39 */ 27 */
diff --git a/include/asm-mips/mach-au1x00/au1000.h b/include/asm-mips/mach-au1x00/au1000.h
index 5bb57bf2b9d7..a05555165d05 100644
--- a/include/asm-mips/mach-au1x00/au1000.h
+++ b/include/asm-mips/mach-au1x00/au1000.h
@@ -3,9 +3,8 @@
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * Include file for Alchemy Semiconductor's Au1k CPU. 4 * Include file for Alchemy Semiconductor's Au1k CPU.
5 * 5 *
6 * Copyright 2000,2001 MontaVista Software Inc. 6 * Copyright 2000-2001, 2006-2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * 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 10 * under the terms of the GNU General Public License as published by the
@@ -117,13 +116,6 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
117 116
118#endif /* !defined (_LANGUAGE_ASSEMBLY) */ 117#endif /* !defined (_LANGUAGE_ASSEMBLY) */
119 118
120#ifdef CONFIG_PM
121/* no CP0 timer irq */
122#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4)
123#else
124#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
125#endif
126
127/* 119/*
128 * SDRAM Register Offsets 120 * SDRAM Register Offsets
129 */ 121 */
@@ -1693,20 +1685,6 @@ enum soc_au1200_ints {
1693#define IOMEM_RESOURCE_START 0x10000000 1685#define IOMEM_RESOURCE_START 0x10000000
1694#define IOMEM_RESOURCE_END 0xffffffff 1686#define IOMEM_RESOURCE_END 0xffffffff
1695 1687
1696 /*
1697 * Borrowed from the PPC arch:
1698 * The following macro is used to lookup irqs in a standard table
1699 * format for those PPC systems that do not already have PCI
1700 * interrupts properly routed.
1701 */
1702 /* FIXME - double check this from asm-ppc/pci-bridge.h */
1703#define PCI_IRQ_TABLE_LOOKUP \
1704 ({ long _ctl_ = -1; \
1705 if (idsel >= min_idsel && idsel <= max_idsel && pin <= irqs_per_slot) \
1706 _ctl_ = pci_irq_table[idsel - min_idsel][pin-1]; \
1707 _ctl_; })
1708
1709
1710#else /* Au1000 and Au1100 and Au1200 */ 1688#else /* Au1000 and Au1100 and Au1200 */
1711 1689
1712/* don't allow any legacy ports probing */ 1690/* don't allow any legacy ports probing */
diff --git a/include/asm-mips/mach-au1x00/au1xxx_ide.h b/include/asm-mips/mach-au1x00/au1xxx_ide.h
index 89655c0cdcd6..b493a5e46c63 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_ide.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_ide.h
@@ -70,7 +70,6 @@ typedef struct
70 ide_hwif_t *hwif; 70 ide_hwif_t *hwif;
71#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 71#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
72 ide_drive_t *drive; 72 ide_drive_t *drive;
73 u8 white_list, black_list;
74 struct dbdma_cmd *dma_table_cpu; 73 struct dbdma_cmd *dma_table_cpu;
75 dma_addr_t dma_table_dma; 74 dma_addr_t dma_table_dma;
76#endif 75#endif
@@ -81,47 +80,6 @@ typedef struct
81#endif 80#endif
82} _auide_hwif; 81} _auide_hwif;
83 82
84#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
85/* HD white list */
86static const struct drive_list_entry dma_white_list [] = {
87/*
88 * Hitachi
89 */
90 { "HITACHI_DK14FA-20" , NULL },
91 { "HTS726060M9AT00" , NULL },
92/*
93 * Maxtor
94 */
95 { "Maxtor 6E040L0" , NULL },
96 { "Maxtor 6Y080P0" , NULL },
97 { "Maxtor 6Y160P0" , NULL },
98/*
99 * Seagate
100 */
101 { "ST3120026A" , NULL },
102 { "ST320014A" , NULL },
103 { "ST94011A" , NULL },
104 { "ST340016A" , NULL },
105/*
106 * Western Digital
107 */
108 { "WDC WD400UE-00HCT0" , NULL },
109 { "WDC WD400JB-00JJC0" , NULL },
110 { NULL , NULL }
111};
112
113/* HD black list */
114static const struct drive_list_entry dma_black_list [] = {
115/*
116 * Western Digital
117 */
118 { "WDC WD100EB-00CGH0" , NULL },
119 { "WDC WD200BB-00AUA1" , NULL },
120 { "WDC AC24300L" , NULL },
121 { NULL , NULL }
122};
123#endif
124
125/******************************************************************************* 83/*******************************************************************************
126* PIO Mode timing calculation : * 84* PIO Mode timing calculation : *
127* * 85* *
diff --git a/include/asm-mips/mach-db1x00/db1200.h b/include/asm-mips/mach-db1x00/db1200.h
index d2e28e64932e..eedd048a7261 100644
--- a/include/asm-mips/mach-db1x00/db1200.h
+++ b/include/asm-mips/mach-db1x00/db1200.h
@@ -169,15 +169,15 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
169#define BCSR_INT_SD0INSERT 0x1000 169#define BCSR_INT_SD0INSERT 0x1000
170#define BCSR_INT_SD0EJECT 0x2000 170#define BCSR_INT_SD0EJECT 0x2000
171 171
172#define AU1XXX_SMC91111_PHYS_ADDR (0x19000300) 172#define SMC91C111_PHYS_ADDR 0x19000300
173#define AU1XXX_SMC91111_IRQ DB1200_ETH_INT 173#define SMC91C111_INT DB1200_ETH_INT
174 174
175#define AU1XXX_ATA_PHYS_ADDR (0x18800000) 175#define IDE_PHYS_ADDR 0x18800000
176#define AU1XXX_ATA_REG_OFFSET (5) 176#define IDE_REG_SHIFT 5
177#define AU1XXX_ATA_PHYS_LEN (16 << AU1XXX_ATA_REG_OFFSET) 177#define IDE_PHYS_LEN (16 << IDE_REG_SHIFT)
178#define AU1XXX_ATA_INT DB1200_IDE_INT 178#define IDE_INT DB1200_IDE_INT
179#define AU1XXX_ATA_DDMA_REQ DSCR_CMD0_DMA_REQ1; 179#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1
180#define AU1XXX_ATA_RQSIZE 128 180#define IDE_RQSIZE 128
181 181
182#define NAND_PHYS_ADDR 0x20000000 182#define NAND_PHYS_ADDR 0x20000000
183 183
diff --git a/include/asm-mips/mach-generic/gpio.h b/include/asm-mips/mach-generic/gpio.h
index 6eaf5efedf3a..e6b376bd9d06 100644
--- a/include/asm-mips/mach-generic/gpio.h
+++ b/include/asm-mips/mach-generic/gpio.h
@@ -1,12 +1,18 @@
1#ifndef __ASM_MACH_GENERIC_GPIO_H 1#ifndef __ASM_MACH_GENERIC_GPIO_H
2#define __ASM_MACH_GENERIC_GPIO_H 2#define __ASM_MACH_GENERIC_GPIO_H
3 3
4#ifdef CONFIG_HAVE_GPIO_LIB
5#define gpio_get_value __gpio_get_value
6#define gpio_set_value __gpio_set_value
7#define gpio_cansleep __gpio_cansleep
8#else
4int gpio_request(unsigned gpio, const char *label); 9int gpio_request(unsigned gpio, const char *label);
5void gpio_free(unsigned gpio); 10void gpio_free(unsigned gpio);
6int gpio_direction_input(unsigned gpio); 11int gpio_direction_input(unsigned gpio);
7int gpio_direction_output(unsigned gpio, int value); 12int gpio_direction_output(unsigned gpio, int value);
8int gpio_get_value(unsigned gpio); 13int gpio_get_value(unsigned gpio);
9void gpio_set_value(unsigned gpio, int value); 14void gpio_set_value(unsigned gpio, int value);
15#endif
10int gpio_to_irq(unsigned gpio); 16int gpio_to_irq(unsigned gpio);
11int irq_to_gpio(unsigned irq); 17int irq_to_gpio(unsigned irq);
12 18
diff --git a/include/asm-mips/mach-generic/ide.h b/include/asm-mips/mach-generic/ide.h
index 4ec2b930dfbb..0f6c251f5fec 100644
--- a/include/asm-mips/mach-generic/ide.h
+++ b/include/asm-mips/mach-generic/ide.h
@@ -27,8 +27,6 @@
27# endif 27# endif
28#endif 28#endif
29 29
30#define IDE_ARCH_OBSOLETE_DEFAULTS
31
32static __inline__ int ide_probe_legacy(void) 30static __inline__ int ide_probe_legacy(void)
33{ 31{
34#ifdef CONFIG_PCI 32#ifdef CONFIG_PCI
@@ -98,14 +96,6 @@ static __inline__ unsigned long ide_default_io_base(int index)
98 } 96 }
99} 97}
100 98
101#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
102
103#ifdef CONFIG_BLK_DEV_IDEPCI
104#define ide_init_default_irq(base) (0)
105#else
106#define ide_init_default_irq(base) ide_default_irq(base)
107#endif
108
109/* MIPS port and memory-mapped I/O string operations. */ 99/* MIPS port and memory-mapped I/O string operations. */
110static inline void __ide_flush_prologue(void) 100static inline void __ide_flush_prologue(void)
111{ 101{
diff --git a/include/asm-mips/mach-ip27/topology.h b/include/asm-mips/mach-ip27/topology.h
index 372291f53fb9..7785bec732f2 100644
--- a/include/asm-mips/mach-ip27/topology.h
+++ b/include/asm-mips/mach-ip27/topology.h
@@ -54,4 +54,6 @@ extern unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES];
54 .nr_balance_failed = 0, \ 54 .nr_balance_failed = 0, \
55} 55}
56 56
57#include <asm-generic/topology.h>
58
57#endif /* _ASM_MACH_TOPOLOGY_H */ 59#endif /* _ASM_MACH_TOPOLOGY_H */
diff --git a/include/asm-mips/mach-pb1x00/pb1200.h b/include/asm-mips/mach-pb1x00/pb1200.h
index edaa489b58f1..e2c6bcac3b42 100644
--- a/include/asm-mips/mach-pb1x00/pb1200.h
+++ b/include/asm-mips/mach-pb1x00/pb1200.h
@@ -182,15 +182,15 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
182#define SET_VCC_VPP(VCC, VPP, SLOT)\ 182#define SET_VCC_VPP(VCC, VPP, SLOT)\
183 ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8)) 183 ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8))
184 184
185#define AU1XXX_SMC91111_PHYS_ADDR (0x0D000300) 185#define SMC91C111_PHYS_ADDR 0x0D000300
186#define AU1XXX_SMC91111_IRQ PB1200_ETH_INT 186#define SMC91C111_INT PB1200_ETH_INT
187 187
188#define AU1XXX_ATA_PHYS_ADDR (0x0C800000) 188#define IDE_PHYS_ADDR 0x0C800000
189#define AU1XXX_ATA_REG_OFFSET (5) 189#define IDE_REG_SHIFT 5
190#define AU1XXX_ATA_PHYS_LEN (16 << AU1XXX_ATA_REG_OFFSET) 190#define IDE_PHYS_LEN (16 << IDE_REG_SHIFT)
191#define AU1XXX_ATA_INT PB1200_IDE_INT 191#define IDE_INT PB1200_IDE_INT
192#define AU1XXX_ATA_DDMA_REQ DSCR_CMD0_DMA_REQ1; 192#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1
193#define AU1XXX_ATA_RQSIZE 128 193#define IDE_RQSIZE 128
194 194
195#define NAND_PHYS_ADDR 0x1C000000 195#define NAND_PHYS_ADDR 0x1C000000
196 196
diff --git a/include/asm-mips/mips-boards/generic.h b/include/asm-mips/mips-boards/generic.h
index 1c39d339521e..33407bee4e73 100644
--- a/include/asm-mips/mips-boards/generic.h
+++ b/include/asm-mips/mips-boards/generic.h
@@ -68,6 +68,7 @@
68#define MIPS_REVISION_CORID_CORE_FPGA3 9 68#define MIPS_REVISION_CORID_CORE_FPGA3 9
69#define MIPS_REVISION_CORID_CORE_24K 10 69#define MIPS_REVISION_CORID_CORE_24K 10
70#define MIPS_REVISION_CORID_CORE_FPGA4 11 70#define MIPS_REVISION_CORID_CORE_FPGA4 11
71#define MIPS_REVISION_CORID_CORE_FPGA5 12
71 72
72/**** Artificial corid defines ****/ 73/**** Artificial corid defines ****/
73/* 74/*
diff --git a/include/asm-mips/mips-boards/launch.h b/include/asm-mips/mips-boards/launch.h
new file mode 100644
index 000000000000..d8ae7f95a522
--- /dev/null
+++ b/include/asm-mips/mips-boards/launch.h
@@ -0,0 +1,35 @@
1/*
2 *
3 */
4
5#ifndef _ASSEMBLER_
6
7struct cpulaunch {
8 unsigned long pc;
9 unsigned long gp;
10 unsigned long sp;
11 unsigned long a0;
12 unsigned long _pad[3]; /* pad to cache line size to avoid thrashing */
13 unsigned long flags;
14};
15
16#else
17
18#define LOG2CPULAUNCH 5
19#define LAUNCH_PC 0
20#define LAUNCH_GP 4
21#define LAUNCH_SP 8
22#define LAUNCH_A0 12
23#define LAUNCH_FLAGS 28
24
25#endif
26
27#define LAUNCH_FREADY 1
28#define LAUNCH_FGO 2
29#define LAUNCH_FGONE 4
30
31#define CPULAUNCH 0x00000f00
32#define NCPULAUNCH 8
33
34/* Polling period in count cycles for secondary CPU's */
35#define LAUNCHPERIOD 10000
diff --git a/include/asm-mips/mips-boards/malta.h b/include/asm-mips/mips-boards/malta.h
index 93bf4e51b8a4..c1891578fa65 100644
--- a/include/asm-mips/mips-boards/malta.h
+++ b/include/asm-mips/mips-boards/malta.h
@@ -52,6 +52,29 @@ static inline unsigned long get_msc_port_base(unsigned long reg)
52} 52}
53 53
54/* 54/*
55 * GCMP Specific definitions
56 */
57#define GCMP_BASE_ADDR 0x1fbf8000
58#define GCMP_ADDRSPACE_SZ (256 * 1024)
59
60/*
61 * GIC Specific definitions
62 */
63#define GIC_BASE_ADDR 0x1bdc0000
64#define GIC_ADDRSPACE_SZ (128 * 1024)
65
66/*
67 * MSC01 BIU Specific definitions
68 * FIXME : These should be elsewhere ?
69 */
70#define MSC01_BIU_REG_BASE 0x1bc80000
71#define MSC01_BIU_ADDRSPACE_SZ (256 * 1024)
72#define MSC01_SC_CFG_OFS 0x0110
73#define MSC01_SC_CFG_GICPRES_MSK 0x00000004
74#define MSC01_SC_CFG_GICPRES_SHF 2
75#define MSC01_SC_CFG_GICENA_SHF 3
76
77/*
55 * Malta RTC-device indirect register access. 78 * Malta RTC-device indirect register access.
56 */ 79 */
57#define MALTA_RTC_ADR_REG 0x70 80#define MALTA_RTC_ADR_REG 0x70
diff --git a/include/asm-mips/mips-boards/maltaint.h b/include/asm-mips/mips-boards/maltaint.h
index 7461318f1cd1..cea872fc6f5c 100644
--- a/include/asm-mips/mips-boards/maltaint.h
+++ b/include/asm-mips/mips-boards/maltaint.h
@@ -39,7 +39,9 @@
39#define MIPSCPU_INT_I8259A MIPSCPU_INT_MB0 39#define MIPSCPU_INT_I8259A MIPSCPU_INT_MB0
40#define MIPSCPU_INT_MB1 3 40#define MIPSCPU_INT_MB1 3
41#define MIPSCPU_INT_SMI MIPSCPU_INT_MB1 41#define MIPSCPU_INT_SMI MIPSCPU_INT_MB1
42#define MIPSCPU_INT_IPI0 MIPSCPU_INT_MB1 /* GIC IPI */
42#define MIPSCPU_INT_MB2 4 43#define MIPSCPU_INT_MB2 4
44#define MIPSCPU_INT_IPI1 MIPSCPU_INT_MB2 /* GIC IPI */
43#define MIPSCPU_INT_MB3 5 45#define MIPSCPU_INT_MB3 5
44#define MIPSCPU_INT_COREHI MIPSCPU_INT_MB3 46#define MIPSCPU_INT_COREHI MIPSCPU_INT_MB3
45#define MIPSCPU_INT_MB4 6 47#define MIPSCPU_INT_MB4 6
@@ -76,6 +78,31 @@
76#define MSC01E_INT_PERFCTR 10 78#define MSC01E_INT_PERFCTR 10
77#define MSC01E_INT_CPUCTR 11 79#define MSC01E_INT_CPUCTR 11
78 80
81/* GIC's Nomenclature for Core Interrupt Pins on the Malta */
82#define GIC_CPU_INT0 0 /* Core Interrupt 2 */
83#define GIC_CPU_INT1 1 /* . */
84#define GIC_CPU_INT2 2 /* . */
85#define GIC_CPU_INT3 3 /* . */
86#define GIC_CPU_INT4 4 /* . */
87#define GIC_CPU_INT5 5 /* Core Interrupt 5 */
88
89#define GIC_EXT_INTR(x) x
90
91/* Dummy data */
92#define X 0xdead
93
94/* External Interrupts used for IPI */
95#define GIC_IPI_EXT_INTR_RESCHED_VPE0 16
96#define GIC_IPI_EXT_INTR_CALLFNC_VPE0 17
97#define GIC_IPI_EXT_INTR_RESCHED_VPE1 18
98#define GIC_IPI_EXT_INTR_CALLFNC_VPE1 19
99#define GIC_IPI_EXT_INTR_RESCHED_VPE2 20
100#define GIC_IPI_EXT_INTR_CALLFNC_VPE2 21
101#define GIC_IPI_EXT_INTR_RESCHED_VPE3 22
102#define GIC_IPI_EXT_INTR_CALLFNC_VPE3 23
103
104#define MIPS_GIC_IRQ_BASE (MIPS_CPU_IRQ_BASE + 8)
105
79#ifndef __ASSEMBLY__ 106#ifndef __ASSEMBLY__
80extern void maltaint_init(void); 107extern void maltaint_init(void);
81#endif 108#endif
diff --git a/include/asm-mips/mips-boards/maltasmp.h b/include/asm-mips/mips-boards/maltasmp.h
new file mode 100644
index 000000000000..8d7e955d506e
--- /dev/null
+++ b/include/asm-mips/mips-boards/maltasmp.h
@@ -0,0 +1,36 @@
1/*
2 * There are several SMP models supported
3 * SMTC is mutually exclusive to other options (atm)
4 */
5#if defined(CONFIG_MIPS_MT_SMTC)
6#define malta_smtc 1
7#define malta_cmp 0
8#define malta_smvp 0
9#else
10#define malta_smtc 0
11#if defined(CONFIG_MIPS_CMP)
12extern int gcmp_present;
13#define malta_cmp gcmp_present
14#else
15#define malta_cmp 0
16#endif
17/* FIXME: should become COMFIG_MIPS_MT_SMVP */
18#if defined(CONFIG_MIPS_MT_SMP)
19#define malta_smvp 1
20#else
21#define malta_smvp 0
22#endif
23#endif
24
25#include <asm/mipsregs.h>
26#include <asm/mipsmtregs.h>
27
28/* malta_smtc */
29#include <asm/smtc.h>
30#include <asm/smtc_ipi.h>
31
32/* malta_cmp */
33#include <asm/cmp.h>
34
35/* malta_smvp */
36#include <asm/smvp.h>
diff --git a/include/asm-mips/mipsmtregs.h b/include/asm-mips/mipsmtregs.h
index 5a2f8a3a6a1f..c9420aa97e32 100644
--- a/include/asm-mips/mipsmtregs.h
+++ b/include/asm-mips/mipsmtregs.h
@@ -197,8 +197,8 @@ static inline void __raw_evpe(void)
197 " .set pop \n"); 197 " .set pop \n");
198} 198}
199 199
200/* Enable multiMT if previous suggested it should be. 200/* Enable virtual processor execution if previous suggested it should be.
201 EMT_ENABLE to force */ 201 EVPE_ENABLE to force */
202 202
203#define EVPE_ENABLE MVPCONTROL_EVP 203#define EVPE_ENABLE MVPCONTROL_EVP
204 204
@@ -238,8 +238,8 @@ static inline void __raw_emt(void)
238 " .set reorder"); 238 " .set reorder");
239} 239}
240 240
241/* enable multiVPE if previous suggested it should be. 241/* enable multi-threaded execution if previous suggested it should be.
242 EVPE_ENABLE to force */ 242 EMT_ENABLE to force */
243 243
244#define EMT_ENABLE VPECONTROL_TE 244#define EMT_ENABLE VPECONTROL_TE
245 245
diff --git a/include/asm-mips/pgtable-32.h b/include/asm-mips/pgtable-32.h
index ceefe027c761..4396e9ffd418 100644
--- a/include/asm-mips/pgtable-32.h
+++ b/include/asm-mips/pgtable-32.h
@@ -107,7 +107,7 @@ static inline void pmd_clear(pmd_t *pmdp)
107 pmd_val(*pmdp) = ((unsigned long) invalid_pte_table); 107 pmd_val(*pmdp) = ((unsigned long) invalid_pte_table);
108} 108}
109 109
110#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) 110#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
111#define pte_page(x) pfn_to_page(pte_pfn(x)) 111#define pte_page(x) pfn_to_page(pte_pfn(x))
112#define pte_pfn(x) ((unsigned long)((x).pte_high >> 6)) 112#define pte_pfn(x) ((unsigned long)((x).pte_high >> 6))
113static inline pte_t 113static inline pte_t
@@ -130,7 +130,7 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
130#define pte_pfn(x) ((unsigned long)((x).pte >> PAGE_SHIFT)) 130#define pte_pfn(x) ((unsigned long)((x).pte >> PAGE_SHIFT))
131#define pfn_pte(pfn, prot) __pte(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) 131#define pfn_pte(pfn, prot) __pte(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
132#endif 132#endif
133#endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) */ 133#endif /* defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) */
134 134
135#define __pgd_offset(address) pgd_index(address) 135#define __pgd_offset(address) pgd_index(address)
136#define __pud_offset(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1)) 136#define __pud_offset(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
diff --git a/include/asm-mips/pgtable-bits.h b/include/asm-mips/pgtable-bits.h
index 7494ba91112a..60e2f9338fcd 100644
--- a/include/asm-mips/pgtable-bits.h
+++ b/include/asm-mips/pgtable-bits.h
@@ -32,14 +32,14 @@
32 * unpredictable things. The code (when it is written) to deal with 32 * unpredictable things. The code (when it is written) to deal with
33 * this problem will be in the update_mmu_cache() code for the r4k. 33 * this problem will be in the update_mmu_cache() code for the r4k.
34 */ 34 */
35#if defined(CONFIG_CPU_MIPS32_R1) && defined(CONFIG_64BIT_PHYS_ADDR) 35#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
36 36
37#define _PAGE_PRESENT (1<<6) /* implemented in software */ 37#define _PAGE_PRESENT (1<<6) /* implemented in software */
38#define _PAGE_READ (1<<7) /* implemented in software */ 38#define _PAGE_READ (1<<7) /* implemented in software */
39#define _PAGE_WRITE (1<<8) /* implemented in software */ 39#define _PAGE_WRITE (1<<8) /* implemented in software */
40#define _PAGE_ACCESSED (1<<9) /* implemented in software */ 40#define _PAGE_ACCESSED (1<<9) /* implemented in software */
41#define _PAGE_MODIFIED (1<<10) /* implemented in software */ 41#define _PAGE_MODIFIED (1<<10) /* implemented in software */
42#define _PAGE_FILE (1<<10) /* set:pagecache unset:swap */ 42#define _PAGE_FILE (1<<10) /* set:pagecache unset:swap */
43 43
44#define _PAGE_R4KBUG (1<<0) /* workaround for r4k bug */ 44#define _PAGE_R4KBUG (1<<0) /* workaround for r4k bug */
45#define _PAGE_GLOBAL (1<<0) 45#define _PAGE_GLOBAL (1<<0)
@@ -47,15 +47,9 @@
47#define _PAGE_SILENT_READ (1<<1) /* synonym */ 47#define _PAGE_SILENT_READ (1<<1) /* synonym */
48#define _PAGE_DIRTY (1<<2) /* The MIPS dirty bit */ 48#define _PAGE_DIRTY (1<<2) /* The MIPS dirty bit */
49#define _PAGE_SILENT_WRITE (1<<2) 49#define _PAGE_SILENT_WRITE (1<<2)
50#define _CACHE_SHIFT 3
50#define _CACHE_MASK (7<<3) 51#define _CACHE_MASK (7<<3)
51 52
52/* MIPS32 defines only values 2 and 3. The rest are implementation
53 * dependent.
54 */
55#define _CACHE_UNCACHED (2<<3)
56#define _CACHE_CACHABLE_NONCOHERENT (3<<3)
57#define _CACHE_CACHABLE_COW (3<<3) /* Au1x */
58
59#else 53#else
60 54
61#define _PAGE_PRESENT (1<<0) /* implemented in software */ 55#define _PAGE_PRESENT (1<<0) /* implemented in software */
@@ -74,75 +68,72 @@
74#define _PAGE_SILENT_WRITE (1<<10) 68#define _PAGE_SILENT_WRITE (1<<10)
75#define _CACHE_UNCACHED (1<<11) 69#define _CACHE_UNCACHED (1<<11)
76#define _CACHE_MASK (1<<11) 70#define _CACHE_MASK (1<<11)
77#define _CACHE_CACHABLE_NONCOHERENT 0
78 71
79#else 72#else
73
80#define _PAGE_R4KBUG (1<<5) /* workaround for r4k bug */ 74#define _PAGE_R4KBUG (1<<5) /* workaround for r4k bug */
81#define _PAGE_GLOBAL (1<<6) 75#define _PAGE_GLOBAL (1<<6)
82#define _PAGE_VALID (1<<7) 76#define _PAGE_VALID (1<<7)
83#define _PAGE_SILENT_READ (1<<7) /* synonym */ 77#define _PAGE_SILENT_READ (1<<7) /* synonym */
84#define _PAGE_DIRTY (1<<8) /* The MIPS dirty bit */ 78#define _PAGE_DIRTY (1<<8) /* The MIPS dirty bit */
85#define _PAGE_SILENT_WRITE (1<<8) 79#define _PAGE_SILENT_WRITE (1<<8)
80#define _CACHE_SHIFT 9
86#define _CACHE_MASK (7<<9) 81#define _CACHE_MASK (7<<9)
87 82
88#ifdef CONFIG_CPU_SB1 83#endif
84#endif /* defined(CONFIG_64BIT_PHYS_ADDR && defined(CONFIG_CPU_MIPS32) */
85
86
87/*
88 * Cache attributes
89 */
90#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
91
92#define _CACHE_CACHABLE_NONCOHERENT 0
93
94#elif defined(CONFIG_CPU_SB1)
89 95
90/* No penalty for being coherent on the SB1, so just 96/* No penalty for being coherent on the SB1, so just
91 use it for "noncoherent" spaces, too. Shouldn't hurt. */ 97 use it for "noncoherent" spaces, too. Shouldn't hurt. */
92 98
93#define _CACHE_UNCACHED (2<<9) 99#define _CACHE_UNCACHED (2<<_CACHE_SHIFT)
94#define _CACHE_CACHABLE_COW (5<<9) 100#define _CACHE_CACHABLE_COW (5<<_CACHE_SHIFT)
95#define _CACHE_CACHABLE_NONCOHERENT (5<<9) 101#define _CACHE_CACHABLE_NONCOHERENT (5<<_CACHE_SHIFT)
96#define _CACHE_UNCACHED_ACCELERATED (7<<9) 102#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT)
97 103
98#elif defined(CONFIG_CPU_RM9000) 104#elif defined(CONFIG_CPU_RM9000)
99 105
100#define _CACHE_WT (0 << 9) 106#define _CACHE_WT (0<<_CACHE_SHIFT)
101#define _CACHE_WTWA (1 << 9) 107#define _CACHE_WTWA (1<<_CACHE_SHIFT)
102#define _CACHE_UC_B (2 << 9) 108#define _CACHE_UC_B (2<<_CACHE_SHIFT)
103#define _CACHE_WB (3 << 9) 109#define _CACHE_WB (3<<_CACHE_SHIFT)
104#define _CACHE_CWBEA (4 << 9) 110#define _CACHE_CWBEA (4<<_CACHE_SHIFT)
105#define _CACHE_CWB (5 << 9) 111#define _CACHE_CWB (5<<_CACHE_SHIFT)
106#define _CACHE_UCNB (6 << 9) 112#define _CACHE_UCNB (6<<_CACHE_SHIFT)
107#define _CACHE_FPC (7 << 9) 113#define _CACHE_FPC (7<<_CACHE_SHIFT)
108 114
109#define _CACHE_UNCACHED _CACHE_UC_B 115#define _CACHE_UNCACHED _CACHE_UC_B
110#define _CACHE_CACHABLE_NONCOHERENT _CACHE_WB 116#define _CACHE_CACHABLE_NONCOHERENT _CACHE_WB
111 117
112#else 118#else
113 119
114#define _CACHE_CACHABLE_NO_WA (0<<9) /* R4600 only */ 120#define _CACHE_CACHABLE_NO_WA (0<<_CACHE_SHIFT) /* R4600 only */
115#define _CACHE_CACHABLE_WA (1<<9) /* R4600 only */ 121#define _CACHE_CACHABLE_WA (1<<_CACHE_SHIFT) /* R4600 only */
116#define _CACHE_UNCACHED (2<<9) /* R4[0246]00 */ 122#define _CACHE_UNCACHED (2<<_CACHE_SHIFT) /* R4[0246]00 */
117#define _CACHE_CACHABLE_NONCOHERENT (3<<9) /* R4[0246]00 */ 123#define _CACHE_CACHABLE_NONCOHERENT (3<<_CACHE_SHIFT) /* R4[0246]00 */
118#define _CACHE_CACHABLE_CE (4<<9) /* R4[04]00MC only */ 124#define _CACHE_CACHABLE_CE (4<<_CACHE_SHIFT) /* R4[04]00MC only */
119#define _CACHE_CACHABLE_COW (5<<9) /* R4[04]00MC only */ 125#define _CACHE_CACHABLE_COW (5<<_CACHE_SHIFT) /* R4[04]00MC only */
120#define _CACHE_CACHABLE_CUW (6<<9) /* R4[04]00MC only */ 126#define _CACHE_CACHABLE_COHERENT (5<<_CACHE_SHIFT) /* MIPS32R2 CMP */
121#define _CACHE_UNCACHED_ACCELERATED (7<<9) /* R10000 only */ 127#define _CACHE_CACHABLE_CUW (6<<_CACHE_SHIFT) /* R4[04]00MC only */
128#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT) /* R10000 only */
122 129
123#endif 130#endif
124#endif
125#endif /* defined(CONFIG_CPU_MIPS32_R1) && defined(CONFIG_64BIT_PHYS_ADDR) */
126 131
127#define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED) 132#define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)
128#define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED) 133#define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
129 134
130#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED | _CACHE_MASK) 135#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED | _CACHE_MASK)
131 136
132#ifdef CONFIG_MIPS_UNCACHED 137#define CONF_CM_DEFAULT (PAGE_CACHABLE_DEFAULT>>_CACHE_SHIFT)
133#define PAGE_CACHABLE_DEFAULT _CACHE_UNCACHED
134#elif defined(CONFIG_DMA_NONCOHERENT)
135#define PAGE_CACHABLE_DEFAULT _CACHE_CACHABLE_NONCOHERENT
136#elif defined(CONFIG_CPU_RM9000)
137#define PAGE_CACHABLE_DEFAULT _CACHE_CWB
138#else
139#define PAGE_CACHABLE_DEFAULT _CACHE_CACHABLE_COW
140#endif
141
142#if defined(CONFIG_CPU_MIPS32_R1) && defined(CONFIG_64BIT_PHYS_ADDR)
143#define CONF_CM_DEFAULT (PAGE_CACHABLE_DEFAULT >> 3)
144#else
145#define CONF_CM_DEFAULT (PAGE_CACHABLE_DEFAULT >> 9)
146#endif
147 138
148#endif /* _ASM_PGTABLE_BITS_H */ 139#endif /* _ASM_PGTABLE_BITS_H */
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
index 17a7703a2969..2f597eea4448 100644
--- a/include/asm-mips/pgtable.h
+++ b/include/asm-mips/pgtable.h
@@ -23,15 +23,15 @@ struct vm_area_struct;
23 23
24#define PAGE_NONE __pgprot(_PAGE_PRESENT | _CACHE_CACHABLE_NONCOHERENT) 24#define PAGE_NONE __pgprot(_PAGE_PRESENT | _CACHE_CACHABLE_NONCOHERENT)
25#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ 25#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
26 PAGE_CACHABLE_DEFAULT) 26 _page_cachable_default)
27#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_READ | \ 27#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_READ | \
28 PAGE_CACHABLE_DEFAULT) 28 _page_cachable_default)
29#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_READ | \ 29#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_READ | \
30 PAGE_CACHABLE_DEFAULT) 30 _page_cachable_default)
31#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \ 31#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \
32 _PAGE_GLOBAL | PAGE_CACHABLE_DEFAULT) 32 _PAGE_GLOBAL | _page_cachable_default)
33#define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ 33#define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
34 PAGE_CACHABLE_DEFAULT) 34 _page_cachable_default)
35#define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \ 35#define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \
36 __WRITEABLE | _PAGE_GLOBAL | _CACHE_UNCACHED) 36 __WRITEABLE | _PAGE_GLOBAL | _CACHE_UNCACHED)
37 37
@@ -40,23 +40,30 @@ struct vm_area_struct;
40 * read. Also, write permissions imply read permissions. This is the closest 40 * read. Also, write permissions imply read permissions. This is the closest
41 * we can get by reasonable means.. 41 * we can get by reasonable means..
42 */ 42 */
43#define __P000 PAGE_NONE 43
44#define __P001 PAGE_READONLY 44/*
45#define __P010 PAGE_COPY 45 * Dummy values to fill the table in mmap.c
46#define __P011 PAGE_COPY 46 * The real values will be generated at runtime
47#define __P100 PAGE_READONLY 47 */
48#define __P101 PAGE_READONLY 48#define __P000 __pgprot(0)
49#define __P110 PAGE_COPY 49#define __P001 __pgprot(0)
50#define __P111 PAGE_COPY 50#define __P010 __pgprot(0)
51 51#define __P011 __pgprot(0)
52#define __S000 PAGE_NONE 52#define __P100 __pgprot(0)
53#define __S001 PAGE_READONLY 53#define __P101 __pgprot(0)
54#define __S010 PAGE_SHARED 54#define __P110 __pgprot(0)
55#define __S011 PAGE_SHARED 55#define __P111 __pgprot(0)
56#define __S100 PAGE_READONLY 56
57#define __S101 PAGE_READONLY 57#define __S000 __pgprot(0)
58#define __S110 PAGE_SHARED 58#define __S001 __pgprot(0)
59#define __S111 PAGE_SHARED 59#define __S010 __pgprot(0)
60#define __S011 __pgprot(0)
61#define __S100 __pgprot(0)
62#define __S101 __pgprot(0)
63#define __S110 __pgprot(0)
64#define __S111 __pgprot(0)
65
66extern unsigned long _page_cachable_default;
60 67
61/* 68/*
62 * ZERO_PAGE is a global shared page that is always zero; used 69 * ZERO_PAGE is a global shared page that is always zero; used
@@ -79,7 +86,7 @@ extern void paging_init(void);
79#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) 86#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
80#define pmd_page_vaddr(pmd) pmd_val(pmd) 87#define pmd_page_vaddr(pmd) pmd_val(pmd)
81 88
82#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) 89#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
83 90
84#define pte_none(pte) (!(((pte).pte_low | (pte).pte_high) & ~_PAGE_GLOBAL)) 91#define pte_none(pte) (!(((pte).pte_low | (pte).pte_high) & ~_PAGE_GLOBAL))
85#define pte_present(pte) ((pte).pte_low & _PAGE_PRESENT) 92#define pte_present(pte) ((pte).pte_low & _PAGE_PRESENT)
@@ -182,7 +189,7 @@ extern pgd_t swapper_pg_dir[];
182 * The following only work if pte_present() is true. 189 * The following only work if pte_present() is true.
183 * Undefined behaviour if not.. 190 * Undefined behaviour if not..
184 */ 191 */
185#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) 192#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
186static inline int pte_write(pte_t pte) { return pte.pte_low & _PAGE_WRITE; } 193static inline int pte_write(pte_t pte) { return pte.pte_low & _PAGE_WRITE; }
187static inline int pte_dirty(pte_t pte) { return pte.pte_low & _PAGE_MODIFIED; } 194static inline int pte_dirty(pte_t pte) { return pte.pte_low & _PAGE_MODIFIED; }
188static inline int pte_young(pte_t pte) { return pte.pte_low & _PAGE_ACCESSED; } 195static inline int pte_young(pte_t pte) { return pte.pte_low & _PAGE_ACCESSED; }
@@ -285,6 +292,8 @@ static inline pte_t pte_mkyoung(pte_t pte)
285 return pte; 292 return pte;
286} 293}
287#endif 294#endif
295static inline int pte_special(pte_t pte) { return 0; }
296static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
288 297
289/* 298/*
290 * Macro to make mark a page protection value as "uncacheable". Note 299 * Macro to make mark a page protection value as "uncacheable". Note
@@ -309,7 +318,7 @@ static inline pgprot_t pgprot_noncached(pgprot_t _prot)
309 */ 318 */
310#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 319#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
311 320
312#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32_R1) 321#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
313static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 322static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
314{ 323{
315 pte.pte_low &= _PAGE_CHG_MASK; 324 pte.pte_low &= _PAGE_CHG_MASK;
diff --git a/include/asm-mips/r4k-timer.h b/include/asm-mips/r4k-timer.h
new file mode 100644
index 000000000000..a37d12b3b61c
--- /dev/null
+++ b/include/asm-mips/r4k-timer.h
@@ -0,0 +1,30 @@
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) 2008 by Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef __ASM_R4K_TYPES_H
9#define __ASM_R4K_TYPES_H
10
11#include <linux/compiler.h>
12
13#ifdef CONFIG_SYNC_R4K
14
15extern void synchronise_count_master(void);
16extern void synchronise_count_slave(void);
17
18#else
19
20static inline void synchronise_count_master(void)
21{
22}
23
24static inline void synchronise_count_slave(void)
25{
26}
27
28#endif
29
30#endif /* __ASM_R4K_TYPES_H */
diff --git a/include/asm-mips/semaphore.h b/include/asm-mips/semaphore.h
index fdf8042b784b..d9b2034ed1d2 100644
--- a/include/asm-mips/semaphore.h
+++ b/include/asm-mips/semaphore.h
@@ -1,108 +1 @@
1/* #include <linux/semaphore.h>
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) 1996 Linus Torvalds
7 * Copyright (C) 1998, 99, 2000, 01, 04 Ralf Baechle
8 * Copyright (C) 1999, 2000, 01 Silicon Graphics, Inc.
9 * Copyright (C) 2000, 01 MIPS Technologies, Inc.
10 *
11 * In all honesty, little of the old MIPS code left - the PPC64 variant was
12 * just looking nice and portable so I ripped it. Credits to whoever wrote
13 * it.
14 */
15#ifndef __ASM_SEMAPHORE_H
16#define __ASM_SEMAPHORE_H
17
18/*
19 * Remove spinlock-based RW semaphores; RW semaphore definitions are
20 * now in rwsem.h and we use the generic lib/rwsem.c implementation.
21 * Rework semaphores to use atomic_dec_if_positive.
22 * -- Paul Mackerras (paulus@samba.org)
23 */
24
25#ifdef __KERNEL__
26
27#include <asm/atomic.h>
28#include <asm/system.h>
29#include <linux/wait.h>
30#include <linux/rwsem.h>
31
32struct semaphore {
33 /*
34 * Note that any negative value of count is equivalent to 0,
35 * but additionally indicates that some process(es) might be
36 * sleeping on `wait'.
37 */
38 atomic_t count;
39 wait_queue_head_t wait;
40};
41
42#define __SEMAPHORE_INITIALIZER(name, n) \
43{ \
44 .count = ATOMIC_INIT(n), \
45 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
46}
47
48#define __DECLARE_SEMAPHORE_GENERIC(name, count) \
49 struct semaphore name = __SEMAPHORE_INITIALIZER(name, count)
50
51#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
52
53static inline void sema_init(struct semaphore *sem, int val)
54{
55 atomic_set(&sem->count, val);
56 init_waitqueue_head(&sem->wait);
57}
58
59static inline void init_MUTEX(struct semaphore *sem)
60{
61 sema_init(sem, 1);
62}
63
64static inline void init_MUTEX_LOCKED(struct semaphore *sem)
65{
66 sema_init(sem, 0);
67}
68
69extern void __down(struct semaphore * sem);
70extern int __down_interruptible(struct semaphore * sem);
71extern void __up(struct semaphore * sem);
72
73static inline void down(struct semaphore * sem)
74{
75 might_sleep();
76
77 /*
78 * Try to get the semaphore, take the slow path if we fail.
79 */
80 if (unlikely(atomic_dec_return(&sem->count) < 0))
81 __down(sem);
82}
83
84static inline int down_interruptible(struct semaphore * sem)
85{
86 int ret = 0;
87
88 might_sleep();
89
90 if (unlikely(atomic_dec_return(&sem->count) < 0))
91 ret = __down_interruptible(sem);
92 return ret;
93}
94
95static inline int down_trylock(struct semaphore * sem)
96{
97 return atomic_dec_if_positive(&sem->count) < 0;
98}
99
100static inline void up(struct semaphore * sem)
101{
102 if (unlikely(atomic_inc_return(&sem->count) <= 0))
103 __up(sem);
104}
105
106#endif /* __KERNEL__ */
107
108#endif /* __ASM_SEMAPHORE_H */
diff --git a/include/asm-mips/smp-ops.h b/include/asm-mips/smp-ops.h
index b17fdfb5d818..43c207e72a63 100644
--- a/include/asm-mips/smp-ops.h
+++ b/include/asm-mips/smp-ops.h
@@ -51,6 +51,7 @@ static inline void register_smp_ops(struct plat_smp_ops *ops)
51#endif /* !CONFIG_SMP */ 51#endif /* !CONFIG_SMP */
52 52
53extern struct plat_smp_ops up_smp_ops; 53extern struct plat_smp_ops up_smp_ops;
54extern struct plat_smp_ops cmp_smp_ops;
54extern struct plat_smp_ops vsmp_smp_ops; 55extern struct plat_smp_ops vsmp_smp_ops;
55 56
56#endif /* __ASM_SMP_OPS_H */ 57#endif /* __ASM_SMP_OPS_H */
diff --git a/include/asm-mips/smtc.h b/include/asm-mips/smtc.h
index ff3e8936b493..3639b28f80db 100644
--- a/include/asm-mips/smtc.h
+++ b/include/asm-mips/smtc.h
@@ -44,6 +44,7 @@ extern int mipsmt_build_cpu_map(int startslot);
44extern void mipsmt_prepare_cpus(void); 44extern void mipsmt_prepare_cpus(void);
45extern void smtc_smp_finish(void); 45extern void smtc_smp_finish(void);
46extern void smtc_boot_secondary(int cpu, struct task_struct *t); 46extern void smtc_boot_secondary(int cpu, struct task_struct *t);
47extern void smtc_cpus_done(void);
47 48
48/* 49/*
49 * Sharing the TLB between multiple VPEs means that the 50 * Sharing the TLB between multiple VPEs means that the
diff --git a/include/asm-mips/smvp.h b/include/asm-mips/smvp.h
new file mode 100644
index 000000000000..0d0e80a39e8a
--- /dev/null
+++ b/include/asm-mips/smvp.h
@@ -0,0 +1,19 @@
1#ifndef _ASM_SMVP_H
2#define _ASM_SMVP_H
3
4/*
5 * Definitions for SMVP multitasking on MIPS MT cores
6 */
7struct task_struct;
8
9extern void smvp_smp_setup(void);
10extern void smvp_smp_finish(void);
11extern void smvp_boot_secondary(int cpu, struct task_struct *t);
12extern void smvp_init_secondary(void);
13extern void smvp_smp_finish(void);
14extern void smvp_cpus_done(void);
15extern void smvp_prepare_cpus(unsigned int max_cpus);
16
17/* This is platform specific */
18extern void smvp_send_ipi(int cpu, unsigned int action);
19#endif /* _ASM_SMVP_H */
diff --git a/include/asm-mips/traps.h b/include/asm-mips/traps.h
index d02e019b0127..e5dbde625ec2 100644
--- a/include/asm-mips/traps.h
+++ b/include/asm-mips/traps.h
@@ -23,5 +23,7 @@ extern int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
23 23
24extern void (*board_nmi_handler_setup)(void); 24extern void (*board_nmi_handler_setup)(void);
25extern void (*board_ejtag_handler_setup)(void); 25extern void (*board_ejtag_handler_setup)(void);
26extern void (*board_bind_eic_interrupt)(int irq, int regset);
27extern void (*board_watchpoint_handler)(struct pt_regs *regs);
26 28
27#endif /* _ASM_TRAPS_H */ 29#endif /* _ASM_TRAPS_H */
diff --git a/include/asm-mips/tx4938/rbtx4938.h b/include/asm-mips/tx4938/rbtx4938.h
index b180488dcdc4..dfed7beb533f 100644
--- a/include/asm-mips/tx4938/rbtx4938.h
+++ b/include/asm-mips/tx4938/rbtx4938.h
@@ -67,44 +67,26 @@
67#define RBTX4938_INTF_MODEM (1 << RBTX4938_INTB_MODEM) 67#define RBTX4938_INTF_MODEM (1 << RBTX4938_INTB_MODEM)
68#define RBTX4938_INTF_SWINT (1 << RBTX4938_INTB_SWINT) 68#define RBTX4938_INTF_SWINT (1 << RBTX4938_INTB_SWINT)
69 69
70#define rbtx4938_fpga_rev_ptr \ 70#define rbtx4938_fpga_rev_addr ((__u8 __iomem *)RBTX4938_FPGA_REV_ADDR)
71 ((volatile unsigned char *)RBTX4938_FPGA_REV_ADDR) 71#define rbtx4938_led_addr ((__u8 __iomem *)RBTX4938_LED_ADDR)
72#define rbtx4938_led_ptr \ 72#define rbtx4938_dipsw_addr ((__u8 __iomem *)RBTX4938_DIPSW_ADDR)
73 ((volatile unsigned char *)RBTX4938_LED_ADDR) 73#define rbtx4938_bdipsw_addr ((__u8 __iomem *)RBTX4938_BDIPSW_ADDR)
74#define rbtx4938_dipsw_ptr \ 74#define rbtx4938_imask_addr ((__u8 __iomem *)RBTX4938_IMASK_ADDR)
75 ((volatile unsigned char *)RBTX4938_DIPSW_ADDR) 75#define rbtx4938_imask2_addr ((__u8 __iomem *)RBTX4938_IMASK2_ADDR)
76#define rbtx4938_bdipsw_ptr \ 76#define rbtx4938_intpol_addr ((__u8 __iomem *)RBTX4938_INTPOL_ADDR)
77 ((volatile unsigned char *)RBTX4938_BDIPSW_ADDR) 77#define rbtx4938_istat_addr ((__u8 __iomem *)RBTX4938_ISTAT_ADDR)
78#define rbtx4938_imask_ptr \ 78#define rbtx4938_istat2_addr ((__u8 __iomem *)RBTX4938_ISTAT2_ADDR)
79 ((volatile unsigned char *)RBTX4938_IMASK_ADDR) 79#define rbtx4938_imstat_addr ((__u8 __iomem *)RBTX4938_IMSTAT_ADDR)
80#define rbtx4938_imask2_ptr \ 80#define rbtx4938_imstat2_addr ((__u8 __iomem *)RBTX4938_IMSTAT2_ADDR)
81 ((volatile unsigned char *)RBTX4938_IMASK2_ADDR) 81#define rbtx4938_softint_addr ((__u8 __iomem *)RBTX4938_SOFTINT_ADDR)
82#define rbtx4938_intpol_ptr \ 82#define rbtx4938_piosel_addr ((__u8 __iomem *)RBTX4938_PIOSEL_ADDR)
83 ((volatile unsigned char *)RBTX4938_INTPOL_ADDR) 83#define rbtx4938_spics_addr ((__u8 __iomem *)RBTX4938_SPICS_ADDR)
84#define rbtx4938_istat_ptr \ 84#define rbtx4938_sfpwr_addr ((__u8 __iomem *)RBTX4938_SFPWR_ADDR)
85 ((volatile unsigned char *)RBTX4938_ISTAT_ADDR) 85#define rbtx4938_sfvol_addr ((__u8 __iomem *)RBTX4938_SFVOL_ADDR)
86#define rbtx4938_istat2_ptr \ 86#define rbtx4938_softreset_addr ((__u8 __iomem *)RBTX4938_SOFTRESET_ADDR)
87 ((volatile unsigned char *)RBTX4938_ISTAT2_ADDR) 87#define rbtx4938_softresetlock_addr \
88#define rbtx4938_imstat_ptr \ 88 ((__u8 __iomem *)RBTX4938_SOFTRESETLOCK_ADDR)
89 ((volatile unsigned char *)RBTX4938_IMSTAT_ADDR) 89#define rbtx4938_pcireset_addr ((__u8 __iomem *)RBTX4938_PCIRESET_ADDR)
90#define rbtx4938_imstat2_ptr \
91 ((volatile unsigned char *)RBTX4938_IMSTAT2_ADDR)
92#define rbtx4938_softint_ptr \
93 ((volatile unsigned char *)RBTX4938_SOFTINT_ADDR)
94#define rbtx4938_piosel_ptr \
95 ((volatile unsigned char *)RBTX4938_PIOSEL_ADDR)
96#define rbtx4938_spics_ptr \
97 ((volatile unsigned char *)RBTX4938_SPICS_ADDR)
98#define rbtx4938_sfpwr_ptr \
99 ((volatile unsigned char *)RBTX4938_SFPWR_ADDR)
100#define rbtx4938_sfvol_ptr \
101 ((volatile unsigned char *)RBTX4938_SFVOL_ADDR)
102#define rbtx4938_softreset_ptr \
103 ((volatile unsigned char *)RBTX4938_SOFTRESET_ADDR)
104#define rbtx4938_softresetlock_ptr \
105 ((volatile unsigned char *)RBTX4938_SOFTRESETLOCK_ADDR)
106#define rbtx4938_pcireset_ptr \
107 ((volatile unsigned char *)RBTX4938_PCIRESET_ADDR)
108 90
109/* 91/*
110 * IRQ mappings 92 * IRQ mappings
diff --git a/include/asm-mips/tx4938/tx4938.h b/include/asm-mips/tx4938/tx4938.h
index f7c448b90578..e8807f5c61e9 100644
--- a/include/asm-mips/tx4938/tx4938.h
+++ b/include/asm-mips/tx4938/tx4938.h
@@ -13,8 +13,6 @@
13#ifndef __ASM_TX_BOARDS_TX4938_H 13#ifndef __ASM_TX_BOARDS_TX4938_H
14#define __ASM_TX_BOARDS_TX4938_H 14#define __ASM_TX_BOARDS_TX4938_H
15 15
16#include <asm/tx4938/tx4938_mips.h>
17
18#define tx4938_read_nfmc(addr) (*(volatile unsigned int *)(addr)) 16#define tx4938_read_nfmc(addr) (*(volatile unsigned int *)(addr))
19#define tx4938_write_nfmc(b, addr) (*(volatile unsigned int *)(addr)) = (b) 17#define tx4938_write_nfmc(b, addr) (*(volatile unsigned int *)(addr)) = (b)
20 18
@@ -54,28 +52,6 @@
54#define TX4938_ACLC_REG (TX4938_REG_BASE + 0xf700) 52#define TX4938_ACLC_REG (TX4938_REG_BASE + 0xf700)
55#define TX4938_SPI_REG (TX4938_REG_BASE + 0xf800) 53#define TX4938_SPI_REG (TX4938_REG_BASE + 0xf800)
56 54
57#ifndef _LANGUAGE_ASSEMBLY
58#include <asm/byteorder.h>
59
60#define TX4938_MKA(x) ((u32)( ((u32)(TX4938_REG_BASE)) | ((u32)(x)) ))
61
62#define TX4938_RD08( reg ) (*(vu08*)(reg))
63#define TX4938_WR08( reg, val ) ((*(vu08*)(reg))=(val))
64
65#define TX4938_RD16( reg ) (*(vu16*)(reg))
66#define TX4938_WR16( reg, val ) ((*(vu16*)(reg))=(val))
67
68#define TX4938_RD32( reg ) (*(vu32*)(reg))
69#define TX4938_WR32( reg, val ) ((*(vu32*)(reg))=(val))
70
71#define TX4938_RD64( reg ) (*(vu64*)(reg))
72#define TX4938_WR64( reg, val ) ((*(vu64*)(reg))=(val))
73
74#define TX4938_RD( reg ) TX4938_RD32( reg )
75#define TX4938_WR( reg, val ) TX4938_WR32( reg, val )
76
77#endif /* !__ASSEMBLY__ */
78
79#ifdef __ASSEMBLY__ 55#ifdef __ASSEMBLY__
80#define _CONST64(c) c 56#define _CONST64(c) c
81#else 57#else
@@ -261,18 +237,6 @@ struct tx4938_sio_reg {
261 volatile unsigned long rfifo; 237 volatile unsigned long rfifo;
262}; 238};
263 239
264struct tx4938_pio_reg {
265 volatile unsigned long dout;
266 volatile unsigned long din;
267 volatile unsigned long dir;
268 volatile unsigned long od;
269 volatile unsigned long flag[2];
270 volatile unsigned long pol;
271 volatile unsigned long intc;
272 volatile unsigned long maskcpu;
273 volatile unsigned long maskext;
274};
275
276struct tx4938_ndfmc_reg { 240struct tx4938_ndfmc_reg {
277 endian_def_l2(unused0, dtr); 241 endian_def_l2(unused0, dtr);
278 endian_def_l2(unused1, mcr); 242 endian_def_l2(unused1, mcr);
@@ -642,7 +606,7 @@ struct tx4938_ccfg_reg {
642#define tx4938_pcic1ptr ((struct tx4938_pcic_reg *)TX4938_PCIC1_REG) 606#define tx4938_pcic1ptr ((struct tx4938_pcic_reg *)TX4938_PCIC1_REG)
643#define tx4938_ccfgptr ((struct tx4938_ccfg_reg *)TX4938_CCFG_REG) 607#define tx4938_ccfgptr ((struct tx4938_ccfg_reg *)TX4938_CCFG_REG)
644#define tx4938_sioptr(ch) ((struct tx4938_sio_reg *)TX4938_SIO_REG(ch)) 608#define tx4938_sioptr(ch) ((struct tx4938_sio_reg *)TX4938_SIO_REG(ch))
645#define tx4938_pioptr ((struct tx4938_pio_reg *)TX4938_PIO_REG) 609#define tx4938_pioptr ((struct txx9_pio_reg __iomem *)TX4938_PIO_REG)
646#define tx4938_aclcptr ((struct tx4938_aclc_reg *)TX4938_ACLC_REG) 610#define tx4938_aclcptr ((struct tx4938_aclc_reg *)TX4938_ACLC_REG)
647#define tx4938_spiptr ((struct tx4938_spi_reg *)TX4938_SPI_REG) 611#define tx4938_spiptr ((struct tx4938_spi_reg *)TX4938_SPI_REG)
648#define tx4938_sramcptr ((struct tx4938_sramc_reg *)TX4938_SRAMC_REG) 612#define tx4938_sramcptr ((struct tx4938_sramc_reg *)TX4938_SRAMC_REG)
diff --git a/include/asm-mips/tx4938/tx4938_mips.h b/include/asm-mips/tx4938/tx4938_mips.h
deleted file mode 100644
index f346ff58b947..000000000000
--- a/include/asm-mips/tx4938/tx4938_mips.h
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * linux/include/asm-mips/tx4938/tx4938_mips.h
3 * Generic bitmask definitions
4 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 *
10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11 */
12
13#ifndef TX4938_TX4938_MIPS_H
14#define TX4938_TX4938_MIPS_H
15#ifndef __ASSEMBLY__
16
17#define reg_rd08(r) ((u8 )(*((vu8 *)(r))))
18#define reg_rd16(r) ((u16)(*((vu16*)(r))))
19#define reg_rd32(r) ((u32)(*((vu32*)(r))))
20#define reg_rd64(r) ((u64)(*((vu64*)(r))))
21
22#define reg_wr08(r, v) ((*((vu8 *)(r)))=((u8 )(v)))
23#define reg_wr16(r, v) ((*((vu16*)(r)))=((u16)(v)))
24#define reg_wr32(r, v) ((*((vu32*)(r)))=((u32)(v)))
25#define reg_wr64(r, v) ((*((vu64*)(r)))=((u64)(v)))
26
27typedef volatile __signed char vs8;
28typedef volatile unsigned char vu8;
29
30typedef volatile __signed short vs16;
31typedef volatile unsigned short vu16;
32
33typedef volatile __signed int vs32;
34typedef volatile unsigned int vu32;
35
36typedef s8 s08;
37typedef vs8 vs08;
38
39typedef u8 u08;
40typedef vu8 vu08;
41
42#if (_MIPS_SZLONG == 64)
43
44typedef volatile __signed__ long vs64;
45typedef volatile unsigned long vu64;
46
47#else
48
49typedef volatile __signed__ long long vs64;
50typedef volatile unsigned long long vu64;
51
52#endif
53#endif
54#endif
diff --git a/include/asm-mips/txx9pio.h b/include/asm-mips/txx9pio.h
new file mode 100644
index 000000000000..3d6fa9f8d513
--- /dev/null
+++ b/include/asm-mips/txx9pio.h
@@ -0,0 +1,29 @@
1/*
2 * include/asm-mips/txx9pio.h
3 * TX39/TX49 PIO 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_TXX9PIO_H
10#define __ASM_TXX9PIO_H
11
12#include <linux/types.h>
13
14struct txx9_pio_reg {
15 __u32 dout;
16 __u32 din;
17 __u32 dir;
18 __u32 od;
19 __u32 flag[2];
20 __u32 pol;
21 __u32 intc;
22 __u32 maskcpu;
23 __u32 maskext;
24};
25
26int txx9_gpio_init(unsigned long baseaddr,
27 unsigned int base, unsigned int num);
28
29#endif /* __ASM_TXX9PIO_H */
diff --git a/include/asm-mips/unaligned.h b/include/asm-mips/unaligned.h
index 3249049e93aa..792404948571 100644
--- a/include/asm-mips/unaligned.h
+++ b/include/asm-mips/unaligned.h
@@ -5,25 +5,24 @@
5 * 5 *
6 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) 6 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
7 */ 7 */
8#ifndef __ASM_GENERIC_UNALIGNED_H 8#ifndef _ASM_MIPS_UNALIGNED_H
9#define __ASM_GENERIC_UNALIGNED_H 9#define _ASM_MIPS_UNALIGNED_H
10 10
11#include <linux/compiler.h> 11#include <linux/compiler.h>
12#if defined(__MIPSEB__)
13# include <linux/unaligned/be_struct.h>
14# include <linux/unaligned/le_byteshift.h>
15# include <linux/unaligned/generic.h>
16# define get_unaligned __get_unaligned_be
17# define put_unaligned __put_unaligned_be
18#elif defined(__MIPSEL__)
19# include <linux/unaligned/le_struct.h>
20# include <linux/unaligned/be_byteshift.h>
21# include <linux/unaligned/generic.h>
22# define get_unaligned __get_unaligned_le
23# define put_unaligned __put_unaligned_le
24#else
25# error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???"
26#endif
12 27
13#define get_unaligned(ptr) \ 28#endif /* _ASM_MIPS_UNALIGNED_H */
14({ \
15 struct __packed { \
16 typeof(*(ptr)) __v; \
17 } *__p = (void *) (ptr); \
18 __p->__v; \
19})
20
21#define put_unaligned(val, ptr) \
22do { \
23 struct __packed { \
24 typeof(*(ptr)) __v; \
25 } *__p = (void *) (ptr); \
26 __p->__v = (val); \
27} while(0)
28
29#endif /* __ASM_GENERIC_UNALIGNED_H */
diff --git a/include/asm-mips/vr41xx/siu.h b/include/asm-mips/vr41xx/siu.h
index 98cdb4096485..da9f6e373409 100644
--- a/include/asm-mips/vr41xx/siu.h
+++ b/include/asm-mips/vr41xx/siu.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Include file for NEC VR4100 series Serial Interface Unit. 2 * Include file for NEC VR4100 series Serial Interface Unit.
3 * 3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2005-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
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 as published by 7 * it under the terms of the GNU General Public License as published by
@@ -49,4 +49,10 @@ typedef enum {
49 49
50extern void vr41xx_select_irda_module(irda_module_t module, irda_speed_t speed); 50extern void vr41xx_select_irda_module(irda_module_t module, irda_speed_t speed);
51 51
52#ifdef CONFIG_SERIAL_VR41XX_CONSOLE
53extern void vr41xx_siu_early_setup(struct uart_port *port);
54#else
55static inline void vr41xx_siu_early_setup(struct uart_port *port) {}
56#endif
57
52#endif /* __NEC_VR41XX_SIU_H */ 58#endif /* __NEC_VR41XX_SIU_H */
diff --git a/include/asm-mips/vr41xx/vr41xx.h b/include/asm-mips/vr41xx/vr41xx.h
index 88b492f6ea9c..22be64971cc6 100644
--- a/include/asm-mips/vr41xx/vr41xx.h
+++ b/include/asm-mips/vr41xx/vr41xx.h
@@ -7,7 +7,7 @@
7 * Copyright (C) 2001, 2002 Paul Mundt 7 * Copyright (C) 2001, 2002 Paul Mundt
8 * Copyright (C) 2002 MontaVista Software, Inc. 8 * Copyright (C) 2002 MontaVista Software, Inc.
9 * Copyright (C) 2002 TimeSys Corp. 9 * Copyright (C) 2002 TimeSys Corp.
10 * Copyright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 10 * Copyright (C) 2003-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
@@ -143,4 +143,10 @@ extern void vr41xx_disable_csiint(uint16_t mask);
143extern void vr41xx_enable_bcuint(void); 143extern void vr41xx_enable_bcuint(void);
144extern void vr41xx_disable_bcuint(void); 144extern void vr41xx_disable_bcuint(void);
145 145
146#ifdef CONFIG_SERIAL_VR41XX_CONSOLE
147extern void vr41xx_siu_setup(void);
148#else
149static inline void vr41xx_siu_setup(void) {}
150#endif
151
146#endif /* __NEC_VR41XX_H */ 152#endif /* __NEC_VR41XX_H */
diff --git a/include/asm-mn10300/div64.h b/include/asm-mn10300/div64.h
index bf9c515a998c..3a8329b3e869 100644
--- a/include/asm-mn10300/div64.h
+++ b/include/asm-mn10300/div64.h
@@ -97,7 +97,4 @@ signed __muldiv64s(signed val, signed mult, signed div)
97 return result; 97 return result;
98} 98}
99 99
100extern __attribute__((const))
101uint64_t div64_64(uint64_t dividend, uint64_t divisor);
102
103#endif /* _ASM_DIV64 */ 100#endif /* _ASM_DIV64 */
diff --git a/include/asm-mn10300/pgtable.h b/include/asm-mn10300/pgtable.h
index 375c4941deda..6dc30fc827c4 100644
--- a/include/asm-mn10300/pgtable.h
+++ b/include/asm-mn10300/pgtable.h
@@ -224,6 +224,7 @@ static inline int pte_read(pte_t pte) { return pte_val(pte) & __PAGE_PROT_USER;
224static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 224static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
225static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 225static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
226static inline int pte_write(pte_t pte) { return pte_val(pte) & __PAGE_PROT_WRITE; } 226static inline int pte_write(pte_t pte) { return pte_val(pte) & __PAGE_PROT_WRITE; }
227static inline int pte_special(pte_t pte){ return 0; }
227 228
228/* 229/*
229 * The following only works if pte_present() is not true. 230 * The following only works if pte_present() is not true.
@@ -265,6 +266,8 @@ static inline pte_t pte_mkwrite(pte_t pte)
265 return pte; 266 return pte;
266} 267}
267 268
269static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
270
268#define pte_ERROR(e) \ 271#define pte_ERROR(e) \
269 printk(KERN_ERR "%s:%d: bad pte %08lx.\n", \ 272 printk(KERN_ERR "%s:%d: bad pte %08lx.\n", \
270 __FILE__, __LINE__, pte_val(e)) 273 __FILE__, __LINE__, pte_val(e))
diff --git a/include/asm-mn10300/semaphore.h b/include/asm-mn10300/semaphore.h
index 5a9e1ad0b253..d9b2034ed1d2 100644
--- a/include/asm-mn10300/semaphore.h
+++ b/include/asm-mn10300/semaphore.h
@@ -1,169 +1 @@
1/* MN10300 Semaphores #include <linux/semaphore.h>
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11#ifndef _ASM_SEMAPHORE_H
12#define _ASM_SEMAPHORE_H
13
14#ifndef __ASSEMBLY__
15
16#include <linux/linkage.h>
17#include <linux/wait.h>
18#include <linux/spinlock.h>
19#include <linux/rwsem.h>
20
21#define SEMAPHORE_DEBUG 0
22
23/*
24 * the semaphore definition
25 * - if count is >0 then there are tokens available on the semaphore for down
26 * to collect
27 * - if count is <=0 then there are no spare tokens, and anyone that wants one
28 * must wait
29 * - if wait_list is not empty, then there are processes waiting for the
30 * semaphore
31 */
32struct semaphore {
33 atomic_t count; /* it's not really atomic, it's
34 * just that certain modules
35 * expect to be able to access
36 * it directly */
37 spinlock_t wait_lock;
38 struct list_head wait_list;
39#if SEMAPHORE_DEBUG
40 unsigned __magic;
41#endif
42};
43
44#if SEMAPHORE_DEBUG
45# define __SEM_DEBUG_INIT(name) , (long)&(name).__magic
46#else
47# define __SEM_DEBUG_INIT(name)
48#endif
49
50
51#define __SEMAPHORE_INITIALIZER(name, init_count) \
52{ \
53 .count = ATOMIC_INIT(init_count), \
54 .wait_lock = __SPIN_LOCK_UNLOCKED((name).wait_lock), \
55 .wait_list = LIST_HEAD_INIT((name).wait_list) \
56 __SEM_DEBUG_INIT(name) \
57}
58
59#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
60 struct semaphore name = __SEMAPHORE_INITIALIZER(name, count)
61
62#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
63#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name, 0)
64
65static inline void sema_init(struct semaphore *sem, int val)
66{
67 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
68}
69
70static inline void init_MUTEX(struct semaphore *sem)
71{
72 sema_init(sem, 1);
73}
74
75static inline void init_MUTEX_LOCKED(struct semaphore *sem)
76{
77 sema_init(sem, 0);
78}
79
80extern void __down(struct semaphore *sem, unsigned long flags);
81extern int __down_interruptible(struct semaphore *sem, unsigned long flags);
82extern void __up(struct semaphore *sem);
83
84static inline void down(struct semaphore *sem)
85{
86 unsigned long flags;
87 int count;
88
89#if SEMAPHORE_DEBUG
90 CHECK_MAGIC(sem->__magic);
91#endif
92
93 spin_lock_irqsave(&sem->wait_lock, flags);
94 count = atomic_read(&sem->count);
95 if (likely(count > 0)) {
96 atomic_set(&sem->count, count - 1);
97 spin_unlock_irqrestore(&sem->wait_lock, flags);
98 } else {
99 __down(sem, flags);
100 }
101}
102
103static inline int down_interruptible(struct semaphore *sem)
104{
105 unsigned long flags;
106 int count, ret = 0;
107
108#if SEMAPHORE_DEBUG
109 CHECK_MAGIC(sem->__magic);
110#endif
111
112 spin_lock_irqsave(&sem->wait_lock, flags);
113 count = atomic_read(&sem->count);
114 if (likely(count > 0)) {
115 atomic_set(&sem->count, count - 1);
116 spin_unlock_irqrestore(&sem->wait_lock, flags);
117 } else {
118 ret = __down_interruptible(sem, flags);
119 }
120 return ret;
121}
122
123/*
124 * non-blockingly attempt to down() a semaphore.
125 * - returns zero if we acquired it
126 */
127static inline int down_trylock(struct semaphore *sem)
128{
129 unsigned long flags;
130 int count, success = 0;
131
132#if SEMAPHORE_DEBUG
133 CHECK_MAGIC(sem->__magic);
134#endif
135
136 spin_lock_irqsave(&sem->wait_lock, flags);
137 count = atomic_read(&sem->count);
138 if (likely(count > 0)) {
139 atomic_set(&sem->count, count - 1);
140 success = 1;
141 }
142 spin_unlock_irqrestore(&sem->wait_lock, flags);
143 return !success;
144}
145
146static inline void up(struct semaphore *sem)
147{
148 unsigned long flags;
149
150#if SEMAPHORE_DEBUG
151 CHECK_MAGIC(sem->__magic);
152#endif
153
154 spin_lock_irqsave(&sem->wait_lock, flags);
155 if (!list_empty(&sem->wait_list))
156 __up(sem);
157 else
158 atomic_set(&sem->count, atomic_read(&sem->count) + 1);
159 spin_unlock_irqrestore(&sem->wait_lock, flags);
160}
161
162static inline int sem_getcount(struct semaphore *sem)
163{
164 return atomic_read(&sem->count);
165}
166
167#endif /* __ASSEMBLY__ */
168
169#endif
diff --git a/include/asm-mn10300/unaligned.h b/include/asm-mn10300/unaligned.h
index cad3afbd035f..0df671318ae4 100644
--- a/include/asm-mn10300/unaligned.h
+++ b/include/asm-mn10300/unaligned.h
@@ -8,129 +8,13 @@
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version. 9 * 2 of the Licence, or (at your option) any later version.
10 */ 10 */
11#ifndef _ASM_UNALIGNED_H 11#ifndef _ASM_MN10300_UNALIGNED_H
12#define _ASM_UNALIGNED_H 12#define _ASM_MN10300_UNALIGNED_H
13 13
14#include <asm/types.h> 14#include <linux/unaligned/access_ok.h>
15#include <linux/unaligned/generic.h>
15 16
16#if 0 17#define get_unaligned __get_unaligned_le
17extern int __bug_unaligned_x(void *ptr); 18#define put_unaligned __put_unaligned_le
18 19
19/* 20#endif /* _ASM_MN10300_UNALIGNED_H */
20 * What is the most efficient way of loading/storing an unaligned value?
21 *
22 * That is the subject of this file. Efficiency here is defined as
23 * minimum code size with minimum register usage for the common cases.
24 * It is currently not believed that long longs are common, so we
25 * trade efficiency for the chars, shorts and longs against the long
26 * longs.
27 *
28 * Current stats with gcc 2.7.2.2 for these functions:
29 *
30 * ptrsize get: code regs put: code regs
31 * 1 1 1 1 2
32 * 2 3 2 3 2
33 * 4 7 3 7 3
34 * 8 20 6 16 6
35 *
36 * gcc 2.95.1 seems to code differently:
37 *
38 * ptrsize get: code regs put: code regs
39 * 1 1 1 1 2
40 * 2 3 2 3 2
41 * 4 7 4 7 4
42 * 8 19 8 15 6
43 *
44 * which may or may not be more efficient (depending upon whether
45 * you can afford the extra registers). Hopefully the gcc 2.95
46 * is inteligent enough to decide if it is better to use the
47 * extra register, but evidence so far seems to suggest otherwise.
48 *
49 * Unfortunately, gcc is not able to optimise the high word
50 * out of long long >> 32, or the low word from long long << 32
51 */
52
53#define __get_unaligned_2(__p) \
54 (__p[0] | __p[1] << 8)
55
56#define __get_unaligned_4(__p) \
57 (__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24)
58
59#define get_unaligned(ptr) \
60({ \
61 unsigned int __v1, __v2; \
62 __typeof__(*(ptr)) __v; \
63 __u8 *__p = (__u8 *)(ptr); \
64 \
65 switch (sizeof(*(ptr))) { \
66 case 1: __v = *(ptr); break; \
67 case 2: __v = __get_unaligned_2(__p); break; \
68 case 4: __v = __get_unaligned_4(__p); break; \
69 case 8: \
70 __v2 = __get_unaligned_4((__p+4)); \
71 __v1 = __get_unaligned_4(__p); \
72 __v = ((unsigned long long)__v2 << 32 | __v1); \
73 break; \
74 default: __v = __bug_unaligned_x(__p); break; \
75 } \
76 __v; \
77})
78
79
80static inline void __put_unaligned_2(__u32 __v, register __u8 *__p)
81{
82 *__p++ = __v;
83 *__p++ = __v >> 8;
84}
85
86static inline void __put_unaligned_4(__u32 __v, register __u8 *__p)
87{
88 __put_unaligned_2(__v >> 16, __p + 2);
89 __put_unaligned_2(__v, __p);
90}
91
92static inline void __put_unaligned_8(const unsigned long long __v, __u8 *__p)
93{
94 /*
95 * tradeoff: 8 bytes of stack for all unaligned puts (2
96 * instructions), or an extra register in the long long
97 * case - go for the extra register.
98 */
99 __put_unaligned_4(__v >> 32, __p + 4);
100 __put_unaligned_4(__v, __p);
101}
102
103/*
104 * Try to store an unaligned value as efficiently as possible.
105 */
106#define put_unaligned(val, ptr) \
107 ({ \
108 switch (sizeof(*(ptr))) { \
109 case 1: \
110 *(ptr) = (val); \
111 break; \
112 case 2: \
113 __put_unaligned_2((val), (__u8 *)(ptr)); \
114 break; \
115 case 4: \
116 __put_unaligned_4((val), (__u8 *)(ptr)); \
117 break; \
118 case 8: \
119 __put_unaligned_8((val), (__u8 *)(ptr)); \
120 break; \
121 default: \
122 __bug_unaligned_x(ptr); \
123 break; \
124 } \
125 (void) 0; \
126 })
127
128
129#else
130
131#define get_unaligned(ptr) (*(ptr))
132#define put_unaligned(val, ptr) ({ *(ptr) = (val); (void) 0; })
133
134#endif
135
136#endif
diff --git a/include/asm-parisc/bitops.h b/include/asm-parisc/bitops.h
index f8eebcbad01f..7a6ea10bd231 100644
--- a/include/asm-parisc/bitops.h
+++ b/include/asm-parisc/bitops.h
@@ -210,6 +210,7 @@ static __inline__ int fls(int x)
210 return ret; 210 return ret;
211} 211}
212 212
213#include <asm-generic/bitops/__fls.h>
213#include <asm-generic/bitops/fls64.h> 214#include <asm-generic/bitops/fls64.h>
214#include <asm-generic/bitops/hweight.h> 215#include <asm-generic/bitops/hweight.h>
215#include <asm-generic/bitops/lock.h> 216#include <asm-generic/bitops/lock.h>
diff --git a/include/asm-parisc/futex.h b/include/asm-parisc/futex.h
index fdc6d055ef7f..0c705c3a55ef 100644
--- a/include/asm-parisc/futex.h
+++ b/include/asm-parisc/futex.h
@@ -4,8 +4,8 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/futex.h> 6#include <linux/futex.h>
7#include <linux/uaccess.h>
7#include <asm/errno.h> 8#include <asm/errno.h>
8#include <asm/uaccess.h>
9 9
10static inline int 10static inline int
11futex_atomic_op_inuser (int encoded_op, int __user *uaddr) 11futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
diff --git a/include/asm-parisc/ide.h b/include/asm-parisc/ide.h
index be8760fbc8ee..db0c94410095 100644
--- a/include/asm-parisc/ide.h
+++ b/include/asm-parisc/ide.h
@@ -17,8 +17,6 @@
17#define MAX_HWIFS 2 17#define MAX_HWIFS 2
18#endif 18#endif
19 19
20#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
21
22#define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id)) 20#define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id))
23#define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id)) 21#define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id))
24#define ide_request_region(from,extent,name) request_region((from), (extent), (name)) 22#define ide_request_region(from,extent,name) request_region((from), (extent), (name))
diff --git a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h
index dc86adbec916..470a4b88124d 100644
--- a/include/asm-parisc/pgtable.h
+++ b/include/asm-parisc/pgtable.h
@@ -323,6 +323,7 @@ static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
323static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 323static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
324static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; } 324static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; }
325static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 325static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
326static inline int pte_special(pte_t pte) { return 0; }
326 327
327static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~_PAGE_DIRTY; return pte; } 328static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
328static inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~_PAGE_ACCESSED; return pte; } 329static inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
@@ -330,6 +331,7 @@ static inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_WRITE; ret
330static inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= _PAGE_DIRTY; return pte; } 331static inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= _PAGE_DIRTY; return pte; }
331static inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= _PAGE_ACCESSED; return pte; } 332static inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= _PAGE_ACCESSED; return pte; }
332static inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) |= _PAGE_WRITE; return pte; } 333static inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) |= _PAGE_WRITE; return pte; }
334static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
333 335
334/* 336/*
335 * Conversion functions: convert a page and protection to a page entry, 337 * Conversion functions: convert a page and protection to a page entry,
diff --git a/include/asm-parisc/semaphore-helper.h b/include/asm-parisc/semaphore-helper.h
deleted file mode 100644
index 387f7c1277a2..000000000000
--- a/include/asm-parisc/semaphore-helper.h
+++ /dev/null
@@ -1,89 +0,0 @@
1#ifndef _ASM_PARISC_SEMAPHORE_HELPER_H
2#define _ASM_PARISC_SEMAPHORE_HELPER_H
3
4/*
5 * SMP- and interrupt-safe semaphores helper functions.
6 *
7 * (C) Copyright 1996 Linus Torvalds
8 * (C) Copyright 1999 Andrea Arcangeli
9 */
10
11/*
12 * These two _must_ execute atomically wrt each other.
13 *
14 * This is trivially done with load_locked/store_cond,
15 * which we have. Let the rest of the losers suck eggs.
16 */
17static __inline__ void wake_one_more(struct semaphore * sem)
18{
19 atomic_inc((atomic_t *)&sem->waking);
20}
21
22static __inline__ int waking_non_zero(struct semaphore *sem)
23{
24 unsigned long flags;
25 int ret = 0;
26
27 spin_lock_irqsave(&semaphore_wake_lock, flags);
28 if (sem->waking > 0) {
29 sem->waking--;
30 ret = 1;
31 }
32 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
33 return ret;
34}
35
36/*
37 * waking_non_zero_interruptible:
38 * 1 got the lock
39 * 0 go to sleep
40 * -EINTR interrupted
41 *
42 * We must undo the sem->count down_interruptible() increment while we are
43 * protected by the spinlock in order to make atomic this atomic_inc() with the
44 * atomic_read() in wake_one_more(), otherwise we can race. -arca
45 */
46static __inline__ int waking_non_zero_interruptible(struct semaphore *sem,
47 struct task_struct *tsk)
48{
49 unsigned long flags;
50 int ret = 0;
51
52 spin_lock_irqsave(&semaphore_wake_lock, flags);
53 if (sem->waking > 0) {
54 sem->waking--;
55 ret = 1;
56 } else if (signal_pending(tsk)) {
57 atomic_inc(&sem->count);
58 ret = -EINTR;
59 }
60 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
61 return ret;
62}
63
64/*
65 * waking_non_zero_trylock:
66 * 1 failed to lock
67 * 0 got the lock
68 *
69 * We must undo the sem->count down_trylock() increment while we are
70 * protected by the spinlock in order to make atomic this atomic_inc() with the
71 * atomic_read() in wake_one_more(), otherwise we can race. -arca
72 */
73static __inline__ int waking_non_zero_trylock(struct semaphore *sem)
74{
75 unsigned long flags;
76 int ret = 1;
77
78 spin_lock_irqsave(&semaphore_wake_lock, flags);
79 if (sem->waking <= 0)
80 atomic_inc(&sem->count);
81 else {
82 sem->waking--;
83 ret = 0;
84 }
85 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
86 return ret;
87}
88
89#endif /* _ASM_PARISC_SEMAPHORE_HELPER_H */
diff --git a/include/asm-parisc/semaphore.h b/include/asm-parisc/semaphore.h
index a16271cdc748..d9b2034ed1d2 100644
--- a/include/asm-parisc/semaphore.h
+++ b/include/asm-parisc/semaphore.h
@@ -1,145 +1 @@
1/* SMP- and interrupt-safe semaphores. #include <linux/semaphore.h>
2 * PA-RISC version by Matthew Wilcox
3 *
4 * Linux/PA-RISC Project (http://www.parisc-linux.org/)
5 * Copyright (C) 1996 Linus Torvalds
6 * Copyright (C) 1999-2001 Matthew Wilcox < willy at debian d0T org >
7 * Copyright (C) 2000 Grant Grundler < grundler a debian org >
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#ifndef _ASM_PARISC_SEMAPHORE_H
25#define _ASM_PARISC_SEMAPHORE_H
26
27#include <linux/spinlock.h>
28#include <linux/wait.h>
29#include <linux/rwsem.h>
30
31#include <asm/system.h>
32
33/*
34 * The `count' is initialised to the number of people who are allowed to
35 * take the lock. (Normally we want a mutex, so this is `1'). if
36 * `count' is positive, the lock can be taken. if it's 0, no-one is
37 * waiting on it. if it's -1, at least one task is waiting.
38 */
39struct semaphore {
40 spinlock_t sentry;
41 int count;
42 wait_queue_head_t wait;
43};
44
45#define __SEMAPHORE_INITIALIZER(name, n) \
46{ \
47 .sentry = SPIN_LOCK_UNLOCKED, \
48 .count = n, \
49 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
50}
51
52#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
53 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
54
55#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
56
57static inline void sema_init (struct semaphore *sem, int val)
58{
59 *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
60}
61
62static inline void init_MUTEX (struct semaphore *sem)
63{
64 sema_init(sem, 1);
65}
66
67static inline void init_MUTEX_LOCKED (struct semaphore *sem)
68{
69 sema_init(sem, 0);
70}
71
72static inline int sem_getcount(struct semaphore *sem)
73{
74 return sem->count;
75}
76
77asmlinkage void __down(struct semaphore * sem);
78asmlinkage int __down_interruptible(struct semaphore * sem);
79asmlinkage void __up(struct semaphore * sem);
80
81/* Semaphores can be `tried' from irq context. So we have to disable
82 * interrupts while we're messing with the semaphore. Sorry.
83 */
84
85static inline void down(struct semaphore * sem)
86{
87 might_sleep();
88 spin_lock_irq(&sem->sentry);
89 if (sem->count > 0) {
90 sem->count--;
91 } else {
92 __down(sem);
93 }
94 spin_unlock_irq(&sem->sentry);
95}
96
97static inline int down_interruptible(struct semaphore * sem)
98{
99 int ret = 0;
100 might_sleep();
101 spin_lock_irq(&sem->sentry);
102 if (sem->count > 0) {
103 sem->count--;
104 } else {
105 ret = __down_interruptible(sem);
106 }
107 spin_unlock_irq(&sem->sentry);
108 return ret;
109}
110
111/*
112 * down_trylock returns 0 on success, 1 if we failed to get the lock.
113 * May not sleep, but must preserve irq state
114 */
115static inline int down_trylock(struct semaphore * sem)
116{
117 unsigned long flags;
118 int count;
119
120 spin_lock_irqsave(&sem->sentry, flags);
121 count = sem->count - 1;
122 if (count >= 0)
123 sem->count = count;
124 spin_unlock_irqrestore(&sem->sentry, flags);
125 return (count < 0);
126}
127
128/*
129 * Note! This is subtle. We jump to wake people up only if
130 * the semaphore was negative (== somebody was waiting on it).
131 */
132static inline void up(struct semaphore * sem)
133{
134 unsigned long flags;
135
136 spin_lock_irqsave(&sem->sentry, flags);
137 if (sem->count < 0) {
138 __up(sem);
139 } else {
140 sem->count++;
141 }
142 spin_unlock_irqrestore(&sem->sentry, flags);
143}
144
145#endif /* _ASM_PARISC_SEMAPHORE_H */
diff --git a/include/asm-parisc/unaligned.h b/include/asm-parisc/unaligned.h
index 53c905838d93..dfc5d3321a54 100644
--- a/include/asm-parisc/unaligned.h
+++ b/include/asm-parisc/unaligned.h
@@ -1,7 +1,11 @@
1#ifndef _ASM_PARISC_UNALIGNED_H_ 1#ifndef _ASM_PARISC_UNALIGNED_H
2#define _ASM_PARISC_UNALIGNED_H_ 2#define _ASM_PARISC_UNALIGNED_H
3 3
4#include <asm-generic/unaligned.h> 4#include <linux/unaligned/be_struct.h>
5#include <linux/unaligned/le_byteshift.h>
6#include <linux/unaligned/generic.h>
7#define get_unaligned __get_unaligned_be
8#define put_unaligned __put_unaligned_be
5 9
6#ifdef __KERNEL__ 10#ifdef __KERNEL__
7struct pt_regs; 11struct pt_regs;
@@ -9,4 +13,4 @@ void handle_unaligned(struct pt_regs *regs);
9int check_unaligned(struct pt_regs *regs); 13int check_unaligned(struct pt_regs *regs);
10#endif 14#endif
11 15
12#endif /* _ASM_PARISC_UNALIGNED_H_ */ 16#endif /* _ASM_PARISC_UNALIGNED_H */
diff --git a/include/asm-powerpc/Kbuild b/include/asm-powerpc/Kbuild
index 5f640e542475..7381916dfcbb 100644
--- a/include/asm-powerpc/Kbuild
+++ b/include/asm-powerpc/Kbuild
@@ -1,5 +1,6 @@
1include include/asm-generic/Kbuild.asm 1include include/asm-generic/Kbuild.asm
2 2
3header-y += a.out.h
3header-y += auxvec.h 4header-y += auxvec.h
4header-y += ioctls.h 5header-y += ioctls.h
5header-y += mman.h 6header-y += mman.h
@@ -23,7 +24,6 @@ header-y += sigcontext.h
23header-y += statfs.h 24header-y += statfs.h
24header-y += ps3fb.h 25header-y += ps3fb.h
25 26
26unifdef-y += a.out.h
27unifdef-y += asm-compat.h 27unifdef-y += asm-compat.h
28unifdef-y += bootx.h 28unifdef-y += bootx.h
29unifdef-y += byteorder.h 29unifdef-y += byteorder.h
diff --git a/include/asm-powerpc/abs_addr.h b/include/asm-powerpc/abs_addr.h
index 4aa220718b19..98324c5a8286 100644
--- a/include/asm-powerpc/abs_addr.h
+++ b/include/asm-powerpc/abs_addr.h
@@ -12,10 +12,11 @@
12 * 2 of the License, or (at your option) any later version. 12 * 2 of the License, or (at your option) any later version.
13 */ 13 */
14 14
15#include <linux/lmb.h>
16
15#include <asm/types.h> 17#include <asm/types.h>
16#include <asm/page.h> 18#include <asm/page.h>
17#include <asm/prom.h> 19#include <asm/prom.h>
18#include <asm/lmb.h>
19#include <asm/firmware.h> 20#include <asm/firmware.h>
20 21
21struct mschunks_map { 22struct mschunks_map {
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h
index 220d9a781ab9..897eade3afbe 100644
--- a/include/asm-powerpc/bitops.h
+++ b/include/asm-powerpc/bitops.h
@@ -312,24 +312,31 @@ static __inline__ int fls(unsigned int x)
312 asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x)); 312 asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
313 return 32 - lz; 313 return 32 - lz;
314} 314}
315#include <asm-generic/bitops/fls64.h>
316 315
317#include <asm-generic/bitops/hweight.h> 316static __inline__ unsigned long __fls(unsigned long x)
317{
318 return __ilog2(x);
319}
318 320
319#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) 321/*
320unsigned long find_next_zero_bit(const unsigned long *addr, 322 * 64-bit can do this using one cntlzd (count leading zeroes doubleword)
321 unsigned long size, unsigned long offset); 323 * instruction; for 32-bit we use the generic version, which does two
322/** 324 * 32-bit fls calls.
323 * find_first_bit - find the first set bit in a memory region
324 * @addr: The address to start the search at
325 * @size: The maximum size to search
326 *
327 * Returns the bit-number of the first set bit, not the number of the byte
328 * containing a bit.
329 */ 325 */
330#define find_first_bit(addr, size) find_next_bit((addr), (size), 0) 326#ifdef __powerpc64__
331unsigned long find_next_bit(const unsigned long *addr, 327static __inline__ int fls64(__u64 x)
332 unsigned long size, unsigned long offset); 328{
329 int lz;
330
331 asm ("cntlzd %0,%1" : "=r" (lz) : "r" (x));
332 return 64 - lz;
333}
334#else
335#include <asm-generic/bitops/fls64.h>
336#endif /* __powerpc64__ */
337
338#include <asm-generic/bitops/hweight.h>
339#include <asm-generic/bitops/find.h>
333 340
334/* Little-endian versions */ 341/* Little-endian versions */
335 342
diff --git a/include/asm-powerpc/cpm.h b/include/asm-powerpc/cpm.h
index 77e39dad9728..ede38ffe466a 100644
--- a/include/asm-powerpc/cpm.h
+++ b/include/asm-powerpc/cpm.h
@@ -4,6 +4,20 @@
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <linux/types.h> 5#include <linux/types.h>
6 6
7/* Opcodes common to CPM1 and CPM2
8*/
9#define CPM_CR_INIT_TRX ((ushort)0x0000)
10#define CPM_CR_INIT_RX ((ushort)0x0001)
11#define CPM_CR_INIT_TX ((ushort)0x0002)
12#define CPM_CR_HUNT_MODE ((ushort)0x0003)
13#define CPM_CR_STOP_TX ((ushort)0x0004)
14#define CPM_CR_GRA_STOP_TX ((ushort)0x0005)
15#define CPM_CR_RESTART_TX ((ushort)0x0006)
16#define CPM_CR_CLOSE_RX_BD ((ushort)0x0007)
17#define CPM_CR_SET_GADDR ((ushort)0x0008)
18#define CPM_CR_SET_TIMER ((ushort)0x0008)
19#define CPM_CR_STOP_IDMA ((ushort)0x000b)
20
7/* Buffer descriptors used by many of the CPM protocols. */ 21/* Buffer descriptors used by many of the CPM protocols. */
8typedef struct cpm_buf_desc { 22typedef struct cpm_buf_desc {
9 ushort cbd_sc; /* Status and Control */ 23 ushort cbd_sc; /* Status and Control */
diff --git a/include/asm-powerpc/cpm1.h b/include/asm-powerpc/cpm1.h
index b2ebd6ac6dae..3df439678006 100644
--- a/include/asm-powerpc/cpm1.h
+++ b/include/asm-powerpc/cpm1.h
@@ -28,19 +28,6 @@
28#define CPM_CR_CHAN ((ushort)0x00f0) 28#define CPM_CR_CHAN ((ushort)0x00f0)
29#define CPM_CR_FLG ((ushort)0x0001) 29#define CPM_CR_FLG ((ushort)0x0001)
30 30
31/* Some commands (there are more...later)
32*/
33#define CPM_CR_INIT_TRX ((ushort)0x0000)
34#define CPM_CR_INIT_RX ((ushort)0x0001)
35#define CPM_CR_INIT_TX ((ushort)0x0002)
36#define CPM_CR_HUNT_MODE ((ushort)0x0003)
37#define CPM_CR_STOP_TX ((ushort)0x0004)
38#define CPM_CR_GRA_STOP_TX ((ushort)0x0005)
39#define CPM_CR_RESTART_TX ((ushort)0x0006)
40#define CPM_CR_CLOSE_RX_BD ((ushort)0x0007)
41#define CPM_CR_SET_GADDR ((ushort)0x0008)
42#define CPM_CR_SET_TIMER CPM_CR_SET_GADDR
43
44/* Channel numbers. 31/* Channel numbers.
45*/ 32*/
46#define CPM_CR_CH_SCC1 ((ushort)0x0000) 33#define CPM_CR_CH_SCC1 ((ushort)0x0000)
diff --git a/include/asm-powerpc/cpm2.h b/include/asm-powerpc/cpm2.h
index b93a53eb55c1..4c85ed9cd43f 100644
--- a/include/asm-powerpc/cpm2.h
+++ b/include/asm-powerpc/cpm2.h
@@ -71,18 +71,9 @@
71 71
72#define CPM_CR_FCC_PAGE(x) (x + 0x04) 72#define CPM_CR_FCC_PAGE(x) (x + 0x04)
73 73
74/* Some opcodes (there are more...later) 74/* CPM2-specific opcodes (see cpm.h for common opcodes)
75*/ 75*/
76#define CPM_CR_INIT_TRX ((ushort)0x0000)
77#define CPM_CR_INIT_RX ((ushort)0x0001)
78#define CPM_CR_INIT_TX ((ushort)0x0002)
79#define CPM_CR_HUNT_MODE ((ushort)0x0003)
80#define CPM_CR_STOP_TX ((ushort)0x0004)
81#define CPM_CR_GRA_STOP_TX ((ushort)0x0005)
82#define CPM_CR_RESTART_TX ((ushort)0x0006)
83#define CPM_CR_SET_GADDR ((ushort)0x0008)
84#define CPM_CR_START_IDMA ((ushort)0x0009) 76#define CPM_CR_START_IDMA ((ushort)0x0009)
85#define CPM_CR_STOP_IDMA ((ushort)0x000b)
86 77
87#define mk_cr_cmd(PG, SBC, MCN, OP) \ 78#define mk_cr_cmd(PG, SBC, MCN, OP) \
88 ((PG << 26) | (SBC << 21) | (MCN << 6) | OP) 79 ((PG << 26) | (SBC << 21) | (MCN << 6) | OP)
diff --git a/include/asm-powerpc/cputhreads.h b/include/asm-powerpc/cputhreads.h
index 8485c28b5f47..fb11b0c459b8 100644
--- a/include/asm-powerpc/cputhreads.h
+++ b/include/asm-powerpc/cputhreads.h
@@ -35,7 +35,7 @@ static inline cpumask_t cpu_thread_mask_to_cores(cpumask_t threads)
35 35
36 res = CPU_MASK_NONE; 36 res = CPU_MASK_NONE;
37 for (i = 0; i < NR_CPUS; i += threads_per_core) { 37 for (i = 0; i < NR_CPUS; i += threads_per_core) {
38 cpus_shift_right(tmp, threads_core_mask, i); 38 cpus_shift_left(tmp, threads_core_mask, i);
39 if (cpus_intersects(threads, tmp)) 39 if (cpus_intersects(threads, tmp))
40 cpu_set(i, res); 40 cpu_set(i, res);
41 } 41 }
diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
index be6c879e8760..f8398ce80372 100644
--- a/include/asm-powerpc/dcr-native.h
+++ b/include/asm-powerpc/dcr-native.h
@@ -82,6 +82,19 @@ static inline void __mtdcri(int base_addr, int base_data, int reg,
82 spin_unlock_irqrestore(&dcr_ind_lock, flags); 82 spin_unlock_irqrestore(&dcr_ind_lock, flags);
83} 83}
84 84
85static inline void __dcri_clrset(int base_addr, int base_data, int reg,
86 unsigned clr, unsigned set)
87{
88 unsigned long flags;
89 unsigned int val;
90
91 spin_lock_irqsave(&dcr_ind_lock, flags);
92 __mtdcr(base_addr, reg);
93 val = (__mfdcr(base_data) & ~clr) | set;
94 __mtdcr(base_data, val);
95 spin_unlock_irqrestore(&dcr_ind_lock, flags);
96}
97
85#define mfdcri(base, reg) __mfdcri(DCRN_ ## base ## _CONFIG_ADDR, \ 98#define mfdcri(base, reg) __mfdcri(DCRN_ ## base ## _CONFIG_ADDR, \
86 DCRN_ ## base ## _CONFIG_DATA, \ 99 DCRN_ ## base ## _CONFIG_DATA, \
87 reg) 100 reg)
@@ -90,6 +103,10 @@ static inline void __mtdcri(int base_addr, int base_data, int reg,
90 DCRN_ ## base ## _CONFIG_DATA, \ 103 DCRN_ ## base ## _CONFIG_DATA, \
91 reg, data) 104 reg, data)
92 105
106#define dcri_clrset(base, reg, clr, set) __dcri_clrset(DCRN_ ## base ## _CONFIG_ADDR, \
107 DCRN_ ## base ## _CONFIG_DATA, \
108 reg, clr, set)
109
93#endif /* __ASSEMBLY__ */ 110#endif /* __ASSEMBLY__ */
94#endif /* __KERNEL__ */ 111#endif /* __KERNEL__ */
95#endif /* _ASM_POWERPC_DCR_NATIVE_H */ 112#endif /* _ASM_POWERPC_DCR_NATIVE_H */
diff --git a/include/asm-powerpc/dcr-regs.h b/include/asm-powerpc/dcr-regs.h
index 9f1fb98fcdc6..29b0ecef980a 100644
--- a/include/asm-powerpc/dcr-regs.h
+++ b/include/asm-powerpc/dcr-regs.h
@@ -68,4 +68,82 @@
68#define SDR0_UART3 0x0123 68#define SDR0_UART3 0x0123
69#define SDR0_CUST0 0x4000 69#define SDR0_CUST0 0x4000
70 70
71/*
72 * All those DCR register addresses are offsets from the base address
73 * for the SRAM0 controller (e.g. 0x20 on 440GX). The base address is
74 * excluded here and configured in the device tree.
75 */
76#define DCRN_SRAM0_SB0CR 0x00
77#define DCRN_SRAM0_SB1CR 0x01
78#define DCRN_SRAM0_SB2CR 0x02
79#define DCRN_SRAM0_SB3CR 0x03
80#define SRAM_SBCR_BU_MASK 0x00000180
81#define SRAM_SBCR_BS_64KB 0x00000800
82#define SRAM_SBCR_BU_RO 0x00000080
83#define SRAM_SBCR_BU_RW 0x00000180
84#define DCRN_SRAM0_BEAR 0x04
85#define DCRN_SRAM0_BESR0 0x05
86#define DCRN_SRAM0_BESR1 0x06
87#define DCRN_SRAM0_PMEG 0x07
88#define DCRN_SRAM0_CID 0x08
89#define DCRN_SRAM0_REVID 0x09
90#define DCRN_SRAM0_DPC 0x0a
91#define SRAM_DPC_ENABLE 0x80000000
92
93/*
94 * All those DCR register addresses are offsets from the base address
95 * for the SRAM0 controller (e.g. 0x30 on 440GX). The base address is
96 * excluded here and configured in the device tree.
97 */
98#define DCRN_L2C0_CFG 0x00
99#define L2C_CFG_L2M 0x80000000
100#define L2C_CFG_ICU 0x40000000
101#define L2C_CFG_DCU 0x20000000
102#define L2C_CFG_DCW_MASK 0x1e000000
103#define L2C_CFG_TPC 0x01000000
104#define L2C_CFG_CPC 0x00800000
105#define L2C_CFG_FRAN 0x00200000
106#define L2C_CFG_SS_MASK 0x00180000
107#define L2C_CFG_SS_256 0x00000000
108#define L2C_CFG_CPIM 0x00040000
109#define L2C_CFG_TPIM 0x00020000
110#define L2C_CFG_LIM 0x00010000
111#define L2C_CFG_PMUX_MASK 0x00007000
112#define L2C_CFG_PMUX_SNP 0x00000000
113#define L2C_CFG_PMUX_IF 0x00001000
114#define L2C_CFG_PMUX_DF 0x00002000
115#define L2C_CFG_PMUX_DS 0x00003000
116#define L2C_CFG_PMIM 0x00000800
117#define L2C_CFG_TPEI 0x00000400
118#define L2C_CFG_CPEI 0x00000200
119#define L2C_CFG_NAM 0x00000100
120#define L2C_CFG_SMCM 0x00000080
121#define L2C_CFG_NBRM 0x00000040
122#define L2C_CFG_RDBW 0x00000008 /* only 460EX/GT */
123#define DCRN_L2C0_CMD 0x01
124#define L2C_CMD_CLR 0x80000000
125#define L2C_CMD_DIAG 0x40000000
126#define L2C_CMD_INV 0x20000000
127#define L2C_CMD_CCP 0x10000000
128#define L2C_CMD_CTE 0x08000000
129#define L2C_CMD_STRC 0x04000000
130#define L2C_CMD_STPC 0x02000000
131#define L2C_CMD_RPMC 0x01000000
132#define L2C_CMD_HCC 0x00800000
133#define DCRN_L2C0_ADDR 0x02
134#define DCRN_L2C0_DATA 0x03
135#define DCRN_L2C0_SR 0x04
136#define L2C_SR_CC 0x80000000
137#define L2C_SR_CPE 0x40000000
138#define L2C_SR_TPE 0x20000000
139#define L2C_SR_LRU 0x10000000
140#define L2C_SR_PCS 0x08000000
141#define DCRN_L2C0_REVID 0x05
142#define DCRN_L2C0_SNP0 0x06
143#define DCRN_L2C0_SNP1 0x07
144#define L2C_SNP_BA_MASK 0xffff0000
145#define L2C_SNP_SSR_MASK 0x0000f000
146#define L2C_SNP_SSR_32G 0x0000f000
147#define L2C_SNP_ESR 0x00000800
148
71#endif /* __DCR_REGS_H__ */ 149#endif /* __DCR_REGS_H__ */
diff --git a/include/asm-powerpc/exception.h b/include/asm-powerpc/exception.h
index 39abdb02fdef..329148b5acc6 100644
--- a/include/asm-powerpc/exception.h
+++ b/include/asm-powerpc/exception.h
@@ -228,18 +228,18 @@ label##_pSeries: \
228BEGIN_FW_FTR_SECTION; \ 228BEGIN_FW_FTR_SECTION; \
229 stb r11,PACAHARDIRQEN(r13); \ 229 stb r11,PACAHARDIRQEN(r13); \
230END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES); \ 230END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES); \
231 TRACE_DISABLE_INTS; \
231BEGIN_FW_FTR_SECTION; \ 232BEGIN_FW_FTR_SECTION; \
232 mfmsr r10; \ 233 mfmsr r10; \
233 ori r10,r10,MSR_EE; \ 234 ori r10,r10,MSR_EE; \
234 mtmsrd r10,1; \ 235 mtmsrd r10,1; \
235END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 236END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
236
237#else 237#else
238#define DISABLE_INTS \ 238#define DISABLE_INTS \
239 li r11,0; \ 239 li r11,0; \
240 stb r11,PACASOFTIRQEN(r13); \ 240 stb r11,PACASOFTIRQEN(r13); \
241 stb r11,PACAHARDIRQEN(r13) 241 stb r11,PACAHARDIRQEN(r13); \
242 242 TRACE_DISABLE_INTS
243#endif /* CONFIG_PPC_ISERIES */ 243#endif /* CONFIG_PPC_ISERIES */
244 244
245#define ENABLE_INTS \ 245#define ENABLE_INTS \
diff --git a/include/asm-powerpc/fixmap.h b/include/asm-powerpc/fixmap.h
new file mode 100644
index 000000000000..8428b38a3d30
--- /dev/null
+++ b/include/asm-powerpc/fixmap.h
@@ -0,0 +1,106 @@
1/*
2 * fixmap.h: compile-time virtual memory allocation
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) 1998 Ingo Molnar
9 *
10 * Copyright 2008 Freescale Semiconductor Inc.
11 * Port to powerpc added by Kumar Gala
12 */
13
14#ifndef _ASM_FIXMAP_H
15#define _ASM_FIXMAP_H
16
17extern unsigned long FIXADDR_TOP;
18
19#ifndef __ASSEMBLY__
20#include <linux/kernel.h>
21#include <asm/page.h>
22#ifdef CONFIG_HIGHMEM
23#include <linux/threads.h>
24#include <asm/kmap_types.h>
25#endif
26
27/*
28 * Here we define all the compile-time 'special' virtual
29 * addresses. The point is to have a constant address at
30 * compile time, but to set the physical address only
31 * in the boot process. We allocate these special addresses
32 * from the end of virtual memory (0xfffff000) backwards.
33 * Also this lets us do fail-safe vmalloc(), we
34 * can guarantee that these special addresses and
35 * vmalloc()-ed addresses never overlap.
36 *
37 * these 'compile-time allocated' memory buffers are
38 * fixed-size 4k pages. (or larger if used with an increment
39 * highger than 1) use fixmap_set(idx,phys) to associate
40 * physical memory with fixmap indices.
41 *
42 * TLB entries of such buffers will not be flushed across
43 * task switches.
44 */
45enum fixed_addresses {
46 FIX_HOLE,
47#ifdef CONFIG_HIGHMEM
48 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
49 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
50#endif
51 /* FIX_PCIE_MCFG, */
52 __end_of_fixed_addresses
53};
54
55extern void __set_fixmap (enum fixed_addresses idx,
56 phys_addr_t phys, pgprot_t flags);
57
58#define set_fixmap(idx, phys) \
59 __set_fixmap(idx, phys, PAGE_KERNEL)
60/*
61 * Some hardware wants to get fixmapped without caching.
62 */
63#define set_fixmap_nocache(idx, phys) \
64 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
65
66#define clear_fixmap(idx) \
67 __set_fixmap(idx, 0, __pgprot(0))
68
69#define __FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
70#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
71
72#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
73#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
74
75extern void __this_fixmap_does_not_exist(void);
76
77/*
78 * 'index to address' translation. If anyone tries to use the idx
79 * directly without tranlation, we catch the bug with a NULL-deference
80 * kernel oops. Illegal ranges of incoming indices are caught too.
81 */
82static __always_inline unsigned long fix_to_virt(const unsigned int idx)
83{
84 /*
85 * this branch gets completely eliminated after inlining,
86 * except when someone tries to use fixaddr indices in an
87 * illegal way. (such as mixing up address types or using
88 * out-of-range indices).
89 *
90 * If it doesn't get removed, the linker will complain
91 * loudly with a reasonably clear error message..
92 */
93 if (idx >= __end_of_fixed_addresses)
94 __this_fixmap_does_not_exist();
95
96 return __fix_to_virt(idx);
97}
98
99static inline unsigned long virt_to_fix(const unsigned long vaddr)
100{
101 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
102 return __virt_to_fix(vaddr);
103}
104
105#endif /* !__ASSEMBLY__ */
106#endif
diff --git a/include/asm-powerpc/fsl_lbc.h b/include/asm-powerpc/fsl_lbc.h
new file mode 100644
index 000000000000..303f5484c050
--- /dev/null
+++ b/include/asm-powerpc/fsl_lbc.h
@@ -0,0 +1,311 @@
1/* Freescale Local Bus Controller
2 *
3 * Copyright (c) 2006-2007 Freescale Semiconductor
4 *
5 * Authors: Nick Spence <nick.spence@freescale.com>,
6 * Scott Wood <scottwood@freescale.com>
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#ifndef __ASM_FSL_LBC_H
24#define __ASM_FSL_LBC_H
25
26#include <linux/types.h>
27#include <linux/spinlock.h>
28#include <asm/io.h>
29
30struct fsl_lbc_bank {
31 __be32 br; /**< Base Register */
32#define BR_BA 0xFFFF8000
33#define BR_BA_SHIFT 15
34#define BR_PS 0x00001800
35#define BR_PS_SHIFT 11
36#define BR_PS_8 0x00000800 /* Port Size 8 bit */
37#define BR_PS_16 0x00001000 /* Port Size 16 bit */
38#define BR_PS_32 0x00001800 /* Port Size 32 bit */
39#define BR_DECC 0x00000600
40#define BR_DECC_SHIFT 9
41#define BR_DECC_OFF 0x00000000 /* HW ECC checking and generation off */
42#define BR_DECC_CHK 0x00000200 /* HW ECC checking on, generation off */
43#define BR_DECC_CHK_GEN 0x00000400 /* HW ECC checking and generation on */
44#define BR_WP 0x00000100
45#define BR_WP_SHIFT 8
46#define BR_MSEL 0x000000E0
47#define BR_MSEL_SHIFT 5
48#define BR_MS_GPCM 0x00000000 /* GPCM */
49#define BR_MS_FCM 0x00000020 /* FCM */
50#define BR_MS_SDRAM 0x00000060 /* SDRAM */
51#define BR_MS_UPMA 0x00000080 /* UPMA */
52#define BR_MS_UPMB 0x000000A0 /* UPMB */
53#define BR_MS_UPMC 0x000000C0 /* UPMC */
54#define BR_V 0x00000001
55#define BR_V_SHIFT 0
56#define BR_RES ~(BR_BA|BR_PS|BR_DECC|BR_WP|BR_MSEL|BR_V)
57
58 __be32 or; /**< Base Register */
59#define OR0 0x5004
60#define OR1 0x500C
61#define OR2 0x5014
62#define OR3 0x501C
63#define OR4 0x5024
64#define OR5 0x502C
65#define OR6 0x5034
66#define OR7 0x503C
67
68#define OR_FCM_AM 0xFFFF8000
69#define OR_FCM_AM_SHIFT 15
70#define OR_FCM_BCTLD 0x00001000
71#define OR_FCM_BCTLD_SHIFT 12
72#define OR_FCM_PGS 0x00000400
73#define OR_FCM_PGS_SHIFT 10
74#define OR_FCM_CSCT 0x00000200
75#define OR_FCM_CSCT_SHIFT 9
76#define OR_FCM_CST 0x00000100
77#define OR_FCM_CST_SHIFT 8
78#define OR_FCM_CHT 0x00000080
79#define OR_FCM_CHT_SHIFT 7
80#define OR_FCM_SCY 0x00000070
81#define OR_FCM_SCY_SHIFT 4
82#define OR_FCM_SCY_1 0x00000010
83#define OR_FCM_SCY_2 0x00000020
84#define OR_FCM_SCY_3 0x00000030
85#define OR_FCM_SCY_4 0x00000040
86#define OR_FCM_SCY_5 0x00000050
87#define OR_FCM_SCY_6 0x00000060
88#define OR_FCM_SCY_7 0x00000070
89#define OR_FCM_RST 0x00000008
90#define OR_FCM_RST_SHIFT 3
91#define OR_FCM_TRLX 0x00000004
92#define OR_FCM_TRLX_SHIFT 2
93#define OR_FCM_EHTR 0x00000002
94#define OR_FCM_EHTR_SHIFT 1
95};
96
97struct fsl_lbc_regs {
98 struct fsl_lbc_bank bank[8];
99 u8 res0[0x28];
100 __be32 mar; /**< UPM Address Register */
101 u8 res1[0x4];
102 __be32 mamr; /**< UPMA Mode Register */
103#define MxMR_OP_NO (0 << 28) /**< normal operation */
104#define MxMR_OP_WA (1 << 28) /**< write array */
105#define MxMR_OP_RA (2 << 28) /**< read array */
106#define MxMR_OP_RP (3 << 28) /**< run pattern */
107#define MxMR_MAD 0x3f /**< machine address */
108 __be32 mbmr; /**< UPMB Mode Register */
109 __be32 mcmr; /**< UPMC Mode Register */
110 u8 res2[0x8];
111 __be32 mrtpr; /**< Memory Refresh Timer Prescaler Register */
112 __be32 mdr; /**< UPM Data Register */
113 u8 res3[0x4];
114 __be32 lsor; /**< Special Operation Initiation Register */
115 __be32 lsdmr; /**< SDRAM Mode Register */
116 u8 res4[0x8];
117 __be32 lurt; /**< UPM Refresh Timer */
118 __be32 lsrt; /**< SDRAM Refresh Timer */
119 u8 res5[0x8];
120 __be32 ltesr; /**< Transfer Error Status Register */
121#define LTESR_BM 0x80000000
122#define LTESR_FCT 0x40000000
123#define LTESR_PAR 0x20000000
124#define LTESR_WP 0x04000000
125#define LTESR_ATMW 0x00800000
126#define LTESR_ATMR 0x00400000
127#define LTESR_CS 0x00080000
128#define LTESR_CC 0x00000001
129#define LTESR_NAND_MASK (LTESR_FCT | LTESR_PAR | LTESR_CC)
130 __be32 ltedr; /**< Transfer Error Disable Register */
131 __be32 lteir; /**< Transfer Error Interrupt Register */
132 __be32 lteatr; /**< Transfer Error Attributes Register */
133 __be32 ltear; /**< Transfer Error Address Register */
134 u8 res6[0xC];
135 __be32 lbcr; /**< Configuration Register */
136#define LBCR_LDIS 0x80000000
137#define LBCR_LDIS_SHIFT 31
138#define LBCR_BCTLC 0x00C00000
139#define LBCR_BCTLC_SHIFT 22
140#define LBCR_AHD 0x00200000
141#define LBCR_LPBSE 0x00020000
142#define LBCR_LPBSE_SHIFT 17
143#define LBCR_EPAR 0x00010000
144#define LBCR_EPAR_SHIFT 16
145#define LBCR_BMT 0x0000FF00
146#define LBCR_BMT_SHIFT 8
147#define LBCR_INIT 0x00040000
148 __be32 lcrr; /**< Clock Ratio Register */
149#define LCRR_DBYP 0x80000000
150#define LCRR_DBYP_SHIFT 31
151#define LCRR_BUFCMDC 0x30000000
152#define LCRR_BUFCMDC_SHIFT 28
153#define LCRR_ECL 0x03000000
154#define LCRR_ECL_SHIFT 24
155#define LCRR_EADC 0x00030000
156#define LCRR_EADC_SHIFT 16
157#define LCRR_CLKDIV 0x0000000F
158#define LCRR_CLKDIV_SHIFT 0
159 u8 res7[0x8];
160 __be32 fmr; /**< Flash Mode Register */
161#define FMR_CWTO 0x0000F000
162#define FMR_CWTO_SHIFT 12
163#define FMR_BOOT 0x00000800
164#define FMR_ECCM 0x00000100
165#define FMR_AL 0x00000030
166#define FMR_AL_SHIFT 4
167#define FMR_OP 0x00000003
168#define FMR_OP_SHIFT 0
169 __be32 fir; /**< Flash Instruction Register */
170#define FIR_OP0 0xF0000000
171#define FIR_OP0_SHIFT 28
172#define FIR_OP1 0x0F000000
173#define FIR_OP1_SHIFT 24
174#define FIR_OP2 0x00F00000
175#define FIR_OP2_SHIFT 20
176#define FIR_OP3 0x000F0000
177#define FIR_OP3_SHIFT 16
178#define FIR_OP4 0x0000F000
179#define FIR_OP4_SHIFT 12
180#define FIR_OP5 0x00000F00
181#define FIR_OP5_SHIFT 8
182#define FIR_OP6 0x000000F0
183#define FIR_OP6_SHIFT 4
184#define FIR_OP7 0x0000000F
185#define FIR_OP7_SHIFT 0
186#define FIR_OP_NOP 0x0 /* No operation and end of sequence */
187#define FIR_OP_CA 0x1 /* Issue current column address */
188#define FIR_OP_PA 0x2 /* Issue current block+page address */
189#define FIR_OP_UA 0x3 /* Issue user defined address */
190#define FIR_OP_CM0 0x4 /* Issue command from FCR[CMD0] */
191#define FIR_OP_CM1 0x5 /* Issue command from FCR[CMD1] */
192#define FIR_OP_CM2 0x6 /* Issue command from FCR[CMD2] */
193#define FIR_OP_CM3 0x7 /* Issue command from FCR[CMD3] */
194#define FIR_OP_WB 0x8 /* Write FBCR bytes from FCM buffer */
195#define FIR_OP_WS 0x9 /* Write 1 or 2 bytes from MDR[AS] */
196#define FIR_OP_RB 0xA /* Read FBCR bytes to FCM buffer */
197#define FIR_OP_RS 0xB /* Read 1 or 2 bytes to MDR[AS] */
198#define FIR_OP_CW0 0xC /* Wait then issue FCR[CMD0] */
199#define FIR_OP_CW1 0xD /* Wait then issue FCR[CMD1] */
200#define FIR_OP_RBW 0xE /* Wait then read FBCR bytes */
201#define FIR_OP_RSW 0xE /* Wait then read 1 or 2 bytes */
202 __be32 fcr; /**< Flash Command Register */
203#define FCR_CMD0 0xFF000000
204#define FCR_CMD0_SHIFT 24
205#define FCR_CMD1 0x00FF0000
206#define FCR_CMD1_SHIFT 16
207#define FCR_CMD2 0x0000FF00
208#define FCR_CMD2_SHIFT 8
209#define FCR_CMD3 0x000000FF
210#define FCR_CMD3_SHIFT 0
211 __be32 fbar; /**< Flash Block Address Register */
212#define FBAR_BLK 0x00FFFFFF
213 __be32 fpar; /**< Flash Page Address Register */
214#define FPAR_SP_PI 0x00007C00
215#define FPAR_SP_PI_SHIFT 10
216#define FPAR_SP_MS 0x00000200
217#define FPAR_SP_CI 0x000001FF
218#define FPAR_SP_CI_SHIFT 0
219#define FPAR_LP_PI 0x0003F000
220#define FPAR_LP_PI_SHIFT 12
221#define FPAR_LP_MS 0x00000800
222#define FPAR_LP_CI 0x000007FF
223#define FPAR_LP_CI_SHIFT 0
224 __be32 fbcr; /**< Flash Byte Count Register */
225#define FBCR_BC 0x00000FFF
226 u8 res11[0x8];
227 u8 res8[0xF00];
228};
229
230extern struct fsl_lbc_regs __iomem *fsl_lbc_regs;
231extern spinlock_t fsl_lbc_lock;
232
233/*
234 * FSL UPM routines
235 */
236struct fsl_upm {
237 __be32 __iomem *mxmr;
238 int width;
239};
240
241extern int fsl_lbc_find(phys_addr_t addr_base);
242extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm);
243
244/**
245 * fsl_upm_start_pattern - start UPM patterns execution
246 * @upm: pointer to the fsl_upm structure obtained via fsl_upm_find
247 * @pat_offset: UPM pattern offset for the command to be executed
248 *
249 * This routine programmes UPM so the next memory access that hits an UPM
250 * will trigger pattern execution, starting at pat_offset.
251 */
252static inline void fsl_upm_start_pattern(struct fsl_upm *upm, u8 pat_offset)
253{
254 clrsetbits_be32(upm->mxmr, MxMR_MAD, MxMR_OP_RP | pat_offset);
255}
256
257/**
258 * fsl_upm_end_pattern - end UPM patterns execution
259 * @upm: pointer to the fsl_upm structure obtained via fsl_upm_find
260 *
261 * This routine reverts UPM to normal operation mode.
262 */
263static inline void fsl_upm_end_pattern(struct fsl_upm *upm)
264{
265 clrbits32(upm->mxmr, MxMR_OP_RP);
266
267 while (in_be32(upm->mxmr) & MxMR_OP_RP)
268 cpu_relax();
269}
270
271/**
272 * fsl_upm_run_pattern - actually run an UPM pattern
273 * @upm: pointer to the fsl_upm structure obtained via fsl_upm_find
274 * @io_base: remapped pointer to where memory access should happen
275 * @mar: MAR register content during pattern execution
276 *
277 * This function triggers dummy write to the memory specified by the io_base,
278 * thus UPM pattern actually executed. Note that mar usage depends on the
279 * pre-programmed AMX bits in the UPM RAM.
280 */
281static inline int fsl_upm_run_pattern(struct fsl_upm *upm,
282 void __iomem *io_base, u32 mar)
283{
284 int ret = 0;
285 unsigned long flags;
286
287 spin_lock_irqsave(&fsl_lbc_lock, flags);
288
289 out_be32(&fsl_lbc_regs->mar, mar << (32 - upm->width));
290
291 switch (upm->width) {
292 case 8:
293 out_8(io_base, 0x0);
294 break;
295 case 16:
296 out_be16(io_base, 0x0);
297 break;
298 case 32:
299 out_be32(io_base, 0x0);
300 break;
301 default:
302 ret = -EINVAL;
303 break;
304 }
305
306 spin_unlock_irqrestore(&fsl_lbc_lock, flags);
307
308 return ret;
309}
310
311#endif /* __ASM_FSL_LBC_H */
diff --git a/include/asm-powerpc/futex.h b/include/asm-powerpc/futex.h
index 3f3673fd3ff3..6d406c5c5de4 100644
--- a/include/asm-powerpc/futex.h
+++ b/include/asm-powerpc/futex.h
@@ -4,9 +4,9 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/futex.h> 6#include <linux/futex.h>
7#include <linux/uaccess.h>
7#include <asm/errno.h> 8#include <asm/errno.h>
8#include <asm/synch.h> 9#include <asm/synch.h>
9#include <asm/uaccess.h>
10#include <asm/asm-compat.h> 10#include <asm/asm-compat.h>
11 11
12#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ 12#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
diff --git a/include/asm-powerpc/gpio.h b/include/asm-powerpc/gpio.h
new file mode 100644
index 000000000000..77ad3a890f30
--- /dev/null
+++ b/include/asm-powerpc/gpio.h
@@ -0,0 +1,56 @@
1/*
2 * Generic GPIO API implementation for PowerPC.
3 *
4 * Copyright (c) 2007-2008 MontaVista Software, Inc.
5 *
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
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
14#ifndef __ASM_POWERPC_GPIO_H
15#define __ASM_POWERPC_GPIO_H
16
17#include <linux/errno.h>
18#include <asm-generic/gpio.h>
19
20#ifdef CONFIG_HAVE_GPIO_LIB
21
22/*
23 * We don't (yet) implement inlined/rapid versions for on-chip gpios.
24 * Just call gpiolib.
25 */
26static inline int gpio_get_value(unsigned int gpio)
27{
28 return __gpio_get_value(gpio);
29}
30
31static inline void gpio_set_value(unsigned int gpio, int value)
32{
33 __gpio_set_value(gpio, value);
34}
35
36static inline int gpio_cansleep(unsigned int gpio)
37{
38 return __gpio_cansleep(gpio);
39}
40
41/*
42 * Not implemented, yet.
43 */
44static inline int gpio_to_irq(unsigned int gpio)
45{
46 return -ENOSYS;
47}
48
49static inline int irq_to_gpio(unsigned int irq)
50{
51 return -EINVAL;
52}
53
54#endif /* CONFIG_HAVE_GPIO_LIB */
55
56#endif /* __ASM_POWERPC_GPIO_H */
diff --git a/include/asm-powerpc/highmem.h b/include/asm-powerpc/highmem.h
index f7b21ee302b4..5d99b6489d56 100644
--- a/include/asm-powerpc/highmem.h
+++ b/include/asm-powerpc/highmem.h
@@ -27,9 +27,7 @@
27#include <asm/kmap_types.h> 27#include <asm/kmap_types.h>
28#include <asm/tlbflush.h> 28#include <asm/tlbflush.h>
29#include <asm/page.h> 29#include <asm/page.h>
30 30#include <asm/fixmap.h>
31/* undef for production */
32#define HIGHMEM_DEBUG 1
33 31
34extern pte_t *kmap_pte; 32extern pte_t *kmap_pte;
35extern pgprot_t kmap_prot; 33extern pgprot_t kmap_prot;
@@ -40,14 +38,12 @@ extern pte_t *pkmap_page_table;
40 * easily, subsequent pte tables have to be allocated in one physical 38 * easily, subsequent pte tables have to be allocated in one physical
41 * chunk of RAM. 39 * chunk of RAM.
42 */ 40 */
43#define PKMAP_BASE CONFIG_HIGHMEM_START
44#define LAST_PKMAP (1 << PTE_SHIFT) 41#define LAST_PKMAP (1 << PTE_SHIFT)
45#define LAST_PKMAP_MASK (LAST_PKMAP-1) 42#define LAST_PKMAP_MASK (LAST_PKMAP-1)
43#define PKMAP_BASE ((FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK)
46#define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) 44#define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT)
47#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) 45#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
48 46
49#define KMAP_FIX_BEGIN (PKMAP_BASE + 0x00400000UL)
50
51extern void *kmap_high(struct page *page); 47extern void *kmap_high(struct page *page);
52extern void kunmap_high(struct page *page); 48extern void kunmap_high(struct page *page);
53 49
@@ -73,7 +69,7 @@ static inline void kunmap(struct page *page)
73 * be used in IRQ contexts, so in some (very limited) cases we need 69 * be used in IRQ contexts, so in some (very limited) cases we need
74 * it. 70 * it.
75 */ 71 */
76static inline void *kmap_atomic(struct page *page, enum km_type type) 72static inline void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
77{ 73{
78 unsigned int idx; 74 unsigned int idx;
79 unsigned long vaddr; 75 unsigned long vaddr;
@@ -84,34 +80,39 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
84 return page_address(page); 80 return page_address(page);
85 81
86 idx = type + KM_TYPE_NR*smp_processor_id(); 82 idx = type + KM_TYPE_NR*smp_processor_id();
87 vaddr = KMAP_FIX_BEGIN + idx * PAGE_SIZE; 83 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
88#ifdef HIGHMEM_DEBUG 84#ifdef CONFIG_DEBUG_HIGHMEM
89 BUG_ON(!pte_none(*(kmap_pte+idx))); 85 BUG_ON(!pte_none(*(kmap_pte-idx)));
90#endif 86#endif
91 set_pte_at(&init_mm, vaddr, kmap_pte+idx, mk_pte(page, kmap_prot)); 87 set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot));
92 flush_tlb_page(NULL, vaddr); 88 flush_tlb_page(NULL, vaddr);
93 89
94 return (void*) vaddr; 90 return (void*) vaddr;
95} 91}
96 92
93static inline void *kmap_atomic(struct page *page, enum km_type type)
94{
95 return kmap_atomic_prot(page, type, kmap_prot);
96}
97
97static inline void kunmap_atomic(void *kvaddr, enum km_type type) 98static inline void kunmap_atomic(void *kvaddr, enum km_type type)
98{ 99{
99#ifdef HIGHMEM_DEBUG 100#ifdef CONFIG_DEBUG_HIGHMEM
100 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 101 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
101 unsigned int idx = type + KM_TYPE_NR*smp_processor_id(); 102 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
102 103
103 if (vaddr < KMAP_FIX_BEGIN) { // FIXME 104 if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
104 pagefault_enable(); 105 pagefault_enable();
105 return; 106 return;
106 } 107 }
107 108
108 BUG_ON(vaddr != KMAP_FIX_BEGIN + idx * PAGE_SIZE); 109 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
109 110
110 /* 111 /*
111 * force other mappings to Oops if they'll try to access 112 * force other mappings to Oops if they'll try to access
112 * this pte without first remap it 113 * this pte without first remap it
113 */ 114 */
114 pte_clear(&init_mm, vaddr, kmap_pte+idx); 115 pte_clear(&init_mm, vaddr, kmap_pte-idx);
115 flush_tlb_page(NULL, vaddr); 116 flush_tlb_page(NULL, vaddr);
116#endif 117#endif
117 pagefault_enable(); 118 pagefault_enable();
@@ -120,12 +121,14 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
120static inline struct page *kmap_atomic_to_page(void *ptr) 121static inline struct page *kmap_atomic_to_page(void *ptr)
121{ 122{
122 unsigned long idx, vaddr = (unsigned long) ptr; 123 unsigned long idx, vaddr = (unsigned long) ptr;
124 pte_t *pte;
123 125
124 if (vaddr < KMAP_FIX_BEGIN) 126 if (vaddr < FIXADDR_START)
125 return virt_to_page(ptr); 127 return virt_to_page(ptr);
126 128
127 idx = (vaddr - KMAP_FIX_BEGIN) >> PAGE_SHIFT; 129 idx = virt_to_fix(vaddr);
128 return pte_page(kmap_pte[idx]); 130 pte = kmap_pte - (idx - FIX_KMAP_BEGIN);
131 return pte_page(*pte);
129} 132}
130 133
131#define flush_cache_kmaps() flush_cache_all() 134#define flush_cache_kmaps() flush_cache_all()
diff --git a/include/asm-powerpc/hugetlb.h b/include/asm-powerpc/hugetlb.h
new file mode 100644
index 000000000000..649c6c3b87b3
--- /dev/null
+++ b/include/asm-powerpc/hugetlb.h
@@ -0,0 +1,79 @@
1#ifndef _ASM_POWERPC_HUGETLB_H
2#define _ASM_POWERPC_HUGETLB_H
3
4#include <asm/page.h>
5
6
7int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
8 unsigned long len);
9
10void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
11 unsigned long end, unsigned long floor,
12 unsigned long ceiling);
13
14void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
15 pte_t *ptep, pte_t pte);
16
17pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
18 pte_t *ptep);
19
20/*
21 * If the arch doesn't supply something else, assume that hugepage
22 * size aligned regions are ok without further preparation.
23 */
24static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
25{
26 if (len & ~HPAGE_MASK)
27 return -EINVAL;
28 if (addr & ~HPAGE_MASK)
29 return -EINVAL;
30 return 0;
31}
32
33static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm)
34{
35}
36
37static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
38 unsigned long addr, pte_t *ptep)
39{
40}
41
42static inline int huge_pte_none(pte_t pte)
43{
44 return pte_none(pte);
45}
46
47static inline pte_t huge_pte_wrprotect(pte_t pte)
48{
49 return pte_wrprotect(pte);
50}
51
52static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
53 unsigned long addr, pte_t *ptep)
54{
55 ptep_set_wrprotect(mm, addr, ptep);
56}
57
58static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
59 unsigned long addr, pte_t *ptep,
60 pte_t pte, int dirty)
61{
62 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
63}
64
65static inline pte_t huge_ptep_get(pte_t *ptep)
66{
67 return *ptep;
68}
69
70static inline int arch_prepare_hugepage(struct page *page)
71{
72 return 0;
73}
74
75static inline void arch_release_hugepage(struct page *page)
76{
77}
78
79#endif /* _ASM_POWERPC_HUGETLB_H */
diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h
index a7b60bf639e0..ad8c9f7fd0e3 100644
--- a/include/asm-powerpc/hw_irq.h
+++ b/include/asm-powerpc/hw_irq.h
@@ -27,7 +27,7 @@ static inline unsigned long local_get_flags(void)
27 return flags; 27 return flags;
28} 28}
29 29
30static inline unsigned long local_irq_disable(void) 30static inline unsigned long raw_local_irq_disable(void)
31{ 31{
32 unsigned long flags, zero; 32 unsigned long flags, zero;
33 33
@@ -39,14 +39,15 @@ static inline unsigned long local_irq_disable(void)
39 return flags; 39 return flags;
40} 40}
41 41
42extern void local_irq_restore(unsigned long); 42extern void raw_local_irq_restore(unsigned long);
43extern void iseries_handle_interrupts(void); 43extern void iseries_handle_interrupts(void);
44 44
45#define local_irq_enable() local_irq_restore(1) 45#define raw_local_irq_enable() raw_local_irq_restore(1)
46#define local_save_flags(flags) ((flags) = local_get_flags()) 46#define raw_local_save_flags(flags) ((flags) = local_get_flags())
47#define local_irq_save(flags) ((flags) = local_irq_disable()) 47#define raw_local_irq_save(flags) ((flags) = raw_local_irq_disable())
48 48
49#define irqs_disabled() (local_get_flags() == 0) 49#define raw_irqs_disabled() (local_get_flags() == 0)
50#define raw_irqs_disabled_flags(flags) ((flags) == 0)
50 51
51#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1) 52#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1)
52#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1) 53#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1)
diff --git a/include/asm-powerpc/ide.h b/include/asm-powerpc/ide.h
index 6d50310ecaea..3d90bf7d3d73 100644
--- a/include/asm-powerpc/ide.h
+++ b/include/asm-powerpc/ide.h
@@ -31,39 +31,48 @@
31#include <linux/hdreg.h> 31#include <linux/hdreg.h>
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33 33
34struct ide_machdep_calls { 34/* FIXME: use ide_platform host driver */
35 int (*default_irq)(unsigned long base);
36 unsigned long (*default_io_base)(int index);
37 void (*ide_init_hwif)(hw_regs_t *hw,
38 unsigned long data_port,
39 unsigned long ctrl_port,
40 int *irq);
41};
42
43extern struct ide_machdep_calls ppc_ide_md;
44
45#define IDE_ARCH_OBSOLETE_DEFAULTS
46
47static __inline__ int ide_default_irq(unsigned long base) 35static __inline__ int ide_default_irq(unsigned long base)
48{ 36{
49 if (ppc_ide_md.default_irq) 37#ifdef CONFIG_PPLUS
50 return ppc_ide_md.default_irq(base); 38 switch (base) {
39 case 0x1f0: return 14;
40 case 0x170: return 15;
41 }
42#endif
43#ifdef CONFIG_PPC_PREP
44 switch (base) {
45 case 0x1f0: return 13;
46 case 0x170: return 13;
47 case 0x1e8: return 11;
48 case 0x168: return 10;
49 case 0xfff0: return 14; /* MCP(N)750 ide0 */
50 case 0xffe0: return 15; /* MCP(N)750 ide1 */
51 }
52#endif
51 return 0; 53 return 0;
52} 54}
53 55
56/* FIXME: use ide_platform host driver */
54static __inline__ unsigned long ide_default_io_base(int index) 57static __inline__ unsigned long ide_default_io_base(int index)
55{ 58{
56 if (ppc_ide_md.default_io_base) 59#ifdef CONFIG_PPLUS
57 return ppc_ide_md.default_io_base(index); 60 switch (index) {
61 case 0: return 0x1f0;
62 case 1: return 0x170;
63 }
64#endif
65#ifdef CONFIG_PPC_PREP
66 switch (index) {
67 case 0: return 0x1f0;
68 case 1: return 0x170;
69 case 2: return 0x1e8;
70 case 3: return 0x168;
71 }
72#endif
58 return 0; 73 return 0;
59} 74}
60 75
61#ifdef CONFIG_PCI
62#define ide_init_default_irq(base) (0)
63#else
64#define ide_init_default_irq(base) ide_default_irq(base)
65#endif
66
67#ifdef CONFIG_BLK_DEV_MPC8xx_IDE 76#ifdef CONFIG_BLK_DEV_MPC8xx_IDE
68#define IDE_ARCH_ACK_INTR 1 77#define IDE_ARCH_ACK_INTR 1
69#define ide_ack_intr(hwif) ((hwif)->ack_intr ? (hwif)->ack_intr(hwif) : 1) 78#define ide_ack_intr(hwif) ((hwif)->ack_intr ? (hwif)->ack_intr(hwif) : 1)
@@ -71,8 +80,6 @@ static __inline__ unsigned long ide_default_io_base(int index)
71 80
72#endif /* __powerpc64__ */ 81#endif /* __powerpc64__ */
73 82
74#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
75
76#endif /* __KERNEL__ */ 83#endif /* __KERNEL__ */
77 84
78#endif /* _ASM_POWERPC_IDE_H */ 85#endif /* _ASM_POWERPC_IDE_H */
diff --git a/include/asm-powerpc/immap_qe.h b/include/asm-powerpc/immap_qe.h
index 82a452615097..7b6f411db3e6 100644
--- a/include/asm-powerpc/immap_qe.h
+++ b/include/asm-powerpc/immap_qe.h
@@ -20,6 +20,7 @@
20#ifdef __KERNEL__ 20#ifdef __KERNEL__
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <asm/io.h>
23 24
24#define QE_IMMAP_SIZE (1024 * 1024) /* 1MB from 1MB+IMMR */ 25#define QE_IMMAP_SIZE (1024 * 1024) /* 1MB from 1MB+IMMR */
25 26
@@ -468,7 +469,7 @@ struct qe_immap {
468 u8 res18[0xC0000]; /* 0x140000 - 0x200000 */ 469 u8 res18[0xC0000]; /* 0x140000 - 0x200000 */
469} __attribute__ ((packed)); 470} __attribute__ ((packed));
470 471
471extern struct qe_immap *qe_immr; 472extern struct qe_immap __iomem *qe_immr;
472extern phys_addr_t get_qe_base(void); 473extern phys_addr_t get_qe_base(void);
473 474
474static inline unsigned long immrbar_virt_to_phys(void *address) 475static inline unsigned long immrbar_virt_to_phys(void *address)
diff --git a/include/asm-powerpc/io-defs.h b/include/asm-powerpc/io-defs.h
index 03691ab69217..44d7927aec69 100644
--- a/include/asm-powerpc/io-defs.h
+++ b/include/asm-powerpc/io-defs.h
@@ -1,59 +1,60 @@
1/* This file is meant to be include multiple times by other headers */ 1/* This file is meant to be include multiple times by other headers */
2/* last 2 argments are used by platforms/cell/io-workarounds.[ch] */
2 3
3DEF_PCI_AC_RET(readb, u8, (const PCI_IO_ADDR addr), (addr)) 4DEF_PCI_AC_RET(readb, u8, (const PCI_IO_ADDR addr), (addr), mem, addr)
4DEF_PCI_AC_RET(readw, u16, (const PCI_IO_ADDR addr), (addr)) 5DEF_PCI_AC_RET(readw, u16, (const PCI_IO_ADDR addr), (addr), mem, addr)
5DEF_PCI_AC_RET(readl, u32, (const PCI_IO_ADDR addr), (addr)) 6DEF_PCI_AC_RET(readl, u32, (const PCI_IO_ADDR addr), (addr), mem, addr)
6DEF_PCI_AC_RET(readw_be, u16, (const PCI_IO_ADDR addr), (addr)) 7DEF_PCI_AC_RET(readw_be, u16, (const PCI_IO_ADDR addr), (addr), mem, addr)
7DEF_PCI_AC_RET(readl_be, u32, (const PCI_IO_ADDR addr), (addr)) 8DEF_PCI_AC_RET(readl_be, u32, (const PCI_IO_ADDR addr), (addr), mem, addr)
8DEF_PCI_AC_NORET(writeb, (u8 val, PCI_IO_ADDR addr), (val, addr)) 9DEF_PCI_AC_NORET(writeb, (u8 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
9DEF_PCI_AC_NORET(writew, (u16 val, PCI_IO_ADDR addr), (val, addr)) 10DEF_PCI_AC_NORET(writew, (u16 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
10DEF_PCI_AC_NORET(writel, (u32 val, PCI_IO_ADDR addr), (val, addr)) 11DEF_PCI_AC_NORET(writel, (u32 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
11DEF_PCI_AC_NORET(writew_be, (u16 val, PCI_IO_ADDR addr), (val, addr)) 12DEF_PCI_AC_NORET(writew_be, (u16 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
12DEF_PCI_AC_NORET(writel_be, (u32 val, PCI_IO_ADDR addr), (val, addr)) 13DEF_PCI_AC_NORET(writel_be, (u32 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
13 14
14#ifdef __powerpc64__ 15#ifdef __powerpc64__
15DEF_PCI_AC_RET(readq, u64, (const PCI_IO_ADDR addr), (addr)) 16DEF_PCI_AC_RET(readq, u64, (const PCI_IO_ADDR addr), (addr), mem, addr)
16DEF_PCI_AC_RET(readq_be, u64, (const PCI_IO_ADDR addr), (addr)) 17DEF_PCI_AC_RET(readq_be, u64, (const PCI_IO_ADDR addr), (addr), mem, addr)
17DEF_PCI_AC_NORET(writeq, (u64 val, PCI_IO_ADDR addr), (val, addr)) 18DEF_PCI_AC_NORET(writeq, (u64 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
18DEF_PCI_AC_NORET(writeq_be, (u64 val, PCI_IO_ADDR addr), (val, addr)) 19DEF_PCI_AC_NORET(writeq_be, (u64 val, PCI_IO_ADDR addr), (val, addr), mem, addr)
19#endif /* __powerpc64__ */ 20#endif /* __powerpc64__ */
20 21
21DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port)) 22DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port), pio, port)
22DEF_PCI_AC_RET(inw, u16, (unsigned long port), (port)) 23DEF_PCI_AC_RET(inw, u16, (unsigned long port), (port), pio, port)
23DEF_PCI_AC_RET(inl, u32, (unsigned long port), (port)) 24DEF_PCI_AC_RET(inl, u32, (unsigned long port), (port), pio, port)
24DEF_PCI_AC_NORET(outb, (u8 val, unsigned long port), (val, port)) 25DEF_PCI_AC_NORET(outb, (u8 val, unsigned long port), (val, port), pio, port)
25DEF_PCI_AC_NORET(outw, (u16 val, unsigned long port), (val, port)) 26DEF_PCI_AC_NORET(outw, (u16 val, unsigned long port), (val, port), pio, port)
26DEF_PCI_AC_NORET(outl, (u32 val, unsigned long port), (val, port)) 27DEF_PCI_AC_NORET(outl, (u32 val, unsigned long port), (val, port), pio, port)
27 28
28DEF_PCI_AC_NORET(readsb, (const PCI_IO_ADDR a, void *b, unsigned long c), \ 29DEF_PCI_AC_NORET(readsb, (const PCI_IO_ADDR a, void *b, unsigned long c),
29 (a, b, c)) 30 (a, b, c), mem, a)
30DEF_PCI_AC_NORET(readsw, (const PCI_IO_ADDR a, void *b, unsigned long c), \ 31DEF_PCI_AC_NORET(readsw, (const PCI_IO_ADDR a, void *b, unsigned long c),
31 (a, b, c)) 32 (a, b, c), mem, a)
32DEF_PCI_AC_NORET(readsl, (const PCI_IO_ADDR a, void *b, unsigned long c), \ 33DEF_PCI_AC_NORET(readsl, (const PCI_IO_ADDR a, void *b, unsigned long c),
33 (a, b, c)) 34 (a, b, c), mem, a)
34DEF_PCI_AC_NORET(writesb, (PCI_IO_ADDR a, const void *b, unsigned long c), \ 35DEF_PCI_AC_NORET(writesb, (PCI_IO_ADDR a, const void *b, unsigned long c),
35 (a, b, c)) 36 (a, b, c), mem, a)
36DEF_PCI_AC_NORET(writesw, (PCI_IO_ADDR a, const void *b, unsigned long c), \ 37DEF_PCI_AC_NORET(writesw, (PCI_IO_ADDR a, const void *b, unsigned long c),
37 (a, b, c)) 38 (a, b, c), mem, a)
38DEF_PCI_AC_NORET(writesl, (PCI_IO_ADDR a, const void *b, unsigned long c), \ 39DEF_PCI_AC_NORET(writesl, (PCI_IO_ADDR a, const void *b, unsigned long c),
39 (a, b, c)) 40 (a, b, c), mem, a)
40 41
41DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c), \ 42DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c),
42 (p, b, c)) 43 (p, b, c), pio, p)
43DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c), \ 44DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
44 (p, b, c)) 45 (p, b, c), pio, p)
45DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), \ 46DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
46 (p, b, c)) 47 (p, b, c), pio, p)
47DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), \ 48DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
48 (p, b, c)) 49 (p, b, c), pio, p)
49DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c), \ 50DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
50 (p, b, c)) 51 (p, b, c), pio, p)
51DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c), \ 52DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
52 (p, b, c)) 53 (p, b, c), pio, p)
53 54
54DEF_PCI_AC_NORET(memset_io, (PCI_IO_ADDR a, int c, unsigned long n), \ 55DEF_PCI_AC_NORET(memset_io, (PCI_IO_ADDR a, int c, unsigned long n),
55 (a, c, n)) 56 (a, c, n), mem, a)
56DEF_PCI_AC_NORET(memcpy_fromio,(void *d,const PCI_IO_ADDR s,unsigned long n), \ 57DEF_PCI_AC_NORET(memcpy_fromio, (void *d, const PCI_IO_ADDR s, unsigned long n),
57 (d, s, n)) 58 (d, s, n), mem, s)
58DEF_PCI_AC_NORET(memcpy_toio,(PCI_IO_ADDR d,const void *s,unsigned long n), \ 59DEF_PCI_AC_NORET(memcpy_toio, (PCI_IO_ADDR d, const void *s, unsigned long n),
59 (d, s, n)) 60 (d, s, n), mem, d)
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index 7be26f615755..afae0697e8ce 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -458,8 +458,8 @@ __do_out_asm(_rec_outl, "stwbrx")
458/* Structure containing all the hooks */ 458/* Structure containing all the hooks */
459extern struct ppc_pci_io { 459extern struct ppc_pci_io {
460 460
461#define DEF_PCI_AC_RET(name, ret, at, al) ret (*name) at; 461#define DEF_PCI_AC_RET(name, ret, at, al, space, aa) ret (*name) at;
462#define DEF_PCI_AC_NORET(name, at, al) void (*name) at; 462#define DEF_PCI_AC_NORET(name, at, al, space, aa) void (*name) at;
463 463
464#include <asm/io-defs.h> 464#include <asm/io-defs.h>
465 465
@@ -469,7 +469,7 @@ extern struct ppc_pci_io {
469} ppc_pci_io; 469} ppc_pci_io;
470 470
471/* The inline wrappers */ 471/* The inline wrappers */
472#define DEF_PCI_AC_RET(name, ret, at, al) \ 472#define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \
473static inline ret name at \ 473static inline ret name at \
474{ \ 474{ \
475 if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \ 475 if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \
@@ -477,7 +477,7 @@ static inline ret name at \
477 return __do_##name al; \ 477 return __do_##name al; \
478} 478}
479 479
480#define DEF_PCI_AC_NORET(name, at, al) \ 480#define DEF_PCI_AC_NORET(name, at, al, space, aa) \
481static inline void name at \ 481static inline void name at \
482{ \ 482{ \
483 if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \ 483 if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
index b5c03127a9b9..5089deb8fec3 100644
--- a/include/asm-powerpc/irq.h
+++ b/include/asm-powerpc/irq.h
@@ -619,8 +619,6 @@ struct pt_regs;
619 619
620#define __ARCH_HAS_DO_SOFTIRQ 620#define __ARCH_HAS_DO_SOFTIRQ
621 621
622extern void __do_softirq(void);
623
624#ifdef CONFIG_IRQSTACKS 622#ifdef CONFIG_IRQSTACKS
625/* 623/*
626 * Per-cpu stacks for handling hard and soft interrupts. 624 * Per-cpu stacks for handling hard and soft interrupts.
diff --git a/include/asm-powerpc/irqflags.h b/include/asm-powerpc/irqflags.h
index 7970cbaeaa54..cc6fdba33660 100644
--- a/include/asm-powerpc/irqflags.h
+++ b/include/asm-powerpc/irqflags.h
@@ -2,30 +2,43 @@
2 * include/asm-powerpc/irqflags.h 2 * include/asm-powerpc/irqflags.h
3 * 3 *
4 * IRQ flags handling 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_*() macros from the lowlevel headers.
9 */ 5 */
10#ifndef _ASM_IRQFLAGS_H 6#ifndef _ASM_IRQFLAGS_H
11#define _ASM_IRQFLAGS_H 7#define _ASM_IRQFLAGS_H
12 8
9#ifndef __ASSEMBLY__
13/* 10/*
14 * Get definitions for raw_local_save_flags(x), etc. 11 * Get definitions for raw_local_save_flags(x), etc.
15 */ 12 */
16#include <asm-powerpc/hw_irq.h> 13#include <asm-powerpc/hw_irq.h>
17 14
15#else
16#ifdef CONFIG_TRACE_IRQFLAGS
18/* 17/*
19 * Do the CPU's IRQ-state tracing from assembly code. We call a 18 * Most of the CPU's IRQ-state tracing is done from assembly code; we
20 * C function, so save all the C-clobbered registers: 19 * have to call a C function so call a wrapper that saves all the
20 * C-clobbered registers.
21 */ 21 */
22#ifdef CONFIG_TRACE_IRQFLAGS 22#define TRACE_ENABLE_INTS bl .trace_hardirqs_on
23 23#define TRACE_DISABLE_INTS bl .trace_hardirqs_off
24#error No support on PowerPC yet for CONFIG_TRACE_IRQFLAGS 24#define TRACE_AND_RESTORE_IRQ_PARTIAL(en,skip) \
25 25 cmpdi en, 0; \
26 bne 95f; \
27 stb en,PACASOFTIRQEN(r13); \
28 bl .trace_hardirqs_off; \
29 b skip; \
3095: bl .trace_hardirqs_on; \
31 li en,1;
32#define TRACE_AND_RESTORE_IRQ(en) \
33 TRACE_AND_RESTORE_IRQ_PARTIAL(en,96f); \
3496: stb en,PACASOFTIRQEN(r13)
26#else 35#else
27# define TRACE_IRQS_ON 36#define TRACE_ENABLE_INTS
28# define TRACE_IRQS_OFF 37#define TRACE_DISABLE_INTS
38#define TRACE_AND_RESTORE_IRQ_PARTIAL(en,skip)
39#define TRACE_AND_RESTORE_IRQ(en) \
40 stb en,PACASOFTIRQEN(r13)
41#endif
29#endif 42#endif
30 43
31#endif 44#endif
diff --git a/include/asm-powerpc/iseries/alpaca.h b/include/asm-powerpc/iseries/alpaca.h
new file mode 100644
index 000000000000..c0cce6727a69
--- /dev/null
+++ b/include/asm-powerpc/iseries/alpaca.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright © 2008 Stephen Rothwell IBM Corporation
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#ifndef _ASM_POWERPC_ISERIES_ALPACA_H
19#define _ASM_POWERPC_ISERIES_ALPACA_H
20
21/*
22 * This is the part of the paca that the iSeries hypervisor
23 * needs to be statically initialised. Immediately after boot
24 * we switch to the normal Linux paca.
25 */
26struct alpaca {
27 struct lppaca *lppaca_ptr; /* Pointer to LpPaca for PLIC */
28 const void *reg_save_ptr; /* Pointer to LpRegSave for PLIC */
29};
30
31#endif /* _ASM_POWERPC_ISERIES_ALPACA_H */
diff --git a/include/asm-powerpc/iseries/it_lp_reg_save.h b/include/asm-powerpc/iseries/it_lp_reg_save.h
deleted file mode 100644
index 5403b756f654..000000000000
--- a/include/asm-powerpc/iseries/it_lp_reg_save.h
+++ /dev/null
@@ -1,85 +0,0 @@
1/*
2 * Copyright (C) 2001 Mike Corrigan IBM Corporation
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#ifndef _ASM_POWERPC_ISERIES_IT_LP_REG_SAVE_H
19#define _ASM_POWERPC_ISERIES_IT_LP_REG_SAVE_H
20
21/*
22 * This control block contains the data that is shared between PLIC
23 * and the OS
24 */
25
26struct ItLpRegSave {
27 u32 xDesc; // Eye catcher "LpRS" ebcdic 000-003
28 u16 xSize; // Size of this class 004-005
29 u8 xInUse; // Area is live 006-007
30 u8 xRsvd1[9]; // Reserved 007-00F
31
32 u8 xFixedRegSave[352]; // Fixed Register Save Area 010-16F
33 u32 xCTRL; // Control Register 170-173
34 u32 xDEC; // Decrementer 174-177
35 u32 xFPSCR; // FP Status and Control Reg 178-17B
36 u32 xPVR; // Processor Version Number 17C-17F
37
38 u64 xMMCR0; // Monitor Mode Control Reg 0 180-187
39 u32 xPMC1; // Perf Monitor Counter 1 188-18B
40 u32 xPMC2; // Perf Monitor Counter 2 18C-18F
41 u32 xPMC3; // Perf Monitor Counter 3 190-193
42 u32 xPMC4; // Perf Monitor Counter 4 194-197
43 u32 xPIR; // Processor ID Reg 198-19B
44
45 u32 xMMCR1; // Monitor Mode Control Reg 1 19C-19F
46 u32 xMMCRA; // Monitor Mode Control Reg A 1A0-1A3
47 u32 xPMC5; // Perf Monitor Counter 5 1A4-1A7
48 u32 xPMC6; // Perf Monitor Counter 6 1A8-1AB
49 u32 xPMC7; // Perf Monitor Counter 7 1AC-1AF
50 u32 xPMC8; // Perf Monitor Counter 8 1B0-1B3
51 u32 xTSC; // Thread Switch Control 1B4-1B7
52 u32 xTST; // Thread Switch Timeout 1B8-1BB
53 u32 xRsvd; // Reserved 1BC-1BF
54
55 u64 xACCR; // Address Compare Control Reg 1C0-1C7
56 u64 xIMR; // Instruction Match Register 1C8-1CF
57 u64 xSDR1; // Storage Description Reg 1 1D0-1D7
58 u64 xSPRG0; // Special Purpose Reg General0 1D8-1DF
59 u64 xSPRG1; // Special Purpose Reg General1 1E0-1E7
60 u64 xSPRG2; // Special Purpose Reg General2 1E8-1EF
61 u64 xSPRG3; // Special Purpose Reg General3 1F0-1F7
62 u64 xTB; // Time Base Register 1F8-1FF
63
64 u64 xFPR[32]; // Floating Point Registers 200-2FF
65
66 u64 xMSR; // Machine State Register 300-307
67 u64 xNIA; // Next Instruction Address 308-30F
68
69 u64 xDABR; // Data Address Breakpoint Reg 310-317
70 u64 xIABR; // Inst Address Breakpoint Reg 318-31F
71
72 u64 xHID0; // HW Implementation Dependent0 320-327
73
74 u64 xHID4; // HW Implementation Dependent4 328-32F
75 u64 xSCOMd; // SCON Data Reg (SPRG4) 330-337
76 u64 xSCOMc; // SCON Command Reg (SPRG5) 338-33F
77 u64 xSDAR; // Sample Data Address Register 340-347
78 u64 xSIAR; // Sample Inst Address Register 348-34F
79
80 u8 xRsvd3[176]; // Reserved 350-3FF
81};
82
83extern struct ItLpRegSave iseries_reg_save[];
84
85#endif /* _ASM_POWERPC_ISERIES_IT_LP_REG_SAVE_H */
diff --git a/include/asm-powerpc/kdump.h b/include/asm-powerpc/kdump.h
index 10e8eb1e6f4f..f6c93c716898 100644
--- a/include/asm-powerpc/kdump.h
+++ b/include/asm-powerpc/kdump.h
@@ -11,16 +11,11 @@
11 11
12#ifdef CONFIG_CRASH_DUMP 12#ifdef CONFIG_CRASH_DUMP
13 13
14#define PHYSICAL_START KDUMP_KERNELBASE
15#define KDUMP_TRAMPOLINE_START 0x0100 14#define KDUMP_TRAMPOLINE_START 0x0100
16#define KDUMP_TRAMPOLINE_END 0x3000 15#define KDUMP_TRAMPOLINE_END 0x3000
17 16
18#define KDUMP_MIN_TCE_ENTRIES 2048 17#define KDUMP_MIN_TCE_ENTRIES 2048
19 18
20#else /* !CONFIG_CRASH_DUMP */
21
22#define PHYSICAL_START 0x0
23
24#endif /* CONFIG_CRASH_DUMP */ 19#endif /* CONFIG_CRASH_DUMP */
25 20
26#ifndef __ASSEMBLY__ 21#ifndef __ASSEMBLY__
diff --git a/include/asm-powerpc/kvm.h b/include/asm-powerpc/kvm.h
index d1b530fbf8dd..f993e4198d5c 100644
--- a/include/asm-powerpc/kvm.h
+++ b/include/asm-powerpc/kvm.h
@@ -1,6 +1,55 @@
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, version 2, as
4 * published by the Free Software Foundation.
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 * Copyright IBM Corp. 2007
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
1#ifndef __LINUX_KVM_POWERPC_H 20#ifndef __LINUX_KVM_POWERPC_H
2#define __LINUX_KVM_POWERPC_H 21#define __LINUX_KVM_POWERPC_H
3 22
4/* powerpc does not support KVM */ 23#include <asm/types.h>
24
25struct kvm_regs {
26 __u64 pc;
27 __u64 cr;
28 __u64 ctr;
29 __u64 lr;
30 __u64 xer;
31 __u64 msr;
32 __u64 srr0;
33 __u64 srr1;
34 __u64 pid;
35
36 __u64 sprg0;
37 __u64 sprg1;
38 __u64 sprg2;
39 __u64 sprg3;
40 __u64 sprg4;
41 __u64 sprg5;
42 __u64 sprg6;
43 __u64 sprg7;
44
45 __u64 gpr[32];
46};
47
48struct kvm_sregs {
49};
50
51struct kvm_fpu {
52 __u64 fpr[32];
53};
5 54
6#endif 55#endif /* __LINUX_KVM_POWERPC_H */
diff --git a/include/asm-powerpc/kvm_asm.h b/include/asm-powerpc/kvm_asm.h
new file mode 100644
index 000000000000..2197764796d9
--- /dev/null
+++ b/include/asm-powerpc/kvm_asm.h
@@ -0,0 +1,55 @@
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, version 2, as
4 * published by the Free Software Foundation.
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 * Copyright IBM Corp. 2008
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
20#ifndef __POWERPC_KVM_ASM_H__
21#define __POWERPC_KVM_ASM_H__
22
23/* IVPR must be 64KiB-aligned. */
24#define VCPU_SIZE_ORDER 4
25#define VCPU_SIZE_LOG (VCPU_SIZE_ORDER + 12)
26#define VCPU_TLB_PGSZ PPC44x_TLB_64K
27#define VCPU_SIZE_BYTES (1<<VCPU_SIZE_LOG)
28
29#define BOOKE_INTERRUPT_CRITICAL 0
30#define BOOKE_INTERRUPT_MACHINE_CHECK 1
31#define BOOKE_INTERRUPT_DATA_STORAGE 2
32#define BOOKE_INTERRUPT_INST_STORAGE 3
33#define BOOKE_INTERRUPT_EXTERNAL 4
34#define BOOKE_INTERRUPT_ALIGNMENT 5
35#define BOOKE_INTERRUPT_PROGRAM 6
36#define BOOKE_INTERRUPT_FP_UNAVAIL 7
37#define BOOKE_INTERRUPT_SYSCALL 8
38#define BOOKE_INTERRUPT_AP_UNAVAIL 9
39#define BOOKE_INTERRUPT_DECREMENTER 10
40#define BOOKE_INTERRUPT_FIT 11
41#define BOOKE_INTERRUPT_WATCHDOG 12
42#define BOOKE_INTERRUPT_DTLB_MISS 13
43#define BOOKE_INTERRUPT_ITLB_MISS 14
44#define BOOKE_INTERRUPT_DEBUG 15
45#define BOOKE_MAX_INTERRUPT 15
46
47#define RESUME_FLAG_NV (1<<0) /* Reload guest nonvolatile state? */
48#define RESUME_FLAG_HOST (1<<1) /* Resume host? */
49
50#define RESUME_GUEST 0
51#define RESUME_GUEST_NV RESUME_FLAG_NV
52#define RESUME_HOST RESUME_FLAG_HOST
53#define RESUME_HOST_NV (RESUME_FLAG_HOST|RESUME_FLAG_NV)
54
55#endif /* __POWERPC_KVM_ASM_H__ */
diff --git a/include/asm-powerpc/kvm_host.h b/include/asm-powerpc/kvm_host.h
new file mode 100644
index 000000000000..04ffbb8e0a35
--- /dev/null
+++ b/include/asm-powerpc/kvm_host.h
@@ -0,0 +1,152 @@
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, version 2, as
4 * published by the Free Software Foundation.
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 * Copyright IBM Corp. 2007
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
20#ifndef __POWERPC_KVM_HOST_H__
21#define __POWERPC_KVM_HOST_H__
22
23#include <linux/mutex.h>
24#include <linux/timer.h>
25#include <linux/types.h>
26#include <linux/kvm_types.h>
27#include <asm/kvm_asm.h>
28
29#define KVM_MAX_VCPUS 1
30#define KVM_MEMORY_SLOTS 32
31/* memory slots that does not exposed to userspace */
32#define KVM_PRIVATE_MEM_SLOTS 4
33
34/* We don't currently support large pages. */
35#define KVM_PAGES_PER_HPAGE (1<<31)
36
37struct kvm;
38struct kvm_run;
39struct kvm_vcpu;
40
41struct kvm_vm_stat {
42 u32 remote_tlb_flush;
43};
44
45struct kvm_vcpu_stat {
46 u32 sum_exits;
47 u32 mmio_exits;
48 u32 dcr_exits;
49 u32 signal_exits;
50 u32 light_exits;
51 /* Account for special types of light exits: */
52 u32 itlb_real_miss_exits;
53 u32 itlb_virt_miss_exits;
54 u32 dtlb_real_miss_exits;
55 u32 dtlb_virt_miss_exits;
56 u32 syscall_exits;
57 u32 isi_exits;
58 u32 dsi_exits;
59 u32 emulated_inst_exits;
60 u32 dec_exits;
61 u32 ext_intr_exits;
62};
63
64struct tlbe {
65 u32 tid; /* Only the low 8 bits are used. */
66 u32 word0;
67 u32 word1;
68 u32 word2;
69};
70
71struct kvm_arch {
72};
73
74struct kvm_vcpu_arch {
75 /* Unmodified copy of the guest's TLB. */
76 struct tlbe guest_tlb[PPC44x_TLB_SIZE];
77 /* TLB that's actually used when the guest is running. */
78 struct tlbe shadow_tlb[PPC44x_TLB_SIZE];
79 /* Pages which are referenced in the shadow TLB. */
80 struct page *shadow_pages[PPC44x_TLB_SIZE];
81 /* Copy of the host's TLB. */
82 struct tlbe host_tlb[PPC44x_TLB_SIZE];
83
84 u32 host_stack;
85 u32 host_pid;
86
87 u64 fpr[32];
88 u32 gpr[32];
89
90 u32 pc;
91 u32 cr;
92 u32 ctr;
93 u32 lr;
94 u32 xer;
95
96 u32 msr;
97 u32 mmucr;
98 u32 sprg0;
99 u32 sprg1;
100 u32 sprg2;
101 u32 sprg3;
102 u32 sprg4;
103 u32 sprg5;
104 u32 sprg6;
105 u32 sprg7;
106 u32 srr0;
107 u32 srr1;
108 u32 csrr0;
109 u32 csrr1;
110 u32 dsrr0;
111 u32 dsrr1;
112 u32 dear;
113 u32 esr;
114 u32 dec;
115 u32 decar;
116 u32 tbl;
117 u32 tbu;
118 u32 tcr;
119 u32 tsr;
120 u32 ivor[16];
121 u32 ivpr;
122 u32 pir;
123 u32 pid;
124 u32 pvr;
125 u32 ccr0;
126 u32 ccr1;
127 u32 dbcr0;
128 u32 dbcr1;
129
130 u32 last_inst;
131 u32 fault_dear;
132 u32 fault_esr;
133 gpa_t paddr_accessed;
134
135 u8 io_gpr; /* GPR used as IO source/target */
136 u8 mmio_is_bigendian;
137 u8 dcr_needed;
138 u8 dcr_is_write;
139
140 u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */
141
142 struct timer_list dec_timer;
143 unsigned long pending_exceptions;
144};
145
146struct kvm_guest_debug {
147 int enabled;
148 unsigned long bp[4];
149 int singlestep;
150};
151
152#endif /* __POWERPC_KVM_HOST_H__ */
diff --git a/include/asm-powerpc/kvm_para.h b/include/asm-powerpc/kvm_para.h
new file mode 100644
index 000000000000..2d48f6a63d0b
--- /dev/null
+++ b/include/asm-powerpc/kvm_para.h
@@ -0,0 +1,37 @@
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, version 2, as
4 * published by the Free Software Foundation.
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 * Copyright IBM Corp. 2008
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
20#ifndef __POWERPC_KVM_PARA_H__
21#define __POWERPC_KVM_PARA_H__
22
23#ifdef __KERNEL__
24
25static inline int kvm_para_available(void)
26{
27 return 0;
28}
29
30static inline unsigned int kvm_arch_para_features(void)
31{
32 return 0;
33}
34
35#endif /* __KERNEL__ */
36
37#endif /* __POWERPC_KVM_PARA_H__ */
diff --git a/include/asm-powerpc/kvm_ppc.h b/include/asm-powerpc/kvm_ppc.h
new file mode 100644
index 000000000000..7ac820308a7e
--- /dev/null
+++ b/include/asm-powerpc/kvm_ppc.h
@@ -0,0 +1,88 @@
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, version 2, as
4 * published by the Free Software Foundation.
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 * Copyright IBM Corp. 2008
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
20#ifndef __POWERPC_KVM_PPC_H__
21#define __POWERPC_KVM_PPC_H__
22
23/* This file exists just so we can dereference kvm_vcpu, avoiding nested header
24 * dependencies. */
25
26#include <linux/mutex.h>
27#include <linux/timer.h>
28#include <linux/types.h>
29#include <linux/kvm_types.h>
30#include <linux/kvm_host.h>
31
32struct kvm_tlb {
33 struct tlbe guest_tlb[PPC44x_TLB_SIZE];
34 struct tlbe shadow_tlb[PPC44x_TLB_SIZE];
35};
36
37enum emulation_result {
38 EMULATE_DONE, /* no further processing */
39 EMULATE_DO_MMIO, /* kvm_run filled with MMIO request */
40 EMULATE_DO_DCR, /* kvm_run filled with DCR request */
41 EMULATE_FAIL, /* can't emulate this instruction */
42};
43
44extern const unsigned char exception_priority[];
45extern const unsigned char priority_exception[];
46
47extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
48extern char kvmppc_handlers_start[];
49extern unsigned long kvmppc_handler_len;
50
51extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu);
52extern int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
53 unsigned int rt, unsigned int bytes,
54 int is_bigendian);
55extern int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
56 u32 val, unsigned int bytes, int is_bigendian);
57
58extern int kvmppc_emulate_instruction(struct kvm_run *run,
59 struct kvm_vcpu *vcpu);
60
61extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn,
62 u64 asid, u32 flags);
63extern void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, u64 eaddr, u64 asid);
64extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode);
65
66extern void kvmppc_check_and_deliver_interrupts(struct kvm_vcpu *vcpu);
67
68static inline void kvmppc_queue_exception(struct kvm_vcpu *vcpu, int exception)
69{
70 unsigned int priority = exception_priority[exception];
71 set_bit(priority, &vcpu->arch.pending_exceptions);
72}
73
74static inline void kvmppc_clear_exception(struct kvm_vcpu *vcpu, int exception)
75{
76 unsigned int priority = exception_priority[exception];
77 clear_bit(priority, &vcpu->arch.pending_exceptions);
78}
79
80static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
81{
82 if ((new_msr & MSR_PR) != (vcpu->arch.msr & MSR_PR))
83 kvmppc_mmu_priv_switch(vcpu, new_msr & MSR_PR);
84
85 vcpu->arch.msr = new_msr;
86}
87
88#endif /* __POWERPC_KVM_PPC_H__ */
diff --git a/include/asm-powerpc/lmb.h b/include/asm-powerpc/lmb.h
index 5d1dc48a0bb8..6f5fdf0a19ae 100644
--- a/include/asm-powerpc/lmb.h
+++ b/include/asm-powerpc/lmb.h
@@ -1,81 +1,15 @@
1#ifndef _ASM_POWERPC_LMB_H 1#ifndef _ASM_POWERPC_LMB_H
2#define _ASM_POWERPC_LMB_H 2#define _ASM_POWERPC_LMB_H
3#ifdef __KERNEL__
4 3
5/* 4#include <asm/udbg.h>
6 * Definitions for talking to the Open Firmware PROM on
7 * Power Macintosh computers.
8 *
9 * Copyright (C) 2001 Peter Bergner, IBM Corp.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16 5
17#include <linux/init.h> 6#define LMB_DBG(fmt...) udbg_printf(fmt)
18#include <asm/prom.h>
19 7
20#define MAX_LMB_REGIONS 128 8#ifdef CONFIG_PPC32
9extern phys_addr_t lowmem_end_addr;
10#define LMB_REAL_LIMIT lowmem_end_addr
11#else
12#define LMB_REAL_LIMIT 0
13#endif
21 14
22struct lmb_property {
23 unsigned long base;
24 unsigned long size;
25};
26
27struct lmb_region {
28 unsigned long cnt;
29 unsigned long size;
30 struct lmb_property region[MAX_LMB_REGIONS+1];
31};
32
33struct lmb {
34 unsigned long debug;
35 unsigned long rmo_size;
36 struct lmb_region memory;
37 struct lmb_region reserved;
38};
39
40extern struct lmb lmb;
41
42extern void __init lmb_init(void);
43extern void __init lmb_analyze(void);
44extern long __init lmb_add(unsigned long base, unsigned long size);
45extern long __init lmb_reserve(unsigned long base, unsigned long size);
46extern unsigned long __init lmb_alloc(unsigned long size, unsigned long align);
47extern unsigned long __init lmb_alloc_base(unsigned long size,
48 unsigned long align, unsigned long max_addr);
49extern unsigned long __init __lmb_alloc_base(unsigned long size,
50 unsigned long align, unsigned long max_addr);
51extern unsigned long __init lmb_phys_mem_size(void);
52extern unsigned long __init lmb_end_of_DRAM(void);
53extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
54extern int __init lmb_is_reserved(unsigned long addr);
55
56extern void lmb_dump_all(void);
57
58static inline unsigned long
59lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
60{
61 return type->region[region_nr].size;
62}
63static inline unsigned long
64lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
65{
66 return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
67}
68static inline unsigned long
69lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
70{
71 return type->region[region_nr].base >> PAGE_SHIFT;
72}
73static inline unsigned long
74lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
75{
76 return lmb_start_pfn(type, region_nr) +
77 lmb_size_pages(type, region_nr);
78}
79
80#endif /* __KERNEL__ */
81#endif /* _ASM_POWERPC_LMB_H */ 15#endif /* _ASM_POWERPC_LMB_H */
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
index 0872ec228c1e..54ed64df95b8 100644
--- a/include/asm-powerpc/machdep.h
+++ b/include/asm-powerpc/machdep.h
@@ -68,6 +68,8 @@ struct machdep_calls {
68 unsigned long vflags, 68 unsigned long vflags,
69 int psize, int ssize); 69 int psize, int ssize);
70 long (*hpte_remove)(unsigned long hpte_group); 70 long (*hpte_remove)(unsigned long hpte_group);
71 void (*hpte_removebolted)(unsigned long ea,
72 int psize, int ssize);
71 void (*flush_hash_range)(unsigned long number, int local); 73 void (*flush_hash_range)(unsigned long number, int local);
72 74
73 /* special for kexec, to be called in real mode, linar mapping is 75 /* special for kexec, to be called in real mode, linar mapping is
@@ -196,9 +198,6 @@ struct machdep_calls {
196 May be NULL. */ 198 May be NULL. */
197 void (*init)(void); 199 void (*init)(void);
198 200
199 void (*setup_io_mappings)(void);
200
201 void (*early_serial_map)(void);
202 void (*kgdb_map_scc)(void); 201 void (*kgdb_map_scc)(void);
203 202
204 /* 203 /*
diff --git a/include/asm-powerpc/macio.h b/include/asm-powerpc/macio.h
index 3a6cb1a513b7..079c06eae446 100644
--- a/include/asm-powerpc/macio.h
+++ b/include/asm-powerpc/macio.h
@@ -2,7 +2,7 @@
2#define __MACIO_ASIC_H__ 2#define __MACIO_ASIC_H__
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <asm/of_device.h> 5#include <linux/of_device.h>
6 6
7extern struct bus_type macio_bus_type; 7extern struct bus_type macio_bus_type;
8 8
diff --git a/include/asm-powerpc/mediabay.h b/include/asm-powerpc/mediabay.h
index de83fe196309..df111c362a7f 100644
--- a/include/asm-powerpc/mediabay.h
+++ b/include/asm-powerpc/mediabay.h
@@ -22,10 +22,14 @@ int check_media_bay(struct device_node *which_bay, int what);
22/* Number of bays in the machine or 0 */ 22/* Number of bays in the machine or 0 */
23extern int media_bay_count; 23extern int media_bay_count;
24 24
25#ifdef CONFIG_BLK_DEV_IDE_PMAC
26#include <linux/ide.h>
27
25int check_media_bay_by_base(unsigned long base, int what); 28int check_media_bay_by_base(unsigned long base, int what);
26/* called by IDE PMAC host driver to register IDE controller for media bay */ 29/* called by IDE PMAC host driver to register IDE controller for media bay */
27int media_bay_set_ide_infos(struct device_node *which_bay, unsigned long base, 30int media_bay_set_ide_infos(struct device_node *which_bay, unsigned long base,
28 int irq, int index); 31 int irq, ide_hwif_t *hwif);
32#endif
29 33
30#endif /* __KERNEL__ */ 34#endif /* __KERNEL__ */
31#endif /* _PPC_MEDIABAY_H */ 35#endif /* _PPC_MEDIABAY_H */
diff --git a/include/asm-powerpc/mmu-40x.h b/include/asm-powerpc/mmu-40x.h
index 7d37f77043ac..3d108676584c 100644
--- a/include/asm-powerpc/mmu-40x.h
+++ b/include/asm-powerpc/mmu-40x.h
@@ -53,8 +53,6 @@
53 53
54#ifndef __ASSEMBLY__ 54#ifndef __ASSEMBLY__
55 55
56typedef unsigned long phys_addr_t;
57
58typedef struct { 56typedef struct {
59 unsigned long id; 57 unsigned long id;
60 unsigned long vdso_base; 58 unsigned long vdso_base;
diff --git a/include/asm-powerpc/mmu-44x.h b/include/asm-powerpc/mmu-44x.h
index 62772ae839ca..a825524c981a 100644
--- a/include/asm-powerpc/mmu-44x.h
+++ b/include/asm-powerpc/mmu-44x.h
@@ -53,7 +53,7 @@
53 53
54#ifndef __ASSEMBLY__ 54#ifndef __ASSEMBLY__
55 55
56typedef unsigned long long phys_addr_t; 56extern unsigned int tlb_44x_hwater;
57 57
58typedef struct { 58typedef struct {
59 unsigned long id; 59 unsigned long id;
diff --git a/include/asm-powerpc/mmu-8xx.h b/include/asm-powerpc/mmu-8xx.h
index 952bd8899f2f..9db877eb88db 100644
--- a/include/asm-powerpc/mmu-8xx.h
+++ b/include/asm-powerpc/mmu-8xx.h
@@ -136,8 +136,6 @@
136#define SPRN_M_TW 799 136#define SPRN_M_TW 799
137 137
138#ifndef __ASSEMBLY__ 138#ifndef __ASSEMBLY__
139typedef unsigned long phys_addr_t;
140
141typedef struct { 139typedef struct {
142 unsigned long id; 140 unsigned long id;
143 unsigned long vdso_base; 141 unsigned long vdso_base;
diff --git a/include/asm-powerpc/mmu-fsl-booke.h b/include/asm-powerpc/mmu-fsl-booke.h
index 37580004cd7a..925d93cf64d8 100644
--- a/include/asm-powerpc/mmu-fsl-booke.h
+++ b/include/asm-powerpc/mmu-fsl-booke.h
@@ -73,12 +73,6 @@
73 73
74#ifndef __ASSEMBLY__ 74#ifndef __ASSEMBLY__
75 75
76#ifndef CONFIG_PHYS_64BIT
77typedef unsigned long phys_addr_t;
78#else
79typedef unsigned long long phys_addr_t;
80#endif
81
82typedef struct { 76typedef struct {
83 unsigned long id; 77 unsigned long id;
84 unsigned long vdso_base; 78 unsigned long vdso_base;
diff --git a/include/asm-powerpc/mmu-hash32.h b/include/asm-powerpc/mmu-hash32.h
index 4bd735be3833..6e21ca618ec3 100644
--- a/include/asm-powerpc/mmu-hash32.h
+++ b/include/asm-powerpc/mmu-hash32.h
@@ -84,8 +84,6 @@ typedef struct {
84 unsigned long vdso_base; 84 unsigned long vdso_base;
85} mm_context_t; 85} mm_context_t;
86 86
87typedef unsigned long phys_addr_t;
88
89#endif /* !__ASSEMBLY__ */ 87#endif /* !__ASSEMBLY__ */
90 88
91#endif /* _ASM_POWERPC_MMU_HASH32_H_ */ 89#endif /* _ASM_POWERPC_MMU_HASH32_H_ */
diff --git a/include/asm-powerpc/mmu-hash64.h b/include/asm-powerpc/mmu-hash64.h
index 2864fa3989ea..0dff76776044 100644
--- a/include/asm-powerpc/mmu-hash64.h
+++ b/include/asm-powerpc/mmu-hash64.h
@@ -469,9 +469,6 @@ static inline unsigned long get_vsid(unsigned long context, unsigned long ea,
469 VSID_MODULUS_256M) 469 VSID_MODULUS_256M)
470#define KERNEL_VSID(ea) VSID_SCRAMBLE(GET_ESID(ea)) 470#define KERNEL_VSID(ea) VSID_SCRAMBLE(GET_ESID(ea))
471 471
472/* Physical address used by some IO functions */
473typedef unsigned long phys_addr_t;
474
475#endif /* __ASSEMBLY__ */ 472#endif /* __ASSEMBLY__ */
476 473
477#endif /* _ASM_POWERPC_MMU_HASH64_H_ */ 474#endif /* _ASM_POWERPC_MMU_HASH64_H_ */
diff --git a/include/asm-powerpc/paca.h b/include/asm-powerpc/paca.h
index 748b35ab37b5..7b564444ff61 100644
--- a/include/asm-powerpc/paca.h
+++ b/include/asm-powerpc/paca.h
@@ -42,10 +42,7 @@ struct task_struct;
42 * Defines the layout of the paca. 42 * Defines the layout of the paca.
43 * 43 *
44 * This structure is not directly accessed by firmware or the service 44 * This structure is not directly accessed by firmware or the service
45 * processor except for the first two pointers that point to the 45 * processor.
46 * lppaca area and the ItLpRegSave area for this CPU. The lppaca
47 * object is currently contained within the PACA but it doesn't need
48 * to be.
49 */ 46 */
50struct paca_struct { 47struct paca_struct {
51 /* 48 /*
@@ -55,14 +52,7 @@ struct paca_struct {
55 * avoid cacheline bouncing. 52 * avoid cacheline bouncing.
56 */ 53 */
57 54
58 /*
59 * MAGIC: These first two pointers can't be moved - they're
60 * accessed by the firmware
61 */
62 struct lppaca *lppaca_ptr; /* Pointer to LpPaca for PLIC */ 55 struct lppaca *lppaca_ptr; /* Pointer to LpPaca for PLIC */
63#ifdef CONFIG_PPC_ISERIES
64 void *reg_save_ptr; /* Pointer to LpRegSave for PLIC */
65#endif /* CONFIG_PPC_ISERIES */
66 56
67 /* 57 /*
68 * MAGIC: the spinlock functions in arch/powerpc/lib/locks.c 58 * MAGIC: the spinlock functions in arch/powerpc/lib/locks.c
@@ -118,6 +108,7 @@ struct paca_struct {
118}; 108};
119 109
120extern struct paca_struct paca[]; 110extern struct paca_struct paca[];
111extern void initialise_pacas(void);
121 112
122#endif /* __KERNEL__ */ 113#endif /* __KERNEL__ */
123#endif /* _ASM_POWERPC_PACA_H */ 114#endif /* _ASM_POWERPC_PACA_H */
diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h
index df47bbb6ea13..cffdf0eb0df6 100644
--- a/include/asm-powerpc/page.h
+++ b/include/asm-powerpc/page.h
@@ -12,6 +12,7 @@
12 12
13#include <asm/asm-compat.h> 13#include <asm/asm-compat.h>
14#include <asm/kdump.h> 14#include <asm/kdump.h>
15#include <asm/types.h>
15 16
16/* 17/*
17 * On PPC32 page size is 4K. For PPC64 we support either 4K or 64K software 18 * On PPC32 page size is 4K. For PPC64 we support either 4K or 64K software
@@ -42,8 +43,23 @@
42 * 43 *
43 * The kdump dump kernel is one example where KERNELBASE != PAGE_OFFSET. 44 * The kdump dump kernel is one example where KERNELBASE != PAGE_OFFSET.
44 * 45 *
45 * To get a physical address from a virtual one you subtract PAGE_OFFSET, 46 * PAGE_OFFSET is the virtual address of the start of lowmem.
46 * _not_ KERNELBASE. 47 *
48 * PHYSICAL_START is the physical address of the start of the kernel.
49 *
50 * MEMORY_START is the physical address of the start of lowmem.
51 *
52 * KERNELBASE, PAGE_OFFSET, and PHYSICAL_START are all configurable on
53 * ppc32 and based on how they are set we determine MEMORY_START.
54 *
55 * For the linear mapping the following equation should be true:
56 * KERNELBASE - PAGE_OFFSET = PHYSICAL_START - MEMORY_START
57 *
58 * Also, KERNELBASE >= PAGE_OFFSET and PHYSICAL_START >= MEMORY_START
59 *
60 * There are two was to determine a physical address from a virtual one:
61 * va = pa + PAGE_OFFSET - MEMORY_START
62 * va = pa + KERNELBASE - PHYSICAL_START
47 * 63 *
48 * If you want to know something's offset from the start of the kernel you 64 * If you want to know something's offset from the start of the kernel you
49 * should subtract KERNELBASE. 65 * should subtract KERNELBASE.
@@ -51,19 +67,33 @@
51 * If you want to test if something's a kernel address, use is_kernel_addr(). 67 * If you want to test if something's a kernel address, use is_kernel_addr().
52 */ 68 */
53 69
54#define PAGE_OFFSET ASM_CONST(CONFIG_KERNEL_START) 70#define KERNELBASE ASM_CONST(CONFIG_KERNEL_START)
55#define KERNELBASE (PAGE_OFFSET + PHYSICAL_START) 71#define PAGE_OFFSET ASM_CONST(CONFIG_PAGE_OFFSET)
72#define LOAD_OFFSET ASM_CONST((CONFIG_KERNEL_START-CONFIG_PHYSICAL_START))
73
74#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_FLATMEM)
75#ifndef __ASSEMBLY__
76extern phys_addr_t memstart_addr;
77extern phys_addr_t kernstart_addr;
78#endif
79#define PHYSICAL_START kernstart_addr
80#define MEMORY_START memstart_addr
81#else
82#define PHYSICAL_START ASM_CONST(CONFIG_PHYSICAL_START)
83#define MEMORY_START (PHYSICAL_START + PAGE_OFFSET - KERNELBASE)
84#endif
56 85
57#ifdef CONFIG_FLATMEM 86#ifdef CONFIG_FLATMEM
58#define pfn_valid(pfn) ((pfn) < max_mapnr) 87#define ARCH_PFN_OFFSET (MEMORY_START >> PAGE_SHIFT)
88#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < (ARCH_PFN_OFFSET + max_mapnr))
59#endif 89#endif
60 90
61#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 91#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
62#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 92#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
63#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 93#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
64 94
65#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET)) 95#define __va(x) ((void *)((unsigned long)(x) - PHYSICAL_START + KERNELBASE))
66#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) 96#define __pa(x) ((unsigned long)(x) + PHYSICAL_START - KERNELBASE)
67 97
68/* 98/*
69 * Unfortunately the PLT is in the BSS in the PPC32 ELF ABI, 99 * Unfortunately the PLT is in the BSS in the PPC32 ELF ABI,
diff --git a/include/asm-powerpc/page_32.h b/include/asm-powerpc/page_32.h
index 65ea19eec956..ebfae530a379 100644
--- a/include/asm-powerpc/page_32.h
+++ b/include/asm-powerpc/page_32.h
@@ -1,9 +1,13 @@
1#ifndef _ASM_POWERPC_PAGE_32_H 1#ifndef _ASM_POWERPC_PAGE_32_H
2#define _ASM_POWERPC_PAGE_32_H 2#define _ASM_POWERPC_PAGE_32_H
3 3
4#define VM_DATA_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS32 4#if defined(CONFIG_PHYSICAL_ALIGN) && (CONFIG_PHYSICAL_START != 0)
5#if (CONFIG_PHYSICAL_START % CONFIG_PHYSICAL_ALIGN) != 0
6#error "CONFIG_PHYSICAL_START must be a multiple of CONFIG_PHYSICAL_ALIGN"
7#endif
8#endif
5 9
6#define PPC_MEMSTART 0 10#define VM_DATA_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS32
7 11
8#ifdef CONFIG_NOT_COHERENT_CACHE 12#ifdef CONFIG_NOT_COHERENT_CACHE
9#define ARCH_KMALLOC_MINALIGN L1_CACHE_BYTES 13#define ARCH_KMALLOC_MINALIGN L1_CACHE_BYTES
diff --git a/include/asm-powerpc/page_64.h b/include/asm-powerpc/page_64.h
index 67834eae5702..25af4fc8daf4 100644
--- a/include/asm-powerpc/page_64.h
+++ b/include/asm-powerpc/page_64.h
@@ -128,11 +128,6 @@ extern void slice_init_context(struct mm_struct *mm, unsigned int psize);
128extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize); 128extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize);
129#define slice_mm_new_context(mm) ((mm)->context.id == 0) 129#define slice_mm_new_context(mm) ((mm)->context.id == 0)
130 130
131#define ARCH_HAS_HUGEPAGE_ONLY_RANGE
132extern int is_hugepage_only_range(struct mm_struct *m,
133 unsigned long addr,
134 unsigned long len);
135
136#endif /* __ASSEMBLY__ */ 131#endif /* __ASSEMBLY__ */
137#else 132#else
138#define slice_init() 133#define slice_init()
@@ -146,8 +141,6 @@ do { \
146 141
147#ifdef CONFIG_HUGETLB_PAGE 142#ifdef CONFIG_HUGETLB_PAGE
148 143
149#define ARCH_HAS_HUGETLB_FREE_PGD_RANGE
150#define ARCH_HAS_SETCLEAR_HUGE_PTE
151#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 144#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
152 145
153#endif /* !CONFIG_HUGETLB_PAGE */ 146#endif /* !CONFIG_HUGETLB_PAGE */
diff --git a/include/asm-powerpc/pasemi_dma.h b/include/asm-powerpc/pasemi_dma.h
index b4526ff3a50d..19fd7933e2d9 100644
--- a/include/asm-powerpc/pasemi_dma.h
+++ b/include/asm-powerpc/pasemi_dma.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2006 PA Semi, Inc 2 * Copyright (C) 2006-2008 PA Semi, Inc
3 * 3 *
4 * Hardware register layout and descriptor formats for the on-board 4 * Hardware register layout and descriptor formats for the on-board
5 * DMA engine on PA Semi PWRficient. Used by ethernet, function and security 5 * DMA engine on PA Semi PWRficient. Used by ethernet, function and security
@@ -40,6 +40,11 @@ enum {
40 PAS_DMA_COM_TXSTA = 0x104, /* Transmit Status Register */ 40 PAS_DMA_COM_TXSTA = 0x104, /* Transmit Status Register */
41 PAS_DMA_COM_RXCMD = 0x108, /* Receive Command Register */ 41 PAS_DMA_COM_RXCMD = 0x108, /* Receive Command Register */
42 PAS_DMA_COM_RXSTA = 0x10c, /* Receive Status Register */ 42 PAS_DMA_COM_RXSTA = 0x10c, /* Receive Status Register */
43 PAS_DMA_COM_CFG = 0x114, /* Common config reg */
44 PAS_DMA_TXF_SFLG0 = 0x140, /* Set flags */
45 PAS_DMA_TXF_SFLG1 = 0x144, /* Set flags */
46 PAS_DMA_TXF_CFLG0 = 0x148, /* Set flags */
47 PAS_DMA_TXF_CFLG1 = 0x14c, /* Set flags */
43}; 48};
44 49
45 50
@@ -123,11 +128,16 @@ enum {
123#define PAS_DMA_TXCHAN_TCMDSTA_DA 0x00000100 128#define PAS_DMA_TXCHAN_TCMDSTA_DA 0x00000100
124#define PAS_DMA_TXCHAN_CFG(c) (0x304+(c)*_PAS_DMA_TXCHAN_STRIDE) 129#define PAS_DMA_TXCHAN_CFG(c) (0x304+(c)*_PAS_DMA_TXCHAN_STRIDE)
125#define PAS_DMA_TXCHAN_CFG_TY_IFACE 0x00000000 /* Type = interface */ 130#define PAS_DMA_TXCHAN_CFG_TY_IFACE 0x00000000 /* Type = interface */
131#define PAS_DMA_TXCHAN_CFG_TY_COPY 0x00000001 /* Type = copy only */
132#define PAS_DMA_TXCHAN_CFG_TY_FUNC 0x00000002 /* Type = function */
133#define PAS_DMA_TXCHAN_CFG_TY_XOR 0x00000003 /* Type = xor only */
126#define PAS_DMA_TXCHAN_CFG_TATTR_M 0x0000003c 134#define PAS_DMA_TXCHAN_CFG_TATTR_M 0x0000003c
127#define PAS_DMA_TXCHAN_CFG_TATTR_S 2 135#define PAS_DMA_TXCHAN_CFG_TATTR_S 2
128#define PAS_DMA_TXCHAN_CFG_TATTR(x) (((x) << PAS_DMA_TXCHAN_CFG_TATTR_S) & \ 136#define PAS_DMA_TXCHAN_CFG_TATTR(x) (((x) << PAS_DMA_TXCHAN_CFG_TATTR_S) & \
129 PAS_DMA_TXCHAN_CFG_TATTR_M) 137 PAS_DMA_TXCHAN_CFG_TATTR_M)
130#define PAS_DMA_TXCHAN_CFG_WT_M 0x000001c0 138#define PAS_DMA_TXCHAN_CFG_LPDQ 0x00000800
139#define PAS_DMA_TXCHAN_CFG_LPSQ 0x00000400
140#define PAS_DMA_TXCHAN_CFG_WT_M 0x000003c0
131#define PAS_DMA_TXCHAN_CFG_WT_S 6 141#define PAS_DMA_TXCHAN_CFG_WT_S 6
132#define PAS_DMA_TXCHAN_CFG_WT(x) (((x) << PAS_DMA_TXCHAN_CFG_WT_S) & \ 142#define PAS_DMA_TXCHAN_CFG_WT(x) (((x) << PAS_DMA_TXCHAN_CFG_WT_S) & \
133 PAS_DMA_TXCHAN_CFG_WT_M) 143 PAS_DMA_TXCHAN_CFG_WT_M)
@@ -394,11 +404,62 @@ enum {
394 XCT_COPY_LLEN_M) 404 XCT_COPY_LLEN_M)
395#define XCT_COPY_SE 0x0000000000000001ull 405#define XCT_COPY_SE 0x0000000000000001ull
396 406
407/* Function descriptor fields */
408#define XCT_FUN_T 0x8000000000000000ull
409#define XCT_FUN_ST 0x4000000000000000ull
410#define XCT_FUN_RR_M 0x3000000000000000ull
411#define XCT_FUN_RR_NORES 0x0000000000000000ull
412#define XCT_FUN_RR_8BRES 0x1000000000000000ull
413#define XCT_FUN_RR_24BRES 0x2000000000000000ull
414#define XCT_FUN_RR_40BRES 0x3000000000000000ull
415#define XCT_FUN_I 0x0800000000000000ull
416#define XCT_FUN_O 0x0400000000000000ull
417#define XCT_FUN_E 0x0200000000000000ull
418#define XCT_FUN_FUN_M 0x01c0000000000000ull
419#define XCT_FUN_FUN_S 54
420#define XCT_FUN_FUN(x) ((((long)(x)) << XCT_FUN_FUN_S) & XCT_FUN_FUN_M)
421#define XCT_FUN_CRM_M 0x0038000000000000ull
422#define XCT_FUN_CRM_NOP 0x0000000000000000ull
423#define XCT_FUN_CRM_SIG 0x0008000000000000ull
424#define XCT_FUN_LLEN_M 0x0007ffff00000000ull
425#define XCT_FUN_LLEN_S 32
426#define XCT_FUN_LLEN(x) ((((long)(x)) << XCT_FUN_LLEN_S) & XCT_FUN_LLEN_M)
427#define XCT_FUN_SHL_M 0x00000000f8000000ull
428#define XCT_FUN_SHL_S 27
429#define XCT_FUN_SHL(x) ((((long)(x)) << XCT_FUN_SHL_S) & XCT_FUN_SHL_M)
430#define XCT_FUN_CHL_M 0x0000000007c00000ull
431#define XCT_FUN_HSZ_M 0x00000000003c0000ull
432#define XCT_FUN_ALG_M 0x0000000000038000ull
433#define XCT_FUN_HP 0x0000000000004000ull
434#define XCT_FUN_BCM_M 0x0000000000003800ull
435#define XCT_FUN_BCP_M 0x0000000000000600ull
436#define XCT_FUN_SIG_M 0x00000000000001f0ull
437#define XCT_FUN_SIG_TCP4 0x0000000000000140ull
438#define XCT_FUN_SIG_TCP6 0x0000000000000150ull
439#define XCT_FUN_SIG_UDP4 0x0000000000000160ull
440#define XCT_FUN_SIG_UDP6 0x0000000000000170ull
441#define XCT_FUN_A 0x0000000000000008ull
442#define XCT_FUN_C 0x0000000000000004ull
443#define XCT_FUN_AL2 0x0000000000000002ull
444#define XCT_FUN_SE 0x0000000000000001ull
445
446/* Function descriptor 8byte result fields */
447#define XCT_FUNRES_8B_CS_M 0x0000ffff00000000ull
448#define XCT_FUNRES_8B_CS_S 32
449#define XCT_FUNRES_8B_CRC_M 0x00000000ffffffffull
450#define XCT_FUNRES_8B_CRC_S 0
451
397/* Control descriptor fields */ 452/* Control descriptor fields */
398#define CTRL_CMD_T 0x8000000000000000ull 453#define CTRL_CMD_T 0x8000000000000000ull
399#define CTRL_CMD_META_EVT 0x2000000000000000ull 454#define CTRL_CMD_META_EVT 0x2000000000000000ull
400#define CTRL_CMD_O 0x0400000000000000ull 455#define CTRL_CMD_O 0x0400000000000000ull
401#define CTRL_CMD_REG_M 0x000000000000000full 456#define CTRL_CMD_ETYPE_M 0x0038000000000000ull
457#define CTRL_CMD_ETYPE_EXT 0x0000000000000000ull
458#define CTRL_CMD_ETYPE_WSET 0x0020000000000000ull
459#define CTRL_CMD_ETYPE_WCLR 0x0028000000000000ull
460#define CTRL_CMD_ETYPE_SET 0x0030000000000000ull
461#define CTRL_CMD_ETYPE_CLR 0x0038000000000000ull
462#define CTRL_CMD_REG_M 0x000000000000007full
402#define CTRL_CMD_REG_S 0 463#define CTRL_CMD_REG_S 0
403#define CTRL_CMD_REG(x) ((((long)(x)) << CTRL_CMD_REG_S) & \ 464#define CTRL_CMD_REG(x) ((((long)(x)) << CTRL_CMD_REG_S) & \
404 CTRL_CMD_REG_M) 465 CTRL_CMD_REG_M)
@@ -461,6 +522,16 @@ extern void *pasemi_dma_alloc_buf(struct pasemi_dmachan *chan, int size,
461extern void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size, 522extern void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size,
462 dma_addr_t *handle); 523 dma_addr_t *handle);
463 524
525/* Routines to allocate flags (events) for channel syncronization */
526extern int pasemi_dma_alloc_flag(void);
527extern void pasemi_dma_free_flag(int flag);
528extern void pasemi_dma_set_flag(int flag);
529extern void pasemi_dma_clear_flag(int flag);
530
531/* Routines to allocate function engines */
532extern int pasemi_dma_alloc_fun(void);
533extern void pasemi_dma_free_fun(int fun);
534
464/* Initialize the library, must be called before any other functions */ 535/* Initialize the library, must be called before any other functions */
465extern int pasemi_dma_init(void); 536extern int pasemi_dma_init(void);
466 537
diff --git a/include/asm-powerpc/pci-bridge.h b/include/asm-powerpc/pci-bridge.h
index e5802c62f428..b95d033ae6e6 100644
--- a/include/asm-powerpc/pci-bridge.h
+++ b/include/asm-powerpc/pci-bridge.h
@@ -117,7 +117,7 @@ struct pci_controller {
117 117
118#ifndef CONFIG_PPC64 118#ifndef CONFIG_PPC64
119 119
120static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus) 120static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
121{ 121{
122 return bus->sysdata; 122 return bus->sysdata;
123} 123}
@@ -235,7 +235,7 @@ extern void pcibios_fixup_new_pci_devices(struct pci_bus *bus);
235 235
236extern int pcibios_remove_root_bus(struct pci_controller *phb); 236extern int pcibios_remove_root_bus(struct pci_controller *phb);
237 237
238static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus) 238static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
239{ 239{
240 struct device_node *busdn = bus->sysdata; 240 struct device_node *busdn = bus->sysdata;
241 241
diff --git a/include/asm-powerpc/pgtable-ppc32.h b/include/asm-powerpc/pgtable-ppc32.h
index 2c79f550272b..7c97b5a08d08 100644
--- a/include/asm-powerpc/pgtable-ppc32.h
+++ b/include/asm-powerpc/pgtable-ppc32.h
@@ -98,9 +98,6 @@ extern int icache_44x_need_flush;
98#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) 98#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
99#define FIRST_USER_ADDRESS 0 99#define FIRST_USER_ADDRESS 0
100 100
101#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
102#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
103
104#define pte_ERROR(e) \ 101#define pte_ERROR(e) \
105 printk("%s:%d: bad pte %llx.\n", __FILE__, __LINE__, \ 102 printk("%s:%d: bad pte %llx.\n", __FILE__, __LINE__, \
106 (unsigned long long)pte_val(e)) 103 (unsigned long long)pte_val(e))
@@ -420,7 +417,8 @@ extern int icache_44x_need_flush;
420#define _PAGE_IO (_PAGE_KERNEL | _PAGE_NO_CACHE | _PAGE_GUARDED) 417#define _PAGE_IO (_PAGE_KERNEL | _PAGE_NO_CACHE | _PAGE_GUARDED)
421#define _PAGE_RAM (_PAGE_KERNEL | _PAGE_HWEXEC) 418#define _PAGE_RAM (_PAGE_KERNEL | _PAGE_HWEXEC)
422 419
423#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) 420#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\
421 defined(CONFIG_KPROBES)
424/* We want the debuggers to be able to set breakpoints anywhere, so 422/* We want the debuggers to be able to set breakpoints anywhere, so
425 * don't write protect the kernel text */ 423 * don't write protect the kernel text */
426#define _PAGE_RAM_TEXT _PAGE_RAM 424#define _PAGE_RAM_TEXT _PAGE_RAM
@@ -506,6 +504,7 @@ static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
506static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 504static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
507static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 505static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
508static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 506static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
507static inline int pte_special(pte_t pte) { return 0; }
509 508
510static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; } 509static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
511static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; } 510static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; }
@@ -523,6 +522,8 @@ static inline pte_t pte_mkdirty(pte_t pte) {
523 pte_val(pte) |= _PAGE_DIRTY; return pte; } 522 pte_val(pte) |= _PAGE_DIRTY; return pte; }
524static inline pte_t pte_mkyoung(pte_t pte) { 523static inline pte_t pte_mkyoung(pte_t pte) {
525 pte_val(pte) |= _PAGE_ACCESSED; return pte; } 524 pte_val(pte) |= _PAGE_ACCESSED; return pte; }
525static inline pte_t pte_mkspecial(pte_t pte) {
526 return pte; }
526 527
527static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 528static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
528{ 529{
@@ -692,7 +693,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
692#define pmd_page_vaddr(pmd) \ 693#define pmd_page_vaddr(pmd) \
693 ((unsigned long) (pmd_val(pmd) & PAGE_MASK)) 694 ((unsigned long) (pmd_val(pmd) & PAGE_MASK))
694#define pmd_page(pmd) \ 695#define pmd_page(pmd) \
695 (mem_map + (__pa(pmd_val(pmd)) >> PAGE_SHIFT)) 696 pfn_to_page((__pa(pmd_val(pmd)) >> PAGE_SHIFT))
696#endif 697#endif
697 698
698/* to find an entry in a kernel page-table-directory */ 699/* to find an entry in a kernel page-table-directory */
diff --git a/include/asm-powerpc/pgtable-ppc64.h b/include/asm-powerpc/pgtable-ppc64.h
index dd4c26dc57d2..27f18695f7d6 100644
--- a/include/asm-powerpc/pgtable-ppc64.h
+++ b/include/asm-powerpc/pgtable-ppc64.h
@@ -239,6 +239,7 @@ static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW;}
239static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;} 239static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;}
240static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;} 240static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;}
241static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;} 241static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;}
242static inline int pte_special(pte_t pte) { return 0; }
242 243
243static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; } 244static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
244static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; } 245static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; }
@@ -257,6 +258,8 @@ static inline pte_t pte_mkyoung(pte_t pte) {
257 pte_val(pte) |= _PAGE_ACCESSED; return pte; } 258 pte_val(pte) |= _PAGE_ACCESSED; return pte; }
258static inline pte_t pte_mkhuge(pte_t pte) { 259static inline pte_t pte_mkhuge(pte_t pte) {
259 return pte; } 260 return pte; }
261static inline pte_t pte_mkspecial(pte_t pte) {
262 return pte; }
260 263
261/* Atomic PTE updates */ 264/* Atomic PTE updates */
262static inline unsigned long pte_update(struct mm_struct *mm, 265static inline unsigned long pte_update(struct mm_struct *mm,
diff --git a/include/asm-powerpc/phyp_dump.h b/include/asm-powerpc/phyp_dump.h
new file mode 100644
index 000000000000..fa74c6c3e106
--- /dev/null
+++ b/include/asm-powerpc/phyp_dump.h
@@ -0,0 +1,47 @@
1/*
2 * Hypervisor-assisted dump
3 *
4 * Linas Vepstas, Manish Ahuja 2008
5 * Copyright 2008 IBM Corp.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef _PPC64_PHYP_DUMP_H
14#define _PPC64_PHYP_DUMP_H
15
16#ifdef CONFIG_PHYP_DUMP
17
18/* The RMR region will be saved for later dumping
19 * whenever the kernel crashes. Set this to 256MB. */
20#define PHYP_DUMP_RMR_START 0x0
21#define PHYP_DUMP_RMR_END (1UL<<28)
22
23struct phyp_dump {
24 /* Memory that is reserved during very early boot. */
25 unsigned long init_reserve_start;
26 unsigned long init_reserve_size;
27 /* cmd line options during boot */
28 unsigned long reserve_bootvar;
29 unsigned long phyp_dump_at_boot;
30 /* Check status during boot if dump supported, active & present*/
31 unsigned long phyp_dump_configured;
32 unsigned long phyp_dump_is_active;
33 /* store cpu & hpte size */
34 unsigned long cpu_state_size;
35 unsigned long hpte_region_size;
36 /* previous scratch area values */
37 unsigned long reserved_scratch_addr;
38 unsigned long reserved_scratch_size;
39};
40
41extern struct phyp_dump *phyp_dump_info;
42
43int early_init_dt_scan_phyp_dump(unsigned long node,
44 const char *uname, int depth, void *data);
45
46#endif /* CONFIG_PHYP_DUMP */
47#endif /* _PPC64_PHYP_DUMP_H */
diff --git a/include/asm-powerpc/pmi.h b/include/asm-powerpc/pmi.h
index 2259d4ce3846..e1dc090748df 100644
--- a/include/asm-powerpc/pmi.h
+++ b/include/asm-powerpc/pmi.h
@@ -29,8 +29,6 @@
29 29
30#ifdef __KERNEL__ 30#ifdef __KERNEL__
31 31
32#include <asm/of_device.h>
33
34#define PMI_TYPE_FREQ_CHANGE 0x01 32#define PMI_TYPE_FREQ_CHANGE 0x01
35#define PMI_READ_TYPE 0 33#define PMI_READ_TYPE 0
36#define PMI_READ_DATA0 1 34#define PMI_READ_DATA0 1
diff --git a/include/asm-powerpc/ppc4xx.h b/include/asm-powerpc/ppc4xx.h
new file mode 100644
index 000000000000..033039a80c42
--- /dev/null
+++ b/include/asm-powerpc/ppc4xx.h
@@ -0,0 +1,18 @@
1/*
2 * PPC4xx Prototypes and definitions
3 *
4 * Copyright 2008 DENX Software Engineering, Stefan Roese <sr@denx.de>
5 *
6 * This is free software; you can redistribute it and/or modify it
7 * 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 */
12
13#ifndef __ASM_POWERPC_PPC4xx_H__
14#define __ASM_POWERPC_PPC4xx_H__
15
16extern void ppc4xx_reset_system(char *cmd);
17
18#endif /* __ASM_POWERPC_PPC4xx_H__ */
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h
index fd98ca998b4f..cf83f2d7e2a5 100644
--- a/include/asm-powerpc/processor.h
+++ b/include/asm-powerpc/processor.h
@@ -138,6 +138,8 @@ typedef struct {
138 138
139struct thread_struct { 139struct thread_struct {
140 unsigned long ksp; /* Kernel stack pointer */ 140 unsigned long ksp; /* Kernel stack pointer */
141 unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
142
141#ifdef CONFIG_PPC64 143#ifdef CONFIG_PPC64
142 unsigned long ksp_vsid; 144 unsigned long ksp_vsid;
143#endif 145#endif
@@ -182,11 +184,14 @@ struct thread_struct {
182#define ARCH_MIN_TASKALIGN 16 184#define ARCH_MIN_TASKALIGN 16
183 185
184#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) 186#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
187#define INIT_SP_LIMIT \
188 (_ALIGN_UP(sizeof(init_thread_info), 16) + (unsigned long) &init_stack)
185 189
186 190
187#ifdef CONFIG_PPC32 191#ifdef CONFIG_PPC32
188#define INIT_THREAD { \ 192#define INIT_THREAD { \
189 .ksp = INIT_SP, \ 193 .ksp = INIT_SP, \
194 .ksp_limit = INIT_SP_LIMIT, \
190 .fs = KERNEL_DS, \ 195 .fs = KERNEL_DS, \
191 .pgdir = swapper_pg_dir, \ 196 .pgdir = swapper_pg_dir, \
192 .fpexc_mode = MSR_FE0 | MSR_FE1, \ 197 .fpexc_mode = MSR_FE0 | MSR_FE1, \
@@ -194,6 +199,7 @@ struct thread_struct {
194#else 199#else
195#define INIT_THREAD { \ 200#define INIT_THREAD { \
196 .ksp = INIT_SP, \ 201 .ksp = INIT_SP, \
202 .ksp_limit = INIT_SP_LIMIT, \
197 .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \ 203 .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
198 .fs = KERNEL_DS, \ 204 .fs = KERNEL_DS, \
199 .fpr = {0}, \ 205 .fpr = {0}, \
diff --git a/include/asm-powerpc/ps3.h b/include/asm-powerpc/ps3.h
index 2b693673eff4..9e8ed6824e15 100644
--- a/include/asm-powerpc/ps3.h
+++ b/include/asm-powerpc/ps3.h
@@ -434,8 +434,11 @@ struct ps3_sys_manager_ops {
434}; 434};
435 435
436void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops); 436void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops);
437void ps3_sys_manager_power_off(void); 437void __noreturn ps3_sys_manager_power_off(void);
438void ps3_sys_manager_restart(void); 438void __noreturn ps3_sys_manager_restart(void);
439void __noreturn ps3_sys_manager_halt(void);
440int ps3_sys_manager_get_wol(void);
441void ps3_sys_manager_set_wol(int state);
439 442
440struct ps3_prealloc { 443struct ps3_prealloc {
441 const char *name; 444 const char *name;
diff --git a/include/asm-powerpc/ptrace.h b/include/asm-powerpc/ptrace.h
index 891d68932f39..39023dde1cc4 100644
--- a/include/asm-powerpc/ptrace.h
+++ b/include/asm-powerpc/ptrace.h
@@ -58,6 +58,11 @@ struct pt_regs {
58#define __ARCH_WANT_COMPAT_SYS_PTRACE 58#define __ARCH_WANT_COMPAT_SYS_PTRACE
59 59
60#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */ 60#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */
61#define STACK_FRAME_LR_SAVE 2 /* Location of LR in stack frame */
62#define STACK_FRAME_REGS_MARKER ASM_CONST(0x7265677368657265)
63#define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + \
64 STACK_FRAME_OVERHEAD + 288)
65#define STACK_FRAME_MARKER 12
61 66
62/* Size of dummy stack frame allocated when calling signal handler. */ 67/* Size of dummy stack frame allocated when calling signal handler. */
63#define __SIGNAL_FRAMESIZE 128 68#define __SIGNAL_FRAMESIZE 128
@@ -66,6 +71,10 @@ struct pt_regs {
66#else /* __powerpc64__ */ 71#else /* __powerpc64__ */
67 72
68#define STACK_FRAME_OVERHEAD 16 /* size of minimum stack frame */ 73#define STACK_FRAME_OVERHEAD 16 /* size of minimum stack frame */
74#define STACK_FRAME_LR_SAVE 1 /* Location of LR in stack frame */
75#define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773)
76#define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)
77#define STACK_FRAME_MARKER 2
69 78
70/* Size of stack frame allocated when calling signal handler. */ 79/* Size of stack frame allocated when calling signal handler. */
71#define __SIGNAL_FRAMESIZE 64 80#define __SIGNAL_FRAMESIZE 64
diff --git a/include/asm-powerpc/qe.h b/include/asm-powerpc/qe.h
index 430dc77b35fc..c3be6e2e1490 100644
--- a/include/asm-powerpc/qe.h
+++ b/include/asm-powerpc/qe.h
@@ -85,6 +85,7 @@ extern int par_io_data_set(u8 port, u8 pin, u8 val);
85/* QE internal API */ 85/* QE internal API */
86int 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);
87enum qe_clock qe_clock_source(const char *source); 87enum qe_clock qe_clock_source(const char *source);
88unsigned int qe_get_brg_clk(void);
88int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier); 89int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier);
89int qe_get_snum(void); 90int qe_get_snum(void);
90void qe_put_snum(u8 snum); 91void qe_put_snum(u8 snum);
@@ -92,7 +93,16 @@ unsigned long qe_muram_alloc(int size, int align);
92int qe_muram_free(unsigned long offset); 93int qe_muram_free(unsigned long offset);
93unsigned long qe_muram_alloc_fixed(unsigned long offset, int size); 94unsigned long qe_muram_alloc_fixed(unsigned long offset, int size);
94void qe_muram_dump(void); 95void qe_muram_dump(void);
95void *qe_muram_addr(unsigned long offset); 96
97static inline void __iomem *qe_muram_addr(unsigned long offset)
98{
99 return (void __iomem *)&qe_immr->muram[offset];
100}
101
102static inline unsigned long qe_muram_offset(void __iomem *addr)
103{
104 return addr - (void __iomem *)qe_immr->muram;
105}
96 106
97/* Structure that defines QE firmware binary files. 107/* Structure that defines QE firmware binary files.
98 * 108 *
diff --git a/include/asm-ppc/rio.h b/include/asm-powerpc/rio.h
index 0018bf80cb25..0018bf80cb25 100644
--- a/include/asm-ppc/rio.h
+++ b/include/asm-powerpc/rio.h
diff --git a/include/asm-powerpc/rwsem.h b/include/asm-powerpc/rwsem.h
index cefc14728cc5..a6cc93b78b98 100644
--- a/include/asm-powerpc/rwsem.h
+++ b/include/asm-powerpc/rwsem.h
@@ -32,11 +32,20 @@ struct rw_semaphore {
32#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) 32#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
33 spinlock_t wait_lock; 33 spinlock_t wait_lock;
34 struct list_head wait_list; 34 struct list_head wait_list;
35#ifdef CONFIG_DEBUG_LOCK_ALLOC
36 struct lockdep_map dep_map;
37#endif
35}; 38};
36 39
40#ifdef CONFIG_DEBUG_LOCK_ALLOC
41# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
42#else
43# define __RWSEM_DEP_MAP_INIT(lockname)
44#endif
45
37#define __RWSEM_INITIALIZER(name) \ 46#define __RWSEM_INITIALIZER(name) \
38 { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \ 47 { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \
39 LIST_HEAD_INIT((name).wait_list) } 48 LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) }
40 49
41#define DECLARE_RWSEM(name) \ 50#define DECLARE_RWSEM(name) \
42 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 51 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
@@ -46,12 +55,15 @@ extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
46extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); 55extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
47extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); 56extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
48 57
49static inline void init_rwsem(struct rw_semaphore *sem) 58extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
50{ 59 struct lock_class_key *key);
51 sem->count = RWSEM_UNLOCKED_VALUE; 60
52 spin_lock_init(&sem->wait_lock); 61#define init_rwsem(sem) \
53 INIT_LIST_HEAD(&sem->wait_list); 62 do { \
54} 63 static struct lock_class_key __key; \
64 \
65 __init_rwsem((sem), #sem, &__key); \
66 } while (0)
55 67
56/* 68/*
57 * lock for reading 69 * lock for reading
@@ -78,7 +90,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
78/* 90/*
79 * lock for writing 91 * lock for writing
80 */ 92 */
81static inline void __down_write(struct rw_semaphore *sem) 93static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
82{ 94{
83 int tmp; 95 int tmp;
84 96
@@ -88,6 +100,11 @@ static inline void __down_write(struct rw_semaphore *sem)
88 rwsem_down_write_failed(sem); 100 rwsem_down_write_failed(sem);
89} 101}
90 102
103static inline void __down_write(struct rw_semaphore *sem)
104{
105 __down_write_nested(sem, 0);
106}
107
91static inline int __down_write_trylock(struct rw_semaphore *sem) 108static inline int __down_write_trylock(struct rw_semaphore *sem)
92{ 109{
93 int tmp; 110 int tmp;
diff --git a/include/asm-powerpc/semaphore.h b/include/asm-powerpc/semaphore.h
index 48dd32e07749..d9b2034ed1d2 100644
--- a/include/asm-powerpc/semaphore.h
+++ b/include/asm-powerpc/semaphore.h
@@ -1,94 +1 @@
1#ifndef _ASM_POWERPC_SEMAPHORE_H #include <linux/semaphore.h>
2#define _ASM_POWERPC_SEMAPHORE_H
3
4/*
5 * Remove spinlock-based RW semaphores; RW semaphore definitions are
6 * now in rwsem.h and we use the generic lib/rwsem.c implementation.
7 * Rework semaphores to use atomic_dec_if_positive.
8 * -- Paul Mackerras (paulus@samba.org)
9 */
10
11#ifdef __KERNEL__
12
13#include <asm/atomic.h>
14#include <asm/system.h>
15#include <linux/wait.h>
16#include <linux/rwsem.h>
17
18struct semaphore {
19 /*
20 * Note that any negative value of count is equivalent to 0,
21 * but additionally indicates that some process(es) might be
22 * sleeping on `wait'.
23 */
24 atomic_t count;
25 wait_queue_head_t wait;
26};
27
28#define __SEMAPHORE_INITIALIZER(name, n) \
29{ \
30 .count = ATOMIC_INIT(n), \
31 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
32}
33
34#define __DECLARE_SEMAPHORE_GENERIC(name, count) \
35 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
36
37#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
38
39static inline void sema_init (struct semaphore *sem, int val)
40{
41 atomic_set(&sem->count, val);
42 init_waitqueue_head(&sem->wait);
43}
44
45static inline void init_MUTEX (struct semaphore *sem)
46{
47 sema_init(sem, 1);
48}
49
50static inline void init_MUTEX_LOCKED (struct semaphore *sem)
51{
52 sema_init(sem, 0);
53}
54
55extern void __down(struct semaphore * sem);
56extern int __down_interruptible(struct semaphore * sem);
57extern void __up(struct semaphore * sem);
58
59static inline void down(struct semaphore * sem)
60{
61 might_sleep();
62
63 /*
64 * Try to get the semaphore, take the slow path if we fail.
65 */
66 if (unlikely(atomic_dec_return(&sem->count) < 0))
67 __down(sem);
68}
69
70static inline int down_interruptible(struct semaphore * sem)
71{
72 int ret = 0;
73
74 might_sleep();
75
76 if (unlikely(atomic_dec_return(&sem->count) < 0))
77 ret = __down_interruptible(sem);
78 return ret;
79}
80
81static inline int down_trylock(struct semaphore * sem)
82{
83 return atomic_dec_if_positive(&sem->count) < 0;
84}
85
86static inline void up(struct semaphore * sem)
87{
88 if (unlikely(atomic_inc_return(&sem->count) <= 0))
89 __up(sem);
90}
91
92#endif /* __KERNEL__ */
93
94#endif /* _ASM_POWERPC_SEMAPHORE_H */
diff --git a/include/asm-powerpc/sparsemem.h b/include/asm-powerpc/sparsemem.h
index e8b493d52b4f..9aea8e9f0bd1 100644
--- a/include/asm-powerpc/sparsemem.h
+++ b/include/asm-powerpc/sparsemem.h
@@ -15,6 +15,7 @@
15 15
16#ifdef CONFIG_MEMORY_HOTPLUG 16#ifdef CONFIG_MEMORY_HOTPLUG
17extern void create_section_mapping(unsigned long start, unsigned long end); 17extern void create_section_mapping(unsigned long start, unsigned long end);
18extern int remove_section_mapping(unsigned long start, unsigned long end);
18#ifdef CONFIG_NUMA 19#ifdef CONFIG_NUMA
19extern int hot_add_scn_to_nid(unsigned long scn_addr); 20extern int hot_add_scn_to_nid(unsigned long scn_addr);
20#else 21#else
diff --git a/include/asm-powerpc/spinlock.h b/include/asm-powerpc/spinlock.h
index cc4cfceac67c..258c93993190 100644
--- a/include/asm-powerpc/spinlock.h
+++ b/include/asm-powerpc/spinlock.h
@@ -19,6 +19,7 @@
19 * 19 *
20 * (the type definitions are in asm/spinlock_types.h) 20 * (the type definitions are in asm/spinlock_types.h)
21 */ 21 */
22#include <linux/irqflags.h>
22#ifdef CONFIG_PPC64 23#ifdef CONFIG_PPC64
23#include <asm/paca.h> 24#include <asm/paca.h>
24#include <asm/hvcall.h> 25#include <asm/hvcall.h>
diff --git a/include/asm-powerpc/string.h b/include/asm-powerpc/string.h
index aa40f92c298d..e40010abcaf1 100644
--- a/include/asm-powerpc/string.h
+++ b/include/asm-powerpc/string.h
@@ -7,6 +7,7 @@
7#define __HAVE_ARCH_STRNCPY 7#define __HAVE_ARCH_STRNCPY
8#define __HAVE_ARCH_STRLEN 8#define __HAVE_ARCH_STRLEN
9#define __HAVE_ARCH_STRCMP 9#define __HAVE_ARCH_STRCMP
10#define __HAVE_ARCH_STRNCMP
10#define __HAVE_ARCH_STRCAT 11#define __HAVE_ARCH_STRCAT
11#define __HAVE_ARCH_MEMSET 12#define __HAVE_ARCH_MEMSET
12#define __HAVE_ARCH_MEMCPY 13#define __HAVE_ARCH_MEMCPY
@@ -18,6 +19,7 @@ extern char * strcpy(char *,const char *);
18extern char * strncpy(char *,const char *, __kernel_size_t); 19extern char * strncpy(char *,const char *, __kernel_size_t);
19extern __kernel_size_t strlen(const char *); 20extern __kernel_size_t strlen(const char *);
20extern int strcmp(const char *,const char *); 21extern int strcmp(const char *,const char *);
22extern int strncmp(const char *, const char *, __kernel_size_t);
21extern char * strcat(char *, const char *); 23extern char * strcat(char *, const char *);
22extern void * memset(void *,int,__kernel_size_t); 24extern void * memset(void *,int,__kernel_size_t);
23extern void * memcpy(void *,const void *,__kernel_size_t); 25extern void * memcpy(void *,const void *,__kernel_size_t);
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index 29552ff182aa..2b6559a6d113 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -5,6 +5,7 @@
5#define _ASM_POWERPC_SYSTEM_H 5#define _ASM_POWERPC_SYSTEM_H
6 6
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/irqflags.h>
8 9
9#include <asm/hw_irq.h> 10#include <asm/hw_irq.h>
10 11
@@ -203,7 +204,7 @@ extern int powersave_nap; /* set if nap mode can be used in idle loop */
203 * Changes the memory location '*ptr' to be val and returns 204 * Changes the memory location '*ptr' to be val and returns
204 * the previous value stored there. 205 * the previous value stored there.
205 */ 206 */
206static __inline__ unsigned long 207static __always_inline unsigned long
207__xchg_u32(volatile void *p, unsigned long val) 208__xchg_u32(volatile void *p, unsigned long val)
208{ 209{
209 unsigned long prev; 210 unsigned long prev;
@@ -228,7 +229,7 @@ __xchg_u32(volatile void *p, unsigned long val)
228 * Changes the memory location '*ptr' to be val and returns 229 * Changes the memory location '*ptr' to be val and returns
229 * the previous value stored there. 230 * the previous value stored there.
230 */ 231 */
231static __inline__ unsigned long 232static __always_inline unsigned long
232__xchg_u32_local(volatile void *p, unsigned long val) 233__xchg_u32_local(volatile void *p, unsigned long val)
233{ 234{
234 unsigned long prev; 235 unsigned long prev;
@@ -246,7 +247,7 @@ __xchg_u32_local(volatile void *p, unsigned long val)
246} 247}
247 248
248#ifdef CONFIG_PPC64 249#ifdef CONFIG_PPC64
249static __inline__ unsigned long 250static __always_inline unsigned long
250__xchg_u64(volatile void *p, unsigned long val) 251__xchg_u64(volatile void *p, unsigned long val)
251{ 252{
252 unsigned long prev; 253 unsigned long prev;
@@ -265,7 +266,7 @@ __xchg_u64(volatile void *p, unsigned long val)
265 return prev; 266 return prev;
266} 267}
267 268
268static __inline__ unsigned long 269static __always_inline unsigned long
269__xchg_u64_local(volatile void *p, unsigned long val) 270__xchg_u64_local(volatile void *p, unsigned long val)
270{ 271{
271 unsigned long prev; 272 unsigned long prev;
@@ -289,7 +290,7 @@ __xchg_u64_local(volatile void *p, unsigned long val)
289 */ 290 */
290extern void __xchg_called_with_bad_pointer(void); 291extern void __xchg_called_with_bad_pointer(void);
291 292
292static __inline__ unsigned long 293static __always_inline unsigned long
293__xchg(volatile void *ptr, unsigned long x, unsigned int size) 294__xchg(volatile void *ptr, unsigned long x, unsigned int size)
294{ 295{
295 switch (size) { 296 switch (size) {
@@ -304,7 +305,7 @@ __xchg(volatile void *ptr, unsigned long x, unsigned int size)
304 return x; 305 return x;
305} 306}
306 307
307static __inline__ unsigned long 308static __always_inline unsigned long
308__xchg_local(volatile void *ptr, unsigned long x, unsigned int size) 309__xchg_local(volatile void *ptr, unsigned long x, unsigned int size)
309{ 310{
310 switch (size) { 311 switch (size) {
@@ -337,7 +338,7 @@ __xchg_local(volatile void *ptr, unsigned long x, unsigned int size)
337 */ 338 */
338#define __HAVE_ARCH_CMPXCHG 1 339#define __HAVE_ARCH_CMPXCHG 1
339 340
340static __inline__ unsigned long 341static __always_inline unsigned long
341__cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new) 342__cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new)
342{ 343{
343 unsigned int prev; 344 unsigned int prev;
@@ -360,7 +361,7 @@ __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new)
360 return prev; 361 return prev;
361} 362}
362 363
363static __inline__ unsigned long 364static __always_inline unsigned long
364__cmpxchg_u32_local(volatile unsigned int *p, unsigned long old, 365__cmpxchg_u32_local(volatile unsigned int *p, unsigned long old,
365 unsigned long new) 366 unsigned long new)
366{ 367{
@@ -383,7 +384,7 @@ __cmpxchg_u32_local(volatile unsigned int *p, unsigned long old,
383} 384}
384 385
385#ifdef CONFIG_PPC64 386#ifdef CONFIG_PPC64
386static __inline__ unsigned long 387static __always_inline unsigned long
387__cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new) 388__cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new)
388{ 389{
389 unsigned long prev; 390 unsigned long prev;
@@ -405,7 +406,7 @@ __cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new)
405 return prev; 406 return prev;
406} 407}
407 408
408static __inline__ unsigned long 409static __always_inline unsigned long
409__cmpxchg_u64_local(volatile unsigned long *p, unsigned long old, 410__cmpxchg_u64_local(volatile unsigned long *p, unsigned long old,
410 unsigned long new) 411 unsigned long new)
411{ 412{
@@ -431,7 +432,7 @@ __cmpxchg_u64_local(volatile unsigned long *p, unsigned long old,
431 if something tries to do an invalid cmpxchg(). */ 432 if something tries to do an invalid cmpxchg(). */
432extern void __cmpxchg_called_with_bad_pointer(void); 433extern void __cmpxchg_called_with_bad_pointer(void);
433 434
434static __inline__ unsigned long 435static __always_inline unsigned long
435__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, 436__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new,
436 unsigned int size) 437 unsigned int size)
437{ 438{
@@ -447,7 +448,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new,
447 return old; 448 return old;
448} 449}
449 450
450static __inline__ unsigned long 451static __always_inline unsigned long
451__cmpxchg_local(volatile void *ptr, unsigned long old, unsigned long new, 452__cmpxchg_local(volatile void *ptr, unsigned long old, unsigned long new,
452 unsigned int size) 453 unsigned int size)
453{ 454{
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index 40d5f98c44fc..d030f5ce39ad 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -80,12 +80,8 @@ struct thread_info {
80 80
81#else /* THREAD_SHIFT < PAGE_SHIFT */ 81#else /* THREAD_SHIFT < PAGE_SHIFT */
82 82
83#ifdef CONFIG_DEBUG_STACK_USAGE 83extern struct thread_info *alloc_thread_info(struct task_struct *tsk);
84#define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL) 84extern void free_thread_info(struct thread_info *ti);
85#else
86#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
87#endif
88#define free_thread_info(ti) kfree(ti)
89 85
90#endif /* THREAD_SHIFT < PAGE_SHIFT */ 86#endif /* THREAD_SHIFT < PAGE_SHIFT */
91 87
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h
index ca23b681ad05..100c6fbfc587 100644
--- a/include/asm-powerpc/topology.h
+++ b/include/asm-powerpc/topology.h
@@ -96,11 +96,10 @@ static inline void sysfs_remove_device_from_node(struct sys_device *dev,
96{ 96{
97} 97}
98 98
99#endif /* CONFIG_NUMA */
99 100
100#include <asm-generic/topology.h> 101#include <asm-generic/topology.h>
101 102
102#endif /* CONFIG_NUMA */
103
104#ifdef CONFIG_SMP 103#ifdef CONFIG_SMP
105#include <asm/cputable.h> 104#include <asm/cputable.h>
106#define smt_capable() (cpu_has_feature(CPU_FTR_SMT)) 105#define smt_capable() (cpu_has_feature(CPU_FTR_SMT))
diff --git a/include/asm-powerpc/types.h b/include/asm-powerpc/types.h
index 903fd1932436..c243a6ac60e5 100644
--- a/include/asm-powerpc/types.h
+++ b/include/asm-powerpc/types.h
@@ -84,6 +84,13 @@ typedef unsigned long long u64;
84 84
85typedef __vector128 vector128; 85typedef __vector128 vector128;
86 86
87/* Physical address used by some IO functions */
88#if defined(CONFIG_PPC64) || defined(CONFIG_PHYS_64BIT)
89typedef u64 phys_addr_t;
90#else
91typedef u32 phys_addr_t;
92#endif
93
87#ifdef __powerpc64__ 94#ifdef __powerpc64__
88typedef u64 dma_addr_t; 95typedef u64 dma_addr_t;
89#else 96#else
diff --git a/include/asm-powerpc/unaligned.h b/include/asm-powerpc/unaligned.h
index 6c95dfa2652f..5f1b1e3c2137 100644
--- a/include/asm-powerpc/unaligned.h
+++ b/include/asm-powerpc/unaligned.h
@@ -5,15 +5,12 @@
5 5
6/* 6/*
7 * The PowerPC can do unaligned accesses itself in big endian mode. 7 * The PowerPC can do unaligned accesses itself in big endian mode.
8 *
9 * The strange macros are there to make sure these can't
10 * be misused in a way that makes them not work on other
11 * architectures where unaligned accesses aren't as simple.
12 */ 8 */
9#include <linux/unaligned/access_ok.h>
10#include <linux/unaligned/generic.h>
13 11
14#define get_unaligned(ptr) (*(ptr)) 12#define get_unaligned __get_unaligned_be
15 13#define put_unaligned __put_unaligned_be
16#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
17 14
18#endif /* __KERNEL__ */ 15#endif /* __KERNEL__ */
19#endif /* _ASM_POWERPC_UNALIGNED_H */ 16#endif /* _ASM_POWERPC_UNALIGNED_H */
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h
index d46b57b589ae..d76ef098ed37 100644
--- a/include/asm-ppc/mmu.h
+++ b/include/asm-ppc/mmu.h
@@ -15,10 +15,8 @@
15 * physical need a larger than native word size type. -Matt 15 * physical need a larger than native word size type. -Matt
16 */ 16 */
17#ifndef CONFIG_PHYS_64BIT 17#ifndef CONFIG_PHYS_64BIT
18typedef unsigned long phys_addr_t;
19#define PHYS_FMT "%.8lx" 18#define PHYS_FMT "%.8lx"
20#else 19#else
21typedef unsigned long long phys_addr_t;
22extern phys_addr_t fixup_bigphys_addr(phys_addr_t, phys_addr_t); 20extern phys_addr_t fixup_bigphys_addr(phys_addr_t, phys_addr_t);
23#define PHYS_FMT "%16Lx" 21#define PHYS_FMT "%16Lx"
24#endif 22#endif
diff --git a/include/asm-ppc/mpc8260.h b/include/asm-ppc/mpc8260.h
index 23579d4afae7..402ba15c2e80 100644
--- a/include/asm-ppc/mpc8260.h
+++ b/include/asm-ppc/mpc8260.h
@@ -35,10 +35,6 @@
35#include <platforms/tqm8260.h> 35#include <platforms/tqm8260.h>
36#endif 36#endif
37 37
38#if defined(CONFIG_PQ2ADS) || defined (CONFIG_PQ2FADS)
39#include <platforms/pq2ads.h>
40#endif
41
42#ifdef CONFIG_PCI_8260 38#ifdef CONFIG_PCI_8260
43#include <syslib/m82xx_pci.h> 39#include <syslib/m82xx_pci.h>
44#endif 40#endif
diff --git a/include/asm-ppc/mpc8xx.h b/include/asm-ppc/mpc8xx.h
index d3a2f2fe230c..b9e3060b0278 100644
--- a/include/asm-ppc/mpc8xx.h
+++ b/include/asm-ppc/mpc8xx.h
@@ -63,10 +63,6 @@
63#include <platforms/lantec.h> 63#include <platforms/lantec.h>
64#endif 64#endif
65 65
66#if defined(CONFIG_MPC885ADS)
67#include <platforms/mpc885ads.h>
68#endif
69
70/* Currently, all 8xx boards that support a processor to PCI/ISA bridge 66/* Currently, all 8xx boards that support a processor to PCI/ISA bridge
71 * use the same memory map. 67 * use the same memory map.
72 */ 68 */
diff --git a/include/asm-ppc/ocp.h b/include/asm-ppc/ocp.h
index 1379a4f76de3..3909a2eec286 100644
--- a/include/asm-ppc/ocp.h
+++ b/include/asm-ppc/ocp.h
@@ -31,7 +31,6 @@
31 31
32#include <asm/mmu.h> 32#include <asm/mmu.h>
33#include <asm/ocp_ids.h> 33#include <asm/ocp_ids.h>
34#include <asm/semaphore.h>
35 34
36#ifdef CONFIG_PPC_OCP 35#ifdef CONFIG_PPC_OCP
37 36
diff --git a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
index 70435d32129a..55f9d38e3bf8 100644
--- a/include/asm-ppc/pgtable.h
+++ b/include/asm-ppc/pgtable.h
@@ -483,6 +483,7 @@ static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
483static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 483static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
484static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 484static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
485static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 485static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
486static inline int pte_special(pte_t pte) { return 0; }
486 487
487static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; } 488static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
488static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; } 489static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; }
@@ -500,6 +501,8 @@ static inline pte_t pte_mkdirty(pte_t pte) {
500 pte_val(pte) |= _PAGE_DIRTY; return pte; } 501 pte_val(pte) |= _PAGE_DIRTY; return pte; }
501static inline pte_t pte_mkyoung(pte_t pte) { 502static inline pte_t pte_mkyoung(pte_t pte) {
502 pte_val(pte) |= _PAGE_ACCESSED; return pte; } 503 pte_val(pte) |= _PAGE_ACCESSED; return pte; }
504static inline pte_t pte_mkspecial(pte_t pte) {
505 return pte; }
503 506
504static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 507static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
505{ 508{
diff --git a/include/asm-s390/Kbuild b/include/asm-s390/Kbuild
index e92b429d2be1..13c9805349f1 100644
--- a/include/asm-s390/Kbuild
+++ b/include/asm-s390/Kbuild
@@ -7,6 +7,7 @@ header-y += tape390.h
7header-y += ucontext.h 7header-y += ucontext.h
8header-y += vtoc.h 8header-y += vtoc.h
9header-y += zcrypt.h 9header-y += zcrypt.h
10header-y += kvm.h
10 11
11unifdef-y += cmb.h 12unifdef-y += cmb.h
12unifdef-y += debug.h 13unifdef-y += debug.h
diff --git a/include/asm-s390/bitops.h b/include/asm-s390/bitops.h
index 965394e69452..b4eb24ab5af9 100644
--- a/include/asm-s390/bitops.h
+++ b/include/asm-s390/bitops.h
@@ -769,6 +769,7 @@ static inline int sched_find_first_bit(unsigned long *b)
769} 769}
770 770
771#include <asm-generic/bitops/fls.h> 771#include <asm-generic/bitops/fls.h>
772#include <asm-generic/bitops/__fls.h>
772#include <asm-generic/bitops/fls64.h> 773#include <asm-generic/bitops/fls64.h>
773 774
774#include <asm-generic/bitops/hweight.h> 775#include <asm-generic/bitops/hweight.h>
diff --git a/include/asm-s390/ccwgroup.h b/include/asm-s390/ccwgroup.h
index 289053ef5e60..a27f68985a79 100644
--- a/include/asm-s390/ccwgroup.h
+++ b/include/asm-s390/ccwgroup.h
@@ -57,10 +57,9 @@ struct ccwgroup_driver {
57 57
58extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver); 58extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver);
59extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver); 59extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
60extern int ccwgroup_create (struct device *root, 60int ccwgroup_create_from_string(struct device *root, unsigned int creator_id,
61 unsigned int creator_id, 61 struct ccw_driver *cdrv, int num_devices,
62 struct ccw_driver *gdrv, 62 const char *buf);
63 int argc, char *argv[]);
64 63
65extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev); 64extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
66extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev); 65extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
diff --git a/include/asm-s390/cio.h b/include/asm-s390/cio.h
index 123b557c3ff4..0818ecd30ca6 100644
--- a/include/asm-s390/cio.h
+++ b/include/asm-s390/cio.h
@@ -397,6 +397,10 @@ struct cio_iplinfo {
397 397
398extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo); 398extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
399 399
400/* Function from drivers/s390/cio/chsc.c */
401int chsc_sstpc(void *page, unsigned int op, u16 ctrl);
402int chsc_sstpi(void *page, void *result, size_t size);
403
400#endif 404#endif
401 405
402#endif 406#endif
diff --git a/include/asm-s390/cpu.h b/include/asm-s390/cpu.h
index 352dde194f3c..e5a6a9ba3adf 100644
--- a/include/asm-s390/cpu.h
+++ b/include/asm-s390/cpu.h
@@ -22,4 +22,12 @@ struct s390_idle_data {
22 22
23DECLARE_PER_CPU(struct s390_idle_data, s390_idle); 23DECLARE_PER_CPU(struct s390_idle_data, s390_idle);
24 24
25void s390_idle_leave(void);
26
27static inline void s390_idle_check(void)
28{
29 if ((&__get_cpu_var(s390_idle))->in_idle)
30 s390_idle_leave();
31}
32
25#endif /* _ASM_S390_CPU_H_ */ 33#endif /* _ASM_S390_CPU_H_ */
diff --git a/include/asm-s390/debug.h b/include/asm-s390/debug.h
index c00dd2b3dc50..335baf4fc64f 100644
--- a/include/asm-s390/debug.h
+++ b/include/asm-s390/debug.h
@@ -73,6 +73,7 @@ typedef struct debug_info {
73 struct dentry* debugfs_entries[DEBUG_MAX_VIEWS]; 73 struct dentry* debugfs_entries[DEBUG_MAX_VIEWS];
74 struct debug_view* views[DEBUG_MAX_VIEWS]; 74 struct debug_view* views[DEBUG_MAX_VIEWS];
75 char name[DEBUG_MAX_NAME_LEN]; 75 char name[DEBUG_MAX_NAME_LEN];
76 mode_t mode;
76} debug_info_t; 77} debug_info_t;
77 78
78typedef int (debug_header_proc_t) (debug_info_t* id, 79typedef int (debug_header_proc_t) (debug_info_t* id,
@@ -122,6 +123,10 @@ debug_entry_t* debug_exception_common(debug_info_t* id, int level,
122debug_info_t* debug_register(char* name, int pages, int nr_areas, 123debug_info_t* debug_register(char* name, int pages, int nr_areas,
123 int buf_size); 124 int buf_size);
124 125
126debug_info_t *debug_register_mode(char *name, int pages, int nr_areas,
127 int buf_size, mode_t mode, uid_t uid,
128 gid_t gid);
129
125void debug_unregister(debug_info_t* id); 130void debug_unregister(debug_info_t* id);
126 131
127void debug_set_level(debug_info_t* id, int new_level); 132void debug_set_level(debug_info_t* id, int new_level);
diff --git a/include/asm-s390/extmem.h b/include/asm-s390/extmem.h
index c8802c934b74..33837d756184 100644
--- a/include/asm-s390/extmem.h
+++ b/include/asm-s390/extmem.h
@@ -22,11 +22,12 @@
22#define SEGMENT_SHARED 0 22#define SEGMENT_SHARED 0
23#define SEGMENT_EXCLUSIVE 1 23#define SEGMENT_EXCLUSIVE 1
24 24
25extern int segment_load (char *name,int segtype,unsigned long *addr,unsigned long *length); 25int segment_load (char *name, int segtype, unsigned long *addr, unsigned long *length);
26extern void segment_unload(char *name); 26void segment_unload(char *name);
27extern void segment_save(char *name); 27void segment_save(char *name);
28extern int segment_type (char* name); 28int segment_type (char* name);
29extern int segment_modify_shared (char *name, int do_nonshared); 29int segment_modify_shared (char *name, int do_nonshared);
30void segment_warning(int rc, char *seg_name);
30 31
31#endif 32#endif
32#endif 33#endif
diff --git a/include/asm-s390/hardirq.h b/include/asm-s390/hardirq.h
index 31beb18cb3d1..4b7cb964ff35 100644
--- a/include/asm-s390/hardirq.h
+++ b/include/asm-s390/hardirq.h
@@ -32,6 +32,6 @@ typedef struct {
32 32
33#define HARDIRQ_BITS 8 33#define HARDIRQ_BITS 8
34 34
35extern void account_ticks(u64 time); 35void clock_comparator_work(void);
36 36
37#endif /* __ASM_HARDIRQ_H */ 37#endif /* __ASM_HARDIRQ_H */
diff --git a/include/asm-s390/hugetlb.h b/include/asm-s390/hugetlb.h
new file mode 100644
index 000000000000..600a776f8f75
--- /dev/null
+++ b/include/asm-s390/hugetlb.h
@@ -0,0 +1,183 @@
1/*
2 * IBM System z Huge TLB Page Support for Kernel.
3 *
4 * Copyright IBM Corp. 2008
5 * Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
6 */
7
8#ifndef _ASM_S390_HUGETLB_H
9#define _ASM_S390_HUGETLB_H
10
11#include <asm/page.h>
12#include <asm/pgtable.h>
13
14
15#define is_hugepage_only_range(mm, addr, len) 0
16#define hugetlb_free_pgd_range free_pgd_range
17
18void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
19 pte_t *ptep, pte_t pte);
20
21/*
22 * If the arch doesn't supply something else, assume that hugepage
23 * size aligned regions are ok without further preparation.
24 */
25static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
26{
27 if (len & ~HPAGE_MASK)
28 return -EINVAL;
29 if (addr & ~HPAGE_MASK)
30 return -EINVAL;
31 return 0;
32}
33
34#define hugetlb_prefault_arch_hook(mm) do { } while (0)
35
36int arch_prepare_hugepage(struct page *page);
37void arch_release_hugepage(struct page *page);
38
39static inline pte_t pte_mkhuge(pte_t pte)
40{
41 /*
42 * PROT_NONE needs to be remapped from the pte type to the ste type.
43 * The HW invalid bit is also different for pte and ste. The pte
44 * invalid bit happens to be the same as the ste _SEGMENT_ENTRY_LARGE
45 * bit, so we don't have to clear it.
46 */
47 if (pte_val(pte) & _PAGE_INVALID) {
48 if (pte_val(pte) & _PAGE_SWT)
49 pte_val(pte) |= _HPAGE_TYPE_NONE;
50 pte_val(pte) |= _SEGMENT_ENTRY_INV;
51 }
52 /*
53 * Clear SW pte bits SWT and SWX, there are no SW bits in a segment
54 * table entry.
55 */
56 pte_val(pte) &= ~(_PAGE_SWT | _PAGE_SWX);
57 /*
58 * Also set the change-override bit because we don't need dirty bit
59 * tracking for hugetlbfs pages.
60 */
61 pte_val(pte) |= (_SEGMENT_ENTRY_LARGE | _SEGMENT_ENTRY_CO);
62 return pte;
63}
64
65static inline pte_t huge_pte_wrprotect(pte_t pte)
66{
67 pte_val(pte) |= _PAGE_RO;
68 return pte;
69}
70
71static inline int huge_pte_none(pte_t pte)
72{
73 return (pte_val(pte) & _SEGMENT_ENTRY_INV) &&
74 !(pte_val(pte) & _SEGMENT_ENTRY_RO);
75}
76
77static inline pte_t huge_ptep_get(pte_t *ptep)
78{
79 pte_t pte = *ptep;
80 unsigned long mask;
81
82 if (!MACHINE_HAS_HPAGE) {
83 ptep = (pte_t *) (pte_val(pte) & _SEGMENT_ENTRY_ORIGIN);
84 if (ptep) {
85 mask = pte_val(pte) &
86 (_SEGMENT_ENTRY_INV | _SEGMENT_ENTRY_RO);
87 pte = pte_mkhuge(*ptep);
88 pte_val(pte) |= mask;
89 }
90 }
91 return pte;
92}
93
94static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
95 unsigned long addr, pte_t *ptep)
96{
97 pte_t pte = huge_ptep_get(ptep);
98
99 pmd_clear((pmd_t *) ptep);
100 return pte;
101}
102
103static inline void __pmd_csp(pmd_t *pmdp)
104{
105 register unsigned long reg2 asm("2") = pmd_val(*pmdp);
106 register unsigned long reg3 asm("3") = pmd_val(*pmdp) |
107 _SEGMENT_ENTRY_INV;
108 register unsigned long reg4 asm("4") = ((unsigned long) pmdp) + 5;
109
110 asm volatile(
111 " csp %1,%3"
112 : "=m" (*pmdp)
113 : "d" (reg2), "d" (reg3), "d" (reg4), "m" (*pmdp) : "cc");
114 pmd_val(*pmdp) = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY;
115}
116
117static inline void __pmd_idte(unsigned long address, pmd_t *pmdp)
118{
119 unsigned long sto = (unsigned long) pmdp -
120 pmd_index(address) * sizeof(pmd_t);
121
122 if (!(pmd_val(*pmdp) & _SEGMENT_ENTRY_INV)) {
123 asm volatile(
124 " .insn rrf,0xb98e0000,%2,%3,0,0"
125 : "=m" (*pmdp)
126 : "m" (*pmdp), "a" (sto),
127 "a" ((address & HPAGE_MASK))
128 );
129 }
130 pmd_val(*pmdp) = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY;
131}
132
133static inline void huge_ptep_invalidate(struct mm_struct *mm,
134 unsigned long address, pte_t *ptep)
135{
136 pmd_t *pmdp = (pmd_t *) ptep;
137
138 if (!MACHINE_HAS_IDTE) {
139 __pmd_csp(pmdp);
140 if (mm->context.noexec) {
141 pmdp = get_shadow_table(pmdp);
142 __pmd_csp(pmdp);
143 }
144 return;
145 }
146
147 __pmd_idte(address, pmdp);
148 if (mm->context.noexec) {
149 pmdp = get_shadow_table(pmdp);
150 __pmd_idte(address, pmdp);
151 }
152 return;
153}
154
155#define huge_ptep_set_access_flags(__vma, __addr, __ptep, __entry, __dirty) \
156({ \
157 int __changed = !pte_same(huge_ptep_get(__ptep), __entry); \
158 if (__changed) { \
159 huge_ptep_invalidate((__vma)->vm_mm, __addr, __ptep); \
160 set_huge_pte_at((__vma)->vm_mm, __addr, __ptep, __entry); \
161 } \
162 __changed; \
163})
164
165#define huge_ptep_set_wrprotect(__mm, __addr, __ptep) \
166({ \
167 pte_t __pte = huge_ptep_get(__ptep); \
168 if (pte_write(__pte)) { \
169 if (atomic_read(&(__mm)->mm_users) > 1 || \
170 (__mm) != current->active_mm) \
171 huge_ptep_invalidate(__mm, __addr, __ptep); \
172 set_huge_pte_at(__mm, __addr, __ptep, \
173 huge_pte_wrprotect(__pte)); \
174 } \
175})
176
177static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
178 unsigned long address, pte_t *ptep)
179{
180 huge_ptep_invalidate(vma->vm_mm, address, ptep);
181}
182
183#endif /* _ASM_S390_HUGETLB_H */
diff --git a/include/asm-s390/kvm.h b/include/asm-s390/kvm.h
index 573f2a351386..d74002f95794 100644
--- a/include/asm-s390/kvm.h
+++ b/include/asm-s390/kvm.h
@@ -1,6 +1,45 @@
1#ifndef __LINUX_KVM_S390_H 1#ifndef __LINUX_KVM_S390_H
2#define __LINUX_KVM_S390_H 2#define __LINUX_KVM_S390_H
3 3
4/* s390 does not support KVM */ 4/*
5 * asm-s390/kvm.h - KVM s390 specific structures and definitions
6 *
7 * Copyright IBM Corp. 2008
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 only)
11 * as published by the Free Software Foundation.
12 *
13 * Author(s): Carsten Otte <cotte@de.ibm.com>
14 * Christian Borntraeger <borntraeger@de.ibm.com>
15 */
16#include <asm/types.h>
17
18/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
19struct kvm_pic_state {
20 /* no PIC for s390 */
21};
22
23struct kvm_ioapic_state {
24 /* no IOAPIC for s390 */
25};
26
27/* for KVM_GET_REGS and KVM_SET_REGS */
28struct kvm_regs {
29 /* general purpose regs for s390 */
30 __u64 gprs[16];
31};
32
33/* for KVM_GET_SREGS and KVM_SET_SREGS */
34struct kvm_sregs {
35 __u32 acrs[16];
36 __u64 crs[16];
37};
38
39/* for KVM_GET_FPU and KVM_SET_FPU */
40struct kvm_fpu {
41 __u32 fpc;
42 __u64 fprs[16];
43};
5 44
6#endif 45#endif
diff --git a/include/asm-s390/kvm_host.h b/include/asm-s390/kvm_host.h
new file mode 100644
index 000000000000..f8204a4f2e02
--- /dev/null
+++ b/include/asm-s390/kvm_host.h
@@ -0,0 +1,234 @@
1/*
2 * asm-s390/kvm_host.h - definition for kernel virtual machines on s390
3 *
4 * Copyright IBM Corp. 2008
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 only)
8 * as published by the Free Software Foundation.
9 *
10 * Author(s): Carsten Otte <cotte@de.ibm.com>
11 */
12
13
14#ifndef ASM_KVM_HOST_H
15#define ASM_KVM_HOST_H
16#include <linux/kvm_host.h>
17#include <asm/debug.h>
18
19#define KVM_MAX_VCPUS 64
20#define KVM_MEMORY_SLOTS 32
21/* memory slots that does not exposed to userspace */
22#define KVM_PRIVATE_MEM_SLOTS 4
23
24struct kvm_guest_debug {
25};
26
27struct sca_entry {
28 atomic_t scn;
29 __u64 reserved;
30 __u64 sda;
31 __u64 reserved2[2];
32} __attribute__((packed));
33
34
35struct sca_block {
36 __u64 ipte_control;
37 __u64 reserved[5];
38 __u64 mcn;
39 __u64 reserved2;
40 struct sca_entry cpu[64];
41} __attribute__((packed));
42
43#define KVM_PAGES_PER_HPAGE 256
44
45#define CPUSTAT_HOST 0x80000000
46#define CPUSTAT_WAIT 0x10000000
47#define CPUSTAT_ECALL_PEND 0x08000000
48#define CPUSTAT_STOP_INT 0x04000000
49#define CPUSTAT_IO_INT 0x02000000
50#define CPUSTAT_EXT_INT 0x01000000
51#define CPUSTAT_RUNNING 0x00800000
52#define CPUSTAT_RETAINED 0x00400000
53#define CPUSTAT_TIMING_SUB 0x00020000
54#define CPUSTAT_SIE_SUB 0x00010000
55#define CPUSTAT_RRF 0x00008000
56#define CPUSTAT_SLSV 0x00004000
57#define CPUSTAT_SLSR 0x00002000
58#define CPUSTAT_ZARCH 0x00000800
59#define CPUSTAT_MCDS 0x00000100
60#define CPUSTAT_SM 0x00000080
61#define CPUSTAT_G 0x00000008
62#define CPUSTAT_J 0x00000002
63#define CPUSTAT_P 0x00000001
64
65struct sie_block {
66 atomic_t cpuflags; /* 0x0000 */
67 __u32 prefix; /* 0x0004 */
68 __u8 reserved8[32]; /* 0x0008 */
69 __u64 cputm; /* 0x0028 */
70 __u64 ckc; /* 0x0030 */
71 __u64 epoch; /* 0x0038 */
72 __u8 reserved40[4]; /* 0x0040 */
73#define LCTL_CR0 0x8000
74 __u16 lctl; /* 0x0044 */
75 __s16 icpua; /* 0x0046 */
76 __u32 ictl; /* 0x0048 */
77 __u32 eca; /* 0x004c */
78 __u8 icptcode; /* 0x0050 */
79 __u8 reserved51; /* 0x0051 */
80 __u16 ihcpu; /* 0x0052 */
81 __u8 reserved54[2]; /* 0x0054 */
82 __u16 ipa; /* 0x0056 */
83 __u32 ipb; /* 0x0058 */
84 __u32 scaoh; /* 0x005c */
85 __u8 reserved60; /* 0x0060 */
86 __u8 ecb; /* 0x0061 */
87 __u8 reserved62[2]; /* 0x0062 */
88 __u32 scaol; /* 0x0064 */
89 __u8 reserved68[4]; /* 0x0068 */
90 __u32 todpr; /* 0x006c */
91 __u8 reserved70[16]; /* 0x0070 */
92 __u64 gmsor; /* 0x0080 */
93 __u64 gmslm; /* 0x0088 */
94 psw_t gpsw; /* 0x0090 */
95 __u64 gg14; /* 0x00a0 */
96 __u64 gg15; /* 0x00a8 */
97 __u8 reservedb0[30]; /* 0x00b0 */
98 __u16 iprcc; /* 0x00ce */
99 __u8 reservedd0[48]; /* 0x00d0 */
100 __u64 gcr[16]; /* 0x0100 */
101 __u64 gbea; /* 0x0180 */
102 __u8 reserved188[120]; /* 0x0188 */
103} __attribute__((packed));
104
105struct kvm_vcpu_stat {
106 u32 exit_userspace;
107 u32 exit_external_request;
108 u32 exit_external_interrupt;
109 u32 exit_stop_request;
110 u32 exit_validity;
111 u32 exit_instruction;
112 u32 instruction_lctl;
113 u32 instruction_lctg;
114 u32 exit_program_interruption;
115 u32 exit_instr_and_program;
116 u32 deliver_emergency_signal;
117 u32 deliver_service_signal;
118 u32 deliver_virtio_interrupt;
119 u32 deliver_stop_signal;
120 u32 deliver_prefix_signal;
121 u32 deliver_restart_signal;
122 u32 deliver_program_int;
123 u32 exit_wait_state;
124 u32 instruction_stidp;
125 u32 instruction_spx;
126 u32 instruction_stpx;
127 u32 instruction_stap;
128 u32 instruction_storage_key;
129 u32 instruction_stsch;
130 u32 instruction_chsc;
131 u32 instruction_stsi;
132 u32 instruction_stfl;
133 u32 instruction_sigp_sense;
134 u32 instruction_sigp_emergency;
135 u32 instruction_sigp_stop;
136 u32 instruction_sigp_arch;
137 u32 instruction_sigp_prefix;
138 u32 instruction_sigp_restart;
139 u32 diagnose_44;
140};
141
142struct io_info {
143 __u16 subchannel_id; /* 0x0b8 */
144 __u16 subchannel_nr; /* 0x0ba */
145 __u32 io_int_parm; /* 0x0bc */
146 __u32 io_int_word; /* 0x0c0 */
147};
148
149struct ext_info {
150 __u32 ext_params;
151 __u64 ext_params2;
152};
153
154#define PGM_OPERATION 0x01
155#define PGM_PRIVILEGED_OPERATION 0x02
156#define PGM_EXECUTE 0x03
157#define PGM_PROTECTION 0x04
158#define PGM_ADDRESSING 0x05
159#define PGM_SPECIFICATION 0x06
160#define PGM_DATA 0x07
161
162struct pgm_info {
163 __u16 code;
164};
165
166struct prefix_info {
167 __u32 address;
168};
169
170struct interrupt_info {
171 struct list_head list;
172 u64 type;
173 union {
174 struct io_info io;
175 struct ext_info ext;
176 struct pgm_info pgm;
177 struct prefix_info prefix;
178 };
179};
180
181/* for local_interrupt.action_flags */
182#define ACTION_STORE_ON_STOP 1
183#define ACTION_STOP_ON_STOP 2
184
185struct local_interrupt {
186 spinlock_t lock;
187 struct list_head list;
188 atomic_t active;
189 struct float_interrupt *float_int;
190 int timer_due; /* event indicator for waitqueue below */
191 wait_queue_head_t wq;
192 atomic_t *cpuflags;
193 unsigned int action_bits;
194};
195
196struct float_interrupt {
197 spinlock_t lock;
198 struct list_head list;
199 atomic_t active;
200 int next_rr_cpu;
201 unsigned long idle_mask [(64 + sizeof(long) - 1) / sizeof(long)];
202 struct local_interrupt *local_int[64];
203};
204
205
206struct kvm_vcpu_arch {
207 struct sie_block *sie_block;
208 unsigned long guest_gprs[16];
209 s390_fp_regs host_fpregs;
210 unsigned int host_acrs[NUM_ACRS];
211 s390_fp_regs guest_fpregs;
212 unsigned int guest_acrs[NUM_ACRS];
213 struct local_interrupt local_int;
214 struct timer_list ckc_timer;
215 union {
216 cpuid_t cpu_id;
217 u64 stidp_data;
218 };
219};
220
221struct kvm_vm_stat {
222 u32 remote_tlb_flush;
223};
224
225struct kvm_arch{
226 unsigned long guest_origin;
227 unsigned long guest_memsize;
228 struct sca_block *sca;
229 debug_info_t *dbf;
230 struct float_interrupt float_int;
231};
232
233extern int sie64a(struct sie_block *, __u64 *);
234#endif
diff --git a/include/asm-s390/kvm_para.h b/include/asm-s390/kvm_para.h
new file mode 100644
index 000000000000..2c503796b619
--- /dev/null
+++ b/include/asm-s390/kvm_para.h
@@ -0,0 +1,150 @@
1/*
2 * asm-s390/kvm_para.h - definition for paravirtual devices on s390
3 *
4 * Copyright IBM Corp. 2008
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 only)
8 * as published by the Free Software Foundation.
9 *
10 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
11 */
12
13#ifndef __S390_KVM_PARA_H
14#define __S390_KVM_PARA_H
15
16/*
17 * Hypercalls for KVM on s390. The calling convention is similar to the
18 * s390 ABI, so we use R2-R6 for parameters 1-5. In addition we use R1
19 * as hypercall number and R7 as parameter 6. The return value is
20 * written to R2. We use the diagnose instruction as hypercall. To avoid
21 * conflicts with existing diagnoses for LPAR and z/VM, we do not use
22 * the instruction encoded number, but specify the number in R1 and
23 * use 0x500 as KVM hypercall
24 *
25 * Copyright IBM Corp. 2007,2008
26 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
27 *
28 * This work is licensed under the terms of the GNU GPL, version 2.
29 */
30
31static inline long kvm_hypercall0(unsigned long nr)
32{
33 register unsigned long __nr asm("1") = nr;
34 register long __rc asm("2");
35
36 asm volatile ("diag 2,4,0x500\n"
37 : "=d" (__rc) : "d" (__nr): "memory", "cc");
38 return __rc;
39}
40
41static inline long kvm_hypercall1(unsigned long nr, unsigned long p1)
42{
43 register unsigned long __nr asm("1") = nr;
44 register unsigned long __p1 asm("2") = p1;
45 register long __rc asm("2");
46
47 asm volatile ("diag 2,4,0x500\n"
48 : "=d" (__rc) : "d" (__nr), "0" (__p1) : "memory", "cc");
49 return __rc;
50}
51
52static inline long kvm_hypercall2(unsigned long nr, unsigned long p1,
53 unsigned long p2)
54{
55 register unsigned long __nr asm("1") = nr;
56 register unsigned long __p1 asm("2") = p1;
57 register unsigned long __p2 asm("3") = p2;
58 register long __rc asm("2");
59
60 asm volatile ("diag 2,4,0x500\n"
61 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2)
62 : "memory", "cc");
63 return __rc;
64}
65
66static inline long kvm_hypercall3(unsigned long nr, unsigned long p1,
67 unsigned long p2, unsigned long p3)
68{
69 register unsigned long __nr asm("1") = nr;
70 register unsigned long __p1 asm("2") = p1;
71 register unsigned long __p2 asm("3") = p2;
72 register unsigned long __p3 asm("4") = p3;
73 register long __rc asm("2");
74
75 asm volatile ("diag 2,4,0x500\n"
76 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
77 "d" (__p3) : "memory", "cc");
78 return __rc;
79}
80
81
82static inline long kvm_hypercall4(unsigned long nr, unsigned long p1,
83 unsigned long p2, unsigned long p3,
84 unsigned long p4)
85{
86 register unsigned long __nr asm("1") = nr;
87 register unsigned long __p1 asm("2") = p1;
88 register unsigned long __p2 asm("3") = p2;
89 register unsigned long __p3 asm("4") = p3;
90 register unsigned long __p4 asm("5") = p4;
91 register long __rc asm("2");
92
93 asm volatile ("diag 2,4,0x500\n"
94 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
95 "d" (__p3), "d" (__p4) : "memory", "cc");
96 return __rc;
97}
98
99static inline long kvm_hypercall5(unsigned long nr, unsigned long p1,
100 unsigned long p2, unsigned long p3,
101 unsigned long p4, unsigned long p5)
102{
103 register unsigned long __nr asm("1") = nr;
104 register unsigned long __p1 asm("2") = p1;
105 register unsigned long __p2 asm("3") = p2;
106 register unsigned long __p3 asm("4") = p3;
107 register unsigned long __p4 asm("5") = p4;
108 register unsigned long __p5 asm("6") = p5;
109 register long __rc asm("2");
110
111 asm volatile ("diag 2,4,0x500\n"
112 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
113 "d" (__p3), "d" (__p4), "d" (__p5) : "memory", "cc");
114 return __rc;
115}
116
117static inline long kvm_hypercall6(unsigned long nr, unsigned long p1,
118 unsigned long p2, unsigned long p3,
119 unsigned long p4, unsigned long p5,
120 unsigned long p6)
121{
122 register unsigned long __nr asm("1") = nr;
123 register unsigned long __p1 asm("2") = p1;
124 register unsigned long __p2 asm("3") = p2;
125 register unsigned long __p3 asm("4") = p3;
126 register unsigned long __p4 asm("5") = p4;
127 register unsigned long __p5 asm("6") = p5;
128 register unsigned long __p6 asm("7") = p6;
129 register long __rc asm("2");
130
131 asm volatile ("diag 2,4,0x500\n"
132 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
133 "d" (__p3), "d" (__p4), "d" (__p5), "d" (__p6)
134 : "memory", "cc");
135 return __rc;
136}
137
138/* kvm on s390 is always paravirtualization enabled */
139static inline int kvm_para_available(void)
140{
141 return 1;
142}
143
144/* No feature bits are currently assigned for kvm on s390 */
145static inline unsigned int kvm_arch_para_features(void)
146{
147 return 0;
148}
149
150#endif /* __S390_KVM_PARA_H */
diff --git a/include/asm-s390/kvm_virtio.h b/include/asm-s390/kvm_virtio.h
new file mode 100644
index 000000000000..5c871a990c29
--- /dev/null
+++ b/include/asm-s390/kvm_virtio.h
@@ -0,0 +1,53 @@
1/*
2 * kvm_virtio.h - definition for virtio for kvm on s390
3 *
4 * Copyright IBM Corp. 2008
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 only)
8 * as published by the Free Software Foundation.
9 *
10 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
11 */
12
13#ifndef __KVM_S390_VIRTIO_H
14#define __KVM_S390_VIRTIO_H
15
16#include <linux/types.h>
17
18struct kvm_device_desc {
19 /* The device type: console, network, disk etc. Type 0 terminates. */
20 __u8 type;
21 /* The number of virtqueues (first in config array) */
22 __u8 num_vq;
23 /*
24 * The number of bytes of feature bits. Multiply by 2: one for host
25 * features and one for guest acknowledgements.
26 */
27 __u8 feature_len;
28 /* The number of bytes of the config array after virtqueues. */
29 __u8 config_len;
30 /* A status byte, written by the Guest. */
31 __u8 status;
32 __u8 config[0];
33};
34
35/*
36 * This is how we expect the device configuration field for a virtqueue
37 * to be laid out in config space.
38 */
39struct kvm_vqconfig {
40 /* The token returned with an interrupt. Set by the guest */
41 __u64 token;
42 /* The address of the virtio ring */
43 __u64 address;
44 /* The number of entries in the virtio_ring */
45 __u16 num;
46
47};
48
49#define KVM_S390_VIRTIO_NOTIFY 0
50#define KVM_S390_VIRTIO_RESET 1
51#define KVM_S390_VIRTIO_SET_STATUS 2
52
53#endif
diff --git a/include/asm-s390/lowcore.h b/include/asm-s390/lowcore.h
index 801a6fd35b5b..0bc51d52a899 100644
--- a/include/asm-s390/lowcore.h
+++ b/include/asm-s390/lowcore.h
@@ -56,6 +56,8 @@
56#define __LC_IO_INT_WORD 0x0C0 56#define __LC_IO_INT_WORD 0x0C0
57#define __LC_MCCK_CODE 0x0E8 57#define __LC_MCCK_CODE 0x0E8
58 58
59#define __LC_LAST_BREAK 0x110
60
59#define __LC_RETURN_PSW 0x200 61#define __LC_RETURN_PSW 0x200
60 62
61#define __LC_SAVE_AREA 0xC00 63#define __LC_SAVE_AREA 0xC00
@@ -80,7 +82,6 @@
80#define __LC_CPUID 0xC60 82#define __LC_CPUID 0xC60
81#define __LC_CPUADDR 0xC68 83#define __LC_CPUADDR 0xC68
82#define __LC_IPLDEV 0xC7C 84#define __LC_IPLDEV 0xC7C
83#define __LC_JIFFY_TIMER 0xC80
84#define __LC_CURRENT 0xC90 85#define __LC_CURRENT 0xC90
85#define __LC_INT_CLOCK 0xC98 86#define __LC_INT_CLOCK 0xC98
86#else /* __s390x__ */ 87#else /* __s390x__ */
@@ -103,7 +104,6 @@
103#define __LC_CPUID 0xD80 104#define __LC_CPUID 0xD80
104#define __LC_CPUADDR 0xD88 105#define __LC_CPUADDR 0xD88
105#define __LC_IPLDEV 0xDB8 106#define __LC_IPLDEV 0xDB8
106#define __LC_JIFFY_TIMER 0xDC0
107#define __LC_CURRENT 0xDD8 107#define __LC_CURRENT 0xDD8
108#define __LC_INT_CLOCK 0xDE8 108#define __LC_INT_CLOCK 0xDE8
109#endif /* __s390x__ */ 109#endif /* __s390x__ */
@@ -276,7 +276,7 @@ struct _lowcore
276 /* entry.S sensitive area end */ 276 /* entry.S sensitive area end */
277 277
278 /* SMP info area: defined by DJB */ 278 /* SMP info area: defined by DJB */
279 __u64 jiffy_timer; /* 0xc80 */ 279 __u64 clock_comparator; /* 0xc80 */
280 __u32 ext_call_fast; /* 0xc88 */ 280 __u32 ext_call_fast; /* 0xc88 */
281 __u32 percpu_offset; /* 0xc8c */ 281 __u32 percpu_offset; /* 0xc8c */
282 __u32 current_task; /* 0xc90 */ 282 __u32 current_task; /* 0xc90 */
@@ -368,11 +368,12 @@ struct _lowcore
368 /* entry.S sensitive area end */ 368 /* entry.S sensitive area end */
369 369
370 /* SMP info area: defined by DJB */ 370 /* SMP info area: defined by DJB */
371 __u64 jiffy_timer; /* 0xdc0 */ 371 __u64 clock_comparator; /* 0xdc0 */
372 __u64 ext_call_fast; /* 0xdc8 */ 372 __u64 ext_call_fast; /* 0xdc8 */
373 __u64 percpu_offset; /* 0xdd0 */ 373 __u64 percpu_offset; /* 0xdd0 */
374 __u64 current_task; /* 0xdd8 */ 374 __u64 current_task; /* 0xdd8 */
375 __u64 softirq_pending; /* 0xde0 */ 375 __u32 softirq_pending; /* 0xde0 */
376 __u32 pad_0x0de4; /* 0xde4 */
376 __u64 int_clock; /* 0xde8 */ 377 __u64 int_clock; /* 0xde8 */
377 __u8 pad12[0xe00-0xdf0]; /* 0xdf0 */ 378 __u8 pad12[0xe00-0xdf0]; /* 0xdf0 */
378 379
@@ -380,27 +381,32 @@ struct _lowcore
380 /* whether the kernel died with panic() or not */ 381 /* whether the kernel died with panic() or not */
381 __u32 panic_magic; /* 0xe00 */ 382 __u32 panic_magic; /* 0xe00 */
382 383
383 __u8 pad13[0x1200-0xe04]; /* 0xe04 */ 384 __u8 pad13[0x11b8-0xe04]; /* 0xe04 */
385
386 /* 64 bit extparam used for pfault, diag 250 etc */
387 __u64 ext_params2; /* 0x11B8 */
388
389 __u8 pad14[0x1200-0x11C0]; /* 0x11C0 */
384 390
385 /* System info area */ 391 /* System info area */
386 392
387 __u64 floating_pt_save_area[16]; /* 0x1200 */ 393 __u64 floating_pt_save_area[16]; /* 0x1200 */
388 __u64 gpregs_save_area[16]; /* 0x1280 */ 394 __u64 gpregs_save_area[16]; /* 0x1280 */
389 __u32 st_status_fixed_logout[4]; /* 0x1300 */ 395 __u32 st_status_fixed_logout[4]; /* 0x1300 */
390 __u8 pad14[0x1318-0x1310]; /* 0x1310 */ 396 __u8 pad15[0x1318-0x1310]; /* 0x1310 */
391 __u32 prefixreg_save_area; /* 0x1318 */ 397 __u32 prefixreg_save_area; /* 0x1318 */
392 __u32 fpt_creg_save_area; /* 0x131c */ 398 __u32 fpt_creg_save_area; /* 0x131c */
393 __u8 pad15[0x1324-0x1320]; /* 0x1320 */ 399 __u8 pad16[0x1324-0x1320]; /* 0x1320 */
394 __u32 tod_progreg_save_area; /* 0x1324 */ 400 __u32 tod_progreg_save_area; /* 0x1324 */
395 __u32 cpu_timer_save_area[2]; /* 0x1328 */ 401 __u32 cpu_timer_save_area[2]; /* 0x1328 */
396 __u32 clock_comp_save_area[2]; /* 0x1330 */ 402 __u32 clock_comp_save_area[2]; /* 0x1330 */
397 __u8 pad16[0x1340-0x1338]; /* 0x1338 */ 403 __u8 pad17[0x1340-0x1338]; /* 0x1338 */
398 __u32 access_regs_save_area[16]; /* 0x1340 */ 404 __u32 access_regs_save_area[16]; /* 0x1340 */
399 __u64 cregs_save_area[16]; /* 0x1380 */ 405 __u64 cregs_save_area[16]; /* 0x1380 */
400 406
401 /* align to the top of the prefix area */ 407 /* align to the top of the prefix area */
402 408
403 __u8 pad17[0x2000-0x1400]; /* 0x1400 */ 409 __u8 pad18[0x2000-0x1400]; /* 0x1400 */
404#endif /* !__s390x__ */ 410#endif /* !__s390x__ */
405} __attribute__((packed)); /* End structure*/ 411} __attribute__((packed)); /* End structure*/
406 412
diff --git a/include/asm-s390/mmu.h b/include/asm-s390/mmu.h
index 1698e29c5b20..5dd5e7b3476f 100644
--- a/include/asm-s390/mmu.h
+++ b/include/asm-s390/mmu.h
@@ -7,6 +7,7 @@ typedef struct {
7 unsigned long asce_bits; 7 unsigned long asce_bits;
8 unsigned long asce_limit; 8 unsigned long asce_limit;
9 int noexec; 9 int noexec;
10 int pgstes;
10} mm_context_t; 11} mm_context_t;
11 12
12#endif 13#endif
diff --git a/include/asm-s390/mmu_context.h b/include/asm-s390/mmu_context.h
index b5a34c6f91a9..4c2fbf48c9c4 100644
--- a/include/asm-s390/mmu_context.h
+++ b/include/asm-s390/mmu_context.h
@@ -20,7 +20,13 @@ static inline int init_new_context(struct task_struct *tsk,
20#ifdef CONFIG_64BIT 20#ifdef CONFIG_64BIT
21 mm->context.asce_bits |= _ASCE_TYPE_REGION3; 21 mm->context.asce_bits |= _ASCE_TYPE_REGION3;
22#endif 22#endif
23 mm->context.noexec = s390_noexec; 23 if (current->mm->context.pgstes) {
24 mm->context.noexec = 0;
25 mm->context.pgstes = 1;
26 } else {
27 mm->context.noexec = s390_noexec;
28 mm->context.pgstes = 0;
29 }
24 mm->context.asce_limit = STACK_TOP_MAX; 30 mm->context.asce_limit = STACK_TOP_MAX;
25 crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); 31 crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
26 return 0; 32 return 0;
diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h
index fe7f92b6ae6d..f0f4579eac13 100644
--- a/include/asm-s390/page.h
+++ b/include/asm-s390/page.h
@@ -19,17 +19,34 @@
19#define PAGE_DEFAULT_ACC 0 19#define PAGE_DEFAULT_ACC 0
20#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4) 20#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
21 21
22#define HPAGE_SHIFT 20
23#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
24#define HPAGE_MASK (~(HPAGE_SIZE - 1))
25#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
26
27#define ARCH_HAS_SETCLEAR_HUGE_PTE
28#define ARCH_HAS_HUGE_PTE_TYPE
29#define ARCH_HAS_PREPARE_HUGEPAGE
30#define ARCH_HAS_HUGEPAGE_CLEAR_FLUSH
31
22#include <asm/setup.h> 32#include <asm/setup.h>
23#ifndef __ASSEMBLY__ 33#ifndef __ASSEMBLY__
24 34
25static inline void clear_page(void *page) 35static inline void clear_page(void *page)
26{ 36{
27 register unsigned long reg1 asm ("1") = 0; 37 if (MACHINE_HAS_PFMF) {
28 register void *reg2 asm ("2") = page; 38 asm volatile(
29 register unsigned long reg3 asm ("3") = 4096; 39 " .insn rre,0xb9af0000,%0,%1"
30 asm volatile( 40 : : "d" (0x10000), "a" (page) : "memory", "cc");
31 " mvcl 2,0" 41 } else {
32 : "+d" (reg2), "+d" (reg3) : "d" (reg1) : "memory", "cc"); 42 register unsigned long reg1 asm ("1") = 0;
43 register void *reg2 asm ("2") = page;
44 register unsigned long reg3 asm ("3") = 4096;
45 asm volatile(
46 " mvcl 2,0"
47 : "+d" (reg2), "+d" (reg3) : "d" (reg1)
48 : "memory", "cc");
49 }
33} 50}
34 51
35static inline void copy_page(void *to, void *from) 52static inline void copy_page(void *to, void *from)
@@ -108,26 +125,6 @@ page_get_storage_key(unsigned long addr)
108 return skey; 125 return skey;
109} 126}
110 127
111extern unsigned long max_pfn;
112
113static inline int pfn_valid(unsigned long pfn)
114{
115 unsigned long dummy;
116 int ccode;
117
118 if (pfn >= max_pfn)
119 return 0;
120
121 asm volatile(
122 " lra %0,0(%2)\n"
123 " ipm %1\n"
124 " srl %1,28\n"
125 : "=d" (dummy), "=d" (ccode)
126 : "a" (pfn << PAGE_SHIFT)
127 : "cc");
128 return !ccode;
129}
130
131#endif /* !__ASSEMBLY__ */ 128#endif /* !__ASSEMBLY__ */
132 129
133/* to align the pointer to the (next) page boundary */ 130/* to align the pointer to the (next) page boundary */
diff --git a/include/asm-s390/pgtable.h b/include/asm-s390/pgtable.h
index 65154dc9a9e5..c7f4f8e3e297 100644
--- a/include/asm-s390/pgtable.h
+++ b/include/asm-s390/pgtable.h
@@ -30,6 +30,7 @@
30 */ 30 */
31#ifndef __ASSEMBLY__ 31#ifndef __ASSEMBLY__
32#include <linux/mm_types.h> 32#include <linux/mm_types.h>
33#include <asm/bitops.h>
33#include <asm/bug.h> 34#include <asm/bug.h>
34#include <asm/processor.h> 35#include <asm/processor.h>
35 36
@@ -128,7 +129,7 @@ extern char empty_zero_page[PAGE_SIZE];
128#define VMEM_MAX_PAGES ((VMEM_MAP_END - VMALLOC_END) / sizeof(struct page)) 129#define VMEM_MAX_PAGES ((VMEM_MAP_END - VMALLOC_END) / sizeof(struct page))
129#define VMEM_MAX_PFN min(VMALLOC_START >> PAGE_SHIFT, VMEM_MAX_PAGES) 130#define VMEM_MAX_PFN min(VMALLOC_START >> PAGE_SHIFT, VMEM_MAX_PAGES)
130#define VMEM_MAX_PHYS ((VMEM_MAX_PFN << PAGE_SHIFT) & ~((16 << 20) - 1)) 131#define VMEM_MAX_PHYS ((VMEM_MAX_PFN << PAGE_SHIFT) & ~((16 << 20) - 1))
131#define VMEM_MAP ((struct page *) VMALLOC_END) 132#define vmemmap ((struct page *) VMALLOC_END)
132 133
133/* 134/*
134 * A 31 bit pagetable entry of S390 has following format: 135 * A 31 bit pagetable entry of S390 has following format:
@@ -219,6 +220,8 @@ extern char empty_zero_page[PAGE_SIZE];
219/* Software bits in the page table entry */ 220/* Software bits in the page table entry */
220#define _PAGE_SWT 0x001 /* SW pte type bit t */ 221#define _PAGE_SWT 0x001 /* SW pte type bit t */
221#define _PAGE_SWX 0x002 /* SW pte type bit x */ 222#define _PAGE_SWX 0x002 /* SW pte type bit x */
223#define _PAGE_SPECIAL 0x004 /* SW associated with special page */
224#define __HAVE_ARCH_PTE_SPECIAL
222 225
223/* Six different types of pages. */ 226/* Six different types of pages. */
224#define _PAGE_TYPE_EMPTY 0x400 227#define _PAGE_TYPE_EMPTY 0x400
@@ -231,6 +234,15 @@ extern char empty_zero_page[PAGE_SIZE];
231#define _PAGE_TYPE_EX_RW 0x002 234#define _PAGE_TYPE_EX_RW 0x002
232 235
233/* 236/*
237 * Only four types for huge pages, using the invalid bit and protection bit
238 * of a segment table entry.
239 */
240#define _HPAGE_TYPE_EMPTY 0x020 /* _SEGMENT_ENTRY_INV */
241#define _HPAGE_TYPE_NONE 0x220
242#define _HPAGE_TYPE_RO 0x200 /* _SEGMENT_ENTRY_RO */
243#define _HPAGE_TYPE_RW 0x000
244
245/*
234 * PTE type bits are rather complicated. handle_pte_fault uses pte_present, 246 * PTE type bits are rather complicated. handle_pte_fault uses pte_present,
235 * pte_none and pte_file to find out the pte type WITHOUT holding the page 247 * pte_none and pte_file to find out the pte type WITHOUT holding the page
236 * table lock. ptep_clear_flush on the other hand uses ptep_clear_flush to 248 * table lock. ptep_clear_flush on the other hand uses ptep_clear_flush to
@@ -258,6 +270,13 @@ extern char empty_zero_page[PAGE_SIZE];
258 * swap pte is 1011 and 0001, 0011, 0101, 0111 are invalid. 270 * swap pte is 1011 and 0001, 0011, 0101, 0111 are invalid.
259 */ 271 */
260 272
273/* Page status table bits for virtualization */
274#define RCP_PCL_BIT 55
275#define RCP_HR_BIT 54
276#define RCP_HC_BIT 53
277#define RCP_GR_BIT 50
278#define RCP_GC_BIT 49
279
261#ifndef __s390x__ 280#ifndef __s390x__
262 281
263/* Bits in the segment table address-space-control-element */ 282/* Bits in the segment table address-space-control-element */
@@ -315,6 +334,9 @@ extern char empty_zero_page[PAGE_SIZE];
315#define _SEGMENT_ENTRY (0) 334#define _SEGMENT_ENTRY (0)
316#define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INV) 335#define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INV)
317 336
337#define _SEGMENT_ENTRY_LARGE 0x400 /* STE-format control, large page */
338#define _SEGMENT_ENTRY_CO 0x100 /* change-recording override */
339
318#endif /* __s390x__ */ 340#endif /* __s390x__ */
319 341
320/* 342/*
@@ -510,9 +532,56 @@ static inline int pte_file(pte_t pte)
510 return (pte_val(pte) & mask) == _PAGE_TYPE_FILE; 532 return (pte_val(pte) & mask) == _PAGE_TYPE_FILE;
511} 533}
512 534
535static inline int pte_special(pte_t pte)
536{
537 return (pte_val(pte) & _PAGE_SPECIAL);
538}
539
513#define __HAVE_ARCH_PTE_SAME 540#define __HAVE_ARCH_PTE_SAME
514#define pte_same(a,b) (pte_val(a) == pte_val(b)) 541#define pte_same(a,b) (pte_val(a) == pte_val(b))
515 542
543static inline void rcp_lock(pte_t *ptep)
544{
545#ifdef CONFIG_PGSTE
546 unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
547 preempt_disable();
548 while (test_and_set_bit(RCP_PCL_BIT, pgste))
549 ;
550#endif
551}
552
553static inline void rcp_unlock(pte_t *ptep)
554{
555#ifdef CONFIG_PGSTE
556 unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
557 clear_bit(RCP_PCL_BIT, pgste);
558 preempt_enable();
559#endif
560}
561
562/* forward declaration for SetPageUptodate in page-flags.h*/
563static inline void page_clear_dirty(struct page *page);
564#include <linux/page-flags.h>
565
566static inline void ptep_rcp_copy(pte_t *ptep)
567{
568#ifdef CONFIG_PGSTE
569 struct page *page = virt_to_page(pte_val(*ptep));
570 unsigned int skey;
571 unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
572
573 skey = page_get_storage_key(page_to_phys(page));
574 if (skey & _PAGE_CHANGED)
575 set_bit_simple(RCP_GC_BIT, pgste);
576 if (skey & _PAGE_REFERENCED)
577 set_bit_simple(RCP_GR_BIT, pgste);
578 if (test_and_clear_bit_simple(RCP_HC_BIT, pgste))
579 SetPageDirty(page);
580 if (test_and_clear_bit_simple(RCP_HR_BIT, pgste))
581 SetPageReferenced(page);
582#endif
583}
584
516/* 585/*
517 * query functions pte_write/pte_dirty/pte_young only work if 586 * query functions pte_write/pte_dirty/pte_young only work if
518 * pte_present() is true. Undefined behaviour if not.. 587 * pte_present() is true. Undefined behaviour if not..
@@ -599,6 +668,8 @@ static inline void pmd_clear(pmd_t *pmd)
599 668
600static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 669static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
601{ 670{
671 if (mm->context.pgstes)
672 ptep_rcp_copy(ptep);
602 pte_val(*ptep) = _PAGE_TYPE_EMPTY; 673 pte_val(*ptep) = _PAGE_TYPE_EMPTY;
603 if (mm->context.noexec) 674 if (mm->context.noexec)
604 pte_val(ptep[PTRS_PER_PTE]) = _PAGE_TYPE_EMPTY; 675 pte_val(ptep[PTRS_PER_PTE]) = _PAGE_TYPE_EMPTY;
@@ -663,10 +734,34 @@ static inline pte_t pte_mkyoung(pte_t pte)
663 return pte; 734 return pte;
664} 735}
665 736
737static inline pte_t pte_mkspecial(pte_t pte)
738{
739 pte_val(pte) |= _PAGE_SPECIAL;
740 return pte;
741}
742
666#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 743#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
667static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, 744static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
668 unsigned long addr, pte_t *ptep) 745 unsigned long addr, pte_t *ptep)
669{ 746{
747#ifdef CONFIG_PGSTE
748 unsigned long physpage;
749 int young;
750 unsigned long *pgste;
751
752 if (!vma->vm_mm->context.pgstes)
753 return 0;
754 physpage = pte_val(*ptep) & PAGE_MASK;
755 pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
756
757 young = ((page_get_storage_key(physpage) & _PAGE_REFERENCED) != 0);
758 rcp_lock(ptep);
759 if (young)
760 set_bit_simple(RCP_GR_BIT, pgste);
761 young |= test_and_clear_bit_simple(RCP_HR_BIT, pgste);
762 rcp_unlock(ptep);
763 return young;
764#endif
670 return 0; 765 return 0;
671} 766}
672 767
@@ -674,7 +769,13 @@ static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
674static inline int ptep_clear_flush_young(struct vm_area_struct *vma, 769static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
675 unsigned long address, pte_t *ptep) 770 unsigned long address, pte_t *ptep)
676{ 771{
677 /* No need to flush TLB; bits are in storage key */ 772 /* No need to flush TLB
773 * On s390 reference bits are in storage key and never in TLB
774 * With virtualization we handle the reference bit, without we
775 * we can simply return */
776#ifdef CONFIG_PGSTE
777 return ptep_test_and_clear_young(vma, address, ptep);
778#endif
678 return 0; 779 return 0;
679} 780}
680 781
@@ -693,15 +794,25 @@ static inline void __ptep_ipte(unsigned long address, pte_t *ptep)
693 : "=m" (*ptep) : "m" (*ptep), 794 : "=m" (*ptep) : "m" (*ptep),
694 "a" (pto), "a" (address)); 795 "a" (pto), "a" (address));
695 } 796 }
696 pte_val(*ptep) = _PAGE_TYPE_EMPTY;
697} 797}
698 798
699static inline void ptep_invalidate(struct mm_struct *mm, 799static inline void ptep_invalidate(struct mm_struct *mm,
700 unsigned long address, pte_t *ptep) 800 unsigned long address, pte_t *ptep)
701{ 801{
802 if (mm->context.pgstes) {
803 rcp_lock(ptep);
804 __ptep_ipte(address, ptep);
805 ptep_rcp_copy(ptep);
806 pte_val(*ptep) = _PAGE_TYPE_EMPTY;
807 rcp_unlock(ptep);
808 return;
809 }
702 __ptep_ipte(address, ptep); 810 __ptep_ipte(address, ptep);
703 if (mm->context.noexec) 811 pte_val(*ptep) = _PAGE_TYPE_EMPTY;
812 if (mm->context.noexec) {
704 __ptep_ipte(address, ptep + PTRS_PER_PTE); 813 __ptep_ipte(address, ptep + PTRS_PER_PTE);
814 pte_val(*(ptep + PTRS_PER_PTE)) = _PAGE_TYPE_EMPTY;
815 }
705} 816}
706 817
707/* 818/*
@@ -964,17 +1075,15 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
964 1075
965#define kern_addr_valid(addr) (1) 1076#define kern_addr_valid(addr) (1)
966 1077
967extern int add_shared_memory(unsigned long start, unsigned long size); 1078extern int vmem_add_mapping(unsigned long start, unsigned long size);
968extern int remove_shared_memory(unsigned long start, unsigned long size); 1079extern int vmem_remove_mapping(unsigned long start, unsigned long size);
1080extern int s390_enable_sie(void);
969 1081
970/* 1082/*
971 * No page table caches to initialise 1083 * No page table caches to initialise
972 */ 1084 */
973#define pgtable_cache_init() do { } while (0) 1085#define pgtable_cache_init() do { } while (0)
974 1086
975#define __HAVE_ARCH_MEMMAP_INIT
976extern void memmap_init(unsigned long, int, unsigned long, unsigned long);
977
978#include <asm-generic/pgtable.h> 1087#include <asm-generic/pgtable.h>
979 1088
980#endif /* _S390_PAGE_H */ 1089#endif /* _S390_PAGE_H */
diff --git a/include/asm-s390/processor.h b/include/asm-s390/processor.h
index 51d88912aa20..a00f79dd323b 100644
--- a/include/asm-s390/processor.h
+++ b/include/asm-s390/processor.h
@@ -172,9 +172,7 @@ extern unsigned long thread_saved_pc(struct task_struct *t);
172 */ 172 */
173extern void task_show_regs(struct seq_file *m, struct task_struct *task); 173extern void task_show_regs(struct seq_file *m, struct task_struct *task);
174 174
175extern void show_registers(struct pt_regs *regs);
176extern void show_code(struct pt_regs *regs); 175extern void show_code(struct pt_regs *regs);
177extern void show_trace(struct task_struct *task, unsigned long *sp);
178 176
179unsigned long get_wchan(struct task_struct *p); 177unsigned long get_wchan(struct task_struct *p);
180#define task_pt_regs(tsk) ((struct pt_regs *) \ 178#define task_pt_regs(tsk) ((struct pt_regs *) \
diff --git a/include/asm-s390/ptrace.h b/include/asm-s390/ptrace.h
index 61f6952f2e35..441d7c260857 100644
--- a/include/asm-s390/ptrace.h
+++ b/include/asm-s390/ptrace.h
@@ -463,8 +463,6 @@ struct user_regs_struct
463}; 463};
464 464
465#ifdef __KERNEL__ 465#ifdef __KERNEL__
466#define __ARCH_SYS_PTRACE 1
467
468/* 466/*
469 * These are defined as per linux/ptrace.h, which see. 467 * These are defined as per linux/ptrace.h, which see.
470 */ 468 */
diff --git a/include/asm-s390/qdio.h b/include/asm-s390/qdio.h
index 4b8ff55f680e..11240342a0f4 100644
--- a/include/asm-s390/qdio.h
+++ b/include/asm-s390/qdio.h
@@ -127,6 +127,7 @@ extern int do_QDIO(struct ccw_device*, unsigned int flags,
127 unsigned int qidx,unsigned int count, 127 unsigned int qidx,unsigned int count,
128 struct qdio_buffer *buffers); 128 struct qdio_buffer *buffers);
129 129
130extern int qdio_get_ssqd_pct(struct ccw_device*);
130extern int qdio_synchronize(struct ccw_device*, unsigned int flags, 131extern int qdio_synchronize(struct ccw_device*, unsigned int flags,
131 unsigned int queue_number); 132 unsigned int queue_number);
132 133
diff --git a/include/asm-s390/semaphore.h b/include/asm-s390/semaphore.h
index 0e7001ad8392..d9b2034ed1d2 100644
--- a/include/asm-s390/semaphore.h
+++ b/include/asm-s390/semaphore.h
@@ -1,107 +1 @@
1/* #include <linux/semaphore.h>
2 * include/asm-s390/semaphore.h
3 *
4 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 *
7 * Derived from "include/asm-i386/semaphore.h"
8 * (C) Copyright 1996 Linus Torvalds
9 */
10
11#ifndef _S390_SEMAPHORE_H
12#define _S390_SEMAPHORE_H
13
14#include <asm/system.h>
15#include <asm/atomic.h>
16#include <linux/wait.h>
17#include <linux/rwsem.h>
18
19struct semaphore {
20 /*
21 * Note that any negative value of count is equivalent to 0,
22 * but additionally indicates that some process(es) might be
23 * sleeping on `wait'.
24 */
25 atomic_t count;
26 wait_queue_head_t wait;
27};
28
29#define __SEMAPHORE_INITIALIZER(name,count) \
30 { ATOMIC_INIT(count), __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) }
31
32#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
33 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
34
35#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
36
37static inline void sema_init (struct semaphore *sem, int val)
38{
39 atomic_set(&sem->count, val);
40 init_waitqueue_head(&sem->wait);
41}
42
43static inline void init_MUTEX (struct semaphore *sem)
44{
45 sema_init(sem, 1);
46}
47
48static inline void init_MUTEX_LOCKED (struct semaphore *sem)
49{
50 sema_init(sem, 0);
51}
52
53asmlinkage void __down(struct semaphore * sem);
54asmlinkage int __down_interruptible(struct semaphore * sem);
55asmlinkage int __down_trylock(struct semaphore * sem);
56asmlinkage void __up(struct semaphore * sem);
57
58static inline void down(struct semaphore * sem)
59{
60 might_sleep();
61 if (atomic_dec_return(&sem->count) < 0)
62 __down(sem);
63}
64
65static inline int down_interruptible(struct semaphore * sem)
66{
67 int ret = 0;
68
69 might_sleep();
70 if (atomic_dec_return(&sem->count) < 0)
71 ret = __down_interruptible(sem);
72 return ret;
73}
74
75static inline int down_trylock(struct semaphore * sem)
76{
77 int old_val, new_val;
78
79 /*
80 * This inline assembly atomically implements the equivalent
81 * to the following C code:
82 * old_val = sem->count.counter;
83 * if ((new_val = old_val) > 0)
84 * sem->count.counter = --new_val;
85 * In the ppc code this is called atomic_dec_if_positive.
86 */
87 asm volatile(
88 " l %0,0(%3)\n"
89 "0: ltr %1,%0\n"
90 " jle 1f\n"
91 " ahi %1,-1\n"
92 " cs %0,%1,0(%3)\n"
93 " jl 0b\n"
94 "1:"
95 : "=&d" (old_val), "=&d" (new_val), "=m" (sem->count.counter)
96 : "a" (&sem->count.counter), "m" (sem->count.counter)
97 : "cc", "memory");
98 return old_val <= 0;
99}
100
101static inline void up(struct semaphore * sem)
102{
103 if (atomic_inc_return(&sem->count) <= 0)
104 __up(sem);
105}
106
107#endif
diff --git a/include/asm-s390/setup.h b/include/asm-s390/setup.h
index a76a6b8fd887..ba69674012a7 100644
--- a/include/asm-s390/setup.h
+++ b/include/asm-s390/setup.h
@@ -59,22 +59,42 @@ extern unsigned int s390_noexec;
59 */ 59 */
60extern unsigned long machine_flags; 60extern unsigned long machine_flags;
61 61
62#define MACHINE_IS_VM (machine_flags & 1) 62#define MACHINE_FLAG_VM (1UL << 0)
63#define MACHINE_IS_P390 (machine_flags & 4) 63#define MACHINE_FLAG_IEEE (1UL << 1)
64#define MACHINE_HAS_MVPG (machine_flags & 16) 64#define MACHINE_FLAG_P390 (1UL << 2)
65#define MACHINE_HAS_IDTE (machine_flags & 128) 65#define MACHINE_FLAG_CSP (1UL << 3)
66#define MACHINE_HAS_DIAG9C (machine_flags & 256) 66#define MACHINE_FLAG_MVPG (1UL << 4)
67#define MACHINE_FLAG_DIAG44 (1UL << 5)
68#define MACHINE_FLAG_IDTE (1UL << 6)
69#define MACHINE_FLAG_DIAG9C (1UL << 7)
70#define MACHINE_FLAG_MVCOS (1UL << 8)
71#define MACHINE_FLAG_KVM (1UL << 9)
72#define MACHINE_FLAG_HPAGE (1UL << 10)
73#define MACHINE_FLAG_PFMF (1UL << 11)
74
75#define MACHINE_IS_VM (machine_flags & MACHINE_FLAG_VM)
76#define MACHINE_IS_KVM (machine_flags & MACHINE_FLAG_KVM)
77#define MACHINE_IS_P390 (machine_flags & MACHINE_FLAG_P390)
78#define MACHINE_HAS_DIAG9C (machine_flags & MACHINE_FLAG_DIAG9C)
67 79
68#ifndef __s390x__ 80#ifndef __s390x__
69#define MACHINE_HAS_IEEE (machine_flags & 2) 81#define MACHINE_HAS_IEEE (machine_flags & MACHINE_FLAG_IEEE)
70#define MACHINE_HAS_CSP (machine_flags & 8) 82#define MACHINE_HAS_CSP (machine_flags & MACHINE_FLAG_CSP)
83#define MACHINE_HAS_IDTE (0)
71#define MACHINE_HAS_DIAG44 (1) 84#define MACHINE_HAS_DIAG44 (1)
85#define MACHINE_HAS_MVPG (machine_flags & MACHINE_FLAG_MVPG)
72#define MACHINE_HAS_MVCOS (0) 86#define MACHINE_HAS_MVCOS (0)
87#define MACHINE_HAS_HPAGE (0)
88#define MACHINE_HAS_PFMF (0)
73#else /* __s390x__ */ 89#else /* __s390x__ */
74#define MACHINE_HAS_IEEE (1) 90#define MACHINE_HAS_IEEE (1)
75#define MACHINE_HAS_CSP (1) 91#define MACHINE_HAS_CSP (1)
76#define MACHINE_HAS_DIAG44 (machine_flags & 32) 92#define MACHINE_HAS_IDTE (machine_flags & MACHINE_FLAG_IDTE)
77#define MACHINE_HAS_MVCOS (machine_flags & 512) 93#define MACHINE_HAS_DIAG44 (machine_flags & MACHINE_FLAG_DIAG44)
94#define MACHINE_HAS_MVPG (1)
95#define MACHINE_HAS_MVCOS (machine_flags & MACHINE_FLAG_MVCOS)
96#define MACHINE_HAS_HPAGE (machine_flags & MACHINE_FLAG_HPAGE)
97#define MACHINE_HAS_PFMF (machine_flags & MACHINE_FLAG_PFMF)
78#endif /* __s390x__ */ 98#endif /* __s390x__ */
79 99
80#define MACHINE_HAS_SCLP (!MACHINE_IS_P390) 100#define MACHINE_HAS_SCLP (!MACHINE_IS_P390)
diff --git a/include/asm-s390/smp.h b/include/asm-s390/smp.h
index c7b74326a527..ae89cf2478fc 100644
--- a/include/asm-s390/smp.h
+++ b/include/asm-s390/smp.h
@@ -19,6 +19,7 @@
19#include <asm/lowcore.h> 19#include <asm/lowcore.h>
20#include <asm/sigp.h> 20#include <asm/sigp.h>
21#include <asm/ptrace.h> 21#include <asm/ptrace.h>
22#include <asm/system.h>
22 23
23/* 24/*
24 s390 specific smp.c headers 25 s390 specific smp.c headers
@@ -53,10 +54,7 @@ extern void machine_power_off_smp(void);
53 54
54static inline __u16 hard_smp_processor_id(void) 55static inline __u16 hard_smp_processor_id(void)
55{ 56{
56 __u16 cpu_address; 57 return stap();
57
58 asm volatile("stap %0" : "=m" (cpu_address));
59 return cpu_address;
60} 58}
61 59
62/* 60/*
@@ -90,6 +88,9 @@ extern void __cpu_die (unsigned int cpu);
90extern void cpu_die (void) __attribute__ ((noreturn)); 88extern void cpu_die (void) __attribute__ ((noreturn));
91extern int __cpu_up (unsigned int cpu); 89extern int __cpu_up (unsigned int cpu);
92 90
91extern struct mutex smp_cpu_state_mutex;
92extern int smp_cpu_polarization[];
93
93extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *), 94extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
94 void *info, int wait); 95 void *info, int wait);
95#endif 96#endif
@@ -105,5 +106,11 @@ static inline void smp_send_stop(void)
105#define smp_cpu_not_running(cpu) 1 106#define smp_cpu_not_running(cpu) 1
106#endif 107#endif
107 108
109#ifdef CONFIG_HOTPLUG_CPU
110extern int smp_rescan_cpus(void);
111#else
112static inline int smp_rescan_cpus(void) { return 0; }
113#endif
114
108extern union save_area *zfcpdump_save_areas[NR_CPUS + 1]; 115extern union save_area *zfcpdump_save_areas[NR_CPUS + 1];
109#endif 116#endif
diff --git a/include/asm-s390/sparsemem.h b/include/asm-s390/sparsemem.h
new file mode 100644
index 000000000000..06dfdab6c0e8
--- /dev/null
+++ b/include/asm-s390/sparsemem.h
@@ -0,0 +1,18 @@
1#ifndef _ASM_S390_SPARSEMEM_H
2#define _ASM_S390_SPARSEMEM_H
3
4#define SECTION_SIZE_BITS 25
5
6#ifdef CONFIG_64BIT
7
8#define MAX_PHYSADDR_BITS 42
9#define MAX_PHYSMEM_BITS 42
10
11#else
12
13#define MAX_PHYSADDR_BITS 31
14#define MAX_PHYSMEM_BITS 31
15
16#endif /* CONFIG_64BIT */
17
18#endif /* _ASM_S390_SPARSEMEM_H */
diff --git a/include/asm-s390/sysinfo.h b/include/asm-s390/sysinfo.h
new file mode 100644
index 000000000000..79d01343f8b0
--- /dev/null
+++ b/include/asm-s390/sysinfo.h
@@ -0,0 +1,121 @@
1/*
2 * definition for store system information stsi
3 *
4 * Copyright IBM Corp. 2001,2008
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 only)
8 * as published by the Free Software Foundation.
9 *
10 * Author(s): Ulrich Weigand <weigand@de.ibm.com>
11 * Christian Borntraeger <borntraeger@de.ibm.com>
12 */
13
14#ifndef __ASM_S390_SYSINFO_H
15#define __ASM_S390_SYSINFO_H
16
17struct sysinfo_1_1_1 {
18 char reserved_0[32];
19 char manufacturer[16];
20 char type[4];
21 char reserved_1[12];
22 char model_capacity[16];
23 char sequence[16];
24 char plant[4];
25 char model[16];
26 char model_perm_cap[16];
27 char model_temp_cap[16];
28 char model_cap_rating[4];
29 char model_perm_cap_rating[4];
30 char model_temp_cap_rating[4];
31};
32
33struct sysinfo_1_2_1 {
34 char reserved_0[80];
35 char sequence[16];
36 char plant[4];
37 char reserved_1[2];
38 unsigned short cpu_address;
39};
40
41struct sysinfo_1_2_2 {
42 char format;
43 char reserved_0[1];
44 unsigned short acc_offset;
45 char reserved_1[24];
46 unsigned int secondary_capability;
47 unsigned int capability;
48 unsigned short cpus_total;
49 unsigned short cpus_configured;
50 unsigned short cpus_standby;
51 unsigned short cpus_reserved;
52 unsigned short adjustment[0];
53};
54
55struct sysinfo_1_2_2_extension {
56 unsigned int alt_capability;
57 unsigned short alt_adjustment[0];
58};
59
60struct sysinfo_2_2_1 {
61 char reserved_0[80];
62 char sequence[16];
63 char plant[4];
64 unsigned short cpu_id;
65 unsigned short cpu_address;
66};
67
68struct sysinfo_2_2_2 {
69 char reserved_0[32];
70 unsigned short lpar_number;
71 char reserved_1;
72 unsigned char characteristics;
73 unsigned short cpus_total;
74 unsigned short cpus_configured;
75 unsigned short cpus_standby;
76 unsigned short cpus_reserved;
77 char name[8];
78 unsigned int caf;
79 char reserved_2[16];
80 unsigned short cpus_dedicated;
81 unsigned short cpus_shared;
82};
83
84#define LPAR_CHAR_DEDICATED (1 << 7)
85#define LPAR_CHAR_SHARED (1 << 6)
86#define LPAR_CHAR_LIMITED (1 << 5)
87
88struct sysinfo_3_2_2 {
89 char reserved_0[31];
90 unsigned char count;
91 struct {
92 char reserved_0[4];
93 unsigned short cpus_total;
94 unsigned short cpus_configured;
95 unsigned short cpus_standby;
96 unsigned short cpus_reserved;
97 char name[8];
98 unsigned int caf;
99 char cpi[16];
100 char reserved_1[24];
101
102 } vm[8];
103};
104
105static inline int stsi(void *sysinfo, int fc, int sel1, int sel2)
106{
107 register int r0 asm("0") = (fc << 28) | sel1;
108 register int r1 asm("1") = sel2;
109
110 asm volatile(
111 " stsi 0(%2)\n"
112 "0: jz 2f\n"
113 "1: lhi %0,%3\n"
114 "2:\n"
115 EX_TABLE(0b, 1b)
116 : "+d" (r0) : "d" (r1), "a" (sysinfo), "K" (-ENOSYS)
117 : "cc", "memory");
118 return r0;
119}
120
121#endif /* __ASM_S390_SYSINFO_H */
diff --git a/include/asm-s390/system.h b/include/asm-s390/system.h
index 15aba30601a3..c819ae25a842 100644
--- a/include/asm-s390/system.h
+++ b/include/asm-s390/system.h
@@ -16,6 +16,7 @@
16#include <asm/ptrace.h> 16#include <asm/ptrace.h>
17#include <asm/setup.h> 17#include <asm/setup.h>
18#include <asm/processor.h> 18#include <asm/processor.h>
19#include <asm/lowcore.h>
19 20
20#ifdef __KERNEL__ 21#ifdef __KERNEL__
21 22
@@ -406,6 +407,8 @@ __set_psw_mask(unsigned long mask)
406#define local_mcck_enable() __set_psw_mask(psw_kernel_bits) 407#define local_mcck_enable() __set_psw_mask(psw_kernel_bits)
407#define local_mcck_disable() __set_psw_mask(psw_kernel_bits & ~PSW_MASK_MCHECK) 408#define local_mcck_disable() __set_psw_mask(psw_kernel_bits & ~PSW_MASK_MCHECK)
408 409
410int stfle(unsigned long long *list, int doublewords);
411
409#ifdef CONFIG_SMP 412#ifdef CONFIG_SMP
410 413
411extern void smp_ctl_set_bit(int cr, int bit); 414extern void smp_ctl_set_bit(int cr, int bit);
@@ -420,6 +423,23 @@ extern void smp_ctl_clear_bit(int cr, int bit);
420 423
421#endif /* CONFIG_SMP */ 424#endif /* CONFIG_SMP */
422 425
426static inline unsigned int stfl(void)
427{
428 asm volatile(
429 " .insn s,0xb2b10000,0(0)\n" /* stfl */
430 "0:\n"
431 EX_TABLE(0b,0b));
432 return S390_lowcore.stfl_fac_list;
433}
434
435static inline unsigned short stap(void)
436{
437 unsigned short cpu_address;
438
439 asm volatile("stap %0" : "=m" (cpu_address));
440 return cpu_address;
441}
442
423extern void (*_machine_restart)(char *command); 443extern void (*_machine_restart)(char *command);
424extern void (*_machine_halt)(void); 444extern void (*_machine_halt)(void);
425extern void (*_machine_power_off)(void); 445extern void (*_machine_power_off)(void);
diff --git a/include/asm-s390/thread_info.h b/include/asm-s390/thread_info.h
index 0a518915bf90..99bbed99a3b2 100644
--- a/include/asm-s390/thread_info.h
+++ b/include/asm-s390/thread_info.h
@@ -89,7 +89,6 @@ static inline struct thread_info *current_thread_info(void)
89 * thread information flags bit numbers 89 * thread information flags bit numbers
90 */ 90 */
91#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 91#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
92#define TIF_RESTORE_SIGMASK 1 /* restore signal mask in do_signal() */
93#define TIF_SIGPENDING 2 /* signal pending */ 92#define TIF_SIGPENDING 2 /* signal pending */
94#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 93#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
95#define TIF_RESTART_SVC 4 /* restart svc with new svc number */ 94#define TIF_RESTART_SVC 4 /* restart svc with new svc number */
@@ -101,6 +100,7 @@ static inline struct thread_info *current_thread_info(void)
101 TIF_NEED_RESCHED */ 100 TIF_NEED_RESCHED */
102#define TIF_31BIT 18 /* 32bit process */ 101#define TIF_31BIT 18 /* 32bit process */
103#define TIF_MEMDIE 19 102#define TIF_MEMDIE 19
103#define TIF_RESTORE_SIGMASK 20 /* restore signal mask in do_signal() */
104 104
105#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 105#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
106#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 106#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
diff --git a/include/asm-s390/timex.h b/include/asm-s390/timex.h
index 98229db24314..d744c3d62de5 100644
--- a/include/asm-s390/timex.h
+++ b/include/asm-s390/timex.h
@@ -62,16 +62,18 @@ static inline unsigned long long get_clock (void)
62 return clk; 62 return clk;
63} 63}
64 64
65static inline void get_clock_extended(void *dest) 65static inline unsigned long long get_clock_xt(void)
66{ 66{
67 typedef struct { unsigned long long clk[2]; } __clock_t; 67 unsigned char clk[16];
68 68
69#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2) 69#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
70 asm volatile("stcke %0" : "=Q" (*((__clock_t *)dest)) : : "cc"); 70 asm volatile("stcke %0" : "=Q" (clk) : : "cc");
71#else /* __GNUC__ */ 71#else /* __GNUC__ */
72 asm volatile("stcke 0(%1)" : "=m" (*((__clock_t *)dest)) 72 asm volatile("stcke 0(%1)" : "=m" (clk)
73 : "a" ((__clock_t *)dest) : "cc"); 73 : "a" (clk) : "cc");
74#endif /* __GNUC__ */ 74#endif /* __GNUC__ */
75
76 return *((unsigned long long *)&clk[1]);
75} 77}
76 78
77static inline cycles_t get_cycles(void) 79static inline cycles_t get_cycles(void)
@@ -81,5 +83,6 @@ static inline cycles_t get_cycles(void)
81 83
82int get_sync_clock(unsigned long long *clock); 84int get_sync_clock(unsigned long long *clock);
83void init_cpu_timer(void); 85void init_cpu_timer(void);
86unsigned long long monotonic_clock(void);
84 87
85#endif 88#endif
diff --git a/include/asm-s390/tlbflush.h b/include/asm-s390/tlbflush.h
index 35fb4f9127b2..d60394b9745e 100644
--- a/include/asm-s390/tlbflush.h
+++ b/include/asm-s390/tlbflush.h
@@ -2,6 +2,7 @@
2#define _S390_TLBFLUSH_H 2#define _S390_TLBFLUSH_H
3 3
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/sched.h>
5#include <asm/processor.h> 6#include <asm/processor.h>
6#include <asm/pgalloc.h> 7#include <asm/pgalloc.h>
7 8
@@ -13,12 +14,14 @@ static inline void __tlb_flush_local(void)
13 asm volatile("ptlb" : : : "memory"); 14 asm volatile("ptlb" : : : "memory");
14} 15}
15 16
17#ifdef CONFIG_SMP
16/* 18/*
17 * Flush all tlb entries on all cpus. 19 * Flush all tlb entries on all cpus.
18 */ 20 */
21void smp_ptlb_all(void);
22
19static inline void __tlb_flush_global(void) 23static inline void __tlb_flush_global(void)
20{ 24{
21 extern void smp_ptlb_all(void);
22 register unsigned long reg2 asm("2"); 25 register unsigned long reg2 asm("2");
23 register unsigned long reg3 asm("3"); 26 register unsigned long reg3 asm("3");
24 register unsigned long reg4 asm("4"); 27 register unsigned long reg4 asm("4");
@@ -39,6 +42,25 @@ static inline void __tlb_flush_global(void)
39 : : "d" (reg2), "d" (reg3), "d" (reg4), "m" (dummy) : "cc" ); 42 : : "d" (reg2), "d" (reg3), "d" (reg4), "m" (dummy) : "cc" );
40} 43}
41 44
45static inline void __tlb_flush_full(struct mm_struct *mm)
46{
47 cpumask_t local_cpumask;
48
49 preempt_disable();
50 /*
51 * If the process only ran on the local cpu, do a local flush.
52 */
53 local_cpumask = cpumask_of_cpu(smp_processor_id());
54 if (cpus_equal(mm->cpu_vm_mask, local_cpumask))
55 __tlb_flush_local();
56 else
57 __tlb_flush_global();
58 preempt_enable();
59}
60#else
61#define __tlb_flush_full(mm) __tlb_flush_local()
62#endif
63
42/* 64/*
43 * Flush all tlb entries of a page table on all cpus. 65 * Flush all tlb entries of a page table on all cpus.
44 */ 66 */
@@ -51,8 +73,6 @@ static inline void __tlb_flush_idte(unsigned long asce)
51 73
52static inline void __tlb_flush_mm(struct mm_struct * mm) 74static inline void __tlb_flush_mm(struct mm_struct * mm)
53{ 75{
54 cpumask_t local_cpumask;
55
56 if (unlikely(cpus_empty(mm->cpu_vm_mask))) 76 if (unlikely(cpus_empty(mm->cpu_vm_mask)))
57 return; 77 return;
58 /* 78 /*
@@ -69,16 +89,7 @@ static inline void __tlb_flush_mm(struct mm_struct * mm)
69 mm->context.asce_bits); 89 mm->context.asce_bits);
70 return; 90 return;
71 } 91 }
72 preempt_disable(); 92 __tlb_flush_full(mm);
73 /*
74 * If the process only ran on the local cpu, do a local flush.
75 */
76 local_cpumask = cpumask_of_cpu(smp_processor_id());
77 if (cpus_equal(mm->cpu_vm_mask, local_cpumask))
78 __tlb_flush_local();
79 else
80 __tlb_flush_global();
81 preempt_enable();
82} 93}
83 94
84static inline void __tlb_flush_mm_cond(struct mm_struct * mm) 95static inline void __tlb_flush_mm_cond(struct mm_struct * mm)
diff --git a/include/asm-s390/topology.h b/include/asm-s390/topology.h
index 613aa64019da..d96c91643458 100644
--- a/include/asm-s390/topology.h
+++ b/include/asm-s390/topology.h
@@ -1,6 +1,33 @@
1#ifndef _ASM_S390_TOPOLOGY_H 1#ifndef _ASM_S390_TOPOLOGY_H
2#define _ASM_S390_TOPOLOGY_H 2#define _ASM_S390_TOPOLOGY_H
3 3
4#include <linux/cpumask.h>
5
6#define mc_capable() (1)
7
8cpumask_t cpu_coregroup_map(unsigned int cpu);
9
10extern cpumask_t cpu_core_map[NR_CPUS];
11
12#define topology_core_siblings(cpu) (cpu_core_map[cpu])
13
14int topology_set_cpu_management(int fc);
15void topology_schedule_update(void);
16
17#define POLARIZATION_UNKNWN (-1)
18#define POLARIZATION_HRZ (0)
19#define POLARIZATION_VL (1)
20#define POLARIZATION_VM (2)
21#define POLARIZATION_VH (3)
22
23#ifdef CONFIG_SMP
24void s390_init_cpu_topology(void);
25#else
26static inline void s390_init_cpu_topology(void)
27{
28};
29#endif
30
4#include <asm-generic/topology.h> 31#include <asm-generic/topology.h>
5 32
6#endif /* _ASM_S390_TOPOLOGY_H */ 33#endif /* _ASM_S390_TOPOLOGY_H */
diff --git a/include/asm-s390/unaligned.h b/include/asm-s390/unaligned.h
index 8ee86dbedd1f..da9627afe5d8 100644
--- a/include/asm-s390/unaligned.h
+++ b/include/asm-s390/unaligned.h
@@ -1,24 +1,13 @@
1/* 1#ifndef _ASM_S390_UNALIGNED_H
2 * include/asm-s390/unaligned.h 2#define _ASM_S390_UNALIGNED_H
3 *
4 * S390 version
5 *
6 * Derived from "include/asm-i386/unaligned.h"
7 */
8
9#ifndef __S390_UNALIGNED_H
10#define __S390_UNALIGNED_H
11 3
12/* 4/*
13 * The S390 can do unaligned accesses itself. 5 * The S390 can do unaligned accesses itself.
14 *
15 * The strange macros are there to make sure these can't
16 * be misused in a way that makes them not work on other
17 * architectures where unaligned accesses aren't as simple.
18 */ 6 */
7#include <linux/unaligned/access_ok.h>
8#include <linux/unaligned/generic.h>
19 9
20#define get_unaligned(ptr) (*(ptr)) 10#define get_unaligned __get_unaligned_be
21 11#define put_unaligned __put_unaligned_be
22#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
23 12
24#endif 13#endif /* _ASM_S390_UNALIGNED_H */
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
index b6ba5a60dec2..d7d382f63ee5 100644
--- a/include/asm-sh/bitops.h
+++ b/include/asm-sh/bitops.h
@@ -95,6 +95,7 @@ static inline unsigned long ffz(unsigned long word)
95#include <asm-generic/bitops/ext2-atomic.h> 95#include <asm-generic/bitops/ext2-atomic.h>
96#include <asm-generic/bitops/minix.h> 96#include <asm-generic/bitops/minix.h>
97#include <asm-generic/bitops/fls.h> 97#include <asm-generic/bitops/fls.h>
98#include <asm-generic/bitops/__fls.h>
98#include <asm-generic/bitops/fls64.h> 99#include <asm-generic/bitops/fls64.h>
99 100
100#endif /* __KERNEL__ */ 101#endif /* __KERNEL__ */
diff --git a/include/asm-sh/bugs.h b/include/asm-sh/bugs.h
index cfda7d5bf026..121b2ecddfc3 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_SH7203 ... CPU_SH7263: 28 case CPU_SH7203 ... CPU_MXG:
29 *p++ = '2'; 29 *p++ = '2';
30 *p++ = 'a'; 30 *p++ = 'a';
31 break; 31 break;
diff --git a/include/asm-sh/cpu-sh4/freq.h b/include/asm-sh/cpu-sh4/freq.h
index ec028c649215..da46e67ae26d 100644
--- a/include/asm-sh/cpu-sh4/freq.h
+++ b/include/asm-sh/cpu-sh4/freq.h
@@ -10,14 +10,14 @@
10#ifndef __ASM_CPU_SH4_FREQ_H 10#ifndef __ASM_CPU_SH4_FREQ_H
11#define __ASM_CPU_SH4_FREQ_H 11#define __ASM_CPU_SH4_FREQ_H
12 12
13#if defined(CONFIG_CPU_SUBTYPE_SH7722) || defined(CONFIG_CPU_SUBTYPE_SH7366) 13#if defined(CONFIG_CPU_SUBTYPE_SH7722) || \
14 defined(CONFIG_CPU_SUBTYPE_SH7723) || \
15 defined(CONFIG_CPU_SUBTYPE_SH7366)
14#define FRQCR 0xa4150000 16#define FRQCR 0xa4150000
15#define VCLKCR 0xa4150004 17#define VCLKCR 0xa4150004
16#define SCLKACR 0xa4150008 18#define SCLKACR 0xa4150008
17#define SCLKBCR 0xa415000c 19#define SCLKBCR 0xa415000c
18#if defined(CONFIG_CPU_SUBTYPE_SH7722)
19#define IrDACLKCR 0xa4150010 20#define IrDACLKCR 0xa4150010
20#endif
21#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 21#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
22 defined(CONFIG_CPU_SUBTYPE_SH7780) 22 defined(CONFIG_CPU_SUBTYPE_SH7780)
23#define FRQCR 0xffc80000 23#define FRQCR 0xffc80000
diff --git a/include/asm-sh/cpu-sh4/rtc.h b/include/asm-sh/cpu-sh4/rtc.h
index f3d0f53275e4..25b1e6adfe8c 100644
--- a/include/asm-sh/cpu-sh4/rtc.h
+++ b/include/asm-sh/cpu-sh4/rtc.h
@@ -1,7 +1,12 @@
1#ifndef __ASM_SH_CPU_SH4_RTC_H 1#ifndef __ASM_SH_CPU_SH4_RTC_H
2#define __ASM_SH_CPU_SH4_RTC_H 2#define __ASM_SH_CPU_SH4_RTC_H
3 3
4#ifdef CONFIG_CPU_SUBTYPE_SH7723
5#define rtc_reg_size sizeof(u16)
6#else
4#define rtc_reg_size sizeof(u32) 7#define rtc_reg_size sizeof(u32)
8#endif
9
5#define RTC_BIT_INVERTED 0x40 /* bug on SH7750, SH7750S */ 10#define RTC_BIT_INVERTED 0x40 /* bug on SH7750, SH7750S */
6#define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR 11#define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR
7 12
diff --git a/include/asm-sh/futex.h b/include/asm-sh/futex.h
index 74ed3681d33c..68256ec5fa35 100644
--- a/include/asm-sh/futex.h
+++ b/include/asm-sh/futex.h
@@ -4,8 +4,8 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/futex.h> 6#include <linux/futex.h>
7#include <linux/uaccess.h>
7#include <asm/errno.h> 8#include <asm/errno.h>
8#include <asm/uaccess.h>
9 9
10/* XXX: UP variants, fix for SH-4A and SMP.. */ 10/* XXX: UP variants, fix for SH-4A and SMP.. */
11#include <asm/futex-irq.h> 11#include <asm/futex-irq.h>
diff --git a/include/asm-sh/hugetlb.h b/include/asm-sh/hugetlb.h
new file mode 100644
index 000000000000..02402303d89b
--- /dev/null
+++ b/include/asm-sh/hugetlb.h
@@ -0,0 +1,91 @@
1#ifndef _ASM_SH_HUGETLB_H
2#define _ASM_SH_HUGETLB_H
3
4#include <asm/page.h>
5
6
7static inline int is_hugepage_only_range(struct mm_struct *mm,
8 unsigned long addr,
9 unsigned long len) {
10 return 0;
11}
12
13/*
14 * If the arch doesn't supply something else, assume that hugepage
15 * size aligned regions are ok without further preparation.
16 */
17static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
18{
19 if (len & ~HPAGE_MASK)
20 return -EINVAL;
21 if (addr & ~HPAGE_MASK)
22 return -EINVAL;
23 return 0;
24}
25
26static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm) {
27}
28
29static inline void hugetlb_free_pgd_range(struct mmu_gather **tlb,
30 unsigned long addr, unsigned long end,
31 unsigned long floor,
32 unsigned long ceiling)
33{
34 free_pgd_range(tlb, addr, end, floor, ceiling);
35}
36
37static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
38 pte_t *ptep, pte_t pte)
39{
40 set_pte_at(mm, addr, ptep, pte);
41}
42
43static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
44 unsigned long addr, pte_t *ptep)
45{
46 return ptep_get_and_clear(mm, addr, ptep);
47}
48
49static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
50 unsigned long addr, pte_t *ptep)
51{
52}
53
54static inline int huge_pte_none(pte_t pte)
55{
56 return pte_none(pte);
57}
58
59static inline pte_t huge_pte_wrprotect(pte_t pte)
60{
61 return pte_wrprotect(pte);
62}
63
64static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
65 unsigned long addr, pte_t *ptep)
66{
67 ptep_set_wrprotect(mm, addr, ptep);
68}
69
70static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
71 unsigned long addr, pte_t *ptep,
72 pte_t pte, int dirty)
73{
74 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
75}
76
77static inline pte_t huge_ptep_get(pte_t *ptep)
78{
79 return *ptep;
80}
81
82static inline int arch_prepare_hugepage(struct page *page)
83{
84 return 0;
85}
86
87static inline void arch_release_hugepage(struct page *page)
88{
89}
90
91#endif /* _ASM_SH_HUGETLB_H */
diff --git a/include/asm-sh/i2c-sh7760.h b/include/asm-sh/i2c-sh7760.h
new file mode 100644
index 000000000000..24182116711f
--- /dev/null
+++ b/include/asm-sh/i2c-sh7760.h
@@ -0,0 +1,22 @@
1/*
2 * MMIO/IRQ and platform data for SH7760 I2C channels
3 */
4
5#ifndef _I2C_SH7760_H_
6#define _I2C_SH7760_H_
7
8#define SH7760_I2C_DEVNAME "sh7760-i2c"
9
10#define SH7760_I2C0_MMIO 0xFE140000
11#define SH7760_I2C0_MMIOEND 0xFE14003B
12#define SH7760_I2C0_IRQ 62
13
14#define SH7760_I2C1_MMIO 0xFE150000
15#define SH7760_I2C1_MMIOEND 0xFE15003B
16#define SH7760_I2C1_IRQ 63
17
18struct sh7760_i2c_platdata {
19 unsigned int speed_khz;
20};
21
22#endif
diff --git a/include/asm-sh/ide.h b/include/asm-sh/ide.h
index 9f8e9142dc33..58e0bdd52be4 100644
--- a/include/asm-sh/ide.h
+++ b/include/asm-sh/ide.h
@@ -14,9 +14,6 @@
14 14
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16 16
17
18#define ide_default_io_ctl(base) (0)
19
20#include <asm-generic/ide_iops.h> 17#include <asm-generic/ide_iops.h>
21 18
22#endif /* __KERNEL__ */ 19#endif /* __KERNEL__ */
diff --git a/include/asm-sh/migor.h b/include/asm-sh/migor.h
new file mode 100644
index 000000000000..2329363afdc3
--- /dev/null
+++ b/include/asm-sh/migor.h
@@ -0,0 +1,58 @@
1#ifndef __ASM_SH_MIGOR_H
2#define __ASM_SH_MIGOR_H
3
4/*
5 * linux/include/asm-sh/migor.h
6 *
7 * Copyright (C) 2008 Renesas Solutions
8 *
9 * Portions Copyright (C) 2007 Nobuhiro Iwamatsu
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 */
16#include <asm/addrspace.h>
17
18/* GPIO */
19#define MSTPCR0 0xa4150030
20#define MSTPCR1 0xa4150034
21#define MSTPCR2 0xa4150038
22
23#define PORT_PACR 0xa4050100
24#define PORT_PDCR 0xa4050106
25#define PORT_PECR 0xa4050108
26#define PORT_PHCR 0xa405010e
27#define PORT_PJCR 0xa4050110
28#define PORT_PKCR 0xa4050112
29#define PORT_PLCR 0xa4050114
30#define PORT_PMCR 0xa4050116
31#define PORT_PRCR 0xa405011c
32#define PORT_PWCR 0xa4050146
33#define PORT_PXCR 0xa4050148
34#define PORT_PYCR 0xa405014a
35#define PORT_PZCR 0xa405014c
36#define PORT_PADR 0xa4050120
37#define PORT_PWDR 0xa4050166
38
39#define PORT_HIZCRA 0xa4050158
40#define PORT_HIZCRC 0xa405015c
41
42#define PORT_MSELCRB 0xa4050182
43
44#define MSTPCR1 0xa4150034
45#define MSTPCR2 0xa4150038
46
47#define PORT_PSELA 0xa405014e
48#define PORT_PSELB 0xa4050150
49#define PORT_PSELC 0xa4050152
50#define PORT_PSELD 0xa4050154
51
52#define PORT_HIZCRA 0xa4050158
53#define PORT_HIZCRB 0xa405015a
54#define PORT_HIZCRC 0xa405015c
55
56#define BSC_CS6ABCR 0xfec1001c
57
58#endif /* __ASM_SH_MIGOR_H */
diff --git a/include/asm-sh/mpc1211/pci.h b/include/asm-sh/mpc1211/pci.h
index 5d3712c3a701..d9162c5ed76a 100644
--- a/include/asm-sh/mpc1211/pci.h
+++ b/include/asm-sh/mpc1211/pci.h
@@ -24,8 +24,6 @@
24#define PCI_PROBE_BIOS 1 24#define PCI_PROBE_BIOS 1
25#define PCI_PROBE_CONF1 2 25#define PCI_PROBE_CONF1 2
26#define PCI_PROBE_CONF2 4 26#define PCI_PROBE_CONF2 4
27#define PCI_NO_SORT 0x100
28#define PCI_BIOS_SORT 0x200
29#define PCI_NO_CHECKS 0x400 27#define PCI_NO_CHECKS 0x400
30#define PCI_ASSIGN_ROMS 0x1000 28#define PCI_ASSIGN_ROMS 0x1000
31#define PCI_BIOS_IRQ_SCAN 0x2000 29#define PCI_BIOS_IRQ_SCAN 0x2000
diff --git a/include/asm-sh/pgtable_32.h b/include/asm-sh/pgtable_32.h
index 3e3557c53c55..cbc731d35c25 100644
--- a/include/asm-sh/pgtable_32.h
+++ b/include/asm-sh/pgtable_32.h
@@ -326,6 +326,7 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
326#define pte_dirty(pte) ((pte).pte_low & _PAGE_DIRTY) 326#define pte_dirty(pte) ((pte).pte_low & _PAGE_DIRTY)
327#define pte_young(pte) ((pte).pte_low & _PAGE_ACCESSED) 327#define pte_young(pte) ((pte).pte_low & _PAGE_ACCESSED)
328#define pte_file(pte) ((pte).pte_low & _PAGE_FILE) 328#define pte_file(pte) ((pte).pte_low & _PAGE_FILE)
329#define pte_special(pte) (0)
329 330
330#ifdef CONFIG_X2TLB 331#ifdef CONFIG_X2TLB
331#define pte_write(pte) ((pte).pte_high & _PAGE_EXT_USER_WRITE) 332#define pte_write(pte) ((pte).pte_high & _PAGE_EXT_USER_WRITE)
@@ -356,6 +357,8 @@ PTE_BIT_FUNC(low, mkdirty, |= _PAGE_DIRTY);
356PTE_BIT_FUNC(low, mkold, &= ~_PAGE_ACCESSED); 357PTE_BIT_FUNC(low, mkold, &= ~_PAGE_ACCESSED);
357PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED); 358PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED);
358 359
360static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
361
359/* 362/*
360 * Macro and implementation to make a page protection as uncachable. 363 * Macro and implementation to make a page protection as uncachable.
361 */ 364 */
diff --git a/include/asm-sh/pgtable_64.h b/include/asm-sh/pgtable_64.h
index f9dd9d311441..c78990cda557 100644
--- a/include/asm-sh/pgtable_64.h
+++ b/include/asm-sh/pgtable_64.h
@@ -254,10 +254,11 @@ extern void __handle_bad_pmd_kernel(pmd_t * pmd);
254/* 254/*
255 * The following have defined behavior only work if pte_present() is true. 255 * The following have defined behavior only work if pte_present() is true.
256 */ 256 */
257static inline int pte_dirty(pte_t pte){ return pte_val(pte) & _PAGE_DIRTY; } 257static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
258static inline int pte_young(pte_t pte){ return pte_val(pte) & _PAGE_ACCESSED; } 258static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
259static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 259static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
260static inline int pte_write(pte_t pte){ return pte_val(pte) & _PAGE_WRITE; } 260static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; }
261static inline int pte_special(pte_t pte){ return 0; }
261 262
262static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_WRITE)); return pte; } 263static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_WRITE)); return pte; }
263static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; } 264static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
@@ -266,6 +267,7 @@ static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) |
266static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; } 267static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
267static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; } 268static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
268static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; } 269static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; }
270static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
269 271
270 272
271/* 273/*
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index ec707b98e5b9..b7c7ce80f03e 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -16,7 +16,7 @@ enum cpu_type {
16 CPU_SH7619, 16 CPU_SH7619,
17 17
18 /* SH-2A types */ 18 /* SH-2A types */
19 CPU_SH7203, CPU_SH7206, CPU_SH7263, 19 CPU_SH7203, CPU_SH7206, CPU_SH7263, CPU_MXG,
20 20
21 /* SH-3 types */ 21 /* SH-3 types */
22 CPU_SH7705, CPU_SH7706, CPU_SH7707, 22 CPU_SH7705, CPU_SH7706, CPU_SH7707,
@@ -29,7 +29,8 @@ enum cpu_type {
29 CPU_SH7760, CPU_SH4_202, CPU_SH4_501, 29 CPU_SH7760, CPU_SH4_202, CPU_SH4_501,
30 30
31 /* SH-4A types */ 31 /* SH-4A types */
32 CPU_SH7763, CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785, CPU_SHX3, 32 CPU_SH7763, CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785,
33 CPU_SH7723, CPU_SHX3,
33 34
34 /* SH4AL-DSP types */ 35 /* SH4AL-DSP types */
35 CPU_SH7343, CPU_SH7722, CPU_SH7366, 36 CPU_SH7343, CPU_SH7722, CPU_SH7366,
diff --git a/include/asm-sh/r7780rp.h b/include/asm-sh/r7780rp.h
index 1770460a4616..a33838f23a6d 100644
--- a/include/asm-sh/r7780rp.h
+++ b/include/asm-sh/r7780rp.h
@@ -55,11 +55,11 @@
55#define PA_SCSPTR1 (PA_BCR+0x0524) /* SCIF1 Serial Port control */ 55#define PA_SCSPTR1 (PA_BCR+0x0524) /* SCIF1 Serial Port control */
56#define PA_SCLSR1 (PA_BCR+0x0528) /* SCIF1 Line Status control */ 56#define PA_SCLSR1 (PA_BCR+0x0528) /* SCIF1 Line Status control */
57#define PA_SCRER1 (PA_BCR+0x052c) /* SCIF1 Serial Error control */ 57#define PA_SCRER1 (PA_BCR+0x052c) /* SCIF1 Serial Error control */
58#define PA_ICCR (PA_BCR+0x0600) /* Serial control */ 58#define PA_SMCR (PA_BCR+0x0600) /* 2-wire Serial control */
59#define PA_SAR (PA_BCR+0x0602) /* Serial Slave control */ 59#define PA_SMSMADR (PA_BCR+0x0602) /* 2-wire Serial Slave control */
60#define PA_MDR (PA_BCR+0x0604) /* Serial Mode control */ 60#define PA_SMMR (PA_BCR+0x0604) /* 2-wire Serial Mode control */
61#define PA_ADR1 (PA_BCR+0x0606) /* Serial Address1 control */ 61#define PA_SMSADR1 (PA_BCR+0x0606) /* 2-wire Serial Address1 control */
62#define PA_DAR1 (PA_BCR+0x0646) /* Serial Data1 control */ 62#define PA_SMTRDR1 (PA_BCR+0x0646) /* 2-wire Serial Data1 control */
63#define PA_VERREG (PA_BCR+0x0700) /* FPGA Version Register */ 63#define PA_VERREG (PA_BCR+0x0700) /* FPGA Version Register */
64#define PA_POFF (PA_BCR+0x0800) /* System Power Off control */ 64#define PA_POFF (PA_BCR+0x0800) /* System Power Off control */
65#define PA_PMR (PA_BCR+0x0900) /* */ 65#define PA_PMR (PA_BCR+0x0900) /* */
@@ -107,11 +107,11 @@
107#define PA_SCFCR (PA_BCR+0x040c) /* SCIF FIFO control */ 107#define PA_SCFCR (PA_BCR+0x040c) /* SCIF FIFO control */
108#define PA_SCFDR (PA_BCR+0x040e) /* SCIF FIFO data control */ 108#define PA_SCFDR (PA_BCR+0x040e) /* SCIF FIFO data control */
109#define PA_SCLSR (PA_BCR+0x0412) /* SCIF Line Status control */ 109#define PA_SCLSR (PA_BCR+0x0412) /* SCIF Line Status control */
110#define PA_ICCR (PA_BCR+0x0500) /* Serial control */ 110#define PA_SMCR (PA_BCR+0x0500) /* 2-wire Serial control */
111#define PA_SAR (PA_BCR+0x0502) /* Serial Slave control */ 111#define PA_SMSMADR (PA_BCR+0x0502) /* 2-wire Serial Slave control */
112#define PA_MDR (PA_BCR+0x0504) /* Serial Mode control */ 112#define PA_SMMR (PA_BCR+0x0504) /* 2-wire Serial Mode control */
113#define PA_ADR1 (PA_BCR+0x0506) /* Serial Address1 control */ 113#define PA_SMSADR1 (PA_BCR+0x0506) /* 2-wire Serial Address1 control */
114#define PA_DAR1 (PA_BCR+0x0546) /* Serial Data1 control */ 114#define PA_SMTRDR1 (PA_BCR+0x0546) /* 2-wire Serial Data1 control */
115#define PA_VERREG (PA_BCR+0x0600) /* FPGA Version Register */ 115#define PA_VERREG (PA_BCR+0x0600) /* FPGA Version Register */
116 116
117#define PA_AX88796L 0xa5800400 /* AX88796L Area */ 117#define PA_AX88796L 0xa5800400 /* AX88796L Area */
@@ -190,6 +190,8 @@
190#define IRQ_TP (HL_FPGA_IRQ_BASE + 12) 190#define IRQ_TP (HL_FPGA_IRQ_BASE + 12)
191#define IRQ_RTC (HL_FPGA_IRQ_BASE + 13) 191#define IRQ_RTC (HL_FPGA_IRQ_BASE + 13)
192#define IRQ_TH_ALERT (HL_FPGA_IRQ_BASE + 14) 192#define IRQ_TH_ALERT (HL_FPGA_IRQ_BASE + 14)
193#define IRQ_SCIF0 (HL_FPGA_IRQ_BASE + 15)
194#define IRQ_SCIF1 (HL_FPGA_IRQ_BASE + 16)
193 195
194unsigned char *highlander_init_irq_r7780mp(void); 196unsigned char *highlander_init_irq_r7780mp(void);
195unsigned char *highlander_init_irq_r7780rp(void); 197unsigned char *highlander_init_irq_r7780rp(void);
diff --git a/include/asm-sh/se7721.h b/include/asm-sh/se7721.h
new file mode 100644
index 000000000000..b957f6041193
--- /dev/null
+++ b/include/asm-sh/se7721.h
@@ -0,0 +1,70 @@
1/*
2 * Copyright (C) 2008 Renesas Solutions Corp.
3 *
4 * Hitachi UL SolutionEngine 7721 Support.
5 *
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
8 * for more details.
9 *
10 */
11
12#ifndef __ASM_SH_SE7721_H
13#define __ASM_SH_SE7721_H
14#include <asm/addrspace.h>
15
16/* Box specific addresses. */
17#define SE_AREA0_WIDTH 2 /* Area0: 32bit */
18#define PA_ROM 0xa0000000 /* EPROM */
19#define PA_ROM_SIZE 0x00200000 /* EPROM size 2M byte */
20#define PA_FROM 0xa1000000 /* Flash-ROM */
21#define PA_FROM_SIZE 0x01000000 /* Flash-ROM size 16M byte */
22#define PA_EXT1 0xa4000000
23#define PA_EXT1_SIZE 0x04000000
24#define PA_SDRAM 0xaC000000 /* SDRAM(Area3) 64MB */
25#define PA_SDRAM_SIZE 0x04000000
26
27#define PA_EXT4 0xb0000000
28#define PA_EXT4_SIZE 0x04000000
29
30#define PA_PERIPHERAL 0xB8000000
31
32#define PA_PCIC PA_PERIPHERAL
33#define PA_MRSHPC (PA_PERIPHERAL + 0x003fffe0)
34#define PA_MRSHPC_MW1 (PA_PERIPHERAL + 0x00400000)
35#define PA_MRSHPC_MW2 (PA_PERIPHERAL + 0x00500000)
36#define PA_MRSHPC_IO (PA_PERIPHERAL + 0x00600000)
37#define MRSHPC_OPTION (PA_MRSHPC + 6)
38#define MRSHPC_CSR (PA_MRSHPC + 8)
39#define MRSHPC_ISR (PA_MRSHPC + 10)
40#define MRSHPC_ICR (PA_MRSHPC + 12)
41#define MRSHPC_CPWCR (PA_MRSHPC + 14)
42#define MRSHPC_MW0CR1 (PA_MRSHPC + 16)
43#define MRSHPC_MW1CR1 (PA_MRSHPC + 18)
44#define MRSHPC_IOWCR1 (PA_MRSHPC + 20)
45#define MRSHPC_MW0CR2 (PA_MRSHPC + 22)
46#define MRSHPC_MW1CR2 (PA_MRSHPC + 24)
47#define MRSHPC_IOWCR2 (PA_MRSHPC + 26)
48#define MRSHPC_CDCR (PA_MRSHPC + 28)
49#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
50
51#define PA_LED 0xB6800000 /* 8bit LED */
52#define PA_FPGA 0xB7000000 /* FPGA base address */
53
54#define MRSHPC_IRQ0 10
55
56#define FPGA_ILSR1 (PA_FPGA + 0x02)
57#define FPGA_ILSR2 (PA_FPGA + 0x03)
58#define FPGA_ILSR3 (PA_FPGA + 0x04)
59#define FPGA_ILSR4 (PA_FPGA + 0x05)
60#define FPGA_ILSR5 (PA_FPGA + 0x06)
61#define FPGA_ILSR6 (PA_FPGA + 0x07)
62#define FPGA_ILSR7 (PA_FPGA + 0x08)
63#define FPGA_ILSR8 (PA_FPGA + 0x09)
64
65void init_se7721_IRQ(void);
66
67#define __IO_PREFIX se7721
68#include <asm/io_generic.h>
69
70#endif /* __ASM_SH_SE7721_H */
diff --git a/include/asm-sh/se7722.h b/include/asm-sh/se7722.h
index e0e89fcb8388..3690fe5857a4 100644
--- a/include/asm-sh/se7722.h
+++ b/include/asm-sh/se7722.h
@@ -77,6 +77,8 @@
77#define PORT_PSELA 0xA405014EUL 77#define PORT_PSELA 0xA405014EUL
78#define PORT_PYCR 0xA405014AUL 78#define PORT_PYCR 0xA405014AUL
79#define PORT_PZCR 0xA405014CUL 79#define PORT_PZCR 0xA405014CUL
80#define PORT_HIZCRA 0xA4050158UL
81#define PORT_HIZCRC 0xA405015CUL
80 82
81/* IRQ */ 83/* IRQ */
82#define IRQ0_IRQ 32 84#define IRQ0_IRQ 32
diff --git a/include/asm-sh/semaphore-helper.h b/include/asm-sh/semaphore-helper.h
deleted file mode 100644
index bd8230c369ca..000000000000
--- a/include/asm-sh/semaphore-helper.h
+++ /dev/null
@@ -1,89 +0,0 @@
1#ifndef __ASM_SH_SEMAPHORE_HELPER_H
2#define __ASM_SH_SEMAPHORE_HELPER_H
3
4/*
5 * SMP- and interrupt-safe semaphores helper functions.
6 *
7 * (C) Copyright 1996 Linus Torvalds
8 * (C) Copyright 1999 Andrea Arcangeli
9 */
10
11/*
12 * These two _must_ execute atomically wrt each other.
13 *
14 * This is trivially done with load_locked/store_cond,
15 * which we have. Let the rest of the losers suck eggs.
16 */
17static __inline__ void wake_one_more(struct semaphore * sem)
18{
19 atomic_inc((atomic_t *)&sem->sleepers);
20}
21
22static __inline__ int waking_non_zero(struct semaphore *sem)
23{
24 unsigned long flags;
25 int ret = 0;
26
27 spin_lock_irqsave(&semaphore_wake_lock, flags);
28 if (sem->sleepers > 0) {
29 sem->sleepers--;
30 ret = 1;
31 }
32 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
33 return ret;
34}
35
36/*
37 * waking_non_zero_interruptible:
38 * 1 got the lock
39 * 0 go to sleep
40 * -EINTR interrupted
41 *
42 * We must undo the sem->count down_interruptible() increment while we are
43 * protected by the spinlock in order to make atomic this atomic_inc() with the
44 * atomic_read() in wake_one_more(), otherwise we can race. -arca
45 */
46static __inline__ int waking_non_zero_interruptible(struct semaphore *sem,
47 struct task_struct *tsk)
48{
49 unsigned long flags;
50 int ret = 0;
51
52 spin_lock_irqsave(&semaphore_wake_lock, flags);
53 if (sem->sleepers > 0) {
54 sem->sleepers--;
55 ret = 1;
56 } else if (signal_pending(tsk)) {
57 atomic_inc(&sem->count);
58 ret = -EINTR;
59 }
60 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
61 return ret;
62}
63
64/*
65 * waking_non_zero_trylock:
66 * 1 failed to lock
67 * 0 got the lock
68 *
69 * We must undo the sem->count down_trylock() increment while we are
70 * protected by the spinlock in order to make atomic this atomic_inc() with the
71 * atomic_read() in wake_one_more(), otherwise we can race. -arca
72 */
73static __inline__ int waking_non_zero_trylock(struct semaphore *sem)
74{
75 unsigned long flags;
76 int ret = 1;
77
78 spin_lock_irqsave(&semaphore_wake_lock, flags);
79 if (sem->sleepers <= 0)
80 atomic_inc(&sem->count);
81 else {
82 sem->sleepers--;
83 ret = 0;
84 }
85 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
86 return ret;
87}
88
89#endif /* __ASM_SH_SEMAPHORE_HELPER_H */
diff --git a/include/asm-sh/semaphore.h b/include/asm-sh/semaphore.h
index 9e5a37c4dce2..d9b2034ed1d2 100644
--- a/include/asm-sh/semaphore.h
+++ b/include/asm-sh/semaphore.h
@@ -1,115 +1 @@
1#ifndef __ASM_SH_SEMAPHORE_H #include <linux/semaphore.h>
2#define __ASM_SH_SEMAPHORE_H
3
4#include <linux/linkage.h>
5
6#ifdef __KERNEL__
7/*
8 * SMP- and interrupt-safe semaphores.
9 *
10 * (C) Copyright 1996 Linus Torvalds
11 *
12 * SuperH verison by Niibe Yutaka
13 * (Currently no asm implementation but generic C code...)
14 */
15
16#include <linux/spinlock.h>
17#include <linux/rwsem.h>
18#include <linux/wait.h>
19
20#include <asm/system.h>
21#include <asm/atomic.h>
22
23struct semaphore {
24 atomic_t count;
25 int sleepers;
26 wait_queue_head_t wait;
27};
28
29#define __SEMAPHORE_INITIALIZER(name, n) \
30{ \
31 .count = ATOMIC_INIT(n), \
32 .sleepers = 0, \
33 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
34}
35
36#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
37 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
38
39#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
40
41static inline void sema_init (struct semaphore *sem, int val)
42{
43/*
44 * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
45 *
46 * i'd rather use the more flexible initialization above, but sadly
47 * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
48 */
49 atomic_set(&sem->count, val);
50 sem->sleepers = 0;
51 init_waitqueue_head(&sem->wait);
52}
53
54static inline void init_MUTEX (struct semaphore *sem)
55{
56 sema_init(sem, 1);
57}
58
59static inline void init_MUTEX_LOCKED (struct semaphore *sem)
60{
61 sema_init(sem, 0);
62}
63
64#if 0
65asmlinkage void __down_failed(void /* special register calling convention */);
66asmlinkage int __down_failed_interruptible(void /* params in registers */);
67asmlinkage int __down_failed_trylock(void /* params in registers */);
68asmlinkage void __up_wakeup(void /* special register calling convention */);
69#endif
70
71asmlinkage void __down(struct semaphore * sem);
72asmlinkage int __down_interruptible(struct semaphore * sem);
73asmlinkage int __down_trylock(struct semaphore * sem);
74asmlinkage void __up(struct semaphore * sem);
75
76extern spinlock_t semaphore_wake_lock;
77
78static inline void down(struct semaphore * sem)
79{
80 might_sleep();
81 if (atomic_dec_return(&sem->count) < 0)
82 __down(sem);
83}
84
85static inline int down_interruptible(struct semaphore * sem)
86{
87 int ret = 0;
88
89 might_sleep();
90 if (atomic_dec_return(&sem->count) < 0)
91 ret = __down_interruptible(sem);
92 return ret;
93}
94
95static inline int down_trylock(struct semaphore * sem)
96{
97 int ret = 0;
98
99 if (atomic_dec_return(&sem->count) < 0)
100 ret = __down_trylock(sem);
101 return ret;
102}
103
104/*
105 * Note! This is subtle. We jump to wake people up only if
106 * the semaphore was negative (== somebody was waiting on it).
107 */
108static inline void up(struct semaphore * sem)
109{
110 if (atomic_inc_return(&sem->count) <= 0)
111 __up(sem);
112}
113
114#endif
115#endif /* __ASM_SH_SEMAPHORE_H */
diff --git a/include/asm-sh/sh_keysc.h b/include/asm-sh/sh_keysc.h
new file mode 100644
index 000000000000..b5a4dd5a9729
--- /dev/null
+++ b/include/asm-sh/sh_keysc.h
@@ -0,0 +1,13 @@
1#ifndef __ASM_KEYSC_H__
2#define __ASM_KEYSC_H__
3
4#define SH_KEYSC_MAXKEYS 30
5
6struct sh_keysc_info {
7 enum { SH_KEYSC_MODE_1, SH_KEYSC_MODE_2, SH_KEYSC_MODE_3 } mode;
8 int scan_timing; /* 0 -> 7, see KYCR1, SCN[2:0] */
9 int delay;
10 int keycodes[SH_KEYSC_MAXKEYS];
11};
12
13#endif /* __ASM_KEYSC_H__ */
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index 5145aa2a0ce9..e65b6b822cb3 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -146,6 +146,8 @@ extern unsigned int instruction_size(unsigned int insn);
146 146
147extern unsigned long cached_to_uncached; 147extern unsigned long cached_to_uncached;
148 148
149extern struct dentry *sh_debugfs_root;
150
149/* XXX 151/* XXX
150 * disable hlt during certain critical i/o operations 152 * disable hlt during certain critical i/o operations
151 */ 153 */
diff --git a/include/asm-sh/topology.h b/include/asm-sh/topology.h
index f402a3b1cfa4..34cdb28e8f44 100644
--- a/include/asm-sh/topology.h
+++ b/include/asm-sh/topology.h
@@ -16,7 +16,7 @@
16 .cache_nice_tries = 2, \ 16 .cache_nice_tries = 2, \
17 .busy_idx = 3, \ 17 .busy_idx = 3, \
18 .idle_idx = 2, \ 18 .idle_idx = 2, \
19 .newidle_idx = 0, \ 19 .newidle_idx = 2, \
20 .wake_idx = 1, \ 20 .wake_idx = 1, \
21 .forkexec_idx = 1, \ 21 .forkexec_idx = 1, \
22 .flags = SD_LOAD_BALANCE \ 22 .flags = SD_LOAD_BALANCE \
diff --git a/include/asm-sh/uaccess_32.h b/include/asm-sh/uaccess_32.h
index c0318b608893..1e41fda74bd3 100644
--- a/include/asm-sh/uaccess_32.h
+++ b/include/asm-sh/uaccess_32.h
@@ -55,13 +55,10 @@ static inline void set_fs(mm_segment_t s)
55 * If we don't have an MMU (or if its disabled) the only thing we really have 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 56 * to look out for is if the address resides somewhere outside of what
57 * available RAM we have. 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 */ 58 */
62static inline int __access_ok(unsigned long addr, unsigned long size) 59static inline int __access_ok(unsigned long addr, unsigned long size)
63{ 60{
64 return ((addr >= memory_start) && ((addr + size) < memory_end)); 61 return 1;
65} 62}
66#else /* CONFIG_MMU */ 63#else /* CONFIG_MMU */
67#define __addr_ok(addr) \ 64#define __addr_ok(addr) \
diff --git a/include/asm-sh/unaligned.h b/include/asm-sh/unaligned.h
index 5250e3063b42..c1641a01d50f 100644
--- a/include/asm-sh/unaligned.h
+++ b/include/asm-sh/unaligned.h
@@ -1,7 +1,19 @@
1#ifndef __ASM_SH_UNALIGNED_H 1#ifndef _ASM_SH_UNALIGNED_H
2#define __ASM_SH_UNALIGNED_H 2#define _ASM_SH_UNALIGNED_H
3 3
4/* SH can't handle unaligned accesses. */ 4/* SH can't handle unaligned accesses. */
5#include <asm-generic/unaligned.h> 5#ifdef __LITTLE_ENDIAN__
6# include <linux/unaligned/le_struct.h>
7# include <linux/unaligned/be_byteshift.h>
8# include <linux/unaligned/generic.h>
9# define get_unaligned __get_unaligned_le
10# define put_unaligned __put_unaligned_le
11#else
12# include <linux/unaligned/be_struct.h>
13# include <linux/unaligned/le_byteshift.h>
14# include <linux/unaligned/generic.h>
15# define get_unaligned __get_unaligned_be
16# define put_unaligned __put_unaligned_be
17#endif
6 18
7#endif /* __ASM_SH_UNALIGNED_H */ 19#endif /* _ASM_SH_UNALIGNED_H */
diff --git a/include/asm-sparc/Kbuild b/include/asm-sparc/Kbuild
index c6a55cf0d337..671223718f0a 100644
--- a/include/asm-sparc/Kbuild
+++ b/include/asm-sparc/Kbuild
@@ -5,7 +5,6 @@ header-y += asi.h
5header-y += bpp.h 5header-y += bpp.h
6header-y += jsflash.h 6header-y += jsflash.h
7header-y += openpromio.h 7header-y += openpromio.h
8header-y += pconf.h
9header-y += reg.h 8header-y += reg.h
10header-y += traps.h 9header-y += traps.h
11header-y += vfc_ioctls.h 10header-y += vfc_ioctls.h
diff --git a/include/asm-sparc/a.out-core.h b/include/asm-sparc/a.out-core.h
deleted file mode 100644
index e8fd338ed0b2..000000000000
--- a/include/asm-sparc/a.out-core.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/* a.out coredump register dumper
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_A_OUT_CORE_H
13#define _ASM_A_OUT_CORE_H
14
15#ifdef __KERNEL__
16
17#include <linux/user.h>
18
19/*
20 * fill in the user structure for an a.out core dump
21 */
22static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
23{
24 unsigned long first_stack_page;
25
26 dump->magic = SUNOS_CORE_MAGIC;
27 dump->len = sizeof(struct user);
28 dump->regs.psr = regs->psr;
29 dump->regs.pc = regs->pc;
30 dump->regs.npc = regs->npc;
31 dump->regs.y = regs->y;
32 /* fuck me plenty */
33 memcpy(&dump->regs.regs[0], &regs->u_regs[1], (sizeof(unsigned long) * 15));
34 dump->uexec = current->thread.core_exec;
35 dump->u_tsize = (((unsigned long) current->mm->end_code) -
36 ((unsigned long) current->mm->start_code)) & ~(PAGE_SIZE - 1);
37 dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1)));
38 dump->u_dsize -= dump->u_tsize;
39 dump->u_dsize &= ~(PAGE_SIZE - 1);
40 first_stack_page = (regs->u_regs[UREG_FP] & ~(PAGE_SIZE - 1));
41 dump->u_ssize = (TASK_SIZE - first_stack_page) & ~(PAGE_SIZE - 1);
42 memcpy(&dump->fpu.fpstatus.fregs.regs[0], &current->thread.float_regs[0], (sizeof(unsigned long) * 32));
43 dump->fpu.fpstatus.fsr = current->thread.fsr;
44 dump->fpu.fpstatus.flags = dump->fpu.fpstatus.extra = 0;
45 dump->fpu.fpstatus.fpq_count = current->thread.fpqdepth;
46 memcpy(&dump->fpu.fpstatus.fpq[0], &current->thread.fpqueue[0],
47 ((sizeof(unsigned long) * 2) * 16));
48 dump->sigcode = 0;
49}
50
51#endif /* __KERNEL__ */
52#endif /* _ASM_A_OUT_CORE_H */
diff --git a/include/asm-sparc/a.out.h b/include/asm-sparc/a.out.h
deleted file mode 100644
index 2f1c3748a068..000000000000
--- a/include/asm-sparc/a.out.h
+++ /dev/null
@@ -1,97 +0,0 @@
1#ifndef __SPARC_A_OUT_H__
2#define __SPARC_A_OUT_H__
3
4#define SPARC_PGSIZE 0x2000 /* Thanks to the sun4 architecture... */
5#define SEGMENT_SIZE SPARC_PGSIZE /* whee... */
6
7#ifndef __ASSEMBLY__
8
9struct exec {
10 unsigned char a_dynamic:1; /* A __DYNAMIC is in this image */
11 unsigned char a_toolversion:7;
12 unsigned char a_machtype;
13 unsigned short a_info;
14 unsigned int a_text; /* length of text, in bytes */
15 unsigned int a_data; /* length of data, in bytes */
16 unsigned int a_bss; /* length of bss, in bytes */
17 unsigned int a_syms; /* length of symbol table, in bytes */
18 unsigned int a_entry; /* where program begins */
19 unsigned int a_trsize;
20 unsigned int a_drsize;
21};
22
23#endif /* !__ASSEMBLY__ */
24
25/* Where in the file does the text information begin? */
26#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? 0 : sizeof (struct exec))
27
28/* Where do the Symbols start? */
29#define N_SYMOFF(x) (N_TXTOFF(x) + (x).a_text + \
30 (x).a_data + (x).a_trsize + \
31 (x).a_drsize)
32
33/* Where does text segment go in memory after being loaded? */
34#define N_TXTADDR(x) (unsigned long)(((N_MAGIC(x) == ZMAGIC) && \
35 ((x).a_entry < SPARC_PGSIZE)) ? \
36 0 : SPARC_PGSIZE)
37
38/* And same for the data segment.. */
39#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC ? \
40 (N_TXTADDR(x) + (x).a_text) \
41 : (unsigned long) (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
42
43#define N_TRSIZE(a) ((a).a_trsize)
44#define N_DRSIZE(a) ((a).a_drsize)
45#define N_SYMSIZE(a) ((a).a_syms)
46
47#ifndef __ASSEMBLY__
48
49/*
50 * Sparc relocation types
51 */
52enum reloc_type
53{
54 RELOC_8,
55 RELOC_16,
56 RELOC_32, /* simplest relocs */
57 RELOC_DISP8,
58 RELOC_DISP16,
59 RELOC_DISP32, /* Disp's (pc-rel) */
60 RELOC_WDISP30,
61 RELOC_WDISP22, /* SR word disp's */
62 RELOC_HI22,
63 RELOC_22, /* SR 22-bit relocs */
64 RELOC_13,
65 RELOC_LO10, /* SR 13&10-bit relocs */
66 RELOC_SFA_BASE,
67 RELOC_SFA_OFF13, /* SR S.F.A. relocs */
68 RELOC_BASE10,
69 RELOC_BASE13,
70 RELOC_BASE22, /* base_relative pic */
71 RELOC_PC10,
72 RELOC_PC22, /* special pc-rel pic */
73 RELOC_JMP_TBL, /* jmp_tbl_rel in pic */
74 RELOC_SEGOFF16, /* ShLib offset-in-seg */
75 RELOC_GLOB_DAT,
76 RELOC_JMP_SLOT,
77 RELOC_RELATIVE /* rtld relocs */
78};
79
80/*
81 * Format of a relocation datum.
82 */
83struct relocation_info /* used when header.a_machtype == M_SPARC */
84{
85 unsigned int r_address; /* relocation addr */
86 unsigned int r_index:24; /* segment index or symbol index */
87 unsigned int r_extern:1; /* if F, r_index==SEG#; if T, SYM idx */
88 unsigned int r_pad:2; /* <unused> */
89 enum reloc_type r_type:5; /* type of relocation to perform */
90 int r_addend; /* addend for relocation value */
91};
92
93#define N_RELOCATION_INFO_DECLARED 1
94
95#endif /* !(__ASSEMBLY__) */
96
97#endif /* __SPARC_A_OUT_H__ */
diff --git a/include/asm-sparc/device.h b/include/asm-sparc/device.h
index 680e51d87374..19790eb99cc6 100644
--- a/include/asm-sparc/device.h
+++ b/include/asm-sparc/device.h
@@ -16,6 +16,8 @@ struct dev_archdata {
16 16
17 struct device_node *prom_node; 17 struct device_node *prom_node;
18 struct of_device *op; 18 struct of_device *op;
19
20 int numa_node;
19}; 21};
20 22
21#endif /* _ASM_SPARC_DEVICE_H */ 23#endif /* _ASM_SPARC_DEVICE_H */
diff --git a/include/asm-sparc/floppy.h b/include/asm-sparc/floppy.h
index dbe7a586be5b..d3978e068e2b 100644
--- a/include/asm-sparc/floppy.h
+++ b/include/asm-sparc/floppy.h
@@ -280,7 +280,7 @@ static inline void sun_fd_enable_dma(void)
280 280
281/* Our low-level entry point in arch/sparc/kernel/entry.S */ 281/* Our low-level entry point in arch/sparc/kernel/entry.S */
282extern int sparc_floppy_request_irq(int irq, unsigned long flags, 282extern int sparc_floppy_request_irq(int irq, unsigned long flags,
283 irqreturn_t (*irq_handler)(int irq, void *)); 283 irq_handler_t irq_handler);
284 284
285static int sun_fd_request_irq(void) 285static int sun_fd_request_irq(void)
286{ 286{
diff --git a/include/asm-sparc/head.h b/include/asm-sparc/head.h
index 1a03c28da92d..e6532c3e09c9 100644
--- a/include/asm-sparc/head.h
+++ b/include/asm-sparc/head.h
@@ -46,44 +46,22 @@
46 b linux_sparc_syscall; \ 46 b linux_sparc_syscall; \
47 rd %psr, %l0; 47 rd %psr, %l0;
48 48
49/* Software trap for SunOS4.1.x system calls. */
50#define SUNOS_SYSCALL_TRAP \
51 rd %psr, %l0; \
52 sethi %hi(sunos_sys_table), %l7; \
53 b linux_sparc_syscall; \
54 or %l7, %lo(sunos_sys_table), %l7;
55
56#define SUNOS_NO_SYSCALL_TRAP \
57 b sunos_syscall; \
58 rd %psr, %l0; \
59 nop; \
60 nop;
61
62/* Software trap for Slowaris system calls. */
63#define SOLARIS_SYSCALL_TRAP \
64 b solaris_syscall; \
65 rd %psr, %l0; \
66 nop; \
67 nop;
68
69#define INDIRECT_SOLARIS_SYSCALL(x) \
70 mov x, %g1; \
71 b solaris_syscall; \
72 rd %psr, %l0; \
73 nop;
74
75#define BREAKPOINT_TRAP \ 49#define BREAKPOINT_TRAP \
76 b breakpoint_trap; \ 50 b breakpoint_trap; \
77 rd %psr,%l0; \ 51 rd %psr,%l0; \
78 nop; \ 52 nop; \
79 nop; 53 nop;
80 54
81/* Software trap for Sparc-netbsd system calls. */ 55#ifdef CONFIG_KGDB
82#define NETBSD_SYSCALL_TRAP \ 56#define KGDB_TRAP(num) \
83 sethi %hi(sys_call_table), %l7; \ 57 b kgdb_trap_low; \
84 or %l7, %lo(sys_call_table), %l7; \ 58 rd %psr,%l0; \
85 b bsd_syscall; \ 59 nop; \
86 rd %psr, %l0; 60 nop;
61#else
62#define KGDB_TRAP(num) \
63 BAD_TRAP(num)
64#endif
87 65
88/* The Get Condition Codes software trap for userland. */ 66/* The Get Condition Codes software trap for userland. */
89#define GETCC_TRAP \ 67#define GETCC_TRAP \
diff --git a/include/asm-sparc/ide.h b/include/asm-sparc/ide.h
index 4076cb5d1581..afd1736ed480 100644
--- a/include/asm-sparc/ide.h
+++ b/include/asm-sparc/ide.h
@@ -17,8 +17,6 @@
17#undef MAX_HWIFS 17#undef MAX_HWIFS
18#define MAX_HWIFS 2 18#define MAX_HWIFS 2
19 19
20#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
21
22#define __ide_insl(data_reg, buffer, wcount) \ 20#define __ide_insl(data_reg, buffer, wcount) \
23 __ide_insw(data_reg, buffer, (wcount)<<1) 21 __ide_insw(data_reg, buffer, (wcount)<<1)
24#define __ide_outsl(data_reg, buffer, wcount) \ 22#define __ide_outsl(data_reg, buffer, wcount) \
diff --git a/include/asm-sparc/ioctls.h b/include/asm-sparc/ioctls.h
index 058c2064f706..3f4d0087b6a3 100644
--- a/include/asm-sparc/ioctls.h
+++ b/include/asm-sparc/ioctls.h
@@ -43,8 +43,6 @@
43#define __TIOCSETX _IOW('t', 34, int) /* SunOS Specific */ 43#define __TIOCSETX _IOW('t', 34, int) /* SunOS Specific */
44#define __TIOCGETX _IOR('t', 35, int) /* SunOS Specific */ 44#define __TIOCGETX _IOR('t', 35, int) /* SunOS Specific */
45#define TIOCCONS _IO('t', 36) 45#define TIOCCONS _IO('t', 36)
46#define __TIOCSSIZE _IOW('t', 37, struct sunos_ttysize) /* SunOS Specific */
47#define __TIOCGSIZE _IOR('t', 38, struct sunos_ttysize) /* SunOS Specific */
48#define TIOCGSOFTCAR _IOR('t', 100, int) 46#define TIOCGSOFTCAR _IOR('t', 100, int)
49#define TIOCSSOFTCAR _IOW('t', 101, int) 47#define TIOCSSOFTCAR _IOW('t', 101, int)
50#define __TIOCUCNTL _IOW('t', 102, int) /* SunOS Specific */ 48#define __TIOCUCNTL _IOW('t', 102, int) /* SunOS Specific */
diff --git a/include/asm-sparc/kgdb.h b/include/asm-sparc/kgdb.h
index d120adfb429f..b6ef301d05bf 100644
--- a/include/asm-sparc/kgdb.h
+++ b/include/asm-sparc/kgdb.h
@@ -1,94 +1,38 @@
1/* $Id: kgdb.h,v 1.8 1998/01/07 06:33:44 baccala Exp $
2 * kgdb.h: Defines and declarations for serial line source level
3 * remote debugging of the Linux kernel using gdb.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
7#ifndef _SPARC_KGDB_H 1#ifndef _SPARC_KGDB_H
8#define _SPARC_KGDB_H 2#define _SPARC_KGDB_H
9 3
10#ifndef __ASSEMBLY__ 4#ifdef CONFIG_SPARC32
11/* To init the kgdb engine. */ 5#define BUFMAX 2048
12extern void set_debug_traps(void); 6#else
13 7#define BUFMAX 4096
14/* To enter the debugger explicitly. */ 8#endif
15extern void breakpoint(void); 9
16 10enum regnames {
17/* For convenience we define the format of a kgdb trap breakpoint 11 GDB_G0, GDB_G1, GDB_G2, GDB_G3, GDB_G4, GDB_G5, GDB_G6, GDB_G7,
18 * frame here also. 12 GDB_O0, GDB_O1, GDB_O2, GDB_O3, GDB_O4, GDB_O5, GDB_SP, GDB_O7,
19 */ 13 GDB_L0, GDB_L1, GDB_L2, GDB_L3, GDB_L4, GDB_L5, GDB_L6, GDB_L7,
20struct kgdb_frame { 14 GDB_I0, GDB_I1, GDB_I2, GDB_I3, GDB_I4, GDB_I5, GDB_FP, GDB_I7,
21 unsigned long globals[8]; 15 GDB_F0,
22 unsigned long outs[8]; 16 GDB_F31 = GDB_F0 + 31,
23 unsigned long locals[8]; 17#ifdef CONFIG_SPARC32
24 unsigned long ins[8]; 18 GDB_Y, GDB_PSR, GDB_WIM, GDB_TBR, GDB_PC, GDB_NPC,
25 unsigned long fpregs[32]; 19 GDB_FSR, GDB_CSR,
26 unsigned long y; 20#else
27 unsigned long psr; 21 GDB_F32 = GDB_F0 + 32,
28 unsigned long wim; 22 GDB_F62 = GDB_F32 + 15,
29 unsigned long tbr; 23 GDB_PC, GDB_NPC, GDB_STATE, GDB_FSR, GDB_FPRS, GDB_Y,
30 unsigned long pc; 24#endif
31 unsigned long npc;
32 unsigned long fpsr;
33 unsigned long cpsr;
34}; 25};
35#endif /* !(__ASSEMBLY__) */
36
37/* Macros for assembly usage of the kgdb breakpoint frame. */
38#define KGDB_G0 0x000
39#define KGDB_G1 0x004
40#define KGDB_G2 0x008
41#define KGDB_G4 0x010
42#define KGDB_G6 0x018
43#define KGDB_I0 0x020
44#define KGDB_I2 0x028
45#define KGDB_I4 0x030
46#define KGDB_I6 0x038
47#define KGDB_Y 0x100
48#define KGDB_PSR 0x104
49#define KGDB_WIM 0x108
50#define KGDB_TBR 0x10c
51#define KGDB_PC 0x110
52#define KGDB_NPC 0x114
53
54#define SAVE_KGDB_GLOBALS(reg) \
55 std %g0, [%reg + STACKFRAME_SZ + KGDB_G0]; \
56 std %g2, [%reg + STACKFRAME_SZ + KGDB_G2]; \
57 std %g4, [%reg + STACKFRAME_SZ + KGDB_G4]; \
58 std %g6, [%reg + STACKFRAME_SZ + KGDB_G6];
59
60#define SAVE_KGDB_INS(reg) \
61 std %i0, [%reg + STACKFRAME_SZ + KGDB_I0]; \
62 std %i2, [%reg + STACKFRAME_SZ + KGDB_I2]; \
63 std %i4, [%reg + STACKFRAME_SZ + KGDB_I4]; \
64 std %i6, [%reg + STACKFRAME_SZ + KGDB_I6];
65
66#define SAVE_KGDB_SREGS(reg, reg_y, reg_psr, reg_wim, reg_tbr, reg_pc, reg_npc) \
67 st %reg_y, [%reg + STACKFRAME_SZ + KGDB_Y]; \
68 st %reg_psr, [%reg + STACKFRAME_SZ + KGDB_PSR]; \
69 st %reg_wim, [%reg + STACKFRAME_SZ + KGDB_WIM]; \
70 st %reg_tbr, [%reg + STACKFRAME_SZ + KGDB_TBR]; \
71 st %reg_pc, [%reg + STACKFRAME_SZ + KGDB_PC]; \
72 st %reg_npc, [%reg + STACKFRAME_SZ + KGDB_NPC];
73 26
74#define LOAD_KGDB_GLOBALS(reg) \ 27#ifdef CONFIG_SPARC32
75 ld [%reg + STACKFRAME_SZ + KGDB_G1], %g1; \ 28#define NUMREGBYTES ((GDB_CSR + 1) * 4)
76 ldd [%reg + STACKFRAME_SZ + KGDB_G2], %g2; \ 29#else
77 ldd [%reg + STACKFRAME_SZ + KGDB_G4], %g4; \ 30#define NUMREGBYTES ((GDB_Y + 1) * 8)
78 ldd [%reg + STACKFRAME_SZ + KGDB_G6], %g6; 31#endif
79 32
80#define LOAD_KGDB_INS(reg) \ 33extern void arch_kgdb_breakpoint(void);
81 ldd [%reg + STACKFRAME_SZ + KGDB_I0], %i0; \
82 ldd [%reg + STACKFRAME_SZ + KGDB_I2], %i2; \
83 ldd [%reg + STACKFRAME_SZ + KGDB_I4], %i4; \
84 ldd [%reg + STACKFRAME_SZ + KGDB_I6], %i6;
85 34
86#define LOAD_KGDB_SREGS(reg, reg_y, reg_psr, reg_wim, reg_tbr, reg_pc, reg_npc) \ 35#define BREAK_INSTR_SIZE 4
87 ld [%reg + STACKFRAME_SZ + KGDB_Y], %reg_y; \ 36#define CACHE_FLUSH_IS_SAFE 1
88 ld [%reg + STACKFRAME_SZ + KGDB_PSR], %reg_psr; \
89 ld [%reg + STACKFRAME_SZ + KGDB_WIM], %reg_wim; \
90 ld [%reg + STACKFRAME_SZ + KGDB_TBR], %reg_tbr; \
91 ld [%reg + STACKFRAME_SZ + KGDB_PC], %reg_pc; \
92 ld [%reg + STACKFRAME_SZ + KGDB_NPC], %reg_npc;
93 37
94#endif /* !(_SPARC_KGDB_H) */ 38#endif /* _SPARC_KGDB_H */
diff --git a/include/asm-sparc/mman.h b/include/asm-sparc/mman.h
index b7dc40bc68f4..e18be984c01d 100644
--- a/include/asm-sparc/mman.h
+++ b/include/asm-sparc/mman.h
@@ -22,19 +22,6 @@
22#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 22#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
23#define MAP_NONBLOCK 0x10000 /* do not block on IO */ 23#define MAP_NONBLOCK 0x10000 /* do not block on IO */
24 24
25/* XXX Need to add flags to SunOS's mctl, mlockall, and madvise system
26 * XXX calls.
27 */
28
29/* SunOS sys_mctl() stuff... */
30#define MC_SYNC 1 /* Sync pages in memory with storage (usu. a file) */
31#define MC_LOCK 2 /* Lock pages into core ram, do not allow swapping of them */
32#define MC_UNLOCK 3 /* Unlock pages locked via previous mctl() with MC_LOCK arg */
33#define MC_LOCKAS 5 /* Lock an entire address space of the calling process */
34#define MC_UNLOCKAS 6 /* Unlock entire address space of calling process */
35
36#define MADV_FREE 0x5 /* (Solaris) contents can be freed */
37
38#ifdef __KERNEL__ 25#ifdef __KERNEL__
39#ifndef __ASSEMBLY__ 26#ifndef __ASSEMBLY__
40#define arch_mmap_check sparc_mmap_check 27#define arch_mmap_check sparc_mmap_check
diff --git a/include/asm-sparc/namei.h b/include/asm-sparc/namei.h
index f2461e8a11ac..618344d89cc4 100644
--- a/include/asm-sparc/namei.h
+++ b/include/asm-sparc/namei.h
@@ -8,19 +8,6 @@
8#ifndef __SPARC_NAMEI_H 8#ifndef __SPARC_NAMEI_H
9#define __SPARC_NAMEI_H 9#define __SPARC_NAMEI_H
10 10
11#define SPARC_BSD_EMUL "/usr/gnemul/sunos/" 11#define __emul_prefix() NULL
12#define SPARC_SOL_EMUL "/usr/gnemul/solaris/"
13
14static inline char * __emul_prefix(void)
15{
16 switch (current->personality) {
17 case PER_SUNOS:
18 return SPARC_BSD_EMUL;
19 case PER_SVR4:
20 return SPARC_SOL_EMUL;
21 default:
22 return NULL;
23 }
24}
25 12
26#endif /* __SPARC_NAMEI_H */ 13#endif /* __SPARC_NAMEI_H */
diff --git a/include/asm-sparc/pconf.h b/include/asm-sparc/pconf.h
deleted file mode 100644
index d73c1f1c49dc..000000000000
--- a/include/asm-sparc/pconf.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/* $Id: pconf.h,v 1.3 1996/04/25 06:13:25 davem Exp $
2 * pconf.h: pathconf() and fpathconf() defines for SunOS
3 * system call compatibility.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
7
8#ifndef _SPARC_PCONF_H
9#define _SPARC_PCONF_H
10
11#include <linux/fs.h>
12#include <linux/limits.h>
13
14#define _PCONF_LINK 1 /* Max number of links to an object */
15#define _PCONF_CANON 2 /* TTY input buffer line size */
16#define _PCONF_INPUT 3 /* Biggest packet a tty can imbibe at once */
17#define _PCONF_NAME 4 /* Filename length max */
18#define _PCONF_PATH 5 /* Max size of a pathname */
19#define _PCONF_PIPE 6 /* Buffer size for a pipe */
20#define _PCONF_CHRESTRICT 7 /* Can only root chown files? */
21#define _PCONF_NOTRUNC 8 /* Are pathnames truncated if too big? */
22#define _PCONF_VDISABLE 9 /* Magic char to disable special tty chars */
23#define _PCONF_MAXPCONF 9
24
25#endif /* !(_SPARC_PCONF_H) */
diff --git a/include/asm-sparc/pgtable.h b/include/asm-sparc/pgtable.h
index 2cc235b74d94..d84af6d95f5c 100644
--- a/include/asm-sparc/pgtable.h
+++ b/include/asm-sparc/pgtable.h
@@ -219,6 +219,11 @@ static inline int pte_file(pte_t pte)
219 return pte_val(pte) & BTFIXUP_HALF(pte_filei); 219 return pte_val(pte) & BTFIXUP_HALF(pte_filei);
220} 220}
221 221
222static inline int pte_special(pte_t pte)
223{
224 return 0;
225}
226
222/* 227/*
223 */ 228 */
224BTFIXUPDEF_HALF(pte_wrprotecti) 229BTFIXUPDEF_HALF(pte_wrprotecti)
@@ -251,6 +256,8 @@ BTFIXUPDEF_CALL_CONST(pte_t, pte_mkyoung, pte_t)
251#define pte_mkdirty(pte) BTFIXUP_CALL(pte_mkdirty)(pte) 256#define pte_mkdirty(pte) BTFIXUP_CALL(pte_mkdirty)(pte)
252#define pte_mkyoung(pte) BTFIXUP_CALL(pte_mkyoung)(pte) 257#define pte_mkyoung(pte) BTFIXUP_CALL(pte_mkyoung)(pte)
253 258
259#define pte_mkspecial(pte) (pte)
260
254#define pfn_pte(pfn, prot) mk_pte(pfn_to_page(pfn), prot) 261#define pfn_pte(pfn, prot) mk_pte(pfn_to_page(pfn), prot)
255 262
256BTFIXUPDEF_CALL(unsigned long, pte_pfn, pte_t) 263BTFIXUPDEF_CALL(unsigned long, pte_pfn, pte_t)
diff --git a/include/asm-sparc/processor.h b/include/asm-sparc/processor.h
index 40b1e41fdea7..8898efbbbe07 100644
--- a/include/asm-sparc/processor.h
+++ b/include/asm-sparc/processor.h
@@ -1,5 +1,4 @@
1/* $Id: processor.h,v 1.83 2001/10/08 09:32:13 davem Exp $ 1/* include/asm-sparc/processor.h
2 * include/asm-sparc/processor.h
3 * 2 *
4 * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) 3 * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
5 */ 4 */
@@ -13,8 +12,6 @@
13 */ 12 */
14#define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; }) 13#define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; })
15 14
16#include <linux/a.out.h>
17
18#include <asm/psr.h> 15#include <asm/psr.h>
19#include <asm/ptrace.h> 16#include <asm/ptrace.h>
20#include <asm/head.h> 17#include <asm/head.h>
@@ -67,8 +64,6 @@ struct thread_struct {
67 struct fpq fpqueue[16]; 64 struct fpq fpqueue[16];
68 unsigned long flags; 65 unsigned long flags;
69 mm_segment_t current_ds; 66 mm_segment_t current_ds;
70 struct exec core_exec; /* just what it says. */
71 int new_signal;
72}; 67};
73 68
74#define SPARC_FLAG_KTHREAD 0x1 /* task is a kernel thread */ 69#define SPARC_FLAG_KTHREAD 0x1 /* task is a kernel thread */
diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h
index df5dc4422483..fd55522481cd 100644
--- a/include/asm-sparc/prom.h
+++ b/include/asm-sparc/prom.h
@@ -77,6 +77,11 @@ extern int of_getintprop_default(struct device_node *np,
77 const char *name, 77 const char *name,
78 int def); 78 int def);
79extern int of_find_in_proplist(const char *list, const char *match, int len); 79extern int of_find_in_proplist(const char *list, const char *match, int len);
80#ifdef CONFIG_NUMA
81extern int of_node_to_nid(struct device_node *dp);
82#else
83#define of_node_to_nid(dp) (-1)
84#endif
80 85
81extern void prom_build_devicetree(void); 86extern void prom_build_devicetree(void);
82 87
diff --git a/include/asm-sparc/semaphore.h b/include/asm-sparc/semaphore.h
index 8018f9f4d497..d9b2034ed1d2 100644
--- a/include/asm-sparc/semaphore.h
+++ b/include/asm-sparc/semaphore.h
@@ -1,192 +1 @@
1#ifndef _SPARC_SEMAPHORE_H #include <linux/semaphore.h>
2#define _SPARC_SEMAPHORE_H
3
4/* Dinky, good for nothing, just barely irq safe, Sparc semaphores. */
5
6#ifdef __KERNEL__
7
8#include <asm/atomic.h>
9#include <linux/wait.h>
10#include <linux/rwsem.h>
11
12struct semaphore {
13 atomic24_t count;
14 int sleepers;
15 wait_queue_head_t wait;
16};
17
18#define __SEMAPHORE_INITIALIZER(name, n) \
19{ \
20 .count = ATOMIC24_INIT(n), \
21 .sleepers = 0, \
22 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
23}
24
25#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
26 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
27
28#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
29
30static inline void sema_init (struct semaphore *sem, int val)
31{
32 atomic24_set(&sem->count, val);
33 sem->sleepers = 0;
34 init_waitqueue_head(&sem->wait);
35}
36
37static inline void init_MUTEX (struct semaphore *sem)
38{
39 sema_init(sem, 1);
40}
41
42static inline void init_MUTEX_LOCKED (struct semaphore *sem)
43{
44 sema_init(sem, 0);
45}
46
47extern void __down(struct semaphore * sem);
48extern int __down_interruptible(struct semaphore * sem);
49extern int __down_trylock(struct semaphore * sem);
50extern void __up(struct semaphore * sem);
51
52static inline void down(struct semaphore * sem)
53{
54 register volatile int *ptr asm("g1");
55 register int increment asm("g2");
56
57 might_sleep();
58
59 ptr = &(sem->count.counter);
60 increment = 1;
61
62 __asm__ __volatile__(
63 "mov %%o7, %%g4\n\t"
64 "call ___atomic24_sub\n\t"
65 " add %%o7, 8, %%o7\n\t"
66 "tst %%g2\n\t"
67 "bl 2f\n\t"
68 " nop\n"
69 "1:\n\t"
70 ".subsection 2\n"
71 "2:\n\t"
72 "save %%sp, -64, %%sp\n\t"
73 "mov %%g1, %%l1\n\t"
74 "mov %%g5, %%l5\n\t"
75 "call %3\n\t"
76 " mov %%g1, %%o0\n\t"
77 "mov %%l1, %%g1\n\t"
78 "ba 1b\n\t"
79 " restore %%l5, %%g0, %%g5\n\t"
80 ".previous\n"
81 : "=&r" (increment)
82 : "0" (increment), "r" (ptr), "i" (__down)
83 : "g3", "g4", "g7", "memory", "cc");
84}
85
86static inline int down_interruptible(struct semaphore * sem)
87{
88 register volatile int *ptr asm("g1");
89 register int increment asm("g2");
90
91 might_sleep();
92
93 ptr = &(sem->count.counter);
94 increment = 1;
95
96 __asm__ __volatile__(
97 "mov %%o7, %%g4\n\t"
98 "call ___atomic24_sub\n\t"
99 " add %%o7, 8, %%o7\n\t"
100 "tst %%g2\n\t"
101 "bl 2f\n\t"
102 " clr %%g2\n"
103 "1:\n\t"
104 ".subsection 2\n"
105 "2:\n\t"
106 "save %%sp, -64, %%sp\n\t"
107 "mov %%g1, %%l1\n\t"
108 "mov %%g5, %%l5\n\t"
109 "call %3\n\t"
110 " mov %%g1, %%o0\n\t"
111 "mov %%l1, %%g1\n\t"
112 "mov %%l5, %%g5\n\t"
113 "ba 1b\n\t"
114 " restore %%o0, %%g0, %%g2\n\t"
115 ".previous\n"
116 : "=&r" (increment)
117 : "0" (increment), "r" (ptr), "i" (__down_interruptible)
118 : "g3", "g4", "g7", "memory", "cc");
119
120 return increment;
121}
122
123static inline int down_trylock(struct semaphore * sem)
124{
125 register volatile int *ptr asm("g1");
126 register int increment asm("g2");
127
128 ptr = &(sem->count.counter);
129 increment = 1;
130
131 __asm__ __volatile__(
132 "mov %%o7, %%g4\n\t"
133 "call ___atomic24_sub\n\t"
134 " add %%o7, 8, %%o7\n\t"
135 "tst %%g2\n\t"
136 "bl 2f\n\t"
137 " clr %%g2\n"
138 "1:\n\t"
139 ".subsection 2\n"
140 "2:\n\t"
141 "save %%sp, -64, %%sp\n\t"
142 "mov %%g1, %%l1\n\t"
143 "mov %%g5, %%l5\n\t"
144 "call %3\n\t"
145 " mov %%g1, %%o0\n\t"
146 "mov %%l1, %%g1\n\t"
147 "mov %%l5, %%g5\n\t"
148 "ba 1b\n\t"
149 " restore %%o0, %%g0, %%g2\n\t"
150 ".previous\n"
151 : "=&r" (increment)
152 : "0" (increment), "r" (ptr), "i" (__down_trylock)
153 : "g3", "g4", "g7", "memory", "cc");
154
155 return increment;
156}
157
158static inline void up(struct semaphore * sem)
159{
160 register volatile int *ptr asm("g1");
161 register int increment asm("g2");
162
163 ptr = &(sem->count.counter);
164 increment = 1;
165
166 __asm__ __volatile__(
167 "mov %%o7, %%g4\n\t"
168 "call ___atomic24_add\n\t"
169 " add %%o7, 8, %%o7\n\t"
170 "tst %%g2\n\t"
171 "ble 2f\n\t"
172 " nop\n"
173 "1:\n\t"
174 ".subsection 2\n"
175 "2:\n\t"
176 "save %%sp, -64, %%sp\n\t"
177 "mov %%g1, %%l1\n\t"
178 "mov %%g5, %%l5\n\t"
179 "call %3\n\t"
180 " mov %%g1, %%o0\n\t"
181 "mov %%l1, %%g1\n\t"
182 "ba 1b\n\t"
183 " restore %%l5, %%g0, %%g5\n\t"
184 ".previous\n"
185 : "=&r" (increment)
186 : "0" (increment), "r" (ptr), "i" (__up)
187 : "g3", "g4", "g7", "memory", "cc");
188}
189
190#endif /* __KERNEL__ */
191
192#endif /* !(_SPARC_SEMAPHORE_H) */
diff --git a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
index b3f492208fd2..e6d561599726 100644
--- a/include/asm-sparc/smp.h
+++ b/include/asm-sparc/smp.h
@@ -51,13 +51,11 @@ void smp_bogo(struct seq_file *);
51void smp_info(struct seq_file *); 51void smp_info(struct seq_file *);
52 52
53BTFIXUPDEF_CALL(void, smp_cross_call, smpfunc_t, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) 53BTFIXUPDEF_CALL(void, smp_cross_call, smpfunc_t, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
54BTFIXUPDEF_CALL(void, smp_message_pass, int, int, unsigned long, int)
55BTFIXUPDEF_CALL(int, __hard_smp_processor_id, void) 54BTFIXUPDEF_CALL(int, __hard_smp_processor_id, void)
56BTFIXUPDEF_BLACKBOX(hard_smp_processor_id) 55BTFIXUPDEF_BLACKBOX(hard_smp_processor_id)
57BTFIXUPDEF_BLACKBOX(load_current) 56BTFIXUPDEF_BLACKBOX(load_current)
58 57
59#define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5) 58#define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5)
60#define smp_message_pass(target,msg,data,wait) BTFIXUP_CALL(smp_message_pass)(target,msg,data,wait)
61 59
62static inline void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); } 60static inline void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); }
63static inline void xc1(smpfunc_t func, unsigned long arg1) 61static inline void xc1(smpfunc_t func, unsigned long arg1)
diff --git a/include/asm-sparc/socket.h b/include/asm-sparc/socket.h
index 2e2bd0b7c8e3..a00e15df227c 100644
--- a/include/asm-sparc/socket.h
+++ b/include/asm-sparc/socket.h
@@ -24,9 +24,6 @@
24#define SO_SNDTIMEO 0x4000 24#define SO_SNDTIMEO 0x4000
25#define SO_ACCEPTCONN 0x8000 25#define SO_ACCEPTCONN 0x8000
26 26
27/* wha!??? */
28#define SO_DONTLINGER (~SO_LINGER) /* Older SunOS compat. hack */
29
30#define SO_SNDBUF 0x1001 27#define SO_SNDBUF 0x1001
31#define SO_RCVBUF 0x1002 28#define SO_RCVBUF 0x1002
32#define SO_SNDBUFFORCE 0x100a 29#define SO_SNDBUFFORCE 0x100a
diff --git a/include/asm-sparc/solerrno.h b/include/asm-sparc/solerrno.h
deleted file mode 100644
index 8abce7e4639f..000000000000
--- a/include/asm-sparc/solerrno.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/* $Id: solerrno.h,v 1.5 1996/04/25 06:13:32 davem Exp $
2 * solerrno.h: Solaris error return codes for compatibility.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC_SOLERRNO_H
8#define _SPARC_SOLERRNO_H
9
10#define SOL_EPERM 1 /* Required superuser access perms */
11#define SOL_ENOENT 2 /* File or directory does not exist */
12#define SOL_ESRCH 3 /* Process did not exist */
13#define SOL_EINTR 4 /* System call was interrupted */
14#define SOL_EIO 5 /* An i/o error occurred */
15#define SOL_ENXIO 6 /* Device or Address does not exist */
16#define SOL_E2BIG 7 /* Too many arguments were given */
17#define SOL_ENOEXEC 8 /* Header of executable was munged */
18#define SOL_EBADF 9 /* Bogus file number */
19#define SOL_ECHILD 10 /* No children of process exist */
20#define SOL_EAGAIN 11 /* beep beep, "try again later" */
21#define SOL_ENOMEM 12 /* No memory available */
22#define SOL_EACCES 13 /* Access not allowed */
23#define SOL_EFAULT 14 /* Address passed was invalid */
24#define SOL_ENOTBLK 15 /* blkdev op on non-block device */
25#define SOL_EBUSY 16 /* Mounted device was busy */
26#define SOL_EEXIST 17 /* File specified already exists */
27#define SOL_EXDEV 18 /* Link request across diff devices */
28#define SOL_ENODEV 19 /* Device does not exist on system */
29#define SOL_ENOTDIR 20 /* Dir operation on non-directory */
30#define SOL_EISDIR 21 /* File was of directory type */
31#define SOL_EINVAL 22 /* Argument passed was invalid */
32#define SOL_ENFILE 23 /* No more room in file table */
33#define SOL_EMFILE 24 /* Proc has too many files open */
34#define SOL_ENOTTY 25 /* Ioctl was invalid for req device */
35#define SOL_ETXTBSY 26 /* Text file in busy state */
36#define SOL_EFBIG 27 /* Too big of a file for operation */
37#define SOL_ENOSPC 28 /* Disk is full */
38#define SOL_ESPIPE 29 /* Seek attempted on non-seeking dev*/
39#define SOL_EROFS 30 /* Write attempted on read-only fs */
40#define SOL_EMLINK 31 /* Too many links in file search */
41#define SOL_EPIPE 32 /* Call a plumber */
42#define SOL_EDOM 33 /* Argument was out of fct domain */
43#define SOL_ERANGE 34 /* Could not represent math result */
44#define SOL_ENOMSG 35 /* Message of req type doesn't exist */
45#define SOL_EIDRM 36 /* Identifier has been removed */
46#define SOL_ECHRNG 37 /* Req channel number out of range */
47#define SOL_EL2NSYNC 38 /* Could not sync at run level 2 */
48#define SOL_EL3HLT 39 /* Halted at run level 3 */
49#define SOL_EL3RST 40 /* Reset at run level 3 */
50#define SOL_ELNRNG 41 /* Out of range link number */
51#define SOL_EUNATCH 42 /* Driver for protocol not attached */
52#define SOL_ENOCSI 43 /* CSI structure not around */
53#define SOL_EL2HLT 44 /* Halted at run level 2 */
54#define SOL_EDEADLK 45 /* Deadlock condition detected */
55#define SOL_ENOLCK 46 /* Record locks unavailable */
56#define SOL_ECANCELED 47 /* Cancellation of oper. happened */
57#define SOL_ENOTSUP 48 /* Attempt of unsupported operation */
58#define SOL_EDQUOT 49 /* Users disk quota exceeded */
59#define SOL_EBADE 50 /* Invalid exchange */
60#define SOL_EBADR 51 /* Request descriptor was invalid */
61#define SOL_EXFULL 52 /* Full exchange */
62#define SOL_ENOANO 53 /* ano does not exist */
63#define SOL_EBADRQC 54 /* Req code was invalid */
64#define SOL_EBADSLT 55 /* Bad slot number */
65#define SOL_EDEADLOCK 56 /* Deadlock in fs error */
66#define SOL_EBFONT 57 /* Font file format invalid */
67/* YOW, I LOVE SYSV STREAMS!!!! */
68#define SOL_ENOSTR 60 /* Stream-op on non-stream dev */
69#define SOL_ENODATA 61 /* No data avail at this time */
70#define SOL_ETIME 62 /* Expiration of time occurred */
71#define SOL_ENOSR 63 /* Streams resources exhausted */
72#define SOL_ENONET 64 /* No network connected */
73#define SOL_ENOPKG 65 /* Non-installed package */
74#define SOL_EREMOTE 66 /* Object was on remote machine */
75#define SOL_ENOLINK 67 /* Cut link */
76#define SOL_EADV 68 /* Error in advertise */
77#define SOL_ESRMNT 69 /* Some magic srmount problem */
78#define SOL_ECOMM 70 /* During send, comm error occurred */
79#define SOL_EPROTO 71 /* Protocol botch */
80#define SOL_EMULTIHOP 74 /* Multihop attempted */
81#define SOL_EBADMSG 77 /* Message was unreadable */
82#define SOL_ENAMETOOLONG 78 /* Too long of a path name */
83#define SOL_EOVERFLOW 79 /* Data type too small for datum */
84#define SOL_ENOTUNIQ 80 /* Logical name was not unique */
85#define SOL_EBADFD 81 /* Op cannot be performed on fd */
86#define SOL_EREMCHG 82 /* Remote address is now different */
87#define SOL_ELIBACC 83 /* Shared lib could not be accessed */
88#define SOL_ELIBBAD 84 /* ShLib is corrupted in some way */
89#define SOL_ELIBSCN 85 /* A.out ShLib problems */
90#define SOL_ELIBMAX 86 /* Exceeded ShLib linkage limit */
91#define SOL_ELIBEXEC 87 /* Execution of ShLib attempted */
92#define SOL_EILSEQ 88 /* Bad byte sequence found */
93#define SOL_ENOSYS 89 /* Invalid filesystem operation */
94#define SOL_ELOOP 90 /* Detected loop in symbolic links */
95#define SOL_ERESTART 91 /* System call is restartable */
96#define SOL_ESTRPIPE 92 /* Do not sleep in head of stream */
97#define SOL_ENOTEMPTY 93 /* Rmdir of non-empty directory */
98#define SOL_EUSERS 94 /* Over abundance of users for ufs */
99#define SOL_ENOTSOCK 95 /* Sock-op on non-sock */
100#define SOL_EDESTADDRREQ 96 /* No dest addr given, but needed */
101#define SOL_EMSGSIZE 97 /* Msg too big */
102#define SOL_EPROTOTYPE 98 /* Bad socket protocol */
103#define SOL_ENOPROTOOPT 99 /* Unavailable protocol */
104#define SOL_EPROTONOSUPPORT 120 /* Unsupported protocol */
105#define SOL_ESOCKTNOSUPPORT 121 /* Unsupported socket type */
106#define SOL_EOPNOTSUPP 122 /* Unsupported sock-op */
107#define SOL_EPFNOSUPPORT 123 /* Unsupported protocol family */
108#define SOL_EAFNOSUPPORT 124 /* Unsup addr family for protocol */
109#define SOL_EADDRINUSE 125 /* Req addr is already in use */
110#define SOL_EADDRNOTAVAIL 126 /* Req addr not available right now */
111#define SOL_ENETDOWN 127 /* Your subnet is on fire */
112#define SOL_ENETUNREACH 128 /* Someone playing with gateway and */
113 /* did not tell you he was going to */
114#define SOL_ENETRESET 129 /* Buy less-buggy ethernet cards */
115#define SOL_ECONNABORTED 130 /* Aborted connection due to sw */
116#define SOL_ECONNRESET 131 /* Your peers reset your connection */
117#define SOL_ENOBUFS 132 /* No buffer space available */
118#define SOL_EISCONN 133 /* Connect on already connected */
119 /* socket attempted */
120#define SOL_ENOTCONN 134 /* Comm on non-connected socket */
121#define SOL_ESHUTDOWN 143 /* Op attempted after sock-shutdown */
122#define SOL_ETOOMANYREFS 144 /* Reference limit exceeded */
123#define SOL_ETIMEDOUT 145 /* Timed out connection */
124#define SOL_ECONNREFUSED 146 /* Connection refused by remote host*/
125#define SOL_EHOSTDOWN 147 /* Remote host is up in flames */
126#define SOL_EHOSTUNREACH 148 /* Make a left at Easton Ave..... */
127#define SOL_EWOULDBLOCK EAGAIN /* Just an alias */
128#define SOL_EALREADY 149 /* Operation is already occurring */
129#define SOL_EINPROGRESS 150 /* Operation is happening now */
130#define SOL_ESTALE 151 /* Fungus growth on NFS file handle */
131
132#endif /* !(_SPARC_SOLERRNO_H) */
diff --git a/include/asm-sparc/svr4.h b/include/asm-sparc/svr4.h
deleted file mode 100644
index da1f1c980e2d..000000000000
--- a/include/asm-sparc/svr4.h
+++ /dev/null
@@ -1,119 +0,0 @@
1/* Solaris/SPARC constants and definitions --
2 * (C) 1996 Miguel de Icaza
3 *
4 * This file is not meant to be included by user level applications
5 * but the solaris syscall emulator
6 */
7
8#ifndef _SPARC_SVR4_H
9#define _SPARC_SVR4_H
10
11/* Signals as used by svr4 */
12typedef struct { /* signal set type */
13 ulong sigbits[4];
14} svr4_sigset_t;
15
16/* Values for siginfo.code */
17#define SVR4_SINOINFO 32767
18/* Siginfo, sucker expects bunch of information on those parameters */
19typedef union {
20 char total_size [128];
21 struct {
22 int signo;
23 int code;
24 int error;
25 union {
26 } data;
27 } siginfo;
28} svr4_siginfo_t;
29
30/* Context definition */
31
32/* Location of the user stored registers into a greg_t */
33enum {
34 SVR4_PSR, SVR4_PC, SVR4_NPC, SVR4_Y,
35 SVR4_G1, SVR4_G2, SVR4_G3, SVR4_G4,
36 SVR4_G5, SVR4_G6, SVR4_G7, SVR4_O0,
37 SVR4_O1, SVR4_O2, SVR4_O3, SVR4_O4,
38 SVR4_O5, SVR4_O6, SVR4_O7
39};
40
41/* sizeof (regs) / sizeof (greg_t), defined in the ABI */
42#define SVR4_NREGS 19
43#define SVR4_MAXWIN 31
44
45typedef struct {
46 uint rwin_lo[8];
47 uint rwin_in[8];
48} svr4_rwindow_t;
49
50typedef struct {
51 int count;
52 int __user *winptr [SVR4_MAXWIN]; /* pointer to the windows */
53 svr4_rwindow_t win[SVR4_MAXWIN]; /* the windows */
54} svr4_gwindows_t;
55
56typedef int svr4_gregset_t[SVR4_NREGS];
57
58typedef struct {
59 double fpu_regs[32];
60 void *fp_q;
61 unsigned fp_fsr;
62 u_char fp_nqel;
63 u_char fp_nqsize;
64 u_char inuse; /* if fpu is in use */
65} svr4_fregset_t;
66
67typedef struct {
68 uint id; /* if this holds "xrs" string => ptr is valid */
69 caddr_t ptr;
70} svr4_xrs_t;
71
72/* Machine dependent context */
73typedef struct {
74 svr4_gregset_t greg; /* registers 0..19 (see top) */
75 svr4_gwindows_t __user *gwin; /* may point to register windows */
76 svr4_fregset_t freg; /* floating point registers */
77 svr4_xrs_t xrs; /* mhm? */
78 long pad[19];
79} svr4_mcontext_t;
80
81/* flags for stack_t.flags */
82enum svr4_stack_flags {
83 SVR4_SS_ONSTACK,
84 SVR4_SS_DISABLE,
85};
86
87/* signal stack exection place, unsupported */
88typedef struct svr4_stack_t {
89 char __user *sp;
90 int size;
91 int flags;
92} svr4_stack_t;
93
94/* Context used by getcontext and setcontext */
95typedef struct svr4_ucontext_t {
96 u_long flags; /* context flags, indicate what is loaded */
97 struct svr4_ucontext *link;
98 svr4_sigset_t sigmask;
99 svr4_stack_t stack;
100 svr4_mcontext_t mcontext;
101 long pad[23];
102} svr4_ucontext_t;
103
104/* windows hold the windows as they were at signal time,
105 * ucontext->mcontext holds a pointer to them.
106 * addresses for uc and si are passed as parameters to svr4 signal
107 * handler
108 */
109
110/* This is the signal frame that is passed to the signal handler */
111typedef struct {
112 svr4_gwindows_t gw; /* windows */
113 svr4_ucontext_t uc; /* machine context */
114 svr4_siginfo_t si; /* siginfo */
115} svr4_signal_frame_t;
116
117#define SVR4_SF_ALIGNED (((sizeof (svr4_signal_frame_t) + 7) & (~7)))
118
119#endif /* include control */
diff --git a/include/asm-sparc/system.h b/include/asm-sparc/system.h
index 4e08210cd4c2..b4b024445fc9 100644
--- a/include/asm-sparc/system.h
+++ b/include/asm-sparc/system.h
@@ -94,6 +94,8 @@ extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
94 } while(0) 94 } while(0)
95#endif 95#endif
96 96
97extern void flushw_all(void);
98
97/* 99/*
98 * Flush windows so that the VM switch which follows 100 * Flush windows so that the VM switch which follows
99 * would not pull the stack from under us. 101 * would not pull the stack from under us.
diff --git a/include/asm-sparc/termios.h b/include/asm-sparc/termios.h
index 4333232abb9f..733d40504e1e 100644
--- a/include/asm-sparc/termios.h
+++ b/include/asm-sparc/termios.h
@@ -33,11 +33,6 @@ struct ltchars {
33}; 33};
34#endif /* __KERNEL__ */ 34#endif /* __KERNEL__ */
35 35
36struct sunos_ttysize {
37 int st_lines; /* Lines on the terminal */
38 int st_columns; /* Columns on the terminal */
39};
40
41struct winsize { 36struct winsize {
42 unsigned short ws_row; 37 unsigned short ws_row;
43 unsigned short ws_col; 38 unsigned short ws_col;
diff --git a/include/asm-sparc/unaligned.h b/include/asm-sparc/unaligned.h
index b6f8eddd30af..11d2d5fb5902 100644
--- a/include/asm-sparc/unaligned.h
+++ b/include/asm-sparc/unaligned.h
@@ -1,6 +1,10 @@
1#ifndef _ASM_SPARC_UNALIGNED_H_ 1#ifndef _ASM_SPARC_UNALIGNED_H
2#define _ASM_SPARC_UNALIGNED_H_ 2#define _ASM_SPARC_UNALIGNED_H
3 3
4#include <asm-generic/unaligned.h> 4#include <linux/unaligned/be_struct.h>
5#include <linux/unaligned/le_byteshift.h>
6#include <linux/unaligned/generic.h>
7#define get_unaligned __get_unaligned_be
8#define put_unaligned __put_unaligned_be
5 9
6#endif /* _ASM_SPARC_UNALIGNED_H */ 10#endif /* _ASM_SPARC_UNALIGNED_H */
diff --git a/include/asm-sparc/user.h b/include/asm-sparc/user.h
index b5f1abf733d5..3400ea87f148 100644
--- a/include/asm-sparc/user.h
+++ b/include/asm-sparc/user.h
@@ -1,60 +1,6 @@
1/* $Id: user.h,v 1.5 1998/02/23 01:49:22 rth Exp $
2 * asm-sparc/user.h: Core file definitions for the Sparc.
3 *
4 * Keep in sync with reg.h. Actually, we could get rid of this
5 * one, since we won't a.out core dump that much anyways - miguel.
6 * Copyright (C) 1995 (davem@caip.rutgers.edu)
7 */
8#ifndef _SPARC_USER_H 1#ifndef _SPARC_USER_H
9#define _SPARC_USER_H 2#define _SPARC_USER_H
10 3
11#include <asm/a.out.h> 4/* Nothing to define. */
12struct sunos_regs {
13 unsigned long psr, pc, npc, y;
14 unsigned long regs[15];
15};
16
17struct sunos_fpqueue {
18 unsigned long *addr;
19 unsigned long inst;
20};
21
22struct sunos_fp {
23 union {
24 unsigned long regs[32];
25 double reg_dbls[16];
26 } fregs;
27 unsigned long fsr;
28 unsigned long flags;
29 unsigned long extra;
30 unsigned long fpq_count;
31 struct sunos_fpqueue fpq[16];
32};
33
34struct sunos_fpu {
35 struct sunos_fp fpstatus;
36};
37
38/* The SunOS core file header layout. */
39struct user {
40 unsigned long magic;
41 unsigned long len;
42 struct sunos_regs regs;
43 struct exec uexec;
44 int signal;
45 size_t u_tsize; /* all of these in bytes! */
46 size_t u_dsize;
47 size_t u_ssize;
48 char u_comm[17];
49 struct sunos_fpu fpu;
50 unsigned long sigcode; /* Special sigcontext subcode, if any */
51};
52
53#define NBPG 0x2000
54#define UPAGES 1
55#define HOST_TEXT_START_ADDR (u.start_code)
56#define HOST_DATA_START_ADDR (u.uexec.a_data)
57#define HOST_STACK_END_ADDR (- u.u_ssize * NBPG)
58#define SUNOS_CORE_MAGIC 0x080456
59 5
60#endif /* !(_SPARC_USER_H) */ 6#endif /* !(_SPARC_USER_H) */
diff --git a/include/asm-sparc64/Kbuild b/include/asm-sparc64/Kbuild
index a90dc82129d1..dce1cf9a9313 100644
--- a/include/asm-sparc64/Kbuild
+++ b/include/asm-sparc64/Kbuild
@@ -12,7 +12,6 @@ header-y += display7seg.h
12header-y += envctrl.h 12header-y += envctrl.h
13header-y += openprom.h 13header-y += openprom.h
14header-y += openpromio.h 14header-y += openpromio.h
15header-y += pconf.h
16header-y += psrcompat.h 15header-y += psrcompat.h
17header-y += pstate.h 16header-y += pstate.h
18header-y += reg.h 17header-y += reg.h
diff --git a/include/asm-sparc64/a.out-core.h b/include/asm-sparc64/a.out-core.h
deleted file mode 100644
index 3499b3c425ca..000000000000
--- a/include/asm-sparc64/a.out-core.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/* a.out coredump register dumper
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_A_OUT_CORE_H
13#define _ASM_A_OUT_CORE_H
14
15#ifdef __KERNEL__
16
17#include <linux/user.h>
18
19/*
20 * fill in the user structure for an a.out core dump
21 */
22static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
23{
24 /* Only should be used for SunOS and ancient a.out
25 * SparcLinux binaries... Not worth implementing.
26 */
27 memset(dump, 0, sizeof(struct user));
28}
29
30#endif /* __KERNEL__ */
31#endif /* _ASM_A_OUT_CORE_H */
diff --git a/include/asm-sparc64/a.out.h b/include/asm-sparc64/a.out.h
deleted file mode 100644
index 44208c2a188e..000000000000
--- a/include/asm-sparc64/a.out.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sparc/a.out.h>
diff --git a/include/asm-sparc64/bitops.h b/include/asm-sparc64/bitops.h
index 982ce8992b91..11f9d8146cdf 100644
--- a/include/asm-sparc64/bitops.h
+++ b/include/asm-sparc64/bitops.h
@@ -34,6 +34,7 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr);
34#include <asm-generic/bitops/ffz.h> 34#include <asm-generic/bitops/ffz.h>
35#include <asm-generic/bitops/__ffs.h> 35#include <asm-generic/bitops/__ffs.h>
36#include <asm-generic/bitops/fls.h> 36#include <asm-generic/bitops/fls.h>
37#include <asm-generic/bitops/__fls.h>
37#include <asm-generic/bitops/fls64.h> 38#include <asm-generic/bitops/fls64.h>
38 39
39#ifdef __KERNEL__ 40#ifdef __KERNEL__
diff --git a/include/asm-sparc64/floppy.h b/include/asm-sparc64/floppy.h
index c47f58d6c15c..ca19f80a9b7d 100644
--- a/include/asm-sparc64/floppy.h
+++ b/include/asm-sparc64/floppy.h
@@ -293,7 +293,6 @@ static int sun_fd_eject(int drive)
293 293
294#ifdef CONFIG_PCI 294#ifdef CONFIG_PCI
295#include <asm/ebus.h> 295#include <asm/ebus.h>
296#include <asm/isa.h>
297#include <asm/ns87303.h> 296#include <asm/ns87303.h>
298 297
299static struct ebus_dma_info sun_pci_fd_ebus_dma; 298static struct ebus_dma_info sun_pci_fd_ebus_dma;
@@ -558,82 +557,6 @@ static int __init ebus_fdthree_p(struct linux_ebus_device *edev)
558} 557}
559#endif 558#endif
560 559
561#ifdef CONFIG_PCI
562#undef ISA_FLOPPY_WORKS
563
564#ifdef ISA_FLOPPY_WORKS
565static unsigned long __init isa_floppy_init(void)
566{
567 struct sparc_isa_bridge *isa_br;
568 struct sparc_isa_device *isa_dev = NULL;
569
570 for_each_isa(isa_br) {
571 for_each_isadev(isa_dev, isa_br) {
572 if (!strcmp(isa_dev->prom_node->name, "dma")) {
573 struct sparc_isa_device *child =
574 isa_dev->child;
575
576 while (child) {
577 if (!strcmp(child->prom_node->name,
578 "floppy")) {
579 isa_dev = child;
580 goto isa_done;
581 }
582 child = child->next;
583 }
584 }
585 }
586 }
587isa_done:
588 if (!isa_dev)
589 return 0;
590
591 /* We could use DMA on devices behind the ISA bridge, but...
592 *
593 * There is a slight problem. Normally on x86 kit the x86 processor
594 * delays I/O port instructions when the ISA bus "dma in progress"
595 * signal is active. Well, sparc64 systems do not monitor this
596 * signal thus we would need to block all I/O port accesses in software
597 * when a dma transfer is active for some device.
598 */
599
600 sun_fdc = (struct sun_flpy_controller *)isa_dev->resource.start;
601 FLOPPY_IRQ = isa_dev->irq;
602
603 sun_fdops.fd_inb = sun_pci_fd_inb;
604 sun_fdops.fd_outb = sun_pci_fd_outb;
605
606 can_use_virtual_dma = use_virtual_dma = 1;
607 sun_fdops.fd_enable_dma = sun_fd_enable_dma;
608 sun_fdops.fd_disable_dma = sun_fd_disable_dma;
609 sun_fdops.fd_set_dma_mode = sun_fd_set_dma_mode;
610 sun_fdops.fd_set_dma_addr = sun_fd_set_dma_addr;
611 sun_fdops.fd_set_dma_count = sun_fd_set_dma_count;
612 sun_fdops.get_dma_residue = sun_get_dma_residue;
613
614 sun_fdops.fd_request_irq = sun_fd_request_irq;
615 sun_fdops.fd_free_irq = sun_fd_free_irq;
616
617 /* Floppy eject is manual. Actually, could determine this
618 * via presence of 'manual' property in OBP node.
619 */
620 sun_fdops.fd_eject = sun_pci_fd_eject;
621
622 fdc_status = (unsigned long) &sun_fdc->status_82077;
623
624 allowed_drive_mask = 0;
625 sun_floppy_types[0] = 0;
626 sun_floppy_types[1] = 4;
627
628 sun_pci_broken_drive = 1;
629 sun_fdops.fd_outb = sun_pci_fd_broken_outb;
630
631 return sun_floppy_types[0];
632}
633#endif /* ISA_FLOPPY_WORKS */
634
635#endif
636
637static unsigned long __init sun_floppy_init(void) 560static unsigned long __init sun_floppy_init(void)
638{ 561{
639 char state[128]; 562 char state[128];
@@ -667,13 +590,8 @@ static unsigned long __init sun_floppy_init(void)
667 } 590 }
668 } 591 }
669 ebus_done: 592 ebus_done:
670 if (!edev) { 593 if (!edev)
671#ifdef ISA_FLOPPY_WORKS
672 return isa_floppy_init();
673#else
674 return 0; 594 return 0;
675#endif
676 }
677 595
678 state_prop = of_get_property(edev->prom_node, "status", NULL); 596 state_prop = of_get_property(edev->prom_node, "status", NULL);
679 if (state_prop && !strncmp(state_prop, "disabled", 8)) 597 if (state_prop && !strncmp(state_prop, "disabled", 8))
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
index df1097d6ffbe..d8378935ae90 100644
--- a/include/asm-sparc64/futex.h
+++ b/include/asm-sparc64/futex.h
@@ -2,9 +2,9 @@
2#define _SPARC64_FUTEX_H 2#define _SPARC64_FUTEX_H
3 3
4#include <linux/futex.h> 4#include <linux/futex.h>
5#include <linux/uaccess.h>
5#include <asm/errno.h> 6#include <asm/errno.h>
6#include <asm/system.h> 7#include <asm/system.h>
7#include <asm/uaccess.h>
8 8
9#define __futex_cas_op(insn, ret, oldval, uaddr, oparg) \ 9#define __futex_cas_op(insn, ret, oldval, uaddr, oparg) \
10 __asm__ __volatile__( \ 10 __asm__ __volatile__( \
diff --git a/include/asm-sparc64/hugetlb.h b/include/asm-sparc64/hugetlb.h
new file mode 100644
index 000000000000..412af58926a0
--- /dev/null
+++ b/include/asm-sparc64/hugetlb.h
@@ -0,0 +1,84 @@
1#ifndef _ASM_SPARC64_HUGETLB_H
2#define _ASM_SPARC64_HUGETLB_H
3
4#include <asm/page.h>
5
6
7void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
8 pte_t *ptep, pte_t pte);
9
10pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
11 pte_t *ptep);
12
13void hugetlb_prefault_arch_hook(struct mm_struct *mm);
14
15static inline int is_hugepage_only_range(struct mm_struct *mm,
16 unsigned long addr,
17 unsigned long len) {
18 return 0;
19}
20
21/*
22 * If the arch doesn't supply something else, assume that hugepage
23 * size aligned regions are ok without further preparation.
24 */
25static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
26{
27 if (len & ~HPAGE_MASK)
28 return -EINVAL;
29 if (addr & ~HPAGE_MASK)
30 return -EINVAL;
31 return 0;
32}
33
34static inline void hugetlb_free_pgd_range(struct mmu_gather **tlb,
35 unsigned long addr, unsigned long end,
36 unsigned long floor,
37 unsigned long ceiling)
38{
39 free_pgd_range(tlb, addr, end, floor, ceiling);
40}
41
42static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
43 unsigned long addr, pte_t *ptep)
44{
45}
46
47static inline int huge_pte_none(pte_t pte)
48{
49 return pte_none(pte);
50}
51
52static inline pte_t huge_pte_wrprotect(pte_t pte)
53{
54 return pte_wrprotect(pte);
55}
56
57static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
58 unsigned long addr, pte_t *ptep)
59{
60 ptep_set_wrprotect(mm, addr, ptep);
61}
62
63static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
64 unsigned long addr, pte_t *ptep,
65 pte_t pte, int dirty)
66{
67 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
68}
69
70static inline pte_t huge_ptep_get(pte_t *ptep)
71{
72 return *ptep;
73}
74
75static inline int arch_prepare_hugepage(struct page *page)
76{
77 return 0;
78}
79
80static inline void arch_release_hugepage(struct page *page)
81{
82}
83
84#endif /* _ASM_SPARC64_HUGETLB_H */
diff --git a/include/asm-sparc64/ide.h b/include/asm-sparc64/ide.h
index ac7eb210b941..c5fdabe0b42d 100644
--- a/include/asm-sparc64/ide.h
+++ b/include/asm-sparc64/ide.h
@@ -24,8 +24,6 @@
24# endif 24# endif
25#endif 25#endif
26 26
27#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
28
29#define __ide_insl(data_reg, buffer, wcount) \ 27#define __ide_insl(data_reg, buffer, wcount) \
30 __ide_insw(data_reg, buffer, (wcount)<<1) 28 __ide_insw(data_reg, buffer, (wcount)<<1)
31#define __ide_outsl(data_reg, buffer, wcount) \ 29#define __ide_outsl(data_reg, buffer, wcount) \
diff --git a/include/asm-sparc64/ioctls.h b/include/asm-sparc64/ioctls.h
index 083c9a0f37de..c1be40647c99 100644
--- a/include/asm-sparc64/ioctls.h
+++ b/include/asm-sparc64/ioctls.h
@@ -44,8 +44,6 @@
44#define __TIOCSETX _IOW('t', 34, int) /* SunOS Specific */ 44#define __TIOCSETX _IOW('t', 34, int) /* SunOS Specific */
45#define __TIOCGETX _IOR('t', 35, int) /* SunOS Specific */ 45#define __TIOCGETX _IOR('t', 35, int) /* SunOS Specific */
46#define TIOCCONS _IO('t', 36) 46#define TIOCCONS _IO('t', 36)
47#define __TIOCSSIZE _IOW('t', 37, struct sunos_ttysize) /* SunOS Specific */
48#define __TIOCGSIZE _IOR('t', 38, struct sunos_ttysize) /* SunOS Specific */
49#define TIOCGSOFTCAR _IOR('t', 100, int) 47#define TIOCGSOFTCAR _IOR('t', 100, int)
50#define TIOCSSOFTCAR _IOW('t', 101, int) 48#define TIOCSSOFTCAR _IOW('t', 101, int)
51#define __TIOCUCNTL _IOW('t', 102, int) /* SunOS Specific */ 49#define __TIOCUCNTL _IOW('t', 102, int) /* SunOS Specific */
diff --git a/include/asm-sparc64/iommu.h b/include/asm-sparc64/iommu.h
index 46325ddee23b..d7b9afcba08b 100644
--- a/include/asm-sparc64/iommu.h
+++ b/include/asm-sparc64/iommu.h
@@ -56,6 +56,7 @@ struct strbuf {
56}; 56};
57 57
58extern int iommu_table_init(struct iommu *iommu, int tsbsize, 58extern int iommu_table_init(struct iommu *iommu, int tsbsize,
59 u32 dma_offset, u32 dma_addr_mask); 59 u32 dma_offset, u32 dma_addr_mask,
60 int numa_node);
60 61
61#endif /* !(_SPARC64_IOMMU_H) */ 62#endif /* !(_SPARC64_IOMMU_H) */
diff --git a/include/asm-sparc64/isa.h b/include/asm-sparc64/isa.h
deleted file mode 100644
index ecd9290f78d4..000000000000
--- a/include/asm-sparc64/isa.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/* $Id: isa.h,v 1.1 2001/05/11 04:31:55 davem Exp $
2 * isa.h: Sparc64 layer for PCI to ISA bridge devices.
3 *
4 * Copyright (C) 2001 David S. Miller (davem@redhat.com)
5 */
6
7#ifndef __SPARC64_ISA_H
8#define __SPARC64_ISA_H
9
10#include <asm/oplib.h>
11#include <asm/prom.h>
12#include <asm/of_device.h>
13
14struct sparc_isa_bridge;
15
16struct sparc_isa_device {
17 struct of_device ofdev;
18 struct sparc_isa_device *next;
19 struct sparc_isa_device *child;
20 struct sparc_isa_bridge *bus;
21 struct device_node *prom_node;
22 struct resource resource;
23 unsigned int irq;
24};
25#define to_isa_device(d) container_of(d, struct sparc_isa_device, ofdev.dev)
26
27struct sparc_isa_bridge {
28 struct of_device ofdev;
29 struct sparc_isa_bridge *next;
30 struct sparc_isa_device *devices;
31 struct pci_dev *self;
32 int index;
33 struct device_node *prom_node;
34};
35#define to_isa_bridge(d) container_of(d, struct sparc_isa_bridge, ofdev.dev)
36
37extern struct sparc_isa_bridge *isa_chain;
38
39extern void isa_init(void);
40
41#define for_each_isa(bus) \
42 for((bus) = isa_chain; (bus); (bus) = (bus)->next)
43
44#define for_each_isadev(dev, bus) \
45 for((dev) = (bus)->devices; (dev); (dev) = (dev)->next)
46
47#endif /* !(__SPARC64_ISA_H) */
diff --git a/include/asm-sparc64/kgdb.h b/include/asm-sparc64/kgdb.h
new file mode 100644
index 000000000000..aa6532fd3a13
--- /dev/null
+++ b/include/asm-sparc64/kgdb.h
@@ -0,0 +1 @@
#include <asm-sparc/kgdb.h>
diff --git a/include/asm-sparc64/lmb.h b/include/asm-sparc64/lmb.h
new file mode 100644
index 000000000000..6a352cbcf520
--- /dev/null
+++ b/include/asm-sparc64/lmb.h
@@ -0,0 +1,10 @@
1#ifndef _SPARC64_LMB_H
2#define _SPARC64_LMB_H
3
4#include <asm/oplib.h>
5
6#define LMB_DBG(fmt...) prom_printf(fmt)
7
8#define LMB_REAL_LIMIT 0
9
10#endif /* !(_SPARC64_LMB_H) */
diff --git a/include/asm-sparc64/mman.h b/include/asm-sparc64/mman.h
index 8cc1860be630..e584563b56eb 100644
--- a/include/asm-sparc64/mman.h
+++ b/include/asm-sparc64/mman.h
@@ -22,19 +22,6 @@
22#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ 22#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
23#define MAP_NONBLOCK 0x10000 /* do not block on IO */ 23#define MAP_NONBLOCK 0x10000 /* do not block on IO */
24 24
25/* XXX Need to add flags to SunOS's mctl, mlockall, and madvise system
26 * XXX calls.
27 */
28
29/* SunOS sys_mctl() stuff... */
30#define MC_SYNC 1 /* Sync pages in memory with storage (usu. a file) */
31#define MC_LOCK 2 /* Lock pages into core ram, do not allow swapping of them */
32#define MC_UNLOCK 3 /* Unlock pages locked via previous mctl() with MC_LOCK arg */
33#define MC_LOCKAS 5 /* Lock an entire address space of the calling process */
34#define MC_UNLOCKAS 6 /* Unlock entire address space of calling process */
35
36#define MADV_FREE 0x5 /* (Solaris) contents can be freed */
37
38#ifdef __KERNEL__ 25#ifdef __KERNEL__
39#ifndef __ASSEMBLY__ 26#ifndef __ASSEMBLY__
40#define arch_mmap_check sparc64_mmap_check 27#define arch_mmap_check sparc64_mmap_check
diff --git a/include/asm-sparc64/mmzone.h b/include/asm-sparc64/mmzone.h
new file mode 100644
index 000000000000..ebf5986c12ed
--- /dev/null
+++ b/include/asm-sparc64/mmzone.h
@@ -0,0 +1,17 @@
1#ifndef _SPARC64_MMZONE_H
2#define _SPARC64_MMZONE_H
3
4#ifdef CONFIG_NEED_MULTIPLE_NODES
5
6extern struct pglist_data *node_data[];
7
8#define NODE_DATA(nid) (node_data[nid])
9#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
10#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
11
12extern int numa_cpu_lookup_table[];
13extern cpumask_t numa_cpumask_lookup_table[];
14
15#endif /* CONFIG_NEED_MULTIPLE_NODES */
16
17#endif /* _SPARC64_MMZONE_H */
diff --git a/include/asm-sparc64/namei.h b/include/asm-sparc64/namei.h
index ccda19e28695..275161f21213 100644
--- a/include/asm-sparc64/namei.h
+++ b/include/asm-sparc64/namei.h
@@ -8,19 +8,6 @@
8#ifndef __SPARC64_NAMEI_H 8#ifndef __SPARC64_NAMEI_H
9#define __SPARC64_NAMEI_H 9#define __SPARC64_NAMEI_H
10 10
11#define SPARC_BSD_EMUL "/usr/gnemul/sunos/" 11#define __emul_prefix() NULL
12#define SPARC_SOL_EMUL "/usr/gnemul/solaris/"
13
14static inline char * __emul_prefix(void)
15{
16 switch (current->personality) {
17 case PER_SUNOS:
18 return SPARC_BSD_EMUL;
19 case PER_SVR4:
20 return SPARC_SOL_EMUL;
21 default:
22 return NULL;
23 }
24}
25 12
26#endif /* __SPARC64_NAMEI_H */ 13#endif /* __SPARC64_NAMEI_H */
diff --git a/include/asm-sparc64/numnodes.h b/include/asm-sparc64/numnodes.h
deleted file mode 100644
index 017e7e74f5e7..000000000000
--- a/include/asm-sparc64/numnodes.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _SPARC64_NUMNODES_H
2#define _SPARC64_NUMNODES_H
3
4#define NODES_SHIFT 0
5
6#endif /* !(_SPARC64_NUMNODES_H) */
diff --git a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h
index e93a482aa24a..618117def0dc 100644
--- a/include/asm-sparc64/page.h
+++ b/include/asm-sparc64/page.h
@@ -39,8 +39,6 @@
39#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) 39#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
40#define HPAGE_MASK (~(HPAGE_SIZE - 1UL)) 40#define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
41#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) 41#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
42#define ARCH_HAS_SETCLEAR_HUGE_PTE
43#define ARCH_HAS_HUGETLB_PREFAULT_HOOK
44#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 42#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
45#endif 43#endif
46 44
diff --git a/include/asm-sparc64/pconf.h b/include/asm-sparc64/pconf.h
deleted file mode 100644
index aad106a70908..000000000000
--- a/include/asm-sparc64/pconf.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/* $Id: pconf.h,v 1.1 1996/12/02 00:09:10 davem Exp $
2 * pconf.h: pathconf() and fpathconf() defines for SunOS
3 * system call compatibility.
4 *
5 * Copyright (C) 1995, 1996 David S. Miller (davem@caip.rutgers.edu)
6 */
7
8#ifndef _SPARC64_PCONF_H
9#define _SPARC64_PCONF_H
10
11#include <linux/fs.h>
12#include <linux/limits.h>
13
14#define _PCONF_LINK 1 /* Max number of links to an object */
15#define _PCONF_CANON 2 /* TTY input buffer line size */
16#define _PCONF_INPUT 3 /* Biggest packet a tty can imbibe at once */
17#define _PCONF_NAME 4 /* Filename length max */
18#define _PCONF_PATH 5 /* Max size of a pathname */
19#define _PCONF_PIPE 6 /* Buffer size for a pipe */
20#define _PCONF_CHRESTRICT 7 /* Can only root chown files? */
21#define _PCONF_NOTRUNC 8 /* Are pathnames truncated if too big? */
22#define _PCONF_VDISABLE 9 /* Magic char to disable special tty chars */
23#define _PCONF_MAXPCONF 9
24
25#endif /* !(_SPARC64_PCONF_H) */
diff --git a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h
index 549e45266b68..0e200e7acec7 100644
--- a/include/asm-sparc64/pgtable.h
+++ b/include/asm-sparc64/pgtable.h
@@ -506,6 +506,11 @@ static inline pte_t pte_mkyoung(pte_t pte)
506 return __pte(pte_val(pte) | mask); 506 return __pte(pte_val(pte) | mask);
507} 507}
508 508
509static inline pte_t pte_mkspecial(pte_t pte)
510{
511 return pte;
512}
513
509static inline unsigned long pte_young(pte_t pte) 514static inline unsigned long pte_young(pte_t pte)
510{ 515{
511 unsigned long mask; 516 unsigned long mask;
@@ -608,6 +613,11 @@ static inline unsigned long pte_present(pte_t pte)
608 return val; 613 return val;
609} 614}
610 615
616static inline int pte_special(pte_t pte)
617{
618 return 0;
619}
620
611#define pmd_set(pmdp, ptep) \ 621#define pmd_set(pmdp, ptep) \
612 (pmd_val(*(pmdp)) = (__pa((unsigned long) (ptep)) >> 11UL)) 622 (pmd_val(*(pmdp)) = (__pa((unsigned long) (ptep)) >> 11UL))
613#define pud_set(pudp, pmdp) \ 623#define pud_set(pudp, pmdp) \
diff --git a/include/asm-sparc64/pil.h b/include/asm-sparc64/pil.h
index 72927749aebf..2f5d126f7163 100644
--- a/include/asm-sparc64/pil.h
+++ b/include/asm-sparc64/pil.h
@@ -19,11 +19,4 @@
19#define PIL_SMP_CTX_NEW_VERSION 4 19#define PIL_SMP_CTX_NEW_VERSION 4
20#define PIL_DEVICE_IRQ 5 20#define PIL_DEVICE_IRQ 5
21 21
22#ifndef __ASSEMBLY__
23#define PIL_RESERVED(PIL) ((PIL) == PIL_SMP_CALL_FUNC || \
24 (PIL) == PIL_SMP_RECEIVE_SIGNAL || \
25 (PIL) == PIL_SMP_CAPTURE || \
26 (PIL) == PIL_SMP_CTX_NEW_VERSION)
27#endif
28
29#endif /* !(_SPARC64_PIL_H) */ 22#endif /* !(_SPARC64_PIL_H) */
diff --git a/include/asm-sparc64/ptrace.h b/include/asm-sparc64/ptrace.h
index 6da197803efc..714b81956f32 100644
--- a/include/asm-sparc64/ptrace.h
+++ b/include/asm-sparc64/ptrace.h
@@ -1,4 +1,3 @@
1/* $Id: ptrace.h,v 1.14 2002/02/09 19:49:32 davem Exp $ */
2#ifndef _SPARC64_PTRACE_H 1#ifndef _SPARC64_PTRACE_H
3#define _SPARC64_PTRACE_H 2#define _SPARC64_PTRACE_H
4 3
@@ -8,17 +7,53 @@
8 * stack during a system call and basically all traps. 7 * stack during a system call and basically all traps.
9 */ 8 */
10 9
10/* This magic value must have the low 9 bits clear,
11 * as that is where we encode the %tt value, see below.
12 */
13#define PT_REGS_MAGIC 0x57ac6c00
14
11#ifndef __ASSEMBLY__ 15#ifndef __ASSEMBLY__
12 16
17#include <linux/types.h>
18
13struct pt_regs { 19struct pt_regs {
14 unsigned long u_regs[16]; /* globals and ins */ 20 unsigned long u_regs[16]; /* globals and ins */
15 unsigned long tstate; 21 unsigned long tstate;
16 unsigned long tpc; 22 unsigned long tpc;
17 unsigned long tnpc; 23 unsigned long tnpc;
18 unsigned int y; 24 unsigned int y;
19 unsigned int fprs; 25
26 /* We encode a magic number, PT_REGS_MAGIC, along
27 * with the %tt (trap type) register value at trap
28 * entry time. The magic number allows us to identify
29 * accurately a trap stack frame in the stack
30 * unwinder, and the %tt value allows us to test
31 * things like "in a system call" etc. for an arbitray
32 * process.
33 *
34 * The PT_REGS_MAGIC is choosen such that it can be
35 * loaded completely using just a sethi instruction.
36 */
37 unsigned int magic;
20}; 38};
21 39
40static inline int pt_regs_trap_type(struct pt_regs *regs)
41{
42 return regs->magic & 0x1ff;
43}
44
45static inline int pt_regs_clear_trap_type(struct pt_regs *regs)
46{
47 return regs->magic &= ~0x1ff;
48}
49
50static inline bool pt_regs_is_syscall(struct pt_regs *regs)
51{
52 int tt = pt_regs_trap_type(regs);
53
54 return (tt == 0x110 || tt == 0x111 || tt == 0x16d);
55}
56
22struct pt_regs32 { 57struct pt_regs32 {
23 unsigned int psr; 58 unsigned int psr;
24 unsigned int pc; 59 unsigned int pc;
@@ -147,7 +182,7 @@ extern void __show_regs(struct pt_regs *);
147#define PT_V9_TPC 0x88 182#define PT_V9_TPC 0x88
148#define PT_V9_TNPC 0x90 183#define PT_V9_TNPC 0x90
149#define PT_V9_Y 0x98 184#define PT_V9_Y 0x98
150#define PT_V9_FPRS 0x9c 185#define PT_V9_MAGIC 0x9c
151#define PT_TSTATE PT_V9_TSTATE 186#define PT_TSTATE PT_V9_TSTATE
152#define PT_TPC PT_V9_TPC 187#define PT_TPC PT_V9_TPC
153#define PT_TNPC PT_V9_TNPC 188#define PT_TNPC PT_V9_TNPC
diff --git a/include/asm-sparc64/semaphore.h b/include/asm-sparc64/semaphore.h
index 7f7c0c4e024f..d9b2034ed1d2 100644
--- a/include/asm-sparc64/semaphore.h
+++ b/include/asm-sparc64/semaphore.h
@@ -1,53 +1 @@
1#ifndef _SPARC64_SEMAPHORE_H #include <linux/semaphore.h>
2#define _SPARC64_SEMAPHORE_H
3
4/* These are actually reasonable on the V9.
5 *
6 * See asm-ppc/semaphore.h for implementation commentary,
7 * only sparc64 specific issues are commented here.
8 */
9#ifdef __KERNEL__
10
11#include <asm/atomic.h>
12#include <asm/system.h>
13#include <linux/wait.h>
14#include <linux/rwsem.h>
15
16struct semaphore {
17 atomic_t count;
18 wait_queue_head_t wait;
19};
20
21#define __SEMAPHORE_INITIALIZER(name, count) \
22 { ATOMIC_INIT(count), \
23 __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) }
24
25#define __DECLARE_SEMAPHORE_GENERIC(name, count) \
26 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
27
28#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
29
30static inline void sema_init (struct semaphore *sem, int val)
31{
32 atomic_set(&sem->count, val);
33 init_waitqueue_head(&sem->wait);
34}
35
36static inline void init_MUTEX (struct semaphore *sem)
37{
38 sema_init(sem, 1);
39}
40
41static inline void init_MUTEX_LOCKED (struct semaphore *sem)
42{
43 sema_init(sem, 0);
44}
45
46extern void up(struct semaphore *sem);
47extern void down(struct semaphore *sem);
48extern int down_trylock(struct semaphore *sem);
49extern int down_interruptible(struct semaphore *sem);
50
51#endif /* __KERNEL__ */
52
53#endif /* !(_SPARC64_SEMAPHORE_H) */
diff --git a/include/asm-sparc64/socket.h b/include/asm-sparc64/socket.h
index 44a625af6e31..8cf071fae3eb 100644
--- a/include/asm-sparc64/socket.h
+++ b/include/asm-sparc64/socket.h
@@ -24,9 +24,6 @@
24#define SO_SNDTIMEO 0x4000 24#define SO_SNDTIMEO 0x4000
25#define SO_ACCEPTCONN 0x8000 25#define SO_ACCEPTCONN 0x8000
26 26
27/* wha!??? */
28#define SO_DONTLINGER (~SO_LINGER) /* Older SunOS compat. hack */
29
30#define SO_SNDBUF 0x1001 27#define SO_SNDBUF 0x1001
31#define SO_RCVBUF 0x1002 28#define SO_RCVBUF 0x1002
32#define SO_SNDBUFFORCE 0x100a 29#define SO_SNDBUFFORCE 0x100a
diff --git a/include/asm-sparc64/solerrno.h b/include/asm-sparc64/solerrno.h
deleted file mode 100644
index a2ea6fcf3446..000000000000
--- a/include/asm-sparc64/solerrno.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/* $Id: solerrno.h,v 1.1 1996/12/26 14:22:40 davem Exp $
2 * solerrno.h: Solaris error return codes for compatibility.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#ifndef _SPARC64_SOLERRNO_H
8#define _SPARC64_SOLERRNO_H
9
10#define SOL_EPERM 1 /* Required superuser access perms */
11#define SOL_ENOENT 2 /* File or directory does not exist */
12#define SOL_ESRCH 3 /* Process did not exist */
13#define SOL_EINTR 4 /* System call was interrupted */
14#define SOL_EIO 5 /* An i/o error occurred */
15#define SOL_ENXIO 6 /* Device or Address does not exist */
16#define SOL_E2BIG 7 /* Too many arguments were given */
17#define SOL_ENOEXEC 8 /* Header of executable was munged */
18#define SOL_EBADF 9 /* Bogus file number */
19#define SOL_ECHILD 10 /* No children of process exist */
20#define SOL_EAGAIN 11 /* beep beep, "try again later" */
21#define SOL_ENOMEM 12 /* No memory available */
22#define SOL_EACCES 13 /* Access not allowed */
23#define SOL_EFAULT 14 /* Address passed was invalid */
24#define SOL_ENOTBLK 15 /* blkdev op on non-block device */
25#define SOL_EBUSY 16 /* Mounted device was busy */
26#define SOL_EEXIST 17 /* File specified already exists */
27#define SOL_EXDEV 18 /* Link request across diff devices */
28#define SOL_ENODEV 19 /* Device does not exist on system */
29#define SOL_ENOTDIR 20 /* Dir operation on non-directory */
30#define SOL_EISDIR 21 /* File was of directory type */
31#define SOL_EINVAL 22 /* Argument passed was invalid */
32#define SOL_ENFILE 23 /* No more room in file table */
33#define SOL_EMFILE 24 /* Proc has too many files open */
34#define SOL_ENOTTY 25 /* Ioctl was invalid for req device */
35#define SOL_ETXTBSY 26 /* Text file in busy state */
36#define SOL_EFBIG 27 /* Too big of a file for operation */
37#define SOL_ENOSPC 28 /* Disk is full */
38#define SOL_ESPIPE 29 /* Seek attempted on non-seeking dev*/
39#define SOL_EROFS 30 /* Write attempted on read-only fs */
40#define SOL_EMLINK 31 /* Too many links in file search */
41#define SOL_EPIPE 32 /* Call a plumber */
42#define SOL_EDOM 33 /* Argument was out of fct domain */
43#define SOL_ERANGE 34 /* Could not represent math result */
44#define SOL_ENOMSG 35 /* Message of req type doesn't exist */
45#define SOL_EIDRM 36 /* Identifier has been removed */
46#define SOL_ECHRNG 37 /* Req channel number out of range */
47#define SOL_EL2NSYNC 38 /* Could not sync at run level 2 */
48#define SOL_EL3HLT 39 /* Halted at run level 3 */
49#define SOL_EL3RST 40 /* Reset at run level 3 */
50#define SOL_ELNRNG 41 /* Out of range link number */
51#define SOL_EUNATCH 42 /* Driver for protocol not attached */
52#define SOL_ENOCSI 43 /* CSI structure not around */
53#define SOL_EL2HLT 44 /* Halted at run level 2 */
54#define SOL_EDEADLK 45 /* Deadlock condition detected */
55#define SOL_ENOLCK 46 /* Record locks unavailable */
56#define SOL_ECANCELED 47 /* Cancellation of oper. happened */
57#define SOL_ENOTSUP 48 /* Attempt of unsupported operation */
58#define SOL_EDQUOT 49 /* Users disk quota exceeded */
59#define SOL_EBADE 50 /* Invalid exchange */
60#define SOL_EBADR 51 /* Request descriptor was invalid */
61#define SOL_EXFULL 52 /* Full exchange */
62#define SOL_ENOANO 53 /* ano does not exist */
63#define SOL_EBADRQC 54 /* Req code was invalid */
64#define SOL_EBADSLT 55 /* Bad slot number */
65#define SOL_EDEADLOCK 56 /* Deadlock in fs error */
66#define SOL_EBFONT 57 /* Font file format invalid */
67/* YOW, I LOVE SYSV STREAMS!!!! */
68#define SOL_ENOSTR 60 /* Stream-op on non-stream dev */
69#define SOL_ENODATA 61 /* No data avail at this time */
70#define SOL_ETIME 62 /* Expiration of time occurred */
71#define SOL_ENOSR 63 /* Streams resources exhausted */
72#define SOL_ENONET 64 /* No network connected */
73#define SOL_ENOPKG 65 /* Non-installed package */
74#define SOL_EREMOTE 66 /* Object was on remote machine */
75#define SOL_ENOLINK 67 /* Cut link */
76#define SOL_EADV 68 /* Error in advertise */
77#define SOL_ESRMNT 69 /* Some magic srmount problem */
78#define SOL_ECOMM 70 /* During send, comm error occurred */
79#define SOL_EPROTO 71 /* Protocol botch */
80#define SOL_EMULTIHOP 74 /* Multihop attempted */
81#define SOL_EBADMSG 77 /* Message was unreadable */
82#define SOL_ENAMETOOLONG 78 /* Too long of a path name */
83#define SOL_EOVERFLOW 79 /* Data type too small for datum */
84#define SOL_ENOTUNIQ 80 /* Logical name was not unique */
85#define SOL_EBADFD 81 /* Op cannot be performed on fd */
86#define SOL_EREMCHG 82 /* Remote address is now different */
87#define SOL_ELIBACC 83 /* Shared lib could not be accessed */
88#define SOL_ELIBBAD 84 /* ShLib is corrupted in some way */
89#define SOL_ELIBSCN 85 /* A.out ShLib problems */
90#define SOL_ELIBMAX 86 /* Exceeded ShLib linkage limit */
91#define SOL_ELIBEXEC 87 /* Execution of ShLib attempted */
92#define SOL_EILSEQ 88 /* Bad byte sequence found */
93#define SOL_ENOSYS 89 /* Invalid filesystem operation */
94#define SOL_ELOOP 90 /* Detected loop in symbolic links */
95#define SOL_ERESTART 91 /* System call is restartable */
96#define SOL_ESTRPIPE 92 /* Do not sleep in head of stream */
97#define SOL_ENOTEMPTY 93 /* Rmdir of non-empty directory */
98#define SOL_EUSERS 94 /* Over abundance of users for ufs */
99#define SOL_ENOTSOCK 95 /* Sock-op on non-sock */
100#define SOL_EDESTADDRREQ 96 /* No dest addr given, but needed */
101#define SOL_EMSGSIZE 97 /* Msg too big */
102#define SOL_EPROTOTYPE 98 /* Bad socket protocol */
103#define SOL_ENOPROTOOPT 99 /* Unavailable protocol */
104#define SOL_EPROTONOSUPPORT 120 /* Unsupported protocol */
105#define SOL_ESOCKTNOSUPPORT 121 /* Unsupported socket type */
106#define SOL_EOPNOTSUPP 122 /* Unsupported sock-op */
107#define SOL_EPFNOSUPPORT 123 /* Unsupported protocol family */
108#define SOL_EAFNOSUPPORT 124 /* Unsup addr family for protocol */
109#define SOL_EADDRINUSE 125 /* Req addr is already in use */
110#define SOL_EADDRNOTAVAIL 126 /* Req addr not available right now */
111#define SOL_ENETDOWN 127 /* Your subnet is on fire */
112#define SOL_ENETUNREACH 128 /* Someone playing with gateway and */
113 /* did not tell you he was going to */
114#define SOL_ENETRESET 129 /* Buy less-buggy ethernet cards */
115#define SOL_ECONNABORTED 130 /* Aborted connection due to sw */
116#define SOL_ECONNRESET 131 /* Your peers reset your connection */
117#define SOL_ENOBUFS 132 /* No buffer space available */
118#define SOL_EISCONN 133 /* Connect on already connected */
119 /* socket attempted */
120#define SOL_ENOTCONN 134 /* Comm on non-connected socket */
121#define SOL_ESHUTDOWN 143 /* Op attempted after sock-shutdown */
122#define SOL_ETOOMANYREFS 144 /* Reference limit exceeded */
123#define SOL_ETIMEDOUT 145 /* Timed out connection */
124#define SOL_ECONNREFUSED 146 /* Connection refused by remote host*/
125#define SOL_EHOSTDOWN 147 /* Remote host is up in flames */
126#define SOL_EHOSTUNREACH 148 /* Make a left at Easton Ave..... */
127#define SOL_EWOULDBLOCK EAGAIN /* Just an alias */
128#define SOL_EALREADY 149 /* Operation is already occurring */
129#define SOL_EINPROGRESS 150 /* Operation is happening now */
130#define SOL_ESTALE 151 /* Fungus growth on NFS file handle */
131
132#endif /* !(_SPARC64_SOLERRNO_H) */
diff --git a/include/asm-sparc64/sparsemem.h b/include/asm-sparc64/sparsemem.h
index 77bcd2bfa53c..b99d4e4b6d28 100644
--- a/include/asm-sparc64/sparsemem.h
+++ b/include/asm-sparc64/sparsemem.h
@@ -3,7 +3,7 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#define SECTION_SIZE_BITS 31 6#define SECTION_SIZE_BITS 30
7#define MAX_PHYSADDR_BITS 42 7#define MAX_PHYSADDR_BITS 42
8#define MAX_PHYSMEM_BITS 42 8#define MAX_PHYSMEM_BITS 42
9 9
diff --git a/include/asm-sparc64/svr4.h b/include/asm-sparc64/svr4.h
deleted file mode 100644
index c96d5f116e1c..000000000000
--- a/include/asm-sparc64/svr4.h
+++ /dev/null
@@ -1,120 +0,0 @@
1/* Solaris/SPARC constants and definitions --
2 * (C) 1996 Miguel de Icaza
3 *
4 * This file is not meant to be included by user level applications
5 * but the solaris syscall emulator
6 */
7
8#ifndef _SPARC64_SVR4_H
9#define _SPARC64_SVR4_H
10
11/* Signals as used by svr4 */
12typedef struct { /* signal set type */
13 uint sigbits[4];
14} svr4_sigset_t;
15
16/* Values for siginfo.code */
17#define SVR4_SINOINFO 32767
18/* Siginfo, sucker expects bunch of information on those parameters */
19typedef union {
20 char total_size [128];
21 struct {
22 int signo;
23 int code;
24 int error;
25 union {
26 } data;
27 } siginfo;
28} svr4_siginfo_t;
29
30/* Context definition */
31
32/* Location of the user stored registers into a greg_t */
33enum {
34 SVR4_PSR, SVR4_PC, SVR4_NPC, SVR4_Y,
35 SVR4_G1, SVR4_G2, SVR4_G3, SVR4_G4,
36 SVR4_G5, SVR4_G6, SVR4_G7, SVR4_O0,
37 SVR4_O1, SVR4_O2, SVR4_O3, SVR4_O4,
38 SVR4_O5, SVR4_O6, SVR4_O7
39};
40
41/* sizeof (regs) / sizeof (greg_t), defined in the ABI */
42#define SVR4_NREGS 19
43#define SVR4_MAXWIN 31
44
45typedef struct {
46 u32 rwin_lo[8];
47 u32 rwin_in[8];
48} svr4_rwindow_t;
49
50typedef struct {
51 int count;
52 u32 winptr [SVR4_MAXWIN]; /* pointer to the windows */
53
54 svr4_rwindow_t win[SVR4_MAXWIN]; /* the windows */
55} svr4_gwindows_t;
56
57typedef int svr4_gregset_t[SVR4_NREGS];
58
59typedef struct {
60 u64 fpu_regs[32];
61 u32 fp_q;
62 u32 fp_fsr;
63 u_char fp_nqel;
64 u_char fp_nqsize;
65 u_char inuse; /* if fpu is in use */
66} svr4_fregset_t;
67
68typedef struct {
69 u32 id; /* if this holds "xrs" string => ptr is valid */
70 u32 ptr;
71} svr4_xrs_t;
72
73/* Machine dependent context */
74typedef struct {
75 svr4_gregset_t greg; /* registers 0..19 (see top) */
76 u32 gwin; /* may point to register windows */
77 svr4_fregset_t freg; /* floating point registers */
78 svr4_xrs_t xrs; /* mhm? */
79 int pad[19];
80} svr4_mcontext_t;
81
82/* flags for stack_t.flags */
83enum svr4_stack_flags {
84 SVR4_SS_ONSTACK,
85 SVR4_SS_DISABLE,
86};
87
88/* signal stack execution place, unsupported */
89typedef struct svr4_stack_t {
90 u32 sp;
91 int size;
92 int flags;
93} svr4_stack_t;
94
95/* Context used by getcontext and setcontext */
96typedef struct svr4_ucontext_t {
97 u32 flags; /* context flags, indicate what is loaded */
98 u32 link;
99 svr4_sigset_t sigmask;
100 svr4_stack_t stack;
101 svr4_mcontext_t mcontext;
102 int pad[23];
103} svr4_ucontext_t;
104
105/* windows hold the windows as they were at signal time,
106 * ucontext->mcontext holds a pointer to them.
107 * addresses for uc and si are passed as parameters to svr4 signal
108 * handler
109 */
110
111/* This is the signal frame that is passed to the signal handler */
112typedef struct {
113 svr4_gwindows_t gw; /* windows */
114 svr4_ucontext_t uc; /* machine context */
115 svr4_siginfo_t si; /* siginfo */
116} svr4_signal_frame_t;
117
118#define SVR4_SF_ALIGNED (((sizeof (svr4_signal_frame_t) + 7) & (~7)))
119
120#endif /* include control */
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h
index 53eae091a171..6897ac31be41 100644
--- a/include/asm-sparc64/system.h
+++ b/include/asm-sparc64/system.h
@@ -180,12 +180,13 @@ do { if (test_thread_flag(TIF_PERFCTR)) { \
180 "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \ 180 "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \
181 "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \ 181 "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \
182 "ldx [%%g6 + %9], %%g4\n\t" \ 182 "ldx [%%g6 + %9], %%g4\n\t" \
183 "brz,pt %%o7, 1f\n\t" \ 183 "brz,pt %%o7, switch_to_pc\n\t" \
184 " mov %%g7, %0\n\t" \ 184 " mov %%g7, %0\n\t" \
185 "sethi %%hi(ret_from_syscall), %%g1\n\t" \ 185 "sethi %%hi(ret_from_syscall), %%g1\n\t" \
186 "jmpl %%g1 + %%lo(ret_from_syscall), %%g0\n\t" \ 186 "jmpl %%g1 + %%lo(ret_from_syscall), %%g0\n\t" \
187 " nop\n\t" \ 187 " nop\n\t" \
188 "1:\n\t" \ 188 ".globl switch_to_pc\n\t" \
189 "switch_to_pc:\n\t" \
189 : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \ 190 : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \
190 "=r" (__local_per_cpu_offset) \ 191 "=r" (__local_per_cpu_offset) \
191 : "0" (task_thread_info(next)), \ 192 : "0" (task_thread_info(next)), \
diff --git a/include/asm-sparc64/termios.h b/include/asm-sparc64/termios.h
index ef527211f8a8..cacbea171ad7 100644
--- a/include/asm-sparc64/termios.h
+++ b/include/asm-sparc64/termios.h
@@ -33,11 +33,6 @@ struct ltchars {
33}; 33};
34#endif /* __KERNEL__ */ 34#endif /* __KERNEL__ */
35 35
36struct sunos_ttysize {
37 int st_lines; /* Lines on the terminal */
38 int st_columns; /* Columns on the terminal */
39};
40
41struct winsize { 36struct winsize {
42 unsigned short ws_row; 37 unsigned short ws_row;
43 unsigned short ws_col; 38 unsigned short ws_col;
diff --git a/include/asm-sparc64/thread_info.h b/include/asm-sparc64/thread_info.h
index 98252cd44dd6..71e42d1a80d9 100644
--- a/include/asm-sparc64/thread_info.h
+++ b/include/asm-sparc64/thread_info.h
@@ -1,5 +1,4 @@
1/* $Id: thread_info.h,v 1.1 2002/02/10 00:00:58 davem Exp $ 1/* thread_info.h: sparc64 low-level thread information
2 * thread_info.h: sparc64 low-level thread information
3 * 2 *
4 * Copyright (C) 2002 David S. Miller (davem@redhat.com) 3 * Copyright (C) 2002 David S. Miller (davem@redhat.com)
5 */ 4 */
@@ -223,7 +222,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
223#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 222#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
224#define TIF_PERFCTR 4 /* performance counters active */ 223#define TIF_PERFCTR 4 /* performance counters active */
225#define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */ 224#define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
226#define TIF_NEWSIGNALS 6 /* wants new-style signals */ 225/* flag bit 6 is available */
227#define TIF_32BIT 7 /* 32-bit binary */ 226#define TIF_32BIT 7 /* 32-bit binary */
228/* flag bit 8 is available */ 227/* flag bit 8 is available */
229#define TIF_SECCOMP 9 /* secure computing */ 228#define TIF_SECCOMP 9 /* secure computing */
@@ -242,7 +241,6 @@ register struct thread_info *current_thread_info_reg asm("g6");
242#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 241#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
243#define _TIF_PERFCTR (1<<TIF_PERFCTR) 242#define _TIF_PERFCTR (1<<TIF_PERFCTR)
244#define _TIF_UNALIGNED (1<<TIF_UNALIGNED) 243#define _TIF_UNALIGNED (1<<TIF_UNALIGNED)
245#define _TIF_NEWSIGNALS (1<<TIF_NEWSIGNALS)
246#define _TIF_32BIT (1<<TIF_32BIT) 244#define _TIF_32BIT (1<<TIF_32BIT)
247#define _TIF_SECCOMP (1<<TIF_SECCOMP) 245#define _TIF_SECCOMP (1<<TIF_SECCOMP)
248#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 246#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
diff --git a/include/asm-sparc64/topology.h b/include/asm-sparc64/topology.h
index c6b557034f68..001c04027c82 100644
--- a/include/asm-sparc64/topology.h
+++ b/include/asm-sparc64/topology.h
@@ -1,6 +1,77 @@
1#ifndef _ASM_SPARC64_TOPOLOGY_H 1#ifndef _ASM_SPARC64_TOPOLOGY_H
2#define _ASM_SPARC64_TOPOLOGY_H 2#define _ASM_SPARC64_TOPOLOGY_H
3 3
4#ifdef CONFIG_NUMA
5
6#include <asm/mmzone.h>
7
8static inline int cpu_to_node(int cpu)
9{
10 return numa_cpu_lookup_table[cpu];
11}
12
13#define parent_node(node) (node)
14
15static inline cpumask_t node_to_cpumask(int node)
16{
17 return numa_cpumask_lookup_table[node];
18}
19
20/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
21#define node_to_cpumask_ptr(v, node) \
22 cpumask_t *v = &(numa_cpumask_lookup_table[node])
23
24#define node_to_cpumask_ptr_next(v, node) \
25 v = &(numa_cpumask_lookup_table[node])
26
27static inline int node_to_first_cpu(int node)
28{
29 cpumask_t tmp;
30 tmp = node_to_cpumask(node);
31 return first_cpu(tmp);
32}
33
34struct pci_bus;
35#ifdef CONFIG_PCI
36extern int pcibus_to_node(struct pci_bus *pbus);
37#else
38static inline int pcibus_to_node(struct pci_bus *pbus)
39{
40 return -1;
41}
42#endif
43
44#define pcibus_to_cpumask(bus) \
45 (pcibus_to_node(bus) == -1 ? \
46 CPU_MASK_ALL : \
47 node_to_cpumask(pcibus_to_node(bus)))
48
49#define SD_NODE_INIT (struct sched_domain) { \
50 .min_interval = 8, \
51 .max_interval = 32, \
52 .busy_factor = 32, \
53 .imbalance_pct = 125, \
54 .cache_nice_tries = 2, \
55 .busy_idx = 3, \
56 .idle_idx = 2, \
57 .newidle_idx = 0, \
58 .wake_idx = 1, \
59 .forkexec_idx = 1, \
60 .flags = SD_LOAD_BALANCE \
61 | SD_BALANCE_FORK \
62 | SD_BALANCE_EXEC \
63 | SD_SERIALIZE \
64 | SD_WAKE_BALANCE, \
65 .last_balance = jiffies, \
66 .balance_interval = 1, \
67}
68
69#else /* CONFIG_NUMA */
70
71#include <asm-generic/topology.h>
72
73#endif /* !(CONFIG_NUMA) */
74
4#ifdef CONFIG_SMP 75#ifdef CONFIG_SMP
5#define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id) 76#define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id)
6#define topology_core_id(cpu) (cpu_data(cpu).core_id) 77#define topology_core_id(cpu) (cpu_data(cpu).core_id)
@@ -10,8 +81,6 @@
10#define smt_capable() (sparc64_multi_core) 81#define smt_capable() (sparc64_multi_core)
11#endif /* CONFIG_SMP */ 82#endif /* CONFIG_SMP */
12 83
13#include <asm-generic/topology.h>
14
15#define cpu_coregroup_map(cpu) (cpu_core_map[cpu]) 84#define cpu_coregroup_map(cpu) (cpu_core_map[cpu])
16 85
17#endif /* _ASM_SPARC64_TOPOLOGY_H */ 86#endif /* _ASM_SPARC64_TOPOLOGY_H */
diff --git a/include/asm-sparc64/ttable.h b/include/asm-sparc64/ttable.h
index bbb9c8f13d61..1b55538b944f 100644
--- a/include/asm-sparc64/ttable.h
+++ b/include/asm-sparc64/ttable.h
@@ -28,7 +28,7 @@
28 call routine; \ 28 call routine; \
29 add %sp, PTREGS_OFF, %o0; \ 29 add %sp, PTREGS_OFF, %o0; \
30 ba,pt %xcc, rtrap; \ 30 ba,pt %xcc, rtrap; \
31 clr %l6; \ 31 nop; \
32 nop; 32 nop;
33 33
34#define TRAP_7INSNS(routine) \ 34#define TRAP_7INSNS(routine) \
@@ -38,7 +38,7 @@
38 call routine; \ 38 call routine; \
39 add %sp, PTREGS_OFF, %o0; \ 39 add %sp, PTREGS_OFF, %o0; \
40 ba,pt %xcc, rtrap; \ 40 ba,pt %xcc, rtrap; \
41 clr %l6; 41 nop;
42 42
43#define TRAP_SAVEFPU(routine) \ 43#define TRAP_SAVEFPU(routine) \
44 sethi %hi(109f), %g7; \ 44 sethi %hi(109f), %g7; \
@@ -47,7 +47,7 @@
47 call routine; \ 47 call routine; \
48 add %sp, PTREGS_OFF, %o0; \ 48 add %sp, PTREGS_OFF, %o0; \
49 ba,pt %xcc, rtrap; \ 49 ba,pt %xcc, rtrap; \
50 clr %l6; \ 50 nop; \
51 nop; 51 nop;
52 52
53#define TRAP_NOSAVE(routine) \ 53#define TRAP_NOSAVE(routine) \
@@ -67,7 +67,7 @@
67 call routine; \ 67 call routine; \
68 add %sp, PTREGS_OFF, %o0; \ 68 add %sp, PTREGS_OFF, %o0; \
69 ba,pt %xcc, rtrap; \ 69 ba,pt %xcc, rtrap; \
70 clr %l6; \ 70 nop; \
71 nop; 71 nop;
72 72
73#define TRAP_ARG(routine, arg) \ 73#define TRAP_ARG(routine, arg) \
@@ -78,7 +78,7 @@
78 call routine; \ 78 call routine; \
79 mov arg, %o1; \ 79 mov arg, %o1; \
80 ba,pt %xcc, rtrap; \ 80 ba,pt %xcc, rtrap; \
81 clr %l6; 81 nop;
82 82
83#define TRAPTL1_ARG(routine, arg) \ 83#define TRAPTL1_ARG(routine, arg) \
84 sethi %hi(109f), %g7; \ 84 sethi %hi(109f), %g7; \
@@ -88,7 +88,7 @@
88 call routine; \ 88 call routine; \
89 mov arg, %o1; \ 89 mov arg, %o1; \
90 ba,pt %xcc, rtrap; \ 90 ba,pt %xcc, rtrap; \
91 clr %l6; 91 nop;
92 92
93#define SYSCALL_TRAP(routine, systbl) \ 93#define SYSCALL_TRAP(routine, systbl) \
94 sethi %hi(109f), %g7; \ 94 sethi %hi(109f), %g7; \
@@ -99,14 +99,6 @@
99 or %l7, %lo(systbl), %l7; \ 99 or %l7, %lo(systbl), %l7; \
100 nop; nop; 100 nop; nop;
101 101
102#define INDIRECT_SOLARIS_SYSCALL(num) \
103 sethi %hi(109f), %g7; \
104 ba,pt %xcc, etrap; \
105109: or %g7, %lo(109b), %g7; \
106 ba,pt %xcc, tl0_solaris + 0xc; \
107 mov num, %g1; \
108 nop;nop;nop;
109
110#define TRAP_UTRAP(handler,lvl) \ 102#define TRAP_UTRAP(handler,lvl) \
111 mov handler, %g3; \ 103 mov handler, %g3; \
112 ba,pt %xcc, utrap_trap; \ 104 ba,pt %xcc, utrap_trap; \
@@ -117,11 +109,6 @@
117 nop; \ 109 nop; \
118 nop; 110 nop;
119 111
120#ifdef CONFIG_SUNOS_EMUL
121#define SUNOS_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sunos_sys_table)
122#else
123#define SUNOS_SYSCALL_TRAP TRAP(sunos_syscall)
124#endif
125#ifdef CONFIG_COMPAT 112#ifdef CONFIG_COMPAT
126#define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32) 113#define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
127#else 114#else
@@ -130,11 +117,6 @@
130#define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64) 117#define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
131#define GETCC_TRAP TRAP(getcc) 118#define GETCC_TRAP TRAP(getcc)
132#define SETCC_TRAP TRAP(setcc) 119#define SETCC_TRAP TRAP(setcc)
133#ifdef CONFIG_SOLARIS_EMUL
134#define SOLARIS_SYSCALL_TRAP TRAP(solaris_sparc_syscall)
135#else
136#define SOLARIS_SYSCALL_TRAP TRAP(solaris_syscall)
137#endif
138#define BREAKPOINT_TRAP TRAP(breakpoint_trap) 120#define BREAKPOINT_TRAP TRAP(breakpoint_trap)
139 121
140#ifdef CONFIG_TRACE_IRQFLAGS 122#ifdef CONFIG_TRACE_IRQFLAGS
@@ -184,7 +166,7 @@
184 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \ 166 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \
185 add %l1, 4, %l2; \ 167 add %l1, 4, %l2; \
186 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \ 168 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \
187 ba,pt %xcc, rtrap_clr_l6; \ 169 ba,pt %xcc, rtrap; \
188 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]; 170 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
189 171
190#ifdef CONFIG_KPROBES 172#ifdef CONFIG_KPROBES
@@ -193,6 +175,12 @@
193#define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl) 175#define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
194#endif 176#endif
195 177
178#ifdef CONFIG_KGDB
179#define KGDB_TRAP(lvl) TRAP_IRQ(kgdb_trap, lvl)
180#else
181#define KGDB_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
182#endif
183
196#define SUN4V_ITSB_MISS \ 184#define SUN4V_ITSB_MISS \
197 ldxa [%g0] ASI_SCRATCHPAD, %g2; \ 185 ldxa [%g0] ASI_SCRATCHPAD, %g2; \
198 ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \ 186 ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \
diff --git a/include/asm-sparc64/unaligned.h b/include/asm-sparc64/unaligned.h
index 1ed3ba537772..edcebb09441e 100644
--- a/include/asm-sparc64/unaligned.h
+++ b/include/asm-sparc64/unaligned.h
@@ -1,6 +1,10 @@
1#ifndef _ASM_SPARC64_UNALIGNED_H_ 1#ifndef _ASM_SPARC64_UNALIGNED_H
2#define _ASM_SPARC64_UNALIGNED_H_ 2#define _ASM_SPARC64_UNALIGNED_H
3 3
4#include <asm-generic/unaligned.h> 4#include <linux/unaligned/be_struct.h>
5#include <linux/unaligned/le_byteshift.h>
6#include <linux/unaligned/generic.h>
7#define get_unaligned __get_unaligned_be
8#define put_unaligned __put_unaligned_be
5 9
6#endif /* _ASM_SPARC64_UNALIGNED_H */ 10#endif /* _ASM_SPARC64_UNALIGNED_H */
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
index 77559da0ea3f..13be4453a1f0 100644
--- a/include/asm-sparc64/unistd.h
+++ b/include/asm-sparc64/unistd.h
@@ -338,16 +338,6 @@
338#define NR_SYSCALLS 317 338#define NR_SYSCALLS 317
339 339
340#ifdef __KERNEL__ 340#ifdef __KERNEL__
341/* sysconf options, for SunOS compatibility */
342#define _SC_ARG_MAX 1
343#define _SC_CHILD_MAX 2
344#define _SC_CLK_TCK 3
345#define _SC_NGROUPS_MAX 4
346#define _SC_OPEN_MAX 5
347#define _SC_JOB_CONTROL 6
348#define _SC_SAVED_IDS 7
349#define _SC_VERSION 8
350
351#define __ARCH_WANT_IPC_PARSE_VERSION 341#define __ARCH_WANT_IPC_PARSE_VERSION
352#define __ARCH_WANT_OLD_READDIR 342#define __ARCH_WANT_OLD_READDIR
353#define __ARCH_WANT_STAT64 343#define __ARCH_WANT_STAT64
diff --git a/include/asm-sparc64/user.h b/include/asm-sparc64/user.h
index 02b138943837..29fc6e906c29 100644
--- a/include/asm-sparc64/user.h
+++ b/include/asm-sparc64/user.h
@@ -1,60 +1 @@
1/* $Id: user.h,v 1.1 1996/12/26 14:22:44 davem Exp $ #include <asm-sparc/user.h>
2 * asm-sparc64/user.h: Core file definitions for the Sparc.
3 *
4 * Keep in sync with reg.h. Actually, we could get rid of this
5 * one, since we won't a.out core dump that much anyways - miguel.
6 * Copyright (C) 1995 (davem@caip.rutgers.edu)
7 */
8#ifndef _SPARC64_USER_H
9#define _SPARC64_USER_H
10
11#include <linux/a.out.h>
12struct sunos_regs {
13 unsigned int psr, pc, npc, y;
14 unsigned int regs[15];
15};
16
17struct sunos_fpqueue {
18 unsigned int *addr;
19 unsigned int inst;
20};
21
22struct sunos_fp {
23 union {
24 unsigned int regs[32];
25 double reg_dbls[16];
26 } fregs;
27 unsigned int fsr;
28 unsigned int flags;
29 unsigned int extra;
30 unsigned int fpq_count;
31 struct sunos_fpqueue fpq[16];
32};
33
34struct sunos_fpu {
35 struct sunos_fp fpstatus;
36};
37
38/* The SunOS core file header layout. */
39struct user {
40 unsigned int magic;
41 unsigned int len;
42 struct sunos_regs regs;
43 struct exec uexec;
44 int signal;
45 size_t u_tsize; /* all of these in bytes! */
46 size_t u_dsize;
47 size_t u_ssize;
48 char u_comm[17];
49 struct sunos_fpu fpu;
50 unsigned int sigcode; /* Special sigcontext subcode, if any */
51};
52
53#define NBPG PAGE_SIZE /* XXX 4096 maybe? */
54#define UPAGES 1
55#define HOST_TEXT_START_ADDR (u.start_code)
56#define HOST_DATA_START_ADDR (u.start_data)
57#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
58#define SUNOS_CORE_MAGIC 0x080456
59
60#endif /* !(_SPARC64_USER_H) */
diff --git a/include/asm-um/div64.h b/include/asm-um/div64.h
index 7b73b2cd5b34..1e17f7409cab 100644
--- a/include/asm-um/div64.h
+++ b/include/asm-um/div64.h
@@ -3,5 +3,4 @@
3 3
4#include "asm/arch/div64.h" 4#include "asm/arch/div64.h"
5 5
6extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
7#endif 6#endif
diff --git a/include/asm-um/pgtable.h b/include/asm-um/pgtable.h
index 4102b443e925..02db81b7b86e 100644
--- a/include/asm-um/pgtable.h
+++ b/include/asm-um/pgtable.h
@@ -173,6 +173,11 @@ static inline int pte_newprot(pte_t pte)
173 return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT))); 173 return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT)));
174} 174}
175 175
176static inline int pte_special(pte_t pte)
177{
178 return 0;
179}
180
176/* 181/*
177 * ================================= 182 * =================================
178 * Flags setting section. 183 * Flags setting section.
@@ -241,6 +246,11 @@ static inline pte_t pte_mknewpage(pte_t pte)
241 return(pte); 246 return(pte);
242} 247}
243 248
249static inline pte_t pte_mkspecial(pte_t pte)
250{
251 return(pte);
252}
253
244static inline void set_pte(pte_t *pteptr, pte_t pteval) 254static inline void set_pte(pte_t *pteptr, pte_t pteval)
245{ 255{
246 pte_copy(*pteptr, pteval); 256 pte_copy(*pteptr, pteval);
diff --git a/include/asm-um/semaphore.h b/include/asm-um/semaphore.h
index ff13c34de421..d9b2034ed1d2 100644
--- a/include/asm-um/semaphore.h
+++ b/include/asm-um/semaphore.h
@@ -1,6 +1 @@
1#ifndef __UM_SEMAPHORE_H #include <linux/semaphore.h>
2#define __UM_SEMAPHORE_H
3
4#include "asm/arch/semaphore.h"
5
6#endif
diff --git a/include/asm-um/unaligned.h b/include/asm-um/unaligned.h
index 1d2497c57274..a47196974e39 100644
--- a/include/asm-um/unaligned.h
+++ b/include/asm-um/unaligned.h
@@ -1,6 +1,6 @@
1#ifndef __UM_UNALIGNED_H 1#ifndef _ASM_UM_UNALIGNED_H
2#define __UM_UNALIGNED_H 2#define _ASM_UM_UNALIGNED_H
3 3
4#include "asm/arch/unaligned.h" 4#include "asm/arch/unaligned.h"
5 5
6#endif 6#endif /* _ASM_UM_UNALIGNED_H */
diff --git a/include/asm-v850/semaphore.h b/include/asm-v850/semaphore.h
index 10ed0ccf37df..d9b2034ed1d2 100644
--- a/include/asm-v850/semaphore.h
+++ b/include/asm-v850/semaphore.h
@@ -1,84 +1 @@
1#ifndef __V850_SEMAPHORE_H__ #include <linux/semaphore.h>
2#define __V850_SEMAPHORE_H__
3
4#include <linux/linkage.h>
5#include <linux/spinlock.h>
6#include <linux/wait.h>
7#include <linux/rwsem.h>
8
9#include <asm/atomic.h>
10
11struct semaphore {
12 atomic_t count;
13 int sleepers;
14 wait_queue_head_t wait;
15};
16
17#define __SEMAPHORE_INITIALIZER(name,count) \
18 { ATOMIC_INIT (count), 0, \
19 __WAIT_QUEUE_HEAD_INITIALIZER ((name).wait) }
20
21#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
22 struct semaphore name = __SEMAPHORE_INITIALIZER (name,count)
23
24#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC (name,1)
25
26static inline void sema_init (struct semaphore *sem, int val)
27{
28 *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
29}
30
31static inline void init_MUTEX (struct semaphore *sem)
32{
33 sema_init (sem, 1);
34}
35
36static inline void init_MUTEX_LOCKED (struct semaphore *sem)
37{
38 sema_init (sem, 0);
39}
40
41/*
42 * special register calling convention
43 */
44asmlinkage void __down_failed (void);
45asmlinkage int __down_interruptible_failed (void);
46asmlinkage int __down_trylock_failed (void);
47asmlinkage void __up_wakeup (void);
48
49extern void __down (struct semaphore * sem);
50extern int __down_interruptible (struct semaphore * sem);
51extern int __down_trylock (struct semaphore * sem);
52extern void __up (struct semaphore * sem);
53
54static inline void down (struct semaphore * sem)
55{
56 might_sleep();
57 if (atomic_dec_return (&sem->count) < 0)
58 __down (sem);
59}
60
61static inline int down_interruptible (struct semaphore * sem)
62{
63 int ret = 0;
64 might_sleep();
65 if (atomic_dec_return (&sem->count) < 0)
66 ret = __down_interruptible (sem);
67 return ret;
68}
69
70static inline int down_trylock (struct semaphore *sem)
71{
72 int ret = 0;
73 if (atomic_dec_return (&sem->count) < 0)
74 ret = __down_trylock (sem);
75 return ret;
76}
77
78static inline void up (struct semaphore * sem)
79{
80 if (atomic_inc_return (&sem->count) <= 0)
81 __up (sem);
82}
83
84#endif /* __V850_SEMAPHORE_H__ */
diff --git a/include/asm-v850/unaligned.h b/include/asm-v850/unaligned.h
index e30b18653a94..53122b28491e 100644
--- a/include/asm-v850/unaligned.h
+++ b/include/asm-v850/unaligned.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-v850/unaligned.h -- Unaligned memory access
3 *
4 * Copyright (C) 2001 NEC Corporation 2 * Copyright (C) 2001 NEC Corporation
5 * Copyright (C) 2001 Miles Bader <miles@gnu.org> 3 * Copyright (C) 2001 Miles Bader <miles@gnu.org>
6 * 4 *
@@ -8,123 +6,17 @@
8 * Public License. See the file COPYING in the main directory of this 6 * Public License. See the file COPYING in the main directory of this
9 * archive for more details. 7 * archive for more details.
10 * 8 *
11 * This file is a copy of the arm version, include/asm-arm/unaligned.h
12 *
13 * Note that some v850 chips support unaligned access, but it seems too 9 * Note that some v850 chips support unaligned access, but it seems too
14 * annoying to use. 10 * annoying to use.
15 */ 11 */
12#ifndef _ASM_V850_UNALIGNED_H
13#define _ASM_V850_UNALIGNED_H
16 14
17#ifndef __V850_UNALIGNED_H__ 15#include <linux/unaligned/be_byteshift.h>
18#define __V850_UNALIGNED_H__ 16#include <linux/unaligned/le_byteshift.h>
19 17#include <linux/unaligned/generic.h>
20#include <asm/types.h>
21
22extern int __bug_unaligned_x(void *ptr);
23
24/*
25 * What is the most efficient way of loading/storing an unaligned value?
26 *
27 * That is the subject of this file. Efficiency here is defined as
28 * minimum code size with minimum register usage for the common cases.
29 * It is currently not believed that long longs are common, so we
30 * trade efficiency for the chars, shorts and longs against the long
31 * longs.
32 *
33 * Current stats with gcc 2.7.2.2 for these functions:
34 *
35 * ptrsize get: code regs put: code regs
36 * 1 1 1 1 2
37 * 2 3 2 3 2
38 * 4 7 3 7 3
39 * 8 20 6 16 6
40 *
41 * gcc 2.95.1 seems to code differently:
42 *
43 * ptrsize get: code regs put: code regs
44 * 1 1 1 1 2
45 * 2 3 2 3 2
46 * 4 7 4 7 4
47 * 8 19 8 15 6
48 *
49 * which may or may not be more efficient (depending upon whether
50 * you can afford the extra registers). Hopefully the gcc 2.95
51 * is inteligent enough to decide if it is better to use the
52 * extra register, but evidence so far seems to suggest otherwise.
53 *
54 * Unfortunately, gcc is not able to optimise the high word
55 * out of long long >> 32, or the low word from long long << 32
56 */
57
58#define __get_unaligned_2(__p) \
59 (__p[0] | __p[1] << 8)
60
61#define __get_unaligned_4(__p) \
62 (__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24)
63
64#define get_unaligned(ptr) \
65 ({ \
66 __typeof__(*(ptr)) __v; \
67 __u8 *__p = (__u8 *)(ptr); \
68 switch (sizeof(*(ptr))) { \
69 case 1: __v = *(ptr); break; \
70 case 2: __v = __get_unaligned_2(__p); break; \
71 case 4: __v = __get_unaligned_4(__p); break; \
72 case 8: { \
73 unsigned int __v1, __v2; \
74 __v2 = __get_unaligned_4((__p+4)); \
75 __v1 = __get_unaligned_4(__p); \
76 __v = ((unsigned long long)__v2 << 32 | __v1); \
77 } \
78 break; \
79 default: __v = __bug_unaligned_x(__p); break; \
80 } \
81 __v; \
82 })
83
84
85static inline void __put_unaligned_2(__u32 __v, register __u8 *__p)
86{
87 *__p++ = __v;
88 *__p++ = __v >> 8;
89}
90
91static inline void __put_unaligned_4(__u32 __v, register __u8 *__p)
92{
93 __put_unaligned_2(__v >> 16, __p + 2);
94 __put_unaligned_2(__v, __p);
95}
96
97static inline void __put_unaligned_8(const unsigned long long __v, register __u8 *__p)
98{
99 /*
100 * tradeoff: 8 bytes of stack for all unaligned puts (2
101 * instructions), or an extra register in the long long
102 * case - go for the extra register.
103 */
104 __put_unaligned_4(__v >> 32, __p+4);
105 __put_unaligned_4(__v, __p);
106}
107
108/*
109 * Try to store an unaligned value as efficiently as possible.
110 */
111#define put_unaligned(val,ptr) \
112 ({ \
113 switch (sizeof(*(ptr))) { \
114 case 1: \
115 *(ptr) = (val); \
116 break; \
117 case 2: __put_unaligned_2((val),(__u8 *)(ptr)); \
118 break; \
119 case 4: __put_unaligned_4((val),(__u8 *)(ptr)); \
120 break; \
121 case 8: __put_unaligned_8((val),(__u8 *)(ptr)); \
122 break; \
123 default: __bug_unaligned_x(ptr); \
124 break; \
125 } \
126 (void) 0; \
127 })
128 18
19#define get_unaligned __get_unaligned_le
20#define put_unaligned __put_unaligned_le
129 21
130#endif /* __V850_UNALIGNED_H__ */ 22#endif /* _ASM_V850_UNALIGNED_H */
diff --git a/include/asm-x86/Kbuild b/include/asm-x86/Kbuild
index 3b8160a2b47e..1e3554596f72 100644
--- a/include/asm-x86/Kbuild
+++ b/include/asm-x86/Kbuild
@@ -10,6 +10,7 @@ header-y += prctl.h
10header-y += ptrace-abi.h 10header-y += ptrace-abi.h
11header-y += sigcontext32.h 11header-y += sigcontext32.h
12header-y += ucontext.h 12header-y += ucontext.h
13header-y += processor-flags.h
13 14
14unifdef-y += e820.h 15unifdef-y += e820.h
15unifdef-y += ist.h 16unifdef-y += ist.h
diff --git a/include/asm-x86/a.out-core.h b/include/asm-x86/a.out-core.h
index d2b6e11d3e97..714207a1c387 100644
--- a/include/asm-x86/a.out-core.h
+++ b/include/asm-x86/a.out-core.h
@@ -29,8 +29,9 @@ static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
29 dump->magic = CMAGIC; 29 dump->magic = CMAGIC;
30 dump->start_code = 0; 30 dump->start_code = 0;
31 dump->start_stack = regs->sp & ~(PAGE_SIZE - 1); 31 dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
32 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; 32 dump->u_tsize = ((unsigned long)current->mm->end_code) >> PAGE_SHIFT;
33 dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT; 33 dump->u_dsize = ((unsigned long)(current->mm->brk + (PAGE_SIZE - 1)))
34 >> PAGE_SHIFT;
34 dump->u_dsize -= dump->u_tsize; 35 dump->u_dsize -= dump->u_tsize;
35 dump->u_ssize = 0; 36 dump->u_ssize = 0;
36 dump->u_debugreg[0] = current->thread.debugreg0; 37 dump->u_debugreg[0] = current->thread.debugreg0;
@@ -43,7 +44,8 @@ static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
43 dump->u_debugreg[7] = current->thread.debugreg7; 44 dump->u_debugreg[7] = current->thread.debugreg7;
44 45
45 if (dump->start_stack < TASK_SIZE) 46 if (dump->start_stack < TASK_SIZE)
46 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; 47 dump->u_ssize = ((unsigned long)(TASK_SIZE - dump->start_stack))
48 >> PAGE_SHIFT;
47 49
48 dump->regs.bx = regs->bx; 50 dump->regs.bx = regs->bx;
49 dump->regs.cx = regs->cx; 51 dump->regs.cx = regs->cx;
@@ -55,7 +57,7 @@ static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
55 dump->regs.ds = (u16)regs->ds; 57 dump->regs.ds = (u16)regs->ds;
56 dump->regs.es = (u16)regs->es; 58 dump->regs.es = (u16)regs->es;
57 dump->regs.fs = (u16)regs->fs; 59 dump->regs.fs = (u16)regs->fs;
58 savesegment(gs,gs); 60 savesegment(gs, gs);
59 dump->regs.orig_ax = regs->orig_ax; 61 dump->regs.orig_ax = regs->orig_ax;
60 dump->regs.ip = regs->ip; 62 dump->regs.ip = regs->ip;
61 dump->regs.cs = (u16)regs->cs; 63 dump->regs.cs = (u16)regs->cs;
@@ -63,7 +65,7 @@ static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
63 dump->regs.sp = regs->sp; 65 dump->regs.sp = regs->sp;
64 dump->regs.ss = (u16)regs->ss; 66 dump->regs.ss = (u16)regs->ss;
65 67
66 dump->u_fpvalid = dump_fpu (regs, &dump->i387); 68 dump->u_fpvalid = dump_fpu(regs, &dump->i387);
67} 69}
68 70
69#endif /* CONFIG_X86_32 */ 71#endif /* CONFIG_X86_32 */
diff --git a/include/asm-x86/acpi.h b/include/asm-x86/acpi.h
index 7a72d6aa50be..14411c9de46f 100644
--- a/include/asm-x86/acpi.h
+++ b/include/asm-x86/acpi.h
@@ -67,16 +67,16 @@ int __acpi_release_global_lock(unsigned int *lock);
67 */ 67 */
68#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ 68#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
69 asm("divl %2;" \ 69 asm("divl %2;" \
70 :"=a"(q32), "=d"(r32) \ 70 : "=a"(q32), "=d"(r32) \
71 :"r"(d32), \ 71 : "r"(d32), \
72 "0"(n_lo), "1"(n_hi)) 72 "0"(n_lo), "1"(n_hi))
73 73
74 74
75#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ 75#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
76 asm("shrl $1,%2 ;" \ 76 asm("shrl $1,%2 ;" \
77 "rcrl $1,%3;" \ 77 "rcrl $1,%3;" \
78 :"=r"(n_hi), "=r"(n_lo) \ 78 : "=r"(n_hi), "=r"(n_lo) \
79 :"0"(n_hi), "1"(n_lo)) 79 : "0"(n_hi), "1"(n_lo))
80 80
81#ifdef CONFIG_ACPI 81#ifdef CONFIG_ACPI
82extern int acpi_lapic; 82extern int acpi_lapic;
diff --git a/include/asm-x86/alternative.h b/include/asm-x86/alternative.h
index d8bacf3c4b08..1f6a9ca10126 100644
--- a/include/asm-x86/alternative.h
+++ b/include/asm-x86/alternative.h
@@ -66,8 +66,8 @@ extern void alternatives_smp_module_del(struct module *mod);
66extern void alternatives_smp_switch(int smp); 66extern void alternatives_smp_switch(int smp);
67#else 67#else
68static inline void alternatives_smp_module_add(struct module *mod, char *name, 68static inline void alternatives_smp_module_add(struct module *mod, char *name,
69 void *locks, void *locks_end, 69 void *locks, void *locks_end,
70 void *text, void *text_end) {} 70 void *text, void *text_end) {}
71static inline void alternatives_smp_module_del(struct module *mod) {} 71static inline void alternatives_smp_module_del(struct module *mod) {}
72static inline void alternatives_smp_switch(int smp) {} 72static inline void alternatives_smp_switch(int smp) {}
73#endif /* CONFIG_SMP */ 73#endif /* CONFIG_SMP */
@@ -148,14 +148,34 @@ struct paravirt_patch_site;
148void apply_paravirt(struct paravirt_patch_site *start, 148void apply_paravirt(struct paravirt_patch_site *start,
149 struct paravirt_patch_site *end); 149 struct paravirt_patch_site *end);
150#else 150#else
151static inline void 151static inline void apply_paravirt(struct paravirt_patch_site *start,
152apply_paravirt(struct paravirt_patch_site *start, 152 struct paravirt_patch_site *end)
153 struct paravirt_patch_site *end)
154{} 153{}
155#define __parainstructions NULL 154#define __parainstructions NULL
156#define __parainstructions_end NULL 155#define __parainstructions_end NULL
157#endif 156#endif
158 157
159extern void text_poke(void *addr, unsigned char *opcode, int len); 158extern void add_nops(void *insns, unsigned int len);
159
160/*
161 * Clear and restore the kernel write-protection flag on the local CPU.
162 * Allows the kernel to edit read-only pages.
163 * Side-effect: any interrupt handler running between save and restore will have
164 * the ability to write to read-only pages.
165 *
166 * Warning:
167 * Code patching in the UP case is safe if NMIs and MCE handlers are stopped and
168 * no thread can be preempted in the instructions being modified (no iret to an
169 * invalid instruction possible) or if the instructions are changed from a
170 * consistent state to another consistent state atomically.
171 * More care must be taken when modifying code in the SMP case because of
172 * Intel's errata.
173 * On the local CPU you need to be protected again NMI or MCE handlers seeing an
174 * inconsistent instruction while you patch.
175 * The _early version expects the memory to already be RW.
176 */
177
178extern void *text_poke(void *addr, const void *opcode, size_t len);
179extern void *text_poke_early(void *addr, const void *opcode, size_t len);
160 180
161#endif /* _ASM_X86_ALTERNATIVE_H */ 181#endif /* _ASM_X86_ALTERNATIVE_H */
diff --git a/include/asm-x86/apic.h b/include/asm-x86/apic.h
index bcfc07fd3661..be9639a9a186 100644
--- a/include/asm-x86/apic.h
+++ b/include/asm-x86/apic.h
@@ -44,7 +44,6 @@ extern int apic_runs_main_timer;
44extern int ioapic_force; 44extern int ioapic_force;
45extern int disable_apic; 45extern int disable_apic;
46extern int disable_apic_timer; 46extern int disable_apic_timer;
47extern unsigned boot_cpu_id;
48 47
49/* 48/*
50 * Basic functions accessing APICs. 49 * Basic functions accessing APICs.
@@ -59,6 +58,8 @@ extern unsigned boot_cpu_id;
59#define setup_secondary_clock setup_secondary_APIC_clock 58#define setup_secondary_clock setup_secondary_APIC_clock
60#endif 59#endif
61 60
61extern int is_vsmp_box(void);
62
62static inline void native_apic_write(unsigned long reg, u32 v) 63static inline void native_apic_write(unsigned long reg, u32 v)
63{ 64{
64 *((volatile u32 *)(APIC_BASE + reg)) = v; 65 *((volatile u32 *)(APIC_BASE + reg)) = v;
@@ -66,7 +67,7 @@ static inline void native_apic_write(unsigned long reg, u32 v)
66 67
67static inline void native_apic_write_atomic(unsigned long reg, u32 v) 68static inline void native_apic_write_atomic(unsigned long reg, u32 v)
68{ 69{
69 (void) xchg((u32*)(APIC_BASE + reg), v); 70 (void)xchg((u32 *)(APIC_BASE + reg), v);
70} 71}
71 72
72static inline u32 native_apic_read(unsigned long reg) 73static inline u32 native_apic_read(unsigned long reg)
@@ -123,7 +124,7 @@ extern void enable_NMI_through_LVT0(void);
123 * On 32bit this is mach-xxx local 124 * On 32bit this is mach-xxx local
124 */ 125 */
125#ifdef CONFIG_X86_64 126#ifdef CONFIG_X86_64
126extern void setup_apic_routing(void); 127extern void early_init_lapic_mapping(void);
127#endif 128#endif
128 129
129extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask); 130extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
diff --git a/include/asm-x86/apicdef.h b/include/asm-x86/apicdef.h
index 550af7a6f88e..6b9008c78731 100644
--- a/include/asm-x86/apicdef.h
+++ b/include/asm-x86/apicdef.h
@@ -12,17 +12,15 @@
12 12
13#define APIC_ID 0x20 13#define APIC_ID 0x20
14 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 15#define APIC_LVR 0x30
22#define APIC_LVR_MASK 0xFF00FF 16#define APIC_LVR_MASK 0xFF00FF
23#define GET_APIC_VERSION(x) ((x)&0xFFu) 17#define GET_APIC_VERSION(x) ((x) & 0xFFu)
24#define GET_APIC_MAXLVT(x) (((x)>>16)&0xFFu) 18#define GET_APIC_MAXLVT(x) (((x) >> 16) & 0xFFu)
25#define APIC_INTEGRATED(x) ((x)&0xF0u) 19#ifdef CONFIG_X86_32
20# define APIC_INTEGRATED(x) ((x) & 0xF0u)
21#else
22# define APIC_INTEGRATED(x) (1)
23#endif
26#define APIC_XAPIC(x) ((x) >= 0x14) 24#define APIC_XAPIC(x) ((x) >= 0x14)
27#define APIC_TASKPRI 0x80 25#define APIC_TASKPRI 0x80
28#define APIC_TPRI_MASK 0xFFu 26#define APIC_TPRI_MASK 0xFFu
@@ -33,16 +31,16 @@
33#define APIC_EIO_ACK 0x0 31#define APIC_EIO_ACK 0x0
34#define APIC_RRR 0xC0 32#define APIC_RRR 0xC0
35#define APIC_LDR 0xD0 33#define APIC_LDR 0xD0
36#define APIC_LDR_MASK (0xFFu<<24) 34#define APIC_LDR_MASK (0xFFu << 24)
37#define GET_APIC_LOGICAL_ID(x) (((x)>>24)&0xFFu) 35#define GET_APIC_LOGICAL_ID(x) (((x) >> 24) & 0xFFu)
38#define SET_APIC_LOGICAL_ID(x) (((x)<<24)) 36#define SET_APIC_LOGICAL_ID(x) (((x) << 24))
39#define APIC_ALL_CPUS 0xFFu 37#define APIC_ALL_CPUS 0xFFu
40#define APIC_DFR 0xE0 38#define APIC_DFR 0xE0
41#define APIC_DFR_CLUSTER 0x0FFFFFFFul 39#define APIC_DFR_CLUSTER 0x0FFFFFFFul
42#define APIC_DFR_FLAT 0xFFFFFFFFul 40#define APIC_DFR_FLAT 0xFFFFFFFFul
43#define APIC_SPIV 0xF0 41#define APIC_SPIV 0xF0
44#define APIC_SPIV_FOCUS_DISABLED (1<<9) 42#define APIC_SPIV_FOCUS_DISABLED (1 << 9)
45#define APIC_SPIV_APIC_ENABLED (1<<8) 43#define APIC_SPIV_APIC_ENABLED (1 << 8)
46#define APIC_ISR 0x100 44#define APIC_ISR 0x100
47#define APIC_ISR_NR 0x8 /* Number of 32 bit ISR registers. */ 45#define APIC_ISR_NR 0x8 /* Number of 32 bit ISR registers. */
48#define APIC_TMR 0x180 46#define APIC_TMR 0x180
@@ -78,27 +76,27 @@
78#define APIC_DM_EXTINT 0x00700 76#define APIC_DM_EXTINT 0x00700
79#define APIC_VECTOR_MASK 0x000FF 77#define APIC_VECTOR_MASK 0x000FF
80#define APIC_ICR2 0x310 78#define APIC_ICR2 0x310
81#define GET_APIC_DEST_FIELD(x) (((x)>>24)&0xFF) 79#define GET_APIC_DEST_FIELD(x) (((x) >> 24) & 0xFF)
82#define SET_APIC_DEST_FIELD(x) ((x)<<24) 80#define SET_APIC_DEST_FIELD(x) ((x) << 24)
83#define APIC_LVTT 0x320 81#define APIC_LVTT 0x320
84#define APIC_LVTTHMR 0x330 82#define APIC_LVTTHMR 0x330
85#define APIC_LVTPC 0x340 83#define APIC_LVTPC 0x340
86#define APIC_LVT0 0x350 84#define APIC_LVT0 0x350
87#define APIC_LVT_TIMER_BASE_MASK (0x3<<18) 85#define APIC_LVT_TIMER_BASE_MASK (0x3 << 18)
88#define GET_APIC_TIMER_BASE(x) (((x)>>18)&0x3) 86#define GET_APIC_TIMER_BASE(x) (((x) >> 18) & 0x3)
89#define SET_APIC_TIMER_BASE(x) (((x)<<18)) 87#define SET_APIC_TIMER_BASE(x) (((x) << 18))
90#define APIC_TIMER_BASE_CLKIN 0x0 88#define APIC_TIMER_BASE_CLKIN 0x0
91#define APIC_TIMER_BASE_TMBASE 0x1 89#define APIC_TIMER_BASE_TMBASE 0x1
92#define APIC_TIMER_BASE_DIV 0x2 90#define APIC_TIMER_BASE_DIV 0x2
93#define APIC_LVT_TIMER_PERIODIC (1<<17) 91#define APIC_LVT_TIMER_PERIODIC (1 << 17)
94#define APIC_LVT_MASKED (1<<16) 92#define APIC_LVT_MASKED (1 << 16)
95#define APIC_LVT_LEVEL_TRIGGER (1<<15) 93#define APIC_LVT_LEVEL_TRIGGER (1 << 15)
96#define APIC_LVT_REMOTE_IRR (1<<14) 94#define APIC_LVT_REMOTE_IRR (1 << 14)
97#define APIC_INPUT_POLARITY (1<<13) 95#define APIC_INPUT_POLARITY (1 << 13)
98#define APIC_SEND_PENDING (1<<12) 96#define APIC_SEND_PENDING (1 << 12)
99#define APIC_MODE_MASK 0x700 97#define APIC_MODE_MASK 0x700
100#define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7) 98#define GET_APIC_DELIVERY_MODE(x) (((x) >> 8) & 0x7)
101#define SET_APIC_DELIVERY_MODE(x, y) (((x)&~0x700)|((y)<<8)) 99#define SET_APIC_DELIVERY_MODE(x, y) (((x) & ~0x700) | ((y) << 8))
102#define APIC_MODE_FIXED 0x0 100#define APIC_MODE_FIXED 0x0
103#define APIC_MODE_NMI 0x4 101#define APIC_MODE_NMI 0x4
104#define APIC_MODE_EXTINT 0x7 102#define APIC_MODE_EXTINT 0x7
@@ -107,7 +105,7 @@
107#define APIC_TMICT 0x380 105#define APIC_TMICT 0x380
108#define APIC_TMCCT 0x390 106#define APIC_TMCCT 0x390
109#define APIC_TDCR 0x3E0 107#define APIC_TDCR 0x3E0
110#define APIC_TDR_DIV_TMBASE (1<<2) 108#define APIC_TDR_DIV_TMBASE (1 << 2)
111#define APIC_TDR_DIV_1 0xB 109#define APIC_TDR_DIV_1 0xB
112#define APIC_TDR_DIV_2 0x0 110#define APIC_TDR_DIV_2 0x0
113#define APIC_TDR_DIV_4 0x1 111#define APIC_TDR_DIV_4 0x1
@@ -117,14 +115,14 @@
117#define APIC_TDR_DIV_64 0x9 115#define APIC_TDR_DIV_64 0x9
118#define APIC_TDR_DIV_128 0xA 116#define APIC_TDR_DIV_128 0xA
119#define APIC_EILVT0 0x500 117#define APIC_EILVT0 0x500
120#define APIC_EILVT_NR_AMD_K8 1 /* Number of extended interrupts */ 118#define APIC_EILVT_NR_AMD_K8 1 /* # of extended interrupts */
121#define APIC_EILVT_NR_AMD_10H 4 119#define APIC_EILVT_NR_AMD_10H 4
122#define APIC_EILVT_LVTOFF(x) (((x)>>4)&0xF) 120#define APIC_EILVT_LVTOFF(x) (((x) >> 4) & 0xF)
123#define APIC_EILVT_MSG_FIX 0x0 121#define APIC_EILVT_MSG_FIX 0x0
124#define APIC_EILVT_MSG_SMI 0x2 122#define APIC_EILVT_MSG_SMI 0x2
125#define APIC_EILVT_MSG_NMI 0x4 123#define APIC_EILVT_MSG_NMI 0x4
126#define APIC_EILVT_MSG_EXT 0x7 124#define APIC_EILVT_MSG_EXT 0x7
127#define APIC_EILVT_MASKED (1<<16) 125#define APIC_EILVT_MASKED (1 << 16)
128#define APIC_EILVT1 0x510 126#define APIC_EILVT1 0x510
129#define APIC_EILVT2 0x520 127#define APIC_EILVT2 0x520
130#define APIC_EILVT3 0x530 128#define APIC_EILVT3 0x530
@@ -135,7 +133,7 @@
135# define MAX_IO_APICS 64 133# define MAX_IO_APICS 64
136#else 134#else
137# define MAX_IO_APICS 128 135# define MAX_IO_APICS 128
138# define MAX_LOCAL_APIC 256 136# define MAX_LOCAL_APIC 32768
139#endif 137#endif
140 138
141/* 139/*
@@ -408,6 +406,9 @@ struct local_apic {
408 406
409#undef u32 407#undef u32
410 408
411#define BAD_APICID 0xFFu 409#ifdef CONFIG_X86_32
412 410 #define BAD_APICID 0xFFu
411#else
412 #define BAD_APICID 0xFFFFu
413#endif
413#endif 414#endif
diff --git a/include/asm-x86/atomic_32.h b/include/asm-x86/atomic_32.h
index 437aac801711..21a4825148c0 100644
--- a/include/asm-x86/atomic_32.h
+++ b/include/asm-x86/atomic_32.h
@@ -15,138 +15,133 @@
15 * on us. We need to use _exactly_ the address the user gave us, 15 * on us. We need to use _exactly_ the address the user gave us,
16 * not some alias that contains the same information. 16 * not some alias that contains the same information.
17 */ 17 */
18typedef struct { int counter; } atomic_t; 18typedef struct {
19 int counter;
20} atomic_t;
19 21
20#define ATOMIC_INIT(i) { (i) } 22#define ATOMIC_INIT(i) { (i) }
21 23
22/** 24/**
23 * atomic_read - read atomic variable 25 * atomic_read - read atomic variable
24 * @v: pointer of type atomic_t 26 * @v: pointer of type atomic_t
25 * 27 *
26 * Atomically reads the value of @v. 28 * Atomically reads the value of @v.
27 */ 29 */
28#define atomic_read(v) ((v)->counter) 30#define atomic_read(v) ((v)->counter)
29 31
30/** 32/**
31 * atomic_set - set atomic variable 33 * atomic_set - set atomic variable
32 * @v: pointer of type atomic_t 34 * @v: pointer of type atomic_t
33 * @i: required value 35 * @i: required value
34 * 36 *
35 * Atomically sets the value of @v to @i. 37 * Atomically sets the value of @v to @i.
36 */ 38 */
37#define atomic_set(v,i) (((v)->counter) = (i)) 39#define atomic_set(v, i) (((v)->counter) = (i))
38 40
39/** 41/**
40 * atomic_add - add integer to atomic variable 42 * atomic_add - add integer to atomic variable
41 * @i: integer value to add 43 * @i: integer value to add
42 * @v: pointer of type atomic_t 44 * @v: pointer of type atomic_t
43 * 45 *
44 * Atomically adds @i to @v. 46 * Atomically adds @i to @v.
45 */ 47 */
46static __inline__ void atomic_add(int i, atomic_t *v) 48static inline void atomic_add(int i, atomic_t *v)
47{ 49{
48 __asm__ __volatile__( 50 asm volatile(LOCK_PREFIX "addl %1,%0"
49 LOCK_PREFIX "addl %1,%0" 51 : "+m" (v->counter)
50 :"+m" (v->counter) 52 : "ir" (i));
51 :"ir" (i));
52} 53}
53 54
54/** 55/**
55 * atomic_sub - subtract integer from atomic variable 56 * atomic_sub - subtract integer from atomic variable
56 * @i: integer value to subtract 57 * @i: integer value to subtract
57 * @v: pointer of type atomic_t 58 * @v: pointer of type atomic_t
58 * 59 *
59 * Atomically subtracts @i from @v. 60 * Atomically subtracts @i from @v.
60 */ 61 */
61static __inline__ void atomic_sub(int i, atomic_t *v) 62static inline void atomic_sub(int i, atomic_t *v)
62{ 63{
63 __asm__ __volatile__( 64 asm volatile(LOCK_PREFIX "subl %1,%0"
64 LOCK_PREFIX "subl %1,%0" 65 : "+m" (v->counter)
65 :"+m" (v->counter) 66 : "ir" (i));
66 :"ir" (i));
67} 67}
68 68
69/** 69/**
70 * atomic_sub_and_test - subtract value from variable and test result 70 * atomic_sub_and_test - subtract value from variable and test result
71 * @i: integer value to subtract 71 * @i: integer value to subtract
72 * @v: pointer of type atomic_t 72 * @v: pointer of type atomic_t
73 * 73 *
74 * Atomically subtracts @i from @v and returns 74 * Atomically subtracts @i from @v and returns
75 * true if the result is zero, or false for all 75 * true if the result is zero, or false for all
76 * other cases. 76 * other cases.
77 */ 77 */
78static __inline__ int atomic_sub_and_test(int i, atomic_t *v) 78static inline int atomic_sub_and_test(int i, atomic_t *v)
79{ 79{
80 unsigned char c; 80 unsigned char c;
81 81
82 __asm__ __volatile__( 82 asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
83 LOCK_PREFIX "subl %2,%0; sete %1" 83 : "+m" (v->counter), "=qm" (c)
84 :"+m" (v->counter), "=qm" (c) 84 : "ir" (i) : "memory");
85 :"ir" (i) : "memory");
86 return c; 85 return c;
87} 86}
88 87
89/** 88/**
90 * atomic_inc - increment atomic variable 89 * atomic_inc - increment atomic variable
91 * @v: pointer of type atomic_t 90 * @v: pointer of type atomic_t
92 * 91 *
93 * Atomically increments @v by 1. 92 * Atomically increments @v by 1.
94 */ 93 */
95static __inline__ void atomic_inc(atomic_t *v) 94static inline void atomic_inc(atomic_t *v)
96{ 95{
97 __asm__ __volatile__( 96 asm volatile(LOCK_PREFIX "incl %0"
98 LOCK_PREFIX "incl %0" 97 : "+m" (v->counter));
99 :"+m" (v->counter));
100} 98}
101 99
102/** 100/**
103 * atomic_dec - decrement atomic variable 101 * atomic_dec - decrement atomic variable
104 * @v: pointer of type atomic_t 102 * @v: pointer of type atomic_t
105 * 103 *
106 * Atomically decrements @v by 1. 104 * Atomically decrements @v by 1.
107 */ 105 */
108static __inline__ void atomic_dec(atomic_t *v) 106static inline void atomic_dec(atomic_t *v)
109{ 107{
110 __asm__ __volatile__( 108 asm volatile(LOCK_PREFIX "decl %0"
111 LOCK_PREFIX "decl %0" 109 : "+m" (v->counter));
112 :"+m" (v->counter));
113} 110}
114 111
115/** 112/**
116 * atomic_dec_and_test - decrement and test 113 * atomic_dec_and_test - decrement and test
117 * @v: pointer of type atomic_t 114 * @v: pointer of type atomic_t
118 * 115 *
119 * Atomically decrements @v by 1 and 116 * Atomically decrements @v by 1 and
120 * returns true if the result is 0, or false for all other 117 * returns true if the result is 0, or false for all other
121 * cases. 118 * cases.
122 */ 119 */
123static __inline__ int atomic_dec_and_test(atomic_t *v) 120static inline int atomic_dec_and_test(atomic_t *v)
124{ 121{
125 unsigned char c; 122 unsigned char c;
126 123
127 __asm__ __volatile__( 124 asm volatile(LOCK_PREFIX "decl %0; sete %1"
128 LOCK_PREFIX "decl %0; sete %1" 125 : "+m" (v->counter), "=qm" (c)
129 :"+m" (v->counter), "=qm" (c) 126 : : "memory");
130 : : "memory");
131 return c != 0; 127 return c != 0;
132} 128}
133 129
134/** 130/**
135 * atomic_inc_and_test - increment and test 131 * atomic_inc_and_test - increment and test
136 * @v: pointer of type atomic_t 132 * @v: pointer of type atomic_t
137 * 133 *
138 * Atomically increments @v by 1 134 * Atomically increments @v by 1
139 * and returns true if the result is zero, or false for all 135 * and returns true if the result is zero, or false for all
140 * other cases. 136 * other cases.
141 */ 137 */
142static __inline__ int atomic_inc_and_test(atomic_t *v) 138static inline int atomic_inc_and_test(atomic_t *v)
143{ 139{
144 unsigned char c; 140 unsigned char c;
145 141
146 __asm__ __volatile__( 142 asm volatile(LOCK_PREFIX "incl %0; sete %1"
147 LOCK_PREFIX "incl %0; sete %1" 143 : "+m" (v->counter), "=qm" (c)
148 :"+m" (v->counter), "=qm" (c) 144 : : "memory");
149 : : "memory");
150 return c != 0; 145 return c != 0;
151} 146}
152 147
@@ -154,19 +149,18 @@ static __inline__ int atomic_inc_and_test(atomic_t *v)
154 * atomic_add_negative - add and test if negative 149 * atomic_add_negative - add and test if negative
155 * @v: pointer of type atomic_t 150 * @v: pointer of type atomic_t
156 * @i: integer value to add 151 * @i: integer value to add
157 * 152 *
158 * Atomically adds @i to @v and returns true 153 * Atomically adds @i to @v and returns true
159 * if the result is negative, or false when 154 * if the result is negative, or false when
160 * result is greater than or equal to zero. 155 * result is greater than or equal to zero.
161 */ 156 */
162static __inline__ int atomic_add_negative(int i, atomic_t *v) 157static inline int atomic_add_negative(int i, atomic_t *v)
163{ 158{
164 unsigned char c; 159 unsigned char c;
165 160
166 __asm__ __volatile__( 161 asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
167 LOCK_PREFIX "addl %2,%0; sets %1" 162 : "+m" (v->counter), "=qm" (c)
168 :"+m" (v->counter), "=qm" (c) 163 : "ir" (i) : "memory");
169 :"ir" (i) : "memory");
170 return c; 164 return c;
171} 165}
172 166
@@ -177,20 +171,19 @@ static __inline__ int atomic_add_negative(int i, atomic_t *v)
177 * 171 *
178 * Atomically adds @i to @v and returns @i + @v 172 * Atomically adds @i to @v and returns @i + @v
179 */ 173 */
180static __inline__ int atomic_add_return(int i, atomic_t *v) 174static inline int atomic_add_return(int i, atomic_t *v)
181{ 175{
182 int __i; 176 int __i;
183#ifdef CONFIG_M386 177#ifdef CONFIG_M386
184 unsigned long flags; 178 unsigned long flags;
185 if(unlikely(boot_cpu_data.x86 <= 3)) 179 if (unlikely(boot_cpu_data.x86 <= 3))
186 goto no_xadd; 180 goto no_xadd;
187#endif 181#endif
188 /* Modern 486+ processor */ 182 /* Modern 486+ processor */
189 __i = i; 183 __i = i;
190 __asm__ __volatile__( 184 asm volatile(LOCK_PREFIX "xaddl %0, %1"
191 LOCK_PREFIX "xaddl %0, %1" 185 : "+r" (i), "+m" (v->counter)
192 :"+r" (i), "+m" (v->counter) 186 : : "memory");
193 : : "memory");
194 return i + __i; 187 return i + __i;
195 188
196#ifdef CONFIG_M386 189#ifdef CONFIG_M386
@@ -210,9 +203,9 @@ no_xadd: /* Legacy 386 processor */
210 * 203 *
211 * Atomically subtracts @i from @v and returns @v - @i 204 * Atomically subtracts @i from @v and returns @v - @i
212 */ 205 */
213static __inline__ int atomic_sub_return(int i, atomic_t *v) 206static inline int atomic_sub_return(int i, atomic_t *v)
214{ 207{
215 return atomic_add_return(-i,v); 208 return atomic_add_return(-i, v);
216} 209}
217 210
218#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) 211#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
@@ -227,7 +220,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
227 * Atomically adds @a to @v, so long as @v was not already @u. 220 * Atomically adds @a to @v, so long as @v was not already @u.
228 * Returns non-zero if @v was not @u, and zero otherwise. 221 * Returns non-zero if @v was not @u, and zero otherwise.
229 */ 222 */
230static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) 223static inline int atomic_add_unless(atomic_t *v, int a, int u)
231{ 224{
232 int c, old; 225 int c, old;
233 c = atomic_read(v); 226 c = atomic_read(v);
@@ -244,17 +237,17 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
244 237
245#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 238#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
246 239
247#define atomic_inc_return(v) (atomic_add_return(1,v)) 240#define atomic_inc_return(v) (atomic_add_return(1, v))
248#define atomic_dec_return(v) (atomic_sub_return(1,v)) 241#define atomic_dec_return(v) (atomic_sub_return(1, v))
249 242
250/* These are x86-specific, used by some header files */ 243/* These are x86-specific, used by some header files */
251#define atomic_clear_mask(mask, addr) \ 244#define atomic_clear_mask(mask, addr) \
252__asm__ __volatile__(LOCK_PREFIX "andl %0,%1" \ 245 asm volatile(LOCK_PREFIX "andl %0,%1" \
253: : "r" (~(mask)),"m" (*addr) : "memory") 246 : : "r" (~(mask)), "m" (*(addr)) : "memory")
254 247
255#define atomic_set_mask(mask, addr) \ 248#define atomic_set_mask(mask, addr) \
256__asm__ __volatile__(LOCK_PREFIX "orl %0,%1" \ 249 asm volatile(LOCK_PREFIX "orl %0,%1" \
257: : "r" (mask),"m" (*(addr)) : "memory") 250 : : "r" (mask), "m" (*(addr)) : "memory")
258 251
259/* Atomic operations are already serializing on x86 */ 252/* Atomic operations are already serializing on x86 */
260#define smp_mb__before_atomic_dec() barrier() 253#define smp_mb__before_atomic_dec() barrier()
diff --git a/include/asm-x86/atomic_64.h b/include/asm-x86/atomic_64.h
index 2d20a7a19f62..3e0cd7d38335 100644
--- a/include/asm-x86/atomic_64.h
+++ b/include/asm-x86/atomic_64.h
@@ -22,140 +22,135 @@
22 * on us. We need to use _exactly_ the address the user gave us, 22 * on us. We need to use _exactly_ the address the user gave us,
23 * not some alias that contains the same information. 23 * not some alias that contains the same information.
24 */ 24 */
25typedef struct { int counter; } atomic_t; 25typedef struct {
26 int counter;
27} atomic_t;
26 28
27#define ATOMIC_INIT(i) { (i) } 29#define ATOMIC_INIT(i) { (i) }
28 30
29/** 31/**
30 * atomic_read - read atomic variable 32 * atomic_read - read atomic variable
31 * @v: pointer of type atomic_t 33 * @v: pointer of type atomic_t
32 * 34 *
33 * Atomically reads the value of @v. 35 * Atomically reads the value of @v.
34 */ 36 */
35#define atomic_read(v) ((v)->counter) 37#define atomic_read(v) ((v)->counter)
36 38
37/** 39/**
38 * atomic_set - set atomic variable 40 * atomic_set - set atomic variable
39 * @v: pointer of type atomic_t 41 * @v: pointer of type atomic_t
40 * @i: required value 42 * @i: required value
41 * 43 *
42 * Atomically sets the value of @v to @i. 44 * Atomically sets the value of @v to @i.
43 */ 45 */
44#define atomic_set(v,i) (((v)->counter) = (i)) 46#define atomic_set(v, i) (((v)->counter) = (i))
45 47
46/** 48/**
47 * atomic_add - add integer to atomic variable 49 * atomic_add - add integer to atomic variable
48 * @i: integer value to add 50 * @i: integer value to add
49 * @v: pointer of type atomic_t 51 * @v: pointer of type atomic_t
50 * 52 *
51 * Atomically adds @i to @v. 53 * Atomically adds @i to @v.
52 */ 54 */
53static __inline__ void atomic_add(int i, atomic_t *v) 55static inline void atomic_add(int i, atomic_t *v)
54{ 56{
55 __asm__ __volatile__( 57 asm volatile(LOCK_PREFIX "addl %1,%0"
56 LOCK_PREFIX "addl %1,%0" 58 : "=m" (v->counter)
57 :"=m" (v->counter) 59 : "ir" (i), "m" (v->counter));
58 :"ir" (i), "m" (v->counter));
59} 60}
60 61
61/** 62/**
62 * atomic_sub - subtract the atomic variable 63 * atomic_sub - subtract the atomic variable
63 * @i: integer value to subtract 64 * @i: integer value to subtract
64 * @v: pointer of type atomic_t 65 * @v: pointer of type atomic_t
65 * 66 *
66 * Atomically subtracts @i from @v. 67 * Atomically subtracts @i from @v.
67 */ 68 */
68static __inline__ void atomic_sub(int i, atomic_t *v) 69static inline void atomic_sub(int i, atomic_t *v)
69{ 70{
70 __asm__ __volatile__( 71 asm volatile(LOCK_PREFIX "subl %1,%0"
71 LOCK_PREFIX "subl %1,%0" 72 : "=m" (v->counter)
72 :"=m" (v->counter) 73 : "ir" (i), "m" (v->counter));
73 :"ir" (i), "m" (v->counter));
74} 74}
75 75
76/** 76/**
77 * atomic_sub_and_test - subtract value from variable and test result 77 * atomic_sub_and_test - subtract value from variable and test result
78 * @i: integer value to subtract 78 * @i: integer value to subtract
79 * @v: pointer of type atomic_t 79 * @v: pointer of type atomic_t
80 * 80 *
81 * Atomically subtracts @i from @v and returns 81 * Atomically subtracts @i from @v and returns
82 * true if the result is zero, or false for all 82 * true if the result is zero, or false for all
83 * other cases. 83 * other cases.
84 */ 84 */
85static __inline__ int atomic_sub_and_test(int i, atomic_t *v) 85static inline int atomic_sub_and_test(int i, atomic_t *v)
86{ 86{
87 unsigned char c; 87 unsigned char c;
88 88
89 __asm__ __volatile__( 89 asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
90 LOCK_PREFIX "subl %2,%0; sete %1" 90 : "=m" (v->counter), "=qm" (c)
91 :"=m" (v->counter), "=qm" (c) 91 : "ir" (i), "m" (v->counter) : "memory");
92 :"ir" (i), "m" (v->counter) : "memory");
93 return c; 92 return c;
94} 93}
95 94
96/** 95/**
97 * atomic_inc - increment atomic variable 96 * atomic_inc - increment atomic variable
98 * @v: pointer of type atomic_t 97 * @v: pointer of type atomic_t
99 * 98 *
100 * Atomically increments @v by 1. 99 * Atomically increments @v by 1.
101 */ 100 */
102static __inline__ void atomic_inc(atomic_t *v) 101static inline void atomic_inc(atomic_t *v)
103{ 102{
104 __asm__ __volatile__( 103 asm volatile(LOCK_PREFIX "incl %0"
105 LOCK_PREFIX "incl %0" 104 : "=m" (v->counter)
106 :"=m" (v->counter) 105 : "m" (v->counter));
107 :"m" (v->counter));
108} 106}
109 107
110/** 108/**
111 * atomic_dec - decrement atomic variable 109 * atomic_dec - decrement atomic variable
112 * @v: pointer of type atomic_t 110 * @v: pointer of type atomic_t
113 * 111 *
114 * Atomically decrements @v by 1. 112 * Atomically decrements @v by 1.
115 */ 113 */
116static __inline__ void atomic_dec(atomic_t *v) 114static inline void atomic_dec(atomic_t *v)
117{ 115{
118 __asm__ __volatile__( 116 asm volatile(LOCK_PREFIX "decl %0"
119 LOCK_PREFIX "decl %0" 117 : "=m" (v->counter)
120 :"=m" (v->counter) 118 : "m" (v->counter));
121 :"m" (v->counter));
122} 119}
123 120
124/** 121/**
125 * atomic_dec_and_test - decrement and test 122 * atomic_dec_and_test - decrement and test
126 * @v: pointer of type atomic_t 123 * @v: pointer of type atomic_t
127 * 124 *
128 * Atomically decrements @v by 1 and 125 * Atomically decrements @v by 1 and
129 * returns true if the result is 0, or false for all other 126 * returns true if the result is 0, or false for all other
130 * cases. 127 * cases.
131 */ 128 */
132static __inline__ int atomic_dec_and_test(atomic_t *v) 129static inline int atomic_dec_and_test(atomic_t *v)
133{ 130{
134 unsigned char c; 131 unsigned char c;
135 132
136 __asm__ __volatile__( 133 asm volatile(LOCK_PREFIX "decl %0; sete %1"
137 LOCK_PREFIX "decl %0; sete %1" 134 : "=m" (v->counter), "=qm" (c)
138 :"=m" (v->counter), "=qm" (c) 135 : "m" (v->counter) : "memory");
139 :"m" (v->counter) : "memory");
140 return c != 0; 136 return c != 0;
141} 137}
142 138
143/** 139/**
144 * atomic_inc_and_test - increment and test 140 * atomic_inc_and_test - increment and test
145 * @v: pointer of type atomic_t 141 * @v: pointer of type atomic_t
146 * 142 *
147 * Atomically increments @v by 1 143 * Atomically increments @v by 1
148 * and returns true if the result is zero, or false for all 144 * and returns true if the result is zero, or false for all
149 * other cases. 145 * other cases.
150 */ 146 */
151static __inline__ int atomic_inc_and_test(atomic_t *v) 147static inline int atomic_inc_and_test(atomic_t *v)
152{ 148{
153 unsigned char c; 149 unsigned char c;
154 150
155 __asm__ __volatile__( 151 asm volatile(LOCK_PREFIX "incl %0; sete %1"
156 LOCK_PREFIX "incl %0; sete %1" 152 : "=m" (v->counter), "=qm" (c)
157 :"=m" (v->counter), "=qm" (c) 153 : "m" (v->counter) : "memory");
158 :"m" (v->counter) : "memory");
159 return c != 0; 154 return c != 0;
160} 155}
161 156
@@ -163,19 +158,18 @@ static __inline__ int atomic_inc_and_test(atomic_t *v)
163 * atomic_add_negative - add and test if negative 158 * atomic_add_negative - add and test if negative
164 * @i: integer value to add 159 * @i: integer value to add
165 * @v: pointer of type atomic_t 160 * @v: pointer of type atomic_t
166 * 161 *
167 * Atomically adds @i to @v and returns true 162 * Atomically adds @i to @v and returns true
168 * if the result is negative, or false when 163 * if the result is negative, or false when
169 * result is greater than or equal to zero. 164 * result is greater than or equal to zero.
170 */ 165 */
171static __inline__ int atomic_add_negative(int i, atomic_t *v) 166static inline int atomic_add_negative(int i, atomic_t *v)
172{ 167{
173 unsigned char c; 168 unsigned char c;
174 169
175 __asm__ __volatile__( 170 asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
176 LOCK_PREFIX "addl %2,%0; sets %1" 171 : "=m" (v->counter), "=qm" (c)
177 :"=m" (v->counter), "=qm" (c) 172 : "ir" (i), "m" (v->counter) : "memory");
178 :"ir" (i), "m" (v->counter) : "memory");
179 return c; 173 return c;
180} 174}
181 175
@@ -186,27 +180,28 @@ static __inline__ int atomic_add_negative(int i, atomic_t *v)
186 * 180 *
187 * Atomically adds @i to @v and returns @i + @v 181 * Atomically adds @i to @v and returns @i + @v
188 */ 182 */
189static __inline__ int atomic_add_return(int i, atomic_t *v) 183static inline int atomic_add_return(int i, atomic_t *v)
190{ 184{
191 int __i = i; 185 int __i = i;
192 __asm__ __volatile__( 186 asm volatile(LOCK_PREFIX "xaddl %0, %1"
193 LOCK_PREFIX "xaddl %0, %1" 187 : "+r" (i), "+m" (v->counter)
194 :"+r" (i), "+m" (v->counter) 188 : : "memory");
195 : : "memory");
196 return i + __i; 189 return i + __i;
197} 190}
198 191
199static __inline__ int atomic_sub_return(int i, atomic_t *v) 192static inline int atomic_sub_return(int i, atomic_t *v)
200{ 193{
201 return atomic_add_return(-i,v); 194 return atomic_add_return(-i, v);
202} 195}
203 196
204#define atomic_inc_return(v) (atomic_add_return(1,v)) 197#define atomic_inc_return(v) (atomic_add_return(1, v))
205#define atomic_dec_return(v) (atomic_sub_return(1,v)) 198#define atomic_dec_return(v) (atomic_sub_return(1, v))
206 199
207/* An 64bit atomic type */ 200/* An 64bit atomic type */
208 201
209typedef struct { long counter; } atomic64_t; 202typedef struct {
203 long counter;
204} atomic64_t;
210 205
211#define ATOMIC64_INIT(i) { (i) } 206#define ATOMIC64_INIT(i) { (i) }
212 207
@@ -226,7 +221,7 @@ typedef struct { long counter; } atomic64_t;
226 * 221 *
227 * Atomically sets the value of @v to @i. 222 * Atomically sets the value of @v to @i.
228 */ 223 */
229#define atomic64_set(v,i) (((v)->counter) = (i)) 224#define atomic64_set(v, i) (((v)->counter) = (i))
230 225
231/** 226/**
232 * atomic64_add - add integer to atomic64 variable 227 * atomic64_add - add integer to atomic64 variable
@@ -235,12 +230,11 @@ typedef struct { long counter; } atomic64_t;
235 * 230 *
236 * Atomically adds @i to @v. 231 * Atomically adds @i to @v.
237 */ 232 */
238static __inline__ void atomic64_add(long i, atomic64_t *v) 233static inline void atomic64_add(long i, atomic64_t *v)
239{ 234{
240 __asm__ __volatile__( 235 asm volatile(LOCK_PREFIX "addq %1,%0"
241 LOCK_PREFIX "addq %1,%0" 236 : "=m" (v->counter)
242 :"=m" (v->counter) 237 : "ir" (i), "m" (v->counter));
243 :"ir" (i), "m" (v->counter));
244} 238}
245 239
246/** 240/**
@@ -250,12 +244,11 @@ static __inline__ void atomic64_add(long i, atomic64_t *v)
250 * 244 *
251 * Atomically subtracts @i from @v. 245 * Atomically subtracts @i from @v.
252 */ 246 */
253static __inline__ void atomic64_sub(long i, atomic64_t *v) 247static inline void atomic64_sub(long i, atomic64_t *v)
254{ 248{
255 __asm__ __volatile__( 249 asm volatile(LOCK_PREFIX "subq %1,%0"
256 LOCK_PREFIX "subq %1,%0" 250 : "=m" (v->counter)
257 :"=m" (v->counter) 251 : "ir" (i), "m" (v->counter));
258 :"ir" (i), "m" (v->counter));
259} 252}
260 253
261/** 254/**
@@ -267,14 +260,13 @@ static __inline__ void atomic64_sub(long i, atomic64_t *v)
267 * true if the result is zero, or false for all 260 * true if the result is zero, or false for all
268 * other cases. 261 * other cases.
269 */ 262 */
270static __inline__ int atomic64_sub_and_test(long i, atomic64_t *v) 263static inline int atomic64_sub_and_test(long i, atomic64_t *v)
271{ 264{
272 unsigned char c; 265 unsigned char c;
273 266
274 __asm__ __volatile__( 267 asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
275 LOCK_PREFIX "subq %2,%0; sete %1" 268 : "=m" (v->counter), "=qm" (c)
276 :"=m" (v->counter), "=qm" (c) 269 : "ir" (i), "m" (v->counter) : "memory");
277 :"ir" (i), "m" (v->counter) : "memory");
278 return c; 270 return c;
279} 271}
280 272
@@ -284,12 +276,11 @@ static __inline__ int atomic64_sub_and_test(long i, atomic64_t *v)
284 * 276 *
285 * Atomically increments @v by 1. 277 * Atomically increments @v by 1.
286 */ 278 */
287static __inline__ void atomic64_inc(atomic64_t *v) 279static inline void atomic64_inc(atomic64_t *v)
288{ 280{
289 __asm__ __volatile__( 281 asm volatile(LOCK_PREFIX "incq %0"
290 LOCK_PREFIX "incq %0" 282 : "=m" (v->counter)
291 :"=m" (v->counter) 283 : "m" (v->counter));
292 :"m" (v->counter));
293} 284}
294 285
295/** 286/**
@@ -298,12 +289,11 @@ static __inline__ void atomic64_inc(atomic64_t *v)
298 * 289 *
299 * Atomically decrements @v by 1. 290 * Atomically decrements @v by 1.
300 */ 291 */
301static __inline__ void atomic64_dec(atomic64_t *v) 292static inline void atomic64_dec(atomic64_t *v)
302{ 293{
303 __asm__ __volatile__( 294 asm volatile(LOCK_PREFIX "decq %0"
304 LOCK_PREFIX "decq %0" 295 : "=m" (v->counter)
305 :"=m" (v->counter) 296 : "m" (v->counter));
306 :"m" (v->counter));
307} 297}
308 298
309/** 299/**
@@ -314,14 +304,13 @@ static __inline__ void atomic64_dec(atomic64_t *v)
314 * returns true if the result is 0, or false for all other 304 * returns true if the result is 0, or false for all other
315 * cases. 305 * cases.
316 */ 306 */
317static __inline__ int atomic64_dec_and_test(atomic64_t *v) 307static inline int atomic64_dec_and_test(atomic64_t *v)
318{ 308{
319 unsigned char c; 309 unsigned char c;
320 310
321 __asm__ __volatile__( 311 asm volatile(LOCK_PREFIX "decq %0; sete %1"
322 LOCK_PREFIX "decq %0; sete %1" 312 : "=m" (v->counter), "=qm" (c)
323 :"=m" (v->counter), "=qm" (c) 313 : "m" (v->counter) : "memory");
324 :"m" (v->counter) : "memory");
325 return c != 0; 314 return c != 0;
326} 315}
327 316
@@ -333,14 +322,13 @@ static __inline__ int atomic64_dec_and_test(atomic64_t *v)
333 * and returns true if the result is zero, or false for all 322 * and returns true if the result is zero, or false for all
334 * other cases. 323 * other cases.
335 */ 324 */
336static __inline__ int atomic64_inc_and_test(atomic64_t *v) 325static inline int atomic64_inc_and_test(atomic64_t *v)
337{ 326{
338 unsigned char c; 327 unsigned char c;
339 328
340 __asm__ __volatile__( 329 asm volatile(LOCK_PREFIX "incq %0; sete %1"
341 LOCK_PREFIX "incq %0; sete %1" 330 : "=m" (v->counter), "=qm" (c)
342 :"=m" (v->counter), "=qm" (c) 331 : "m" (v->counter) : "memory");
343 :"m" (v->counter) : "memory");
344 return c != 0; 332 return c != 0;
345} 333}
346 334
@@ -353,14 +341,13 @@ static __inline__ int atomic64_inc_and_test(atomic64_t *v)
353 * if the result is negative, or false when 341 * if the result is negative, or false when
354 * result is greater than or equal to zero. 342 * result is greater than or equal to zero.
355 */ 343 */
356static __inline__ int atomic64_add_negative(long i, atomic64_t *v) 344static inline int atomic64_add_negative(long i, atomic64_t *v)
357{ 345{
358 unsigned char c; 346 unsigned char c;
359 347
360 __asm__ __volatile__( 348 asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
361 LOCK_PREFIX "addq %2,%0; sets %1" 349 : "=m" (v->counter), "=qm" (c)
362 :"=m" (v->counter), "=qm" (c) 350 : "ir" (i), "m" (v->counter) : "memory");
363 :"ir" (i), "m" (v->counter) : "memory");
364 return c; 351 return c;
365} 352}
366 353
@@ -371,29 +358,28 @@ static __inline__ int atomic64_add_negative(long i, atomic64_t *v)
371 * 358 *
372 * Atomically adds @i to @v and returns @i + @v 359 * Atomically adds @i to @v and returns @i + @v
373 */ 360 */
374static __inline__ long atomic64_add_return(long i, atomic64_t *v) 361static inline long atomic64_add_return(long i, atomic64_t *v)
375{ 362{
376 long __i = i; 363 long __i = i;
377 __asm__ __volatile__( 364 asm volatile(LOCK_PREFIX "xaddq %0, %1;"
378 LOCK_PREFIX "xaddq %0, %1;" 365 : "+r" (i), "+m" (v->counter)
379 :"+r" (i), "+m" (v->counter) 366 : : "memory");
380 : : "memory");
381 return i + __i; 367 return i + __i;
382} 368}
383 369
384static __inline__ long atomic64_sub_return(long i, atomic64_t *v) 370static inline long atomic64_sub_return(long i, atomic64_t *v)
385{ 371{
386 return atomic64_add_return(-i,v); 372 return atomic64_add_return(-i, v);
387} 373}
388 374
389#define atomic64_inc_return(v) (atomic64_add_return(1,v)) 375#define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
390#define atomic64_dec_return(v) (atomic64_sub_return(1,v)) 376#define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
391 377
392#define atomic64_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new)) 378#define atomic64_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
393#define atomic64_xchg(v, new) (xchg(&((v)->counter), new)) 379#define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
394 380
395#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new)) 381#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
396#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 382#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
397 383
398/** 384/**
399 * atomic_add_unless - add unless the number is a given value 385 * atomic_add_unless - add unless the number is a given value
@@ -404,7 +390,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
404 * Atomically adds @a to @v, so long as it was not @u. 390 * Atomically adds @a to @v, so long as it was not @u.
405 * Returns non-zero if @v was not @u, and zero otherwise. 391 * Returns non-zero if @v was not @u, and zero otherwise.
406 */ 392 */
407static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) 393static inline int atomic_add_unless(atomic_t *v, int a, int u)
408{ 394{
409 int c, old; 395 int c, old;
410 c = atomic_read(v); 396 c = atomic_read(v);
@@ -430,7 +416,7 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
430 * Atomically adds @a to @v, so long as it was not @u. 416 * Atomically adds @a to @v, so long as it was not @u.
431 * Returns non-zero if @v was not @u, and zero otherwise. 417 * Returns non-zero if @v was not @u, and zero otherwise.
432 */ 418 */
433static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) 419static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
434{ 420{
435 long c, old; 421 long c, old;
436 c = atomic64_read(v); 422 c = atomic64_read(v);
@@ -448,13 +434,14 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
448#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) 434#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
449 435
450/* These are x86-specific, used by some header files */ 436/* These are x86-specific, used by some header files */
451#define atomic_clear_mask(mask, addr) \ 437#define atomic_clear_mask(mask, addr) \
452__asm__ __volatile__(LOCK_PREFIX "andl %0,%1" \ 438 asm volatile(LOCK_PREFIX "andl %0,%1" \
453: : "r" (~(mask)),"m" (*addr) : "memory") 439 : : "r" (~(mask)), "m" (*(addr)) : "memory")
454 440
455#define atomic_set_mask(mask, addr) \ 441#define atomic_set_mask(mask, addr) \
456__asm__ __volatile__(LOCK_PREFIX "orl %0,%1" \ 442 asm volatile(LOCK_PREFIX "orl %0,%1" \
457: : "r" ((unsigned)mask),"m" (*(addr)) : "memory") 443 : : "r" ((unsigned)(mask)), "m" (*(addr)) \
444 : "memory")
458 445
459/* Atomic operations are already serializing on x86 */ 446/* Atomic operations are already serializing on x86 */
460#define smp_mb__before_atomic_dec() barrier() 447#define smp_mb__before_atomic_dec() barrier()
diff --git a/include/asm-x86/mach-default/bios_ebda.h b/include/asm-x86/bios_ebda.h
index 9cbd9a668af8..b4a46b7be794 100644
--- a/include/asm-x86/mach-default/bios_ebda.h
+++ b/include/asm-x86/bios_ebda.h
@@ -1,6 +1,8 @@
1#ifndef _MACH_BIOS_EBDA_H 1#ifndef _MACH_BIOS_EBDA_H
2#define _MACH_BIOS_EBDA_H 2#define _MACH_BIOS_EBDA_H
3 3
4#include <asm/io.h>
5
4/* 6/*
5 * there is a real-mode segmented pointer pointing to the 7 * there is a real-mode segmented pointer pointing to the
6 * 4K EBDA area at 0x40E. 8 * 4K EBDA area at 0x40E.
diff --git a/include/asm-x86/bitops.h b/include/asm-x86/bitops.h
index 1a23ce1a5697..b81a4d4d3337 100644
--- a/include/asm-x86/bitops.h
+++ b/include/asm-x86/bitops.h
@@ -23,10 +23,13 @@
23#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) 23#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
24/* Technically wrong, but this avoids compilation errors on some gcc 24/* Technically wrong, but this avoids compilation errors on some gcc
25 versions. */ 25 versions. */
26#define ADDR "=m" (*(volatile long *) addr) 26#define ADDR "=m" (*(volatile long *)addr)
27#define BIT_ADDR "=m" (((volatile int *)addr)[nr >> 5])
27#else 28#else
28#define ADDR "+m" (*(volatile long *) addr) 29#define ADDR "+m" (*(volatile long *) addr)
30#define BIT_ADDR "+m" (((volatile int *)addr)[nr >> 5])
29#endif 31#endif
32#define BASE_ADDR "m" (*(volatile int *)addr)
30 33
31/** 34/**
32 * set_bit - Atomically set a bit in memory 35 * set_bit - Atomically set a bit in memory
@@ -45,9 +48,7 @@
45 */ 48 */
46static inline void set_bit(int nr, volatile void *addr) 49static inline void set_bit(int nr, volatile void *addr)
47{ 50{
48 asm volatile(LOCK_PREFIX "bts %1,%0" 51 asm volatile(LOCK_PREFIX "bts %1,%0" : ADDR : "Ir" (nr) : "memory");
49 : ADDR
50 : "Ir" (nr) : "memory");
51} 52}
52 53
53/** 54/**
@@ -61,12 +62,9 @@ static inline void set_bit(int nr, volatile void *addr)
61 */ 62 */
62static inline void __set_bit(int nr, volatile void *addr) 63static inline void __set_bit(int nr, volatile void *addr)
63{ 64{
64 asm volatile("bts %1,%0" 65 asm volatile("bts %1,%0" : ADDR : "Ir" (nr) : "memory");
65 : ADDR
66 : "Ir" (nr) : "memory");
67} 66}
68 67
69
70/** 68/**
71 * clear_bit - Clears a bit in memory 69 * clear_bit - Clears a bit in memory
72 * @nr: Bit to clear 70 * @nr: Bit to clear
@@ -79,9 +77,7 @@ static inline void __set_bit(int nr, volatile void *addr)
79 */ 77 */
80static inline void clear_bit(int nr, volatile void *addr) 78static inline void clear_bit(int nr, volatile void *addr)
81{ 79{
82 asm volatile(LOCK_PREFIX "btr %1,%0" 80 asm volatile(LOCK_PREFIX "btr %1,%2" : BIT_ADDR : "Ir" (nr), BASE_ADDR);
83 : ADDR
84 : "Ir" (nr));
85} 81}
86 82
87/* 83/*
@@ -100,7 +96,7 @@ static inline void clear_bit_unlock(unsigned nr, volatile void *addr)
100 96
101static inline void __clear_bit(int nr, volatile void *addr) 97static inline void __clear_bit(int nr, volatile void *addr)
102{ 98{
103 asm volatile("btr %1,%0" : ADDR : "Ir" (nr)); 99 asm volatile("btr %1,%2" : BIT_ADDR : "Ir" (nr), BASE_ADDR);
104} 100}
105 101
106/* 102/*
@@ -135,7 +131,7 @@ static inline void __clear_bit_unlock(unsigned nr, volatile void *addr)
135 */ 131 */
136static inline void __change_bit(int nr, volatile void *addr) 132static inline void __change_bit(int nr, volatile void *addr)
137{ 133{
138 asm volatile("btc %1,%0" : ADDR : "Ir" (nr)); 134 asm volatile("btc %1,%2" : BIT_ADDR : "Ir" (nr), BASE_ADDR);
139} 135}
140 136
141/** 137/**
@@ -149,8 +145,7 @@ static inline void __change_bit(int nr, volatile void *addr)
149 */ 145 */
150static inline void change_bit(int nr, volatile void *addr) 146static inline void change_bit(int nr, volatile void *addr)
151{ 147{
152 asm volatile(LOCK_PREFIX "btc %1,%0" 148 asm volatile(LOCK_PREFIX "btc %1,%2" : BIT_ADDR : "Ir" (nr), BASE_ADDR);
153 : ADDR : "Ir" (nr));
154} 149}
155 150
156/** 151/**
@@ -166,9 +161,7 @@ static inline int test_and_set_bit(int nr, volatile void *addr)
166 int oldbit; 161 int oldbit;
167 162
168 asm volatile(LOCK_PREFIX "bts %2,%1\n\t" 163 asm volatile(LOCK_PREFIX "bts %2,%1\n\t"
169 "sbb %0,%0" 164 "sbb %0,%0" : "=r" (oldbit), ADDR : "Ir" (nr) : "memory");
170 : "=r" (oldbit), ADDR
171 : "Ir" (nr) : "memory");
172 165
173 return oldbit; 166 return oldbit;
174} 167}
@@ -198,10 +191,9 @@ static inline int __test_and_set_bit(int nr, volatile void *addr)
198{ 191{
199 int oldbit; 192 int oldbit;
200 193
201 asm("bts %2,%1\n\t" 194 asm volatile("bts %2,%3\n\t"
202 "sbb %0,%0" 195 "sbb %0,%0"
203 : "=r" (oldbit), ADDR 196 : "=r" (oldbit), BIT_ADDR : "Ir" (nr), BASE_ADDR);
204 : "Ir" (nr));
205 return oldbit; 197 return oldbit;
206} 198}
207 199
@@ -219,8 +211,7 @@ static inline int test_and_clear_bit(int nr, volatile void *addr)
219 211
220 asm volatile(LOCK_PREFIX "btr %2,%1\n\t" 212 asm volatile(LOCK_PREFIX "btr %2,%1\n\t"
221 "sbb %0,%0" 213 "sbb %0,%0"
222 : "=r" (oldbit), ADDR 214 : "=r" (oldbit), ADDR : "Ir" (nr) : "memory");
223 : "Ir" (nr) : "memory");
224 215
225 return oldbit; 216 return oldbit;
226} 217}
@@ -238,10 +229,9 @@ static inline int __test_and_clear_bit(int nr, volatile void *addr)
238{ 229{
239 int oldbit; 230 int oldbit;
240 231
241 asm volatile("btr %2,%1\n\t" 232 asm volatile("btr %2,%3\n\t"
242 "sbb %0,%0" 233 "sbb %0,%0"
243 : "=r" (oldbit), ADDR 234 : "=r" (oldbit), BIT_ADDR : "Ir" (nr), BASE_ADDR);
244 : "Ir" (nr));
245 return oldbit; 235 return oldbit;
246} 236}
247 237
@@ -250,10 +240,9 @@ static inline int __test_and_change_bit(int nr, volatile void *addr)
250{ 240{
251 int oldbit; 241 int oldbit;
252 242
253 asm volatile("btc %2,%1\n\t" 243 asm volatile("btc %2,%3\n\t"
254 "sbb %0,%0" 244 "sbb %0,%0"
255 : "=r" (oldbit), ADDR 245 : "=r" (oldbit), BIT_ADDR : "Ir" (nr), BASE_ADDR);
256 : "Ir" (nr) : "memory");
257 246
258 return oldbit; 247 return oldbit;
259} 248}
@@ -272,8 +261,7 @@ static inline int test_and_change_bit(int nr, volatile void *addr)
272 261
273 asm volatile(LOCK_PREFIX "btc %2,%1\n\t" 262 asm volatile(LOCK_PREFIX "btc %2,%1\n\t"
274 "sbb %0,%0" 263 "sbb %0,%0"
275 : "=r" (oldbit), ADDR 264 : "=r" (oldbit), ADDR : "Ir" (nr) : "memory");
276 : "Ir" (nr) : "memory");
277 265
278 return oldbit; 266 return oldbit;
279} 267}
@@ -288,10 +276,11 @@ static inline int variable_test_bit(int nr, volatile const void *addr)
288{ 276{
289 int oldbit; 277 int oldbit;
290 278
291 asm volatile("bt %2,%1\n\t" 279 asm volatile("bt %2,%3\n\t"
292 "sbb %0,%0" 280 "sbb %0,%0"
293 : "=r" (oldbit) 281 : "=r" (oldbit)
294 : "m" (*(unsigned long *)addr), "Ir" (nr)); 282 : "m" (((volatile const int *)addr)[nr >> 5]),
283 "Ir" (nr), BASE_ADDR);
295 284
296 return oldbit; 285 return oldbit;
297} 286}
@@ -305,17 +294,145 @@ static inline int variable_test_bit(int nr, volatile const void *addr)
305static int test_bit(int nr, const volatile unsigned long *addr); 294static int test_bit(int nr, const volatile unsigned long *addr);
306#endif 295#endif
307 296
308#define test_bit(nr,addr) \ 297#define test_bit(nr, addr) \
309 (__builtin_constant_p(nr) ? \ 298 (__builtin_constant_p((nr)) \
310 constant_test_bit((nr),(addr)) : \ 299 ? constant_test_bit((nr), (addr)) \
311 variable_test_bit((nr),(addr))) 300 : variable_test_bit((nr), (addr)))
312 301
313#undef ADDR 302/**
303 * __ffs - find first set bit in word
304 * @word: The word to search
305 *
306 * Undefined if no bit exists, so code should check against 0 first.
307 */
308static inline unsigned long __ffs(unsigned long word)
309{
310 asm("bsf %1,%0"
311 : "=r" (word)
312 : "rm" (word));
313 return word;
314}
315
316/**
317 * ffz - find first zero bit in word
318 * @word: The word to search
319 *
320 * Undefined if no zero exists, so code should check against ~0UL first.
321 */
322static inline unsigned long ffz(unsigned long word)
323{
324 asm("bsf %1,%0"
325 : "=r" (word)
326 : "r" (~word));
327 return word;
328}
314 329
315#ifdef CONFIG_X86_32 330/*
316# include "bitops_32.h" 331 * __fls: find last set bit in word
332 * @word: The word to search
333 *
334 * Undefined if no zero exists, so code should check against ~0UL first.
335 */
336static inline unsigned long __fls(unsigned long word)
337{
338 asm("bsr %1,%0"
339 : "=r" (word)
340 : "rm" (word));
341 return word;
342}
343
344#ifdef __KERNEL__
345/**
346 * ffs - find first set bit in word
347 * @x: the word to search
348 *
349 * This is defined the same way as the libc and compiler builtin ffs
350 * routines, therefore differs in spirit from the other bitops.
351 *
352 * ffs(value) returns 0 if value is 0 or the position of the first
353 * set bit if value is nonzero. The first (least significant) bit
354 * is at position 1.
355 */
356static inline int ffs(int x)
357{
358 int r;
359#ifdef CONFIG_X86_CMOV
360 asm("bsfl %1,%0\n\t"
361 "cmovzl %2,%0"
362 : "=r" (r) : "rm" (x), "r" (-1));
317#else 363#else
318# include "bitops_64.h" 364 asm("bsfl %1,%0\n\t"
365 "jnz 1f\n\t"
366 "movl $-1,%0\n"
367 "1:" : "=r" (r) : "rm" (x));
319#endif 368#endif
369 return r + 1;
370}
371
372/**
373 * fls - find last set bit in word
374 * @x: the word to search
375 *
376 * This is defined in a similar way as the libc and compiler builtin
377 * ffs, but returns the position of the most significant set bit.
378 *
379 * fls(value) returns 0 if value is 0 or the position of the last
380 * set bit if value is nonzero. The last (most significant) bit is
381 * at position 32.
382 */
383static inline int fls(int x)
384{
385 int r;
386#ifdef CONFIG_X86_CMOV
387 asm("bsrl %1,%0\n\t"
388 "cmovzl %2,%0"
389 : "=&r" (r) : "rm" (x), "rm" (-1));
390#else
391 asm("bsrl %1,%0\n\t"
392 "jnz 1f\n\t"
393 "movl $-1,%0\n"
394 "1:" : "=r" (r) : "rm" (x));
395#endif
396 return r + 1;
397}
398#endif /* __KERNEL__ */
399
400#undef BASE_ADDR
401#undef BIT_ADDR
402#undef ADDR
403
404static inline void set_bit_string(unsigned long *bitmap,
405 unsigned long i, int len)
406{
407 unsigned long end = i + len;
408 while (i < end) {
409 __set_bit(i, bitmap);
410 i++;
411 }
412}
413
414#ifdef __KERNEL__
415
416#include <asm-generic/bitops/sched.h>
417
418#define ARCH_HAS_FAST_MULTIPLIER 1
419
420#include <asm-generic/bitops/hweight.h>
421
422#endif /* __KERNEL__ */
423
424#include <asm-generic/bitops/fls64.h>
425
426#ifdef __KERNEL__
427
428#include <asm-generic/bitops/ext2-non-atomic.h>
429
430#define ext2_set_bit_atomic(lock, nr, addr) \
431 test_and_set_bit((nr), (unsigned long *)(addr))
432#define ext2_clear_bit_atomic(lock, nr, addr) \
433 test_and_clear_bit((nr), (unsigned long *)(addr))
434
435#include <asm-generic/bitops/minix.h>
320 436
437#endif /* __KERNEL__ */
321#endif /* _ASM_X86_BITOPS_H */ 438#endif /* _ASM_X86_BITOPS_H */
diff --git a/include/asm-x86/bitops_32.h b/include/asm-x86/bitops_32.h
deleted file mode 100644
index e4d75fcf9c03..000000000000
--- a/include/asm-x86/bitops_32.h
+++ /dev/null
@@ -1,164 +0,0 @@
1#ifndef _I386_BITOPS_H
2#define _I386_BITOPS_H
3
4/*
5 * Copyright 1992, Linus Torvalds.
6 */
7
8/**
9 * find_first_zero_bit - find the first zero bit in a memory region
10 * @addr: The address to start the search at
11 * @size: The maximum size to search
12 *
13 * Returns the bit number of the first zero bit, not the number of the byte
14 * containing a bit.
15 */
16static inline int find_first_zero_bit(const unsigned long *addr, unsigned size)
17{
18 int d0, d1, d2;
19 int res;
20
21 if (!size)
22 return 0;
23 /* This looks at memory. Mark it volatile to tell gcc not to move it around */
24 __asm__ __volatile__(
25 "movl $-1,%%eax\n\t"
26 "xorl %%edx,%%edx\n\t"
27 "repe; scasl\n\t"
28 "je 1f\n\t"
29 "xorl -4(%%edi),%%eax\n\t"
30 "subl $4,%%edi\n\t"
31 "bsfl %%eax,%%edx\n"
32 "1:\tsubl %%ebx,%%edi\n\t"
33 "shll $3,%%edi\n\t"
34 "addl %%edi,%%edx"
35 :"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2)
36 :"1" ((size + 31) >> 5), "2" (addr), "b" (addr) : "memory");
37 return res;
38}
39
40/**
41 * find_next_zero_bit - find the first zero bit in a memory region
42 * @addr: The address to base the search on
43 * @offset: The bit number to start searching at
44 * @size: The maximum size to search
45 */
46int find_next_zero_bit(const unsigned long *addr, int size, int offset);
47
48/**
49 * __ffs - find first bit in word.
50 * @word: The word to search
51 *
52 * Undefined if no bit exists, so code should check against 0 first.
53 */
54static inline unsigned long __ffs(unsigned long word)
55{
56 __asm__("bsfl %1,%0"
57 :"=r" (word)
58 :"rm" (word));
59 return word;
60}
61
62/**
63 * find_first_bit - find the first set bit in a memory region
64 * @addr: The address to start the search at
65 * @size: The maximum size to search
66 *
67 * Returns the bit number of the first set bit, not the number of the byte
68 * containing a bit.
69 */
70static inline unsigned find_first_bit(const unsigned long *addr, unsigned size)
71{
72 unsigned x = 0;
73
74 while (x < size) {
75 unsigned long val = *addr++;
76 if (val)
77 return __ffs(val) + x;
78 x += (sizeof(*addr)<<3);
79 }
80 return x;
81}
82
83/**
84 * find_next_bit - find the first set bit in a memory region
85 * @addr: The address to base the search on
86 * @offset: The bit number to start searching at
87 * @size: The maximum size to search
88 */
89int find_next_bit(const unsigned long *addr, int size, int offset);
90
91/**
92 * ffz - find first zero in word.
93 * @word: The word to search
94 *
95 * Undefined if no zero exists, so code should check against ~0UL first.
96 */
97static inline unsigned long ffz(unsigned long word)
98{
99 __asm__("bsfl %1,%0"
100 :"=r" (word)
101 :"r" (~word));
102 return word;
103}
104
105#ifdef __KERNEL__
106
107#include <asm-generic/bitops/sched.h>
108
109/**
110 * ffs - find first bit set
111 * @x: the word to search
112 *
113 * This is defined the same way as
114 * the libc and compiler builtin ffs routines, therefore
115 * differs in spirit from the above ffz() (man ffs).
116 */
117static inline int ffs(int x)
118{
119 int r;
120
121 __asm__("bsfl %1,%0\n\t"
122 "jnz 1f\n\t"
123 "movl $-1,%0\n"
124 "1:" : "=r" (r) : "rm" (x));
125 return r+1;
126}
127
128/**
129 * fls - find last bit set
130 * @x: the word to search
131 *
132 * This is defined the same way as ffs().
133 */
134static inline int fls(int x)
135{
136 int r;
137
138 __asm__("bsrl %1,%0\n\t"
139 "jnz 1f\n\t"
140 "movl $-1,%0\n"
141 "1:" : "=r" (r) : "rm" (x));
142 return r+1;
143}
144
145#include <asm-generic/bitops/hweight.h>
146
147#endif /* __KERNEL__ */
148
149#include <asm-generic/bitops/fls64.h>
150
151#ifdef __KERNEL__
152
153#include <asm-generic/bitops/ext2-non-atomic.h>
154
155#define ext2_set_bit_atomic(lock, nr, addr) \
156 test_and_set_bit((nr), (unsigned long *)addr)
157#define ext2_clear_bit_atomic(lock, nr, addr) \
158 test_and_clear_bit((nr), (unsigned long *)addr)
159
160#include <asm-generic/bitops/minix.h>
161
162#endif /* __KERNEL__ */
163
164#endif /* _I386_BITOPS_H */
diff --git a/include/asm-x86/bitops_64.h b/include/asm-x86/bitops_64.h
deleted file mode 100644
index aaf15194d536..000000000000
--- a/include/asm-x86/bitops_64.h
+++ /dev/null
@@ -1,162 +0,0 @@
1#ifndef _X86_64_BITOPS_H
2#define _X86_64_BITOPS_H
3
4/*
5 * Copyright 1992, Linus Torvalds.
6 */
7
8extern long find_first_zero_bit(const unsigned long *addr, unsigned long size);
9extern long find_next_zero_bit(const unsigned long *addr, long size, long offset);
10extern long find_first_bit(const unsigned long *addr, unsigned long size);
11extern long find_next_bit(const unsigned long *addr, long size, long offset);
12
13/* return index of first bet set in val or max when no bit is set */
14static inline long __scanbit(unsigned long val, unsigned long max)
15{
16 asm("bsfq %1,%0 ; cmovz %2,%0" : "=&r" (val) : "r" (val), "r" (max));
17 return val;
18}
19
20#define find_first_bit(addr,size) \
21((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
22 (__scanbit(*(unsigned long *)addr,(size))) : \
23 find_first_bit(addr,size)))
24
25#define find_next_bit(addr,size,off) \
26((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
27 ((off) + (__scanbit((*(unsigned long *)addr) >> (off),(size)-(off)))) : \
28 find_next_bit(addr,size,off)))
29
30#define find_first_zero_bit(addr,size) \
31((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
32 (__scanbit(~*(unsigned long *)addr,(size))) : \
33 find_first_zero_bit(addr,size)))
34
35#define find_next_zero_bit(addr,size,off) \
36((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \
37 ((off)+(__scanbit(~(((*(unsigned long *)addr)) >> (off)),(size)-(off)))) : \
38 find_next_zero_bit(addr,size,off)))
39
40static inline void set_bit_string(unsigned long *bitmap, unsigned long i,
41 int len)
42{
43 unsigned long end = i + len;
44 while (i < end) {
45 __set_bit(i, bitmap);
46 i++;
47 }
48}
49
50/**
51 * ffz - find first zero in word.
52 * @word: The word to search
53 *
54 * Undefined if no zero exists, so code should check against ~0UL first.
55 */
56static inline unsigned long ffz(unsigned long word)
57{
58 __asm__("bsfq %1,%0"
59 :"=r" (word)
60 :"r" (~word));
61 return word;
62}
63
64/**
65 * __ffs - find first bit in word.
66 * @word: The word to search
67 *
68 * Undefined if no bit exists, so code should check against 0 first.
69 */
70static inline unsigned long __ffs(unsigned long word)
71{
72 __asm__("bsfq %1,%0"
73 :"=r" (word)
74 :"rm" (word));
75 return word;
76}
77
78/*
79 * __fls: find last bit set.
80 * @word: The word to search
81 *
82 * Undefined if no zero exists, so code should check against ~0UL first.
83 */
84static inline unsigned long __fls(unsigned long word)
85{
86 __asm__("bsrq %1,%0"
87 :"=r" (word)
88 :"rm" (word));
89 return word;
90}
91
92#ifdef __KERNEL__
93
94#include <asm-generic/bitops/sched.h>
95
96/**
97 * ffs - find first bit set
98 * @x: the word to search
99 *
100 * This is defined the same way as
101 * the libc and compiler builtin ffs routines, therefore
102 * differs in spirit from the above ffz (man ffs).
103 */
104static inline int ffs(int x)
105{
106 int r;
107
108 __asm__("bsfl %1,%0\n\t"
109 "cmovzl %2,%0"
110 : "=r" (r) : "rm" (x), "r" (-1));
111 return r+1;
112}
113
114/**
115 * fls64 - find last bit set in 64 bit word
116 * @x: the word to search
117 *
118 * This is defined the same way as fls.
119 */
120static inline int fls64(__u64 x)
121{
122 if (x == 0)
123 return 0;
124 return __fls(x) + 1;
125}
126
127/**
128 * fls - find last bit set
129 * @x: the word to search
130 *
131 * This is defined the same way as ffs.
132 */
133static inline int fls(int x)
134{
135 int r;
136
137 __asm__("bsrl %1,%0\n\t"
138 "cmovzl %2,%0"
139 : "=&r" (r) : "rm" (x), "rm" (-1));
140 return r+1;
141}
142
143#define ARCH_HAS_FAST_MULTIPLIER 1
144
145#include <asm-generic/bitops/hweight.h>
146
147#endif /* __KERNEL__ */
148
149#ifdef __KERNEL__
150
151#include <asm-generic/bitops/ext2-non-atomic.h>
152
153#define ext2_set_bit_atomic(lock,nr,addr) \
154 test_and_set_bit((nr),(unsigned long*)addr)
155#define ext2_clear_bit_atomic(lock,nr,addr) \
156 test_and_clear_bit((nr),(unsigned long*)addr)
157
158#include <asm-generic/bitops/minix.h>
159
160#endif /* __KERNEL__ */
161
162#endif /* _X86_64_BITOPS_H */
diff --git a/include/asm-x86/boot.h b/include/asm-x86/boot.h
index ed8affbf96cb..2faed7ecb092 100644
--- a/include/asm-x86/boot.h
+++ b/include/asm-x86/boot.h
@@ -17,4 +17,12 @@
17 + (CONFIG_PHYSICAL_ALIGN - 1)) \ 17 + (CONFIG_PHYSICAL_ALIGN - 1)) \
18 & ~(CONFIG_PHYSICAL_ALIGN - 1)) 18 & ~(CONFIG_PHYSICAL_ALIGN - 1))
19 19
20#ifdef CONFIG_X86_64
21#define BOOT_HEAP_SIZE 0x7000
22#define BOOT_STACK_SIZE 0x4000
23#else
24#define BOOT_HEAP_SIZE 0x4000
25#define BOOT_STACK_SIZE 0x1000
26#endif
27
20#endif /* _ASM_BOOT_H */ 28#endif /* _ASM_BOOT_H */
diff --git a/include/asm-x86/bootparam.h b/include/asm-x86/bootparam.h
index 51151356840f..e8659909e5f6 100644
--- a/include/asm-x86/bootparam.h
+++ b/include/asm-x86/bootparam.h
@@ -9,6 +9,17 @@
9#include <asm/ist.h> 9#include <asm/ist.h>
10#include <video/edid.h> 10#include <video/edid.h>
11 11
12/* setup data types */
13#define SETUP_NONE 0
14
15/* extensible setup data list node */
16struct setup_data {
17 u64 next;
18 u32 type;
19 u32 len;
20 u8 data[0];
21};
22
12struct setup_header { 23struct setup_header {
13 __u8 setup_sects; 24 __u8 setup_sects;
14 __u16 root_flags; 25 __u16 root_flags;
@@ -46,6 +57,9 @@ struct setup_header {
46 __u32 cmdline_size; 57 __u32 cmdline_size;
47 __u32 hardware_subarch; 58 __u32 hardware_subarch;
48 __u64 hardware_subarch_data; 59 __u64 hardware_subarch_data;
60 __u32 payload_offset;
61 __u32 payload_length;
62 __u64 setup_data;
49} __attribute__((packed)); 63} __attribute__((packed));
50 64
51struct sys_desc_table { 65struct sys_desc_table {
diff --git a/include/asm-x86/bug.h b/include/asm-x86/bug.h
index 8d477a201392..b69aa64b82a4 100644
--- a/include/asm-x86/bug.h
+++ b/include/asm-x86/bug.h
@@ -12,25 +12,25 @@
12# define __BUG_C0 "2:\t.quad 1b, %c0\n" 12# define __BUG_C0 "2:\t.quad 1b, %c0\n"
13#endif 13#endif
14 14
15#define BUG() \ 15#define BUG() \
16 do { \ 16do { \
17 asm volatile("1:\tud2\n" \ 17 asm volatile("1:\tud2\n" \
18 ".pushsection __bug_table,\"a\"\n" \ 18 ".pushsection __bug_table,\"a\"\n" \
19 __BUG_C0 \ 19 __BUG_C0 \
20 "\t.word %c1, 0\n" \ 20 "\t.word %c1, 0\n" \
21 "\t.org 2b+%c2\n" \ 21 "\t.org 2b+%c2\n" \
22 ".popsection" \ 22 ".popsection" \
23 : : "i" (__FILE__), "i" (__LINE__), \ 23 : : "i" (__FILE__), "i" (__LINE__), \
24 "i" (sizeof(struct bug_entry))); \ 24 "i" (sizeof(struct bug_entry))); \
25 for(;;) ; \ 25 for (;;) ; \
26 } while(0) 26} while (0)
27 27
28#else 28#else
29#define BUG() \ 29#define BUG() \
30 do { \ 30do { \
31 asm volatile("ud2"); \ 31 asm volatile("ud2"); \
32 for(;;) ; \ 32 for (;;) ; \
33 } while(0) 33} while (0)
34#endif 34#endif
35 35
36#endif /* !CONFIG_BUG */ 36#endif /* !CONFIG_BUG */
diff --git a/include/asm-x86/byteorder.h b/include/asm-x86/byteorder.h
index fe2f2e5d51ba..e02ae2d89acf 100644
--- a/include/asm-x86/byteorder.h
+++ b/include/asm-x86/byteorder.h
@@ -8,50 +8,59 @@
8 8
9#ifdef __i386__ 9#ifdef __i386__
10 10
11static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) 11static inline __attribute_const__ __u32 ___arch__swab32(__u32 x)
12{ 12{
13#ifdef CONFIG_X86_BSWAP 13#ifdef CONFIG_X86_BSWAP
14 __asm__("bswap %0" : "=r" (x) : "0" (x)); 14 asm("bswap %0" : "=r" (x) : "0" (x));
15#else 15#else
16 __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ 16 asm("xchgb %b0,%h0\n\t" /* swap lower bytes */
17 "rorl $16,%0\n\t" /* swap words */ 17 "rorl $16,%0\n\t" /* swap words */
18 "xchgb %b0,%h0" /* swap higher bytes */ 18 "xchgb %b0,%h0" /* swap higher bytes */
19 :"=q" (x) 19 : "=q" (x)
20 : "0" (x)); 20 : "0" (x));
21#endif 21#endif
22 return x; 22 return x;
23} 23}
24 24
25static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val) 25static inline __attribute_const__ __u64 ___arch__swab64(__u64 val)
26{ 26{
27 union { 27 union {
28 struct { __u32 a,b; } s; 28 struct {
29 __u32 a;
30 __u32 b;
31 } s;
29 __u64 u; 32 __u64 u;
30 } v; 33 } v;
31 v.u = val; 34 v.u = val;
32#ifdef CONFIG_X86_BSWAP 35#ifdef CONFIG_X86_BSWAP
33 __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" 36 asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
34 : "=r" (v.s.a), "=r" (v.s.b) 37 : "=r" (v.s.a), "=r" (v.s.b)
35 : "0" (v.s.a), "1" (v.s.b)); 38 : "0" (v.s.a), "1" (v.s.b));
36#else 39#else
37 v.s.a = ___arch__swab32(v.s.a); 40 v.s.a = ___arch__swab32(v.s.a);
38 v.s.b = ___arch__swab32(v.s.b); 41 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)); 42 asm("xchgl %0,%1"
43 : "=r" (v.s.a), "=r" (v.s.b)
44 : "0" (v.s.a), "1" (v.s.b));
40#endif 45#endif
41 return v.u; 46 return v.u;
42} 47}
43 48
44#else /* __i386__ */ 49#else /* __i386__ */
45 50
46static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x) 51static inline __attribute_const__ __u64 ___arch__swab64(__u64 x)
47{ 52{
48 __asm__("bswapq %0" : "=r" (x) : "0" (x)); 53 asm("bswapq %0"
54 : "=r" (x)
55 : "0" (x));
49 return x; 56 return x;
50} 57}
51 58
52static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) 59static inline __attribute_const__ __u32 ___arch__swab32(__u32 x)
53{ 60{
54 __asm__("bswapl %0" : "=r" (x) : "0" (x)); 61 asm("bswapl %0"
62 : "=r" (x)
63 : "0" (x));
55 return x; 64 return x;
56} 65}
57 66
diff --git a/include/asm-x86/cacheflush.h b/include/asm-x86/cacheflush.h
index 5396c212d8c0..f4c0ab50d2c2 100644
--- a/include/asm-x86/cacheflush.h
+++ b/include/asm-x86/cacheflush.h
@@ -14,33 +14,85 @@
14#define flush_dcache_mmap_lock(mapping) do { } while (0) 14#define flush_dcache_mmap_lock(mapping) do { } while (0)
15#define flush_dcache_mmap_unlock(mapping) do { } while (0) 15#define flush_dcache_mmap_unlock(mapping) do { } while (0)
16#define flush_icache_range(start, end) do { } while (0) 16#define flush_icache_range(start, end) do { } while (0)
17#define flush_icache_page(vma,pg) do { } while (0) 17#define flush_icache_page(vma, pg) do { } while (0)
18#define flush_icache_user_range(vma,pg,adr,len) do { } while (0) 18#define flush_icache_user_range(vma, pg, adr, len) do { } while (0)
19#define flush_cache_vmap(start, end) do { } while (0) 19#define flush_cache_vmap(start, end) do { } while (0)
20#define flush_cache_vunmap(start, end) do { } while (0) 20#define flush_cache_vunmap(start, end) do { } while (0)
21 21
22#define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 22#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
23 memcpy(dst, src, len) 23 memcpy((dst), (src), (len))
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
27int __deprecated_for_modules change_page_attr(struct page *page, int numpages,
28 pgprot_t prot);
29 27
30int set_pages_uc(struct page *page, int numpages); 28/*
31int set_pages_wb(struct page *page, int numpages); 29 * The set_memory_* API can be used to change various attributes of a virtual
32int set_pages_x(struct page *page, int numpages); 30 * address range. The attributes include:
33int set_pages_nx(struct page *page, int numpages); 31 * Cachability : UnCached, WriteCombining, WriteBack
34int set_pages_ro(struct page *page, int numpages); 32 * Executability : eXeutable, NoteXecutable
35int set_pages_rw(struct page *page, int numpages); 33 * Read/Write : ReadOnly, ReadWrite
34 * Presence : NotPresent
35 *
36 * Within a catagory, the attributes are mutually exclusive.
37 *
38 * The implementation of this API will take care of various aspects that
39 * are associated with changing such attributes, such as:
40 * - Flushing TLBs
41 * - Flushing CPU caches
42 * - Making sure aliases of the memory behind the mapping don't violate
43 * coherency rules as defined by the CPU in the system.
44 *
45 * What this API does not do:
46 * - Provide exclusion between various callers - including callers that
47 * operation on other mappings of the same physical page
48 * - Restore default attributes when a page is freed
49 * - Guarantee that mappings other than the requested one are
50 * in any state, other than that these do not violate rules for
51 * the CPU you have. Do not depend on any effects on other mappings,
52 * CPUs other than the one you have may have more relaxed rules.
53 * The caller is required to take care of these.
54 */
36 55
56int _set_memory_uc(unsigned long addr, int numpages);
57int _set_memory_wc(unsigned long addr, int numpages);
58int _set_memory_wb(unsigned long addr, int numpages);
37int set_memory_uc(unsigned long addr, int numpages); 59int set_memory_uc(unsigned long addr, int numpages);
60int set_memory_wc(unsigned long addr, int numpages);
38int set_memory_wb(unsigned long addr, int numpages); 61int set_memory_wb(unsigned long addr, int numpages);
39int set_memory_x(unsigned long addr, int numpages); 62int set_memory_x(unsigned long addr, int numpages);
40int set_memory_nx(unsigned long addr, int numpages); 63int set_memory_nx(unsigned long addr, int numpages);
41int set_memory_ro(unsigned long addr, int numpages); 64int set_memory_ro(unsigned long addr, int numpages);
42int set_memory_rw(unsigned long addr, int numpages); 65int set_memory_rw(unsigned long addr, int numpages);
43int set_memory_np(unsigned long addr, int numpages); 66int set_memory_np(unsigned long addr, int numpages);
67int set_memory_4k(unsigned long addr, int numpages);
68
69/*
70 * For legacy compatibility with the old APIs, a few functions
71 * are provided that work on a "struct page".
72 * These functions operate ONLY on the 1:1 kernel mapping of the
73 * memory that the struct page represents, and internally just
74 * call the set_memory_* function. See the description of the
75 * set_memory_* function for more details on conventions.
76 *
77 * These APIs should be considered *deprecated* and are likely going to
78 * be removed in the future.
79 * The reason for this is the implicit operation on the 1:1 mapping only,
80 * making this not a generally useful API.
81 *
82 * Specifically, many users of the old APIs had a virtual address,
83 * called virt_to_page() or vmalloc_to_page() on that address to
84 * get a struct page* that the old API required.
85 * To convert these cases, use set_memory_*() on the original
86 * virtual address, do not use these functions.
87 */
88
89int set_pages_uc(struct page *page, int numpages);
90int set_pages_wb(struct page *page, int numpages);
91int set_pages_x(struct page *page, int numpages);
92int set_pages_nx(struct page *page, int numpages);
93int set_pages_ro(struct page *page, int numpages);
94int set_pages_rw(struct page *page, int numpages);
95
44 96
45void clflush_cache_range(void *addr, unsigned int size); 97void clflush_cache_range(void *addr, unsigned int size);
46 98
diff --git a/include/asm-x86/checksum_32.h b/include/asm-x86/checksum_32.h
index 75194abbe8ee..52bbb0d8c4c1 100644
--- a/include/asm-x86/checksum_32.h
+++ b/include/asm-x86/checksum_32.h
@@ -28,7 +28,8 @@ asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
28 */ 28 */
29 29
30asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst, 30asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
31 int len, __wsum sum, int *src_err_ptr, int *dst_err_ptr); 31 int len, __wsum sum,
32 int *src_err_ptr, int *dst_err_ptr);
32 33
33/* 34/*
34 * Note: when you get a NULL pointer exception here this means someone 35 * Note: when you get a NULL pointer exception here this means someone
@@ -37,20 +38,20 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
37 * If you use these functions directly please don't forget the 38 * If you use these functions directly please don't forget the
38 * access_ok(). 39 * access_ok().
39 */ 40 */
40static __inline__ 41static inline __wsum csum_partial_copy_nocheck(const void *src, void *dst,
41__wsum csum_partial_copy_nocheck (const void *src, void *dst, 42 int len, __wsum sum)
42 int len, __wsum sum)
43{ 43{
44 return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); 44 return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL);
45} 45}
46 46
47static __inline__ 47static inline __wsum csum_partial_copy_from_user(const void __user *src,
48__wsum csum_partial_copy_from_user(const void __user *src, void *dst, 48 void *dst,
49 int len, __wsum sum, int *err_ptr) 49 int len, __wsum sum,
50 int *err_ptr)
50{ 51{
51 might_sleep(); 52 might_sleep();
52 return csum_partial_copy_generic((__force void *)src, dst, 53 return csum_partial_copy_generic((__force void *)src, dst,
53 len, sum, err_ptr, NULL); 54 len, sum, err_ptr, NULL);
54} 55}
55 56
56/* 57/*
@@ -64,30 +65,29 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
64{ 65{
65 unsigned int sum; 66 unsigned int sum;
66 67
67 __asm__ __volatile__( 68 asm volatile("movl (%1), %0 ;\n"
68 "movl (%1), %0 ;\n" 69 "subl $4, %2 ;\n"
69 "subl $4, %2 ;\n" 70 "jbe 2f ;\n"
70 "jbe 2f ;\n" 71 "addl 4(%1), %0 ;\n"
71 "addl 4(%1), %0 ;\n" 72 "adcl 8(%1), %0 ;\n"
72 "adcl 8(%1), %0 ;\n" 73 "adcl 12(%1), %0;\n"
73 "adcl 12(%1), %0 ;\n" 74 "1: adcl 16(%1), %0 ;\n"
74"1: adcl 16(%1), %0 ;\n" 75 "lea 4(%1), %1 ;\n"
75 "lea 4(%1), %1 ;\n" 76 "decl %2 ;\n"
76 "decl %2 ;\n" 77 "jne 1b ;\n"
77 "jne 1b ;\n" 78 "adcl $0, %0 ;\n"
78 "adcl $0, %0 ;\n" 79 "movl %0, %2 ;\n"
79 "movl %0, %2 ;\n" 80 "shrl $16, %0 ;\n"
80 "shrl $16, %0 ;\n" 81 "addw %w2, %w0 ;\n"
81 "addw %w2, %w0 ;\n" 82 "adcl $0, %0 ;\n"
82 "adcl $0, %0 ;\n" 83 "notl %0 ;\n"
83 "notl %0 ;\n" 84 "2: ;\n"
84"2: ;\n"
85 /* Since the input registers which are loaded with iph and ihl 85 /* Since the input registers which are loaded with iph and ihl
86 are modified, we must also specify them as outputs, or gcc 86 are modified, we must also specify them as outputs, or gcc
87 will assume they contain their original values. */ 87 will assume they contain their original values. */
88 : "=r" (sum), "=r" (iph), "=r" (ihl) 88 : "=r" (sum), "=r" (iph), "=r" (ihl)
89 : "1" (iph), "2" (ihl) 89 : "1" (iph), "2" (ihl)
90 : "memory"); 90 : "memory");
91 return (__force __sum16)sum; 91 return (__force __sum16)sum;
92} 92}
93 93
@@ -97,29 +97,27 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
97 97
98static inline __sum16 csum_fold(__wsum sum) 98static inline __sum16 csum_fold(__wsum sum)
99{ 99{
100 __asm__( 100 asm("addl %1, %0 ;\n"
101 "addl %1, %0 ;\n" 101 "adcl $0xffff, %0 ;\n"
102 "adcl $0xffff, %0 ;\n" 102 : "=r" (sum)
103 : "=r" (sum) 103 : "r" ((__force u32)sum << 16),
104 : "r" ((__force u32)sum << 16), 104 "0" ((__force u32)sum & 0xffff0000));
105 "0" ((__force u32)sum & 0xffff0000)
106 );
107 return (__force __sum16)(~(__force u32)sum >> 16); 105 return (__force __sum16)(~(__force u32)sum >> 16);
108} 106}
109 107
110static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, 108static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
111 unsigned short len, 109 unsigned short len,
112 unsigned short proto, 110 unsigned short proto,
113 __wsum sum) 111 __wsum sum)
114{ 112{
115 __asm__( 113 asm("addl %1, %0 ;\n"
116 "addl %1, %0 ;\n" 114 "adcl %2, %0 ;\n"
117 "adcl %2, %0 ;\n" 115 "adcl %3, %0 ;\n"
118 "adcl %3, %0 ;\n" 116 "adcl $0, %0 ;\n"
119 "adcl $0, %0 ;\n" 117 : "=r" (sum)
120 : "=r" (sum) 118 : "g" (daddr), "g"(saddr),
121 : "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum)); 119 "g" ((len + proto) << 8), "0" (sum));
122 return sum; 120 return sum;
123} 121}
124 122
125/* 123/*
@@ -127,11 +125,11 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
127 * returns a 16-bit checksum, already complemented 125 * returns a 16-bit checksum, already complemented
128 */ 126 */
129static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, 127static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
130 unsigned short len, 128 unsigned short len,
131 unsigned short proto, 129 unsigned short proto,
132 __wsum sum) 130 __wsum sum)
133{ 131{
134 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 132 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
135} 133}
136 134
137/* 135/*
@@ -141,30 +139,29 @@ static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
141 139
142static inline __sum16 ip_compute_csum(const void *buff, int len) 140static inline __sum16 ip_compute_csum(const void *buff, int len)
143{ 141{
144 return csum_fold (csum_partial(buff, len, 0)); 142 return csum_fold(csum_partial(buff, len, 0));
145} 143}
146 144
147#define _HAVE_ARCH_IPV6_CSUM 145#define _HAVE_ARCH_IPV6_CSUM
148static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, 146static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
149 const struct in6_addr *daddr, 147 const struct in6_addr *daddr,
150 __u32 len, unsigned short proto, 148 __u32 len, unsigned short proto,
151 __wsum sum) 149 __wsum sum)
152{ 150{
153 __asm__( 151 asm("addl 0(%1), %0 ;\n"
154 "addl 0(%1), %0 ;\n" 152 "adcl 4(%1), %0 ;\n"
155 "adcl 4(%1), %0 ;\n" 153 "adcl 8(%1), %0 ;\n"
156 "adcl 8(%1), %0 ;\n" 154 "adcl 12(%1), %0 ;\n"
157 "adcl 12(%1), %0 ;\n" 155 "adcl 0(%2), %0 ;\n"
158 "adcl 0(%2), %0 ;\n" 156 "adcl 4(%2), %0 ;\n"
159 "adcl 4(%2), %0 ;\n" 157 "adcl 8(%2), %0 ;\n"
160 "adcl 8(%2), %0 ;\n" 158 "adcl 12(%2), %0 ;\n"
161 "adcl 12(%2), %0 ;\n" 159 "adcl %3, %0 ;\n"
162 "adcl %3, %0 ;\n" 160 "adcl %4, %0 ;\n"
163 "adcl %4, %0 ;\n" 161 "adcl $0, %0 ;\n"
164 "adcl $0, %0 ;\n" 162 : "=&r" (sum)
165 : "=&r" (sum) 163 : "r" (saddr), "r" (daddr),
166 : "r" (saddr), "r" (daddr), 164 "r" (htonl(len)), "r" (htonl(proto)), "0" (sum));
167 "r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
168 165
169 return csum_fold(sum); 166 return csum_fold(sum);
170} 167}
@@ -173,14 +170,15 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
173 * Copy and checksum to user 170 * Copy and checksum to user
174 */ 171 */
175#define HAVE_CSUM_COPY_USER 172#define HAVE_CSUM_COPY_USER
176static __inline__ __wsum csum_and_copy_to_user(const void *src, 173static inline __wsum csum_and_copy_to_user(const void *src,
177 void __user *dst, 174 void __user *dst,
178 int len, __wsum sum, 175 int len, __wsum sum,
179 int *err_ptr) 176 int *err_ptr)
180{ 177{
181 might_sleep(); 178 might_sleep();
182 if (access_ok(VERIFY_WRITE, dst, len)) 179 if (access_ok(VERIFY_WRITE, dst, len))
183 return csum_partial_copy_generic(src, (__force void *)dst, len, sum, NULL, err_ptr); 180 return csum_partial_copy_generic(src, (__force void *)dst,
181 len, sum, NULL, err_ptr);
184 182
185 if (len) 183 if (len)
186 *err_ptr = -EFAULT; 184 *err_ptr = -EFAULT;
diff --git a/include/asm-x86/checksum_64.h b/include/asm-x86/checksum_64.h
index e5f79997decc..8bd861cc5267 100644
--- a/include/asm-x86/checksum_64.h
+++ b/include/asm-x86/checksum_64.h
@@ -1,33 +1,31 @@
1#ifndef _X86_64_CHECKSUM_H 1#ifndef _X86_64_CHECKSUM_H
2#define _X86_64_CHECKSUM_H 2#define _X86_64_CHECKSUM_H
3 3
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-x86/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>
11#include <asm/uaccess.h> 11#include <asm/uaccess.h>
12#include <asm/byteorder.h> 12#include <asm/byteorder.h>
13 13
14/** 14/**
15 * csum_fold - Fold and invert a 32bit checksum. 15 * csum_fold - Fold and invert a 32bit checksum.
16 * sum: 32bit unfolded sum 16 * sum: 32bit unfolded sum
17 * 17 *
18 * Fold a 32bit running checksum to 16bit and invert it. This is usually 18 * Fold a 32bit running checksum to 16bit and invert it. This is usually
19 * the last step before putting a checksum into a packet. 19 * the last step before putting a checksum into a packet.
20 * Make sure not to mix with 64bit checksums. 20 * Make sure not to mix with 64bit checksums.
21 */ 21 */
22static inline __sum16 csum_fold(__wsum sum) 22static inline __sum16 csum_fold(__wsum sum)
23{ 23{
24 __asm__( 24 asm(" addl %1,%0\n"
25 " addl %1,%0\n" 25 " adcl $0xffff,%0"
26 " adcl $0xffff,%0" 26 : "=r" (sum)
27 : "=r" (sum) 27 : "r" ((__force u32)sum << 16),
28 : "r" ((__force u32)sum << 16), 28 "0" ((__force u32)sum & 0xffff0000));
29 "0" ((__force u32)sum & 0xffff0000)
30 );
31 return (__force __sum16)(~(__force u32)sum >> 16); 29 return (__force __sum16)(~(__force u32)sum >> 16);
32} 30}
33 31
@@ -43,46 +41,46 @@ static inline __sum16 csum_fold(__wsum sum)
43 * ip_fast_csum - Compute the IPv4 header checksum efficiently. 41 * ip_fast_csum - Compute the IPv4 header checksum efficiently.
44 * iph: ipv4 header 42 * iph: ipv4 header
45 * ihl: length of header / 4 43 * ihl: length of header / 4
46 */ 44 */
47static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) 45static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
48{ 46{
49 unsigned int sum; 47 unsigned int sum;
50 48
51 asm( " movl (%1), %0\n" 49 asm(" movl (%1), %0\n"
52 " subl $4, %2\n" 50 " subl $4, %2\n"
53 " jbe 2f\n" 51 " jbe 2f\n"
54 " addl 4(%1), %0\n" 52 " addl 4(%1), %0\n"
55 " adcl 8(%1), %0\n" 53 " adcl 8(%1), %0\n"
56 " adcl 12(%1), %0\n" 54 " adcl 12(%1), %0\n"
57 "1: adcl 16(%1), %0\n" 55 "1: adcl 16(%1), %0\n"
58 " lea 4(%1), %1\n" 56 " lea 4(%1), %1\n"
59 " decl %2\n" 57 " decl %2\n"
60 " jne 1b\n" 58 " jne 1b\n"
61 " adcl $0, %0\n" 59 " adcl $0, %0\n"
62 " movl %0, %2\n" 60 " movl %0, %2\n"
63 " shrl $16, %0\n" 61 " shrl $16, %0\n"
64 " addw %w2, %w0\n" 62 " addw %w2, %w0\n"
65 " adcl $0, %0\n" 63 " adcl $0, %0\n"
66 " notl %0\n" 64 " notl %0\n"
67 "2:" 65 "2:"
68 /* Since the input registers which are loaded with iph and ihl 66 /* Since the input registers which are loaded with iph and ihl
69 are modified, we must also specify them as outputs, or gcc 67 are modified, we must also specify them as outputs, or gcc
70 will assume they contain their original values. */ 68 will assume they contain their original values. */
71 : "=r" (sum), "=r" (iph), "=r" (ihl) 69 : "=r" (sum), "=r" (iph), "=r" (ihl)
72 : "1" (iph), "2" (ihl) 70 : "1" (iph), "2" (ihl)
73 : "memory"); 71 : "memory");
74 return (__force __sum16)sum; 72 return (__force __sum16)sum;
75} 73}
76 74
77/** 75/**
78 * csum_tcpup_nofold - Compute an IPv4 pseudo header checksum. 76 * csum_tcpup_nofold - Compute an IPv4 pseudo header checksum.
79 * @saddr: source address 77 * @saddr: source address
80 * @daddr: destination address 78 * @daddr: destination address
81 * @len: length of packet 79 * @len: length of packet
82 * @proto: ip protocol of packet 80 * @proto: ip protocol of packet
83 * @sum: initial sum to be added in (32bit unfolded) 81 * @sum: initial sum to be added in (32bit unfolded)
84 * 82 *
85 * Returns the pseudo header checksum the input data. Result is 83 * Returns the pseudo header checksum the input data. Result is
86 * 32bit unfolded. 84 * 32bit unfolded.
87 */ 85 */
88static inline __wsum 86static inline __wsum
@@ -93,32 +91,32 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
93 " adcl %2, %0\n" 91 " adcl %2, %0\n"
94 " adcl %3, %0\n" 92 " adcl %3, %0\n"
95 " adcl $0, %0\n" 93 " adcl $0, %0\n"
96 : "=r" (sum) 94 : "=r" (sum)
97 : "g" (daddr), "g" (saddr), 95 : "g" (daddr), "g" (saddr),
98 "g" ((len + proto)<<8), "0" (sum)); 96 "g" ((len + proto)<<8), "0" (sum));
99 return sum; 97 return sum;
100} 98}
101 99
102 100
103/** 101/**
104 * csum_tcpup_magic - Compute an IPv4 pseudo header checksum. 102 * csum_tcpup_magic - Compute an IPv4 pseudo header checksum.
105 * @saddr: source address 103 * @saddr: source address
106 * @daddr: destination address 104 * @daddr: destination address
107 * @len: length of packet 105 * @len: length of packet
108 * @proto: ip protocol of packet 106 * @proto: ip protocol of packet
109 * @sum: initial sum to be added in (32bit unfolded) 107 * @sum: initial sum to be added in (32bit unfolded)
110 * 108 *
111 * Returns the 16bit pseudo header checksum the input data already 109 * Returns the 16bit pseudo header checksum the input data already
112 * complemented and ready to be filled in. 110 * complemented and ready to be filled in.
113 */ 111 */
114static inline __sum16 112static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
115csum_tcpudp_magic(__be32 saddr, __be32 daddr, 113 unsigned short len,
116 unsigned short len, unsigned short proto, __wsum sum) 114 unsigned short proto, __wsum sum)
117{ 115{
118 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 116 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
119} 117}
120 118
121/** 119/**
122 * csum_partial - Compute an internet checksum. 120 * csum_partial - Compute an internet checksum.
123 * @buff: buffer to be checksummed 121 * @buff: buffer to be checksummed
124 * @len: length of buffer. 122 * @len: length of buffer.
@@ -127,7 +125,7 @@ csum_tcpudp_magic(__be32 saddr, __be32 daddr,
127 * Returns the 32bit unfolded internet checksum of the buffer. 125 * Returns the 32bit unfolded internet checksum of the buffer.
128 * Before filling it in it needs to be csum_fold()'ed. 126 * Before filling it in it needs to be csum_fold()'ed.
129 * buff should be aligned to a 64bit boundary if possible. 127 * buff should be aligned to a 64bit boundary if possible.
130 */ 128 */
131extern __wsum csum_partial(const void *buff, int len, __wsum sum); 129extern __wsum csum_partial(const void *buff, int len, __wsum sum);
132 130
133#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1 131#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1
@@ -136,23 +134,22 @@ extern __wsum csum_partial(const void *buff, int len, __wsum sum);
136 134
137/* Do not call this directly. Use the wrappers below */ 135/* Do not call this directly. Use the wrappers below */
138extern __wsum csum_partial_copy_generic(const void *src, const void *dst, 136extern __wsum csum_partial_copy_generic(const void *src, const void *dst,
139 int len, 137 int len, __wsum sum,
140 __wsum sum, 138 int *src_err_ptr, int *dst_err_ptr);
141 int *src_err_ptr, int *dst_err_ptr);
142 139
143 140
144extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst, 141extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
145 int len, __wsum isum, int *errp); 142 int len, __wsum isum, int *errp);
146extern __wsum csum_partial_copy_to_user(const void *src, void __user *dst, 143extern __wsum csum_partial_copy_to_user(const void *src, void __user *dst,
147 int len, __wsum isum, int *errp); 144 int len, __wsum isum, int *errp);
148extern __wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, 145extern __wsum csum_partial_copy_nocheck(const void *src, void *dst,
149 __wsum sum); 146 int len, __wsum sum);
150 147
151/* Old names. To be removed. */ 148/* Old names. To be removed. */
152#define csum_and_copy_to_user csum_partial_copy_to_user 149#define csum_and_copy_to_user csum_partial_copy_to_user
153#define csum_and_copy_from_user csum_partial_copy_from_user 150#define csum_and_copy_from_user csum_partial_copy_from_user
154 151
155/** 152/**
156 * ip_compute_csum - Compute an 16bit IP checksum. 153 * ip_compute_csum - Compute an 16bit IP checksum.
157 * @buff: buffer address. 154 * @buff: buffer address.
158 * @len: length of buffer. 155 * @len: length of buffer.
@@ -170,7 +167,7 @@ extern __sum16 ip_compute_csum(const void *buff, int len);
170 * @proto: protocol of packet 167 * @proto: protocol of packet
171 * @sum: initial sum (32bit unfolded) to be added in 168 * @sum: initial sum (32bit unfolded) to be added in
172 * 169 *
173 * Computes an IPv6 pseudo header checksum. This sum is added the checksum 170 * Computes an IPv6 pseudo header checksum. This sum is added the checksum
174 * into UDP/TCP packets and contains some link layer information. 171 * into UDP/TCP packets and contains some link layer information.
175 * Returns the unfolded 32bit checksum. 172 * Returns the unfolded 32bit checksum.
176 */ 173 */
@@ -185,11 +182,10 @@ csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
185static inline unsigned add32_with_carry(unsigned a, unsigned b) 182static inline unsigned add32_with_carry(unsigned a, unsigned b)
186{ 183{
187 asm("addl %2,%0\n\t" 184 asm("addl %2,%0\n\t"
188 "adcl $0,%0" 185 "adcl $0,%0"
189 : "=r" (a) 186 : "=r" (a)
190 : "0" (a), "r" (b)); 187 : "0" (a), "r" (b));
191 return a; 188 return a;
192} 189}
193 190
194#endif 191#endif
195
diff --git a/include/asm-x86/cmpxchg_32.h b/include/asm-x86/cmpxchg_32.h
index 959fad00dff5..bf5a69d1329e 100644
--- a/include/asm-x86/cmpxchg_32.h
+++ b/include/asm-x86/cmpxchg_32.h
@@ -8,9 +8,12 @@
8 * you need to test for the feature in boot_cpu_data. 8 * you need to test for the feature in boot_cpu_data.
9 */ 9 */
10 10
11#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr)))) 11#define xchg(ptr, v) \
12 ((__typeof__(*(ptr)))__xchg((unsigned long)(v), (ptr), sizeof(*(ptr))))
12 13
13struct __xchg_dummy { unsigned long a[100]; }; 14struct __xchg_dummy {
15 unsigned long a[100];
16};
14#define __xg(x) ((struct __xchg_dummy *)(x)) 17#define __xg(x) ((struct __xchg_dummy *)(x))
15 18
16/* 19/*
@@ -27,72 +30,74 @@ struct __xchg_dummy { unsigned long a[100]; };
27 * of the instruction set reference 24319102.pdf. We need 30 * of the instruction set reference 24319102.pdf. We need
28 * the reader side to see the coherent 64bit value. 31 * the reader side to see the coherent 64bit value.
29 */ 32 */
30static inline void __set_64bit (unsigned long long * ptr, 33static inline void __set_64bit(unsigned long long *ptr,
31 unsigned int low, unsigned int high) 34 unsigned int low, unsigned int high)
32{ 35{
33 __asm__ __volatile__ ( 36 asm volatile("\n1:\t"
34 "\n1:\t" 37 "movl (%0), %%eax\n\t"
35 "movl (%0), %%eax\n\t" 38 "movl 4(%0), %%edx\n\t"
36 "movl 4(%0), %%edx\n\t" 39 LOCK_PREFIX "cmpxchg8b (%0)\n\t"
37 LOCK_PREFIX "cmpxchg8b (%0)\n\t" 40 "jnz 1b"
38 "jnz 1b" 41 : /* no outputs */
39 : /* no outputs */ 42 : "D"(ptr),
40 : "D"(ptr), 43 "b"(low),
41 "b"(low), 44 "c"(high)
42 "c"(high) 45 : "ax", "dx", "memory");
43 : "ax","dx","memory");
44} 46}
45 47
46static inline void __set_64bit_constant (unsigned long long *ptr, 48static inline void __set_64bit_constant(unsigned long long *ptr,
47 unsigned long long value) 49 unsigned long long value)
48{ 50{
49 __set_64bit(ptr,(unsigned int)(value), (unsigned int)((value)>>32ULL)); 51 __set_64bit(ptr, (unsigned int)value, (unsigned int)(value >> 32));
50} 52}
51#define ll_low(x) *(((unsigned int*)&(x))+0)
52#define ll_high(x) *(((unsigned int*)&(x))+1)
53 53
54static inline void __set_64bit_var (unsigned long long *ptr, 54#define ll_low(x) *(((unsigned int *)&(x)) + 0)
55 unsigned long long value) 55#define ll_high(x) *(((unsigned int *)&(x)) + 1)
56
57static inline void __set_64bit_var(unsigned long long *ptr,
58 unsigned long long value)
56{ 59{
57 __set_64bit(ptr,ll_low(value), ll_high(value)); 60 __set_64bit(ptr, ll_low(value), ll_high(value));
58} 61}
59 62
60#define set_64bit(ptr,value) \ 63#define set_64bit(ptr, value) \
61(__builtin_constant_p(value) ? \ 64 (__builtin_constant_p((value)) \
62 __set_64bit_constant(ptr, value) : \ 65 ? __set_64bit_constant((ptr), (value)) \
63 __set_64bit_var(ptr, value) ) 66 : __set_64bit_var((ptr), (value)))
64 67
65#define _set_64bit(ptr,value) \ 68#define _set_64bit(ptr, value) \
66(__builtin_constant_p(value) ? \ 69 (__builtin_constant_p(value) \
67 __set_64bit(ptr, (unsigned int)(value), (unsigned int)((value)>>32ULL) ) : \ 70 ? __set_64bit(ptr, (unsigned int)(value), \
68 __set_64bit(ptr, ll_low(value), ll_high(value)) ) 71 (unsigned int)((value) >> 32)) \
72 : __set_64bit(ptr, ll_low((value)), ll_high((value))))
69 73
70/* 74/*
71 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway 75 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway
72 * Note 2: xchg has side effect, so that attribute volatile is necessary, 76 * Note 2: xchg has side effect, so that attribute volatile is necessary,
73 * but generally the primitive is invalid, *ptr is output argument. --ANK 77 * but generally the primitive is invalid, *ptr is output argument. --ANK
74 */ 78 */
75static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size) 79static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
80 int size)
76{ 81{
77 switch (size) { 82 switch (size) {
78 case 1: 83 case 1:
79 __asm__ __volatile__("xchgb %b0,%1" 84 asm volatile("xchgb %b0,%1"
80 :"=q" (x) 85 : "=q" (x)
81 :"m" (*__xg(ptr)), "0" (x) 86 : "m" (*__xg(ptr)), "0" (x)
82 :"memory"); 87 : "memory");
83 break; 88 break;
84 case 2: 89 case 2:
85 __asm__ __volatile__("xchgw %w0,%1" 90 asm volatile("xchgw %w0,%1"
86 :"=r" (x) 91 : "=r" (x)
87 :"m" (*__xg(ptr)), "0" (x) 92 : "m" (*__xg(ptr)), "0" (x)
88 :"memory"); 93 : "memory");
89 break; 94 break;
90 case 4: 95 case 4:
91 __asm__ __volatile__("xchgl %0,%1" 96 asm volatile("xchgl %0,%1"
92 :"=r" (x) 97 : "=r" (x)
93 :"m" (*__xg(ptr)), "0" (x) 98 : "m" (*__xg(ptr)), "0" (x)
94 :"memory"); 99 : "memory");
95 break; 100 break;
96 } 101 }
97 return x; 102 return x;
98} 103}
@@ -105,24 +110,27 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
105 110
106#ifdef CONFIG_X86_CMPXCHG 111#ifdef CONFIG_X86_CMPXCHG
107#define __HAVE_ARCH_CMPXCHG 1 112#define __HAVE_ARCH_CMPXCHG 1
108#define cmpxchg(ptr, o, n) \ 113#define cmpxchg(ptr, o, n) \
109 ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \ 114 ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \
110 (unsigned long)(n), sizeof(*(ptr)))) 115 (unsigned long)(n), \
111#define sync_cmpxchg(ptr, o, n) \ 116 sizeof(*(ptr))))
112 ((__typeof__(*(ptr)))__sync_cmpxchg((ptr), (unsigned long)(o), \ 117#define sync_cmpxchg(ptr, o, n) \
113 (unsigned long)(n), sizeof(*(ptr)))) 118 ((__typeof__(*(ptr)))__sync_cmpxchg((ptr), (unsigned long)(o), \
114#define cmpxchg_local(ptr, o, n) \ 119 (unsigned long)(n), \
115 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \ 120 sizeof(*(ptr))))
116 (unsigned long)(n), sizeof(*(ptr)))) 121#define cmpxchg_local(ptr, o, n) \
122 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
123 (unsigned long)(n), \
124 sizeof(*(ptr))))
117#endif 125#endif
118 126
119#ifdef CONFIG_X86_CMPXCHG64 127#ifdef CONFIG_X86_CMPXCHG64
120#define cmpxchg64(ptr, o, n) \ 128#define cmpxchg64(ptr, o, n) \
121 ((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \ 129 ((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \
122 (unsigned long long)(n))) 130 (unsigned long long)(n)))
123#define cmpxchg64_local(ptr, o, n) \ 131#define cmpxchg64_local(ptr, o, n) \
124 ((__typeof__(*(ptr)))__cmpxchg64_local((ptr), (unsigned long long)(o),\ 132 ((__typeof__(*(ptr)))__cmpxchg64_local((ptr), (unsigned long long)(o), \
125 (unsigned long long)(n))) 133 (unsigned long long)(n)))
126#endif 134#endif
127 135
128static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, 136static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
@@ -131,22 +139,22 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
131 unsigned long prev; 139 unsigned long prev;
132 switch (size) { 140 switch (size) {
133 case 1: 141 case 1:
134 __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2" 142 asm volatile(LOCK_PREFIX "cmpxchgb %b1,%2"
135 : "=a"(prev) 143 : "=a"(prev)
136 : "q"(new), "m"(*__xg(ptr)), "0"(old) 144 : "q"(new), "m"(*__xg(ptr)), "0"(old)
137 : "memory"); 145 : "memory");
138 return prev; 146 return prev;
139 case 2: 147 case 2:
140 __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2" 148 asm volatile(LOCK_PREFIX "cmpxchgw %w1,%2"
141 : "=a"(prev) 149 : "=a"(prev)
142 : "r"(new), "m"(*__xg(ptr)), "0"(old) 150 : "r"(new), "m"(*__xg(ptr)), "0"(old)
143 : "memory"); 151 : "memory");
144 return prev; 152 return prev;
145 case 4: 153 case 4:
146 __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2" 154 asm volatile(LOCK_PREFIX "cmpxchgl %1,%2"
147 : "=a"(prev) 155 : "=a"(prev)
148 : "r"(new), "m"(*__xg(ptr)), "0"(old) 156 : "r"(new), "m"(*__xg(ptr)), "0"(old)
149 : "memory"); 157 : "memory");
150 return prev; 158 return prev;
151 } 159 }
152 return old; 160 return old;
@@ -158,85 +166,88 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
158 * isn't. 166 * isn't.
159 */ 167 */
160static inline unsigned long __sync_cmpxchg(volatile void *ptr, 168static inline unsigned long __sync_cmpxchg(volatile void *ptr,
161 unsigned long old, 169 unsigned long old,
162 unsigned long new, int size) 170 unsigned long new, int size)
163{ 171{
164 unsigned long prev; 172 unsigned long prev;
165 switch (size) { 173 switch (size) {
166 case 1: 174 case 1:
167 __asm__ __volatile__("lock; cmpxchgb %b1,%2" 175 asm volatile("lock; cmpxchgb %b1,%2"
168 : "=a"(prev) 176 : "=a"(prev)
169 : "q"(new), "m"(*__xg(ptr)), "0"(old) 177 : "q"(new), "m"(*__xg(ptr)), "0"(old)
170 : "memory"); 178 : "memory");
171 return prev; 179 return prev;
172 case 2: 180 case 2:
173 __asm__ __volatile__("lock; cmpxchgw %w1,%2" 181 asm volatile("lock; cmpxchgw %w1,%2"
174 : "=a"(prev) 182 : "=a"(prev)
175 : "r"(new), "m"(*__xg(ptr)), "0"(old) 183 : "r"(new), "m"(*__xg(ptr)), "0"(old)
176 : "memory"); 184 : "memory");
177 return prev; 185 return prev;
178 case 4: 186 case 4:
179 __asm__ __volatile__("lock; cmpxchgl %1,%2" 187 asm volatile("lock; cmpxchgl %1,%2"
180 : "=a"(prev) 188 : "=a"(prev)
181 : "r"(new), "m"(*__xg(ptr)), "0"(old) 189 : "r"(new), "m"(*__xg(ptr)), "0"(old)
182 : "memory"); 190 : "memory");
183 return prev; 191 return prev;
184 } 192 }
185 return old; 193 return old;
186} 194}
187 195
188static inline unsigned long __cmpxchg_local(volatile void *ptr, 196static inline unsigned long __cmpxchg_local(volatile void *ptr,
189 unsigned long old, unsigned long new, int size) 197 unsigned long old,
198 unsigned long new, int size)
190{ 199{
191 unsigned long prev; 200 unsigned long prev;
192 switch (size) { 201 switch (size) {
193 case 1: 202 case 1:
194 __asm__ __volatile__("cmpxchgb %b1,%2" 203 asm volatile("cmpxchgb %b1,%2"
195 : "=a"(prev) 204 : "=a"(prev)
196 : "q"(new), "m"(*__xg(ptr)), "0"(old) 205 : "q"(new), "m"(*__xg(ptr)), "0"(old)
197 : "memory"); 206 : "memory");
198 return prev; 207 return prev;
199 case 2: 208 case 2:
200 __asm__ __volatile__("cmpxchgw %w1,%2" 209 asm volatile("cmpxchgw %w1,%2"
201 : "=a"(prev) 210 : "=a"(prev)
202 : "r"(new), "m"(*__xg(ptr)), "0"(old) 211 : "r"(new), "m"(*__xg(ptr)), "0"(old)
203 : "memory"); 212 : "memory");
204 return prev; 213 return prev;
205 case 4: 214 case 4:
206 __asm__ __volatile__("cmpxchgl %1,%2" 215 asm volatile("cmpxchgl %1,%2"
207 : "=a"(prev) 216 : "=a"(prev)
208 : "r"(new), "m"(*__xg(ptr)), "0"(old) 217 : "r"(new), "m"(*__xg(ptr)), "0"(old)
209 : "memory"); 218 : "memory");
210 return prev; 219 return prev;
211 } 220 }
212 return old; 221 return old;
213} 222}
214 223
215static inline unsigned long long __cmpxchg64(volatile void *ptr, 224static inline unsigned long long __cmpxchg64(volatile void *ptr,
216 unsigned long long old, unsigned long long new) 225 unsigned long long old,
226 unsigned long long new)
217{ 227{
218 unsigned long long prev; 228 unsigned long long prev;
219 __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3" 229 asm volatile(LOCK_PREFIX "cmpxchg8b %3"
220 : "=A"(prev) 230 : "=A"(prev)
221 : "b"((unsigned long)new), 231 : "b"((unsigned long)new),
222 "c"((unsigned long)(new >> 32)), 232 "c"((unsigned long)(new >> 32)),
223 "m"(*__xg(ptr)), 233 "m"(*__xg(ptr)),
224 "0"(old) 234 "0"(old)
225 : "memory"); 235 : "memory");
226 return prev; 236 return prev;
227} 237}
228 238
229static inline unsigned long long __cmpxchg64_local(volatile void *ptr, 239static inline unsigned long long __cmpxchg64_local(volatile void *ptr,
230 unsigned long long old, unsigned long long new) 240 unsigned long long old,
241 unsigned long long new)
231{ 242{
232 unsigned long long prev; 243 unsigned long long prev;
233 __asm__ __volatile__("cmpxchg8b %3" 244 asm volatile("cmpxchg8b %3"
234 : "=A"(prev) 245 : "=A"(prev)
235 : "b"((unsigned long)new), 246 : "b"((unsigned long)new),
236 "c"((unsigned long)(new >> 32)), 247 "c"((unsigned long)(new >> 32)),
237 "m"(*__xg(ptr)), 248 "m"(*__xg(ptr)),
238 "0"(old) 249 "0"(old)
239 : "memory"); 250 : "memory");
240 return prev; 251 return prev;
241} 252}
242 253
@@ -252,7 +263,7 @@ extern unsigned long cmpxchg_386_u16(volatile void *, u16, u16);
252extern unsigned long cmpxchg_386_u32(volatile void *, u32, u32); 263extern unsigned long cmpxchg_386_u32(volatile void *, u32, u32);
253 264
254static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old, 265static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
255 unsigned long new, int size) 266 unsigned long new, int size)
256{ 267{
257 switch (size) { 268 switch (size) {
258 case 1: 269 case 1:
diff --git a/include/asm-x86/cmpxchg_64.h b/include/asm-x86/cmpxchg_64.h
index 56f5b41e071c..d9b26b9a28cf 100644
--- a/include/asm-x86/cmpxchg_64.h
+++ b/include/asm-x86/cmpxchg_64.h
@@ -3,7 +3,8 @@
3 3
4#include <asm/alternative.h> /* Provides LOCK_PREFIX */ 4#include <asm/alternative.h> /* Provides LOCK_PREFIX */
5 5
6#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr)))) 6#define xchg(ptr, v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v), \
7 (ptr), sizeof(*(ptr))))
7 8
8#define __xg(x) ((volatile long *)(x)) 9#define __xg(x) ((volatile long *)(x))
9 10
@@ -19,33 +20,34 @@ static inline void set_64bit(volatile unsigned long *ptr, unsigned long val)
19 * Note 2: xchg has side effect, so that attribute volatile is necessary, 20 * Note 2: xchg has side effect, so that attribute volatile is necessary,
20 * but generally the primitive is invalid, *ptr is output argument. --ANK 21 * but generally the primitive is invalid, *ptr is output argument. --ANK
21 */ 22 */
22static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size) 23static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
24 int size)
23{ 25{
24 switch (size) { 26 switch (size) {
25 case 1: 27 case 1:
26 __asm__ __volatile__("xchgb %b0,%1" 28 asm volatile("xchgb %b0,%1"
27 :"=q" (x) 29 : "=q" (x)
28 :"m" (*__xg(ptr)), "0" (x) 30 : "m" (*__xg(ptr)), "0" (x)
29 :"memory"); 31 : "memory");
30 break; 32 break;
31 case 2: 33 case 2:
32 __asm__ __volatile__("xchgw %w0,%1" 34 asm volatile("xchgw %w0,%1"
33 :"=r" (x) 35 : "=r" (x)
34 :"m" (*__xg(ptr)), "0" (x) 36 : "m" (*__xg(ptr)), "0" (x)
35 :"memory"); 37 : "memory");
36 break; 38 break;
37 case 4: 39 case 4:
38 __asm__ __volatile__("xchgl %k0,%1" 40 asm volatile("xchgl %k0,%1"
39 :"=r" (x) 41 : "=r" (x)
40 :"m" (*__xg(ptr)), "0" (x) 42 : "m" (*__xg(ptr)), "0" (x)
41 :"memory"); 43 : "memory");
42 break; 44 break;
43 case 8: 45 case 8:
44 __asm__ __volatile__("xchgq %0,%1" 46 asm volatile("xchgq %0,%1"
45 :"=r" (x) 47 : "=r" (x)
46 :"m" (*__xg(ptr)), "0" (x) 48 : "m" (*__xg(ptr)), "0" (x)
47 :"memory"); 49 : "memory");
48 break; 50 break;
49 } 51 }
50 return x; 52 return x;
51} 53}
@@ -64,61 +66,62 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
64 unsigned long prev; 66 unsigned long prev;
65 switch (size) { 67 switch (size) {
66 case 1: 68 case 1:
67 __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2" 69 asm volatile(LOCK_PREFIX "cmpxchgb %b1,%2"
68 : "=a"(prev) 70 : "=a"(prev)
69 : "q"(new), "m"(*__xg(ptr)), "0"(old) 71 : "q"(new), "m"(*__xg(ptr)), "0"(old)
70 : "memory"); 72 : "memory");
71 return prev; 73 return prev;
72 case 2: 74 case 2:
73 __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2" 75 asm volatile(LOCK_PREFIX "cmpxchgw %w1,%2"
74 : "=a"(prev) 76 : "=a"(prev)
75 : "r"(new), "m"(*__xg(ptr)), "0"(old) 77 : "r"(new), "m"(*__xg(ptr)), "0"(old)
76 : "memory"); 78 : "memory");
77 return prev; 79 return prev;
78 case 4: 80 case 4:
79 __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %k1,%2" 81 asm volatile(LOCK_PREFIX "cmpxchgl %k1,%2"
80 : "=a"(prev) 82 : "=a"(prev)
81 : "r"(new), "m"(*__xg(ptr)), "0"(old) 83 : "r"(new), "m"(*__xg(ptr)), "0"(old)
82 : "memory"); 84 : "memory");
83 return prev; 85 return prev;
84 case 8: 86 case 8:
85 __asm__ __volatile__(LOCK_PREFIX "cmpxchgq %1,%2" 87 asm volatile(LOCK_PREFIX "cmpxchgq %1,%2"
86 : "=a"(prev) 88 : "=a"(prev)
87 : "r"(new), "m"(*__xg(ptr)), "0"(old) 89 : "r"(new), "m"(*__xg(ptr)), "0"(old)
88 : "memory"); 90 : "memory");
89 return prev; 91 return prev;
90 } 92 }
91 return old; 93 return old;
92} 94}
93 95
94static inline unsigned long __cmpxchg_local(volatile void *ptr, 96static inline unsigned long __cmpxchg_local(volatile void *ptr,
95 unsigned long old, unsigned long new, int size) 97 unsigned long old,
98 unsigned long new, int size)
96{ 99{
97 unsigned long prev; 100 unsigned long prev;
98 switch (size) { 101 switch (size) {
99 case 1: 102 case 1:
100 __asm__ __volatile__("cmpxchgb %b1,%2" 103 asm volatile("cmpxchgb %b1,%2"
101 : "=a"(prev) 104 : "=a"(prev)
102 : "q"(new), "m"(*__xg(ptr)), "0"(old) 105 : "q"(new), "m"(*__xg(ptr)), "0"(old)
103 : "memory"); 106 : "memory");
104 return prev; 107 return prev;
105 case 2: 108 case 2:
106 __asm__ __volatile__("cmpxchgw %w1,%2" 109 asm volatile("cmpxchgw %w1,%2"
107 : "=a"(prev) 110 : "=a"(prev)
108 : "r"(new), "m"(*__xg(ptr)), "0"(old) 111 : "r"(new), "m"(*__xg(ptr)), "0"(old)
109 : "memory"); 112 : "memory");
110 return prev; 113 return prev;
111 case 4: 114 case 4:
112 __asm__ __volatile__("cmpxchgl %k1,%2" 115 asm volatile("cmpxchgl %k1,%2"
113 : "=a"(prev) 116 : "=a"(prev)
114 : "r"(new), "m"(*__xg(ptr)), "0"(old) 117 : "r"(new), "m"(*__xg(ptr)), "0"(old)
115 : "memory"); 118 : "memory");
116 return prev; 119 return prev;
117 case 8: 120 case 8:
118 __asm__ __volatile__("cmpxchgq %1,%2" 121 asm volatile("cmpxchgq %1,%2"
119 : "=a"(prev) 122 : "=a"(prev)
120 : "r"(new), "m"(*__xg(ptr)), "0"(old) 123 : "r"(new), "m"(*__xg(ptr)), "0"(old)
121 : "memory"); 124 : "memory");
122 return prev; 125 return prev;
123 } 126 }
124 return old; 127 return old;
@@ -126,19 +129,20 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
126 129
127#define cmpxchg(ptr, o, n) \ 130#define cmpxchg(ptr, o, n) \
128 ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \ 131 ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \
129 (unsigned long)(n), sizeof(*(ptr)))) 132 (unsigned long)(n), sizeof(*(ptr))))
130#define cmpxchg64(ptr, o, n) \ 133#define cmpxchg64(ptr, o, n) \
131 ({ \ 134({ \
132 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ 135 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
133 cmpxchg((ptr), (o), (n)); \ 136 cmpxchg((ptr), (o), (n)); \
134 }) 137})
135#define cmpxchg_local(ptr, o, n) \ 138#define cmpxchg_local(ptr, o, n) \
136 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \ 139 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
137 (unsigned long)(n), sizeof(*(ptr)))) 140 (unsigned long)(n), \
141 sizeof(*(ptr))))
138#define cmpxchg64_local(ptr, o, n) \ 142#define cmpxchg64_local(ptr, o, n) \
139 ({ \ 143({ \
140 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ 144 BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
141 cmpxchg_local((ptr), (o), (n)); \ 145 cmpxchg_local((ptr), (o), (n)); \
142 }) 146})
143 147
144#endif 148#endif
diff --git a/include/asm-x86/compat.h b/include/asm-x86/compat.h
index d3e8f3e87ee8..1793ac317a30 100644
--- a/include/asm-x86/compat.h
+++ b/include/asm-x86/compat.h
@@ -204,7 +204,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
204 return (u32)(unsigned long)uptr; 204 return (u32)(unsigned long)uptr;
205} 205}
206 206
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->sp - len; 210 return (void __user *)regs->sp - len;
diff --git a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h
index 065e92966c7c..0d609c837a41 100644
--- a/include/asm-x86/cpufeature.h
+++ b/include/asm-x86/cpufeature.h
@@ -120,6 +120,9 @@
120extern const char * const x86_cap_flags[NCAPINTS*32]; 120extern const char * const x86_cap_flags[NCAPINTS*32];
121extern const char * const x86_power_flags[32]; 121extern const char * const x86_power_flags[32];
122 122
123#define test_cpu_cap(c, bit) \
124 test_bit(bit, (unsigned long *)((c)->x86_capability))
125
123#define cpu_has(c, bit) \ 126#define cpu_has(c, bit) \
124 (__builtin_constant_p(bit) && \ 127 (__builtin_constant_p(bit) && \
125 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \ 128 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
@@ -131,7 +134,8 @@ extern const char * const x86_power_flags[32];
131 (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \ 134 (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
132 (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) \ 135 (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) \
133 ? 1 : \ 136 ? 1 : \
134 test_bit(bit, (unsigned long *)((c)->x86_capability))) 137 test_cpu_cap(c, bit))
138
135#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit) 139#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
136 140
137#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability)) 141#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability))
@@ -181,6 +185,8 @@ extern const char * const x86_power_flags[32];
181#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH) 185#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
182#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS) 186#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
183#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES) 187#define cpu_has_gbpages boot_cpu_has(X86_FEATURE_GBPAGES)
188#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
189#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT)
184 190
185#if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64) 191#if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64)
186# define cpu_has_invlpg 1 192# define cpu_has_invlpg 1
diff --git a/include/asm-x86/current_32.h b/include/asm-x86/current_32.h
index d35248539912..5af9bdb97a16 100644
--- a/include/asm-x86/current_32.h
+++ b/include/asm-x86/current_32.h
@@ -11,7 +11,7 @@ static __always_inline struct task_struct *get_current(void)
11{ 11{
12 return x86_read_percpu(current_task); 12 return x86_read_percpu(current_task);
13} 13}
14 14
15#define current get_current() 15#define current get_current()
16 16
17#endif /* !(_I386_CURRENT_H) */ 17#endif /* !(_I386_CURRENT_H) */
diff --git a/include/asm-x86/current_64.h b/include/asm-x86/current_64.h
index bc8adecee66d..2d368ede2fc1 100644
--- a/include/asm-x86/current_64.h
+++ b/include/asm-x86/current_64.h
@@ -1,23 +1,23 @@
1#ifndef _X86_64_CURRENT_H 1#ifndef _X86_64_CURRENT_H
2#define _X86_64_CURRENT_H 2#define _X86_64_CURRENT_H
3 3
4#if !defined(__ASSEMBLY__) 4#if !defined(__ASSEMBLY__)
5struct task_struct; 5struct task_struct;
6 6
7#include <asm/pda.h> 7#include <asm/pda.h>
8 8
9static inline struct task_struct *get_current(void) 9static inline struct task_struct *get_current(void)
10{ 10{
11 struct task_struct *t = read_pda(pcurrent); 11 struct task_struct *t = read_pda(pcurrent);
12 return t; 12 return t;
13} 13}
14 14
15#define current get_current() 15#define current get_current()
16 16
17#else 17#else
18 18
19#ifndef ASM_OFFSET_H 19#ifndef ASM_OFFSET_H
20#include <asm/asm-offsets.h> 20#include <asm/asm-offsets.h>
21#endif 21#endif
22 22
23#define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg 23#define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg
diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h
index 5b6a05d3a771..268a012bcd79 100644
--- a/include/asm-x86/desc.h
+++ b/include/asm-x86/desc.h
@@ -62,8 +62,8 @@ static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
62} 62}
63 63
64static inline void pack_gate(gate_desc *gate, unsigned char type, 64static inline void pack_gate(gate_desc *gate, unsigned char type,
65 unsigned long base, unsigned dpl, unsigned flags, unsigned short seg) 65 unsigned long base, unsigned dpl, unsigned flags,
66 66 unsigned short seg)
67{ 67{
68 gate->a = (seg << 16) | (base & 0xffff); 68 gate->a = (seg << 16) | (base & 0xffff);
69 gate->b = (base & 0xffff0000) | 69 gate->b = (base & 0xffff0000) |
@@ -84,22 +84,23 @@ static inline int desc_empty(const void *ptr)
84#define load_TR_desc() native_load_tr_desc() 84#define load_TR_desc() native_load_tr_desc()
85#define load_gdt(dtr) native_load_gdt(dtr) 85#define load_gdt(dtr) native_load_gdt(dtr)
86#define load_idt(dtr) native_load_idt(dtr) 86#define load_idt(dtr) native_load_idt(dtr)
87#define load_tr(tr) __asm__ __volatile("ltr %0"::"m" (tr)) 87#define load_tr(tr) asm volatile("ltr %0"::"m" (tr))
88#define load_ldt(ldt) __asm__ __volatile("lldt %0"::"m" (ldt)) 88#define load_ldt(ldt) asm volatile("lldt %0"::"m" (ldt))
89 89
90#define store_gdt(dtr) native_store_gdt(dtr) 90#define store_gdt(dtr) native_store_gdt(dtr)
91#define store_idt(dtr) native_store_idt(dtr) 91#define store_idt(dtr) native_store_idt(dtr)
92#define store_tr(tr) (tr = native_store_tr()) 92#define store_tr(tr) (tr = native_store_tr())
93#define store_ldt(ldt) __asm__ ("sldt %0":"=m" (ldt)) 93#define store_ldt(ldt) asm("sldt %0":"=m" (ldt))
94 94
95#define load_TLS(t, cpu) native_load_tls(t, cpu) 95#define load_TLS(t, cpu) native_load_tls(t, cpu)
96#define set_ldt native_set_ldt 96#define set_ldt native_set_ldt
97 97
98#define write_ldt_entry(dt, entry, desc) \ 98#define write_ldt_entry(dt, entry, desc) \
99 native_write_ldt_entry(dt, entry, desc) 99 native_write_ldt_entry(dt, entry, desc)
100#define write_gdt_entry(dt, entry, desc, type) \ 100#define write_gdt_entry(dt, entry, desc, type) \
101 native_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) 102#define write_idt_entry(dt, entry, g) \
103 native_write_idt_entry(dt, entry, g)
103#endif 104#endif
104 105
105static inline void native_write_idt_entry(gate_desc *idt, int entry, 106static inline void native_write_idt_entry(gate_desc *idt, int entry,
@@ -138,8 +139,8 @@ static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
138{ 139{
139 desc->a = ((base & 0xffff) << 16) | (limit & 0xffff); 140 desc->a = ((base & 0xffff) << 16) | (limit & 0xffff);
140 desc->b = (base & 0xff000000) | ((base & 0xff0000) >> 16) | 141 desc->b = (base & 0xff000000) | ((base & 0xff0000) >> 16) |
141 (limit & 0x000f0000) | ((type & 0xff) << 8) | 142 (limit & 0x000f0000) | ((type & 0xff) << 8) |
142 ((flags & 0xf) << 20); 143 ((flags & 0xf) << 20);
143 desc->p = 1; 144 desc->p = 1;
144} 145}
145 146
@@ -159,7 +160,6 @@ static inline void set_tssldt_descriptor(void *d, unsigned long addr,
159 desc->base2 = (PTR_MIDDLE(addr) >> 8) & 0xFF; 160 desc->base2 = (PTR_MIDDLE(addr) >> 8) & 0xFF;
160 desc->base3 = PTR_HIGH(addr); 161 desc->base3 = PTR_HIGH(addr);
161#else 162#else
162
163 pack_descriptor((struct desc_struct *)d, addr, size, 0x80 | type, 0); 163 pack_descriptor((struct desc_struct *)d, addr, size, 0x80 | type, 0);
164#endif 164#endif
165} 165}
@@ -177,7 +177,8 @@ static inline void __set_tss_desc(unsigned cpu, unsigned int entry, void *addr)
177 * last valid byte 177 * last valid byte
178 */ 178 */
179 set_tssldt_descriptor(&tss, (unsigned long)addr, DESC_TSS, 179 set_tssldt_descriptor(&tss, (unsigned long)addr, DESC_TSS,
180 IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1); 180 IO_BITMAP_OFFSET + IO_BITMAP_BYTES +
181 sizeof(unsigned long) - 1);
181 write_gdt_entry(d, entry, &tss, DESC_TSS); 182 write_gdt_entry(d, entry, &tss, DESC_TSS);
182} 183}
183 184
@@ -186,7 +187,7 @@ static inline void __set_tss_desc(unsigned cpu, unsigned int entry, void *addr)
186static inline void native_set_ldt(const void *addr, unsigned int entries) 187static inline void native_set_ldt(const void *addr, unsigned int entries)
187{ 188{
188 if (likely(entries == 0)) 189 if (likely(entries == 0))
189 __asm__ __volatile__("lldt %w0"::"q" (0)); 190 asm volatile("lldt %w0"::"q" (0));
190 else { 191 else {
191 unsigned cpu = smp_processor_id(); 192 unsigned cpu = smp_processor_id();
192 ldt_desc ldt; 193 ldt_desc ldt;
@@ -195,7 +196,7 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
195 DESC_LDT, entries * sizeof(ldt) - 1); 196 DESC_LDT, entries * sizeof(ldt) - 1);
196 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, 197 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT,
197 &ldt, DESC_LDT); 198 &ldt, DESC_LDT);
198 __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8)); 199 asm volatile("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
199 } 200 }
200} 201}
201 202
@@ -240,15 +241,15 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
240 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]; 241 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
241} 242}
242 243
243#define _LDT_empty(info) (\ 244#define _LDT_empty(info) \
244 (info)->base_addr == 0 && \ 245 ((info)->base_addr == 0 && \
245 (info)->limit == 0 && \ 246 (info)->limit == 0 && \
246 (info)->contents == 0 && \ 247 (info)->contents == 0 && \
247 (info)->read_exec_only == 1 && \ 248 (info)->read_exec_only == 1 && \
248 (info)->seg_32bit == 0 && \ 249 (info)->seg_32bit == 0 && \
249 (info)->limit_in_pages == 0 && \ 250 (info)->limit_in_pages == 0 && \
250 (info)->seg_not_present == 1 && \ 251 (info)->seg_not_present == 1 && \
251 (info)->useable == 0) 252 (info)->useable == 0)
252 253
253#ifdef CONFIG_X86_64 254#ifdef CONFIG_X86_64
254#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0)) 255#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0))
@@ -287,7 +288,7 @@ static inline unsigned long get_desc_limit(const struct desc_struct *desc)
287} 288}
288 289
289static inline void _set_gate(int gate, unsigned type, void *addr, 290static inline void _set_gate(int gate, unsigned type, void *addr,
290 unsigned dpl, unsigned ist, unsigned seg) 291 unsigned dpl, unsigned ist, unsigned seg)
291{ 292{
292 gate_desc s; 293 gate_desc s;
293 pack_gate(&s, type, (unsigned long)addr, dpl, ist, seg); 294 pack_gate(&s, type, (unsigned long)addr, dpl, ist, seg);
@@ -370,10 +371,10 @@ static inline void set_system_gate_ist(int n, void *addr, unsigned ist)
370 * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax. 371 * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
371 */ 372 */
372#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \ 373#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 + 4(gdt), lo_b; \
374 movb idx*8+7(gdt), hi_b; \ 375 movb idx * 8 + 7(gdt), hi_b; \
375 shll $16, base; \ 376 shll $16, base; \
376 movw idx*8+2(gdt), lo_w; 377 movw idx * 8 + 2(gdt), lo_w;
377 378
378 379
379#endif /* __ASSEMBLY__ */ 380#endif /* __ASSEMBLY__ */
diff --git a/include/asm-x86/desc_defs.h b/include/asm-x86/desc_defs.h
index e33f078b3e54..eccb4ea1f918 100644
--- a/include/asm-x86/desc_defs.h
+++ b/include/asm-x86/desc_defs.h
@@ -18,17 +18,19 @@
18 * incrementally. We keep the signature as a struct, rather than an union, 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 19 * so we can get rid of it transparently in the future -- glommer
20 */ 20 */
21// 8 byte segment descriptor 21/* 8 byte segment descriptor */
22struct desc_struct { 22struct desc_struct {
23 union { 23 union {
24 struct { unsigned int a, b; }; 24 struct {
25 unsigned int a;
26 unsigned int b;
27 };
25 struct { 28 struct {
26 u16 limit0; 29 u16 limit0;
27 u16 base0; 30 u16 base0;
28 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1; 31 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; 32 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
30 }; 33 };
31
32 }; 34 };
33} __attribute__((packed)); 35} __attribute__((packed));
34 36
@@ -39,7 +41,7 @@ enum {
39 GATE_TASK = 0x5, 41 GATE_TASK = 0x5,
40}; 42};
41 43
42// 16byte gate 44/* 16byte gate */
43struct gate_struct64 { 45struct gate_struct64 {
44 u16 offset_low; 46 u16 offset_low;
45 u16 segment; 47 u16 segment;
@@ -56,10 +58,10 @@ struct gate_struct64 {
56enum { 58enum {
57 DESC_TSS = 0x9, 59 DESC_TSS = 0x9,
58 DESC_LDT = 0x2, 60 DESC_LDT = 0x2,
59 DESCTYPE_S = 0x10, /* !system */ 61 DESCTYPE_S = 0x10, /* !system */
60}; 62};
61 63
62// LDT or TSS descriptor in the GDT. 16 bytes. 64/* LDT or TSS descriptor in the GDT. 16 bytes. */
63struct ldttss_desc64 { 65struct ldttss_desc64 {
64 u16 limit0; 66 u16 limit0;
65 u16 base0; 67 u16 base0;
@@ -84,7 +86,6 @@ struct desc_ptr {
84 unsigned long address; 86 unsigned long address;
85} __attribute__((packed)) ; 87} __attribute__((packed)) ;
86 88
87
88#endif /* !__ASSEMBLY__ */ 89#endif /* !__ASSEMBLY__ */
89 90
90#endif 91#endif
diff --git a/include/asm-x86/div64.h b/include/asm-x86/div64.h
index e98d16e7a37a..9a2d644c08ef 100644
--- a/include/asm-x86/div64.h
+++ b/include/asm-x86/div64.h
@@ -17,40 +17,41 @@
17 * This ends up being the most efficient "calling 17 * This ends up being the most efficient "calling
18 * convention" on x86. 18 * convention" on x86.
19 */ 19 */
20#define do_div(n,base) ({ \ 20#define do_div(n, base) \
21 unsigned long __upper, __low, __high, __mod, __base; \ 21({ \
22 __base = (base); \ 22 unsigned long __upper, __low, __high, __mod, __base; \
23 asm("":"=a" (__low), "=d" (__high):"A" (n)); \ 23 __base = (base); \
24 __upper = __high; \ 24 asm("":"=a" (__low), "=d" (__high) : "A" (n)); \
25 if (__high) { \ 25 __upper = __high; \
26 __upper = __high % (__base); \ 26 if (__high) { \
27 __high = __high / (__base); \ 27 __upper = __high % (__base); \
28 } \ 28 __high = __high / (__base); \
29 asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \ 29 } \
30 asm("":"=A" (n):"a" (__low),"d" (__high)); \ 30 asm("divl %2":"=a" (__low), "=d" (__mod) \
31 __mod; \ 31 : "rm" (__base), "0" (__low), "1" (__upper)); \
32 asm("":"=A" (n) : "a" (__low), "d" (__high)); \
33 __mod; \
32}) 34})
33 35
34/* 36static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
35 * (long)X = ((long long)divs) / (long)div
36 * (long)rem = ((long long)divs) % (long)div
37 *
38 * Warning, this will do an exception if X overflows.
39 */
40#define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c)
41
42static inline long
43div_ll_X_l_rem(long long divs, long div, long *rem)
44{ 37{
45 long dum2; 38 union {
46 __asm__("divl %2":"=a"(dum2), "=d"(*rem) 39 u64 v64;
47 : "rm"(div), "A"(divs)); 40 u32 v32[2];
48 41 } d = { dividend };
49 return dum2; 42 u32 upper;
50 43
44 upper = d.v32[1];
45 d.v32[1] = 0;
46 if (upper >= divisor) {
47 d.v32[1] = upper / divisor;
48 upper %= divisor;
49 }
50 asm ("divl %2" : "=a" (d.v32[0]), "=d" (*remainder) :
51 "rm" (divisor), "0" (d.v32[0]), "1" (upper));
52 return d.v64;
51} 53}
52 54#define div_u64_rem div_u64_rem
53extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
54 55
55#else 56#else
56# include <asm-generic/div64.h> 57# include <asm-generic/div64.h>
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 58f790f4df52..a1a4dc7fe6ec 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -1,5 +1,237 @@
1#ifndef _ASM_DMA_MAPPING_H_
2#define _ASM_DMA_MAPPING_H_
3
4/*
5 * IOMMU interface. See Documentation/DMA-mapping.txt and DMA-API.txt for
6 * documentation.
7 */
8
9#include <linux/scatterlist.h>
10#include <asm/io.h>
11#include <asm/swiotlb.h>
12
13extern dma_addr_t bad_dma_address;
14extern int iommu_merge;
15extern struct device fallback_dev;
16extern int panic_on_overflow;
17extern int forbid_dac;
18extern int force_iommu;
19
20struct dma_mapping_ops {
21 int (*mapping_error)(dma_addr_t dma_addr);
22 void* (*alloc_coherent)(struct device *dev, size_t size,
23 dma_addr_t *dma_handle, gfp_t gfp);
24 void (*free_coherent)(struct device *dev, size_t size,
25 void *vaddr, dma_addr_t dma_handle);
26 dma_addr_t (*map_single)(struct device *hwdev, phys_addr_t ptr,
27 size_t size, int direction);
28 /* like map_single, but doesn't check the device mask */
29 dma_addr_t (*map_simple)(struct device *hwdev, phys_addr_t ptr,
30 size_t size, int direction);
31 void (*unmap_single)(struct device *dev, dma_addr_t addr,
32 size_t size, int direction);
33 void (*sync_single_for_cpu)(struct device *hwdev,
34 dma_addr_t dma_handle, size_t size,
35 int direction);
36 void (*sync_single_for_device)(struct device *hwdev,
37 dma_addr_t dma_handle, size_t size,
38 int direction);
39 void (*sync_single_range_for_cpu)(struct device *hwdev,
40 dma_addr_t dma_handle, unsigned long offset,
41 size_t size, int direction);
42 void (*sync_single_range_for_device)(struct device *hwdev,
43 dma_addr_t dma_handle, unsigned long offset,
44 size_t size, int direction);
45 void (*sync_sg_for_cpu)(struct device *hwdev,
46 struct scatterlist *sg, int nelems,
47 int direction);
48 void (*sync_sg_for_device)(struct device *hwdev,
49 struct scatterlist *sg, int nelems,
50 int direction);
51 int (*map_sg)(struct device *hwdev, struct scatterlist *sg,
52 int nents, int direction);
53 void (*unmap_sg)(struct device *hwdev,
54 struct scatterlist *sg, int nents,
55 int direction);
56 int (*dma_supported)(struct device *hwdev, u64 mask);
57 int is_phys;
58};
59
60extern const struct dma_mapping_ops *dma_ops;
61
62static inline int dma_mapping_error(dma_addr_t dma_addr)
63{
64 if (dma_ops->mapping_error)
65 return dma_ops->mapping_error(dma_addr);
66
67 return (dma_addr == bad_dma_address);
68}
69
70#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
71#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
72
73void *dma_alloc_coherent(struct device *dev, size_t size,
74 dma_addr_t *dma_handle, gfp_t flag);
75
76void dma_free_coherent(struct device *dev, size_t size,
77 void *vaddr, dma_addr_t dma_handle);
78
79
80extern int dma_supported(struct device *hwdev, u64 mask);
81extern int dma_set_mask(struct device *dev, u64 mask);
82
83static inline dma_addr_t
84dma_map_single(struct device *hwdev, void *ptr, size_t size,
85 int direction)
86{
87 BUG_ON(!valid_dma_direction(direction));
88 return dma_ops->map_single(hwdev, virt_to_phys(ptr), size, direction);
89}
90
91static inline void
92dma_unmap_single(struct device *dev, dma_addr_t addr, size_t size,
93 int direction)
94{
95 BUG_ON(!valid_dma_direction(direction));
96 if (dma_ops->unmap_single)
97 dma_ops->unmap_single(dev, addr, size, direction);
98}
99
100static inline int
101dma_map_sg(struct device *hwdev, struct scatterlist *sg,
102 int nents, int direction)
103{
104 BUG_ON(!valid_dma_direction(direction));
105 return dma_ops->map_sg(hwdev, sg, nents, direction);
106}
107
108static inline void
109dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
110 int direction)
111{
112 BUG_ON(!valid_dma_direction(direction));
113 if (dma_ops->unmap_sg)
114 dma_ops->unmap_sg(hwdev, sg, nents, direction);
115}
116
117static inline void
118dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
119 size_t size, int direction)
120{
121 BUG_ON(!valid_dma_direction(direction));
122 if (dma_ops->sync_single_for_cpu)
123 dma_ops->sync_single_for_cpu(hwdev, dma_handle, size,
124 direction);
125 flush_write_buffers();
126}
127
128static inline void
129dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
130 size_t size, int direction)
131{
132 BUG_ON(!valid_dma_direction(direction));
133 if (dma_ops->sync_single_for_device)
134 dma_ops->sync_single_for_device(hwdev, dma_handle, size,
135 direction);
136 flush_write_buffers();
137}
138
139static inline void
140dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
141 unsigned long offset, size_t size, int direction)
142{
143 BUG_ON(!valid_dma_direction(direction));
144 if (dma_ops->sync_single_range_for_cpu)
145 dma_ops->sync_single_range_for_cpu(hwdev, dma_handle, offset,
146 size, direction);
147
148 flush_write_buffers();
149}
150
151static inline void
152dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
153 unsigned long offset, size_t size,
154 int direction)
155{
156 BUG_ON(!valid_dma_direction(direction));
157 if (dma_ops->sync_single_range_for_device)
158 dma_ops->sync_single_range_for_device(hwdev, dma_handle,
159 offset, size, direction);
160
161 flush_write_buffers();
162}
163
164static inline void
165dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
166 int nelems, int direction)
167{
168 BUG_ON(!valid_dma_direction(direction));
169 if (dma_ops->sync_sg_for_cpu)
170 dma_ops->sync_sg_for_cpu(hwdev, sg, nelems, direction);
171 flush_write_buffers();
172}
173
174static inline void
175dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
176 int nelems, int direction)
177{
178 BUG_ON(!valid_dma_direction(direction));
179 if (dma_ops->sync_sg_for_device)
180 dma_ops->sync_sg_for_device(hwdev, sg, nelems, direction);
181
182 flush_write_buffers();
183}
184
185static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
186 size_t offset, size_t size,
187 int direction)
188{
189 BUG_ON(!valid_dma_direction(direction));
190 return dma_ops->map_single(dev, page_to_phys(page)+offset,
191 size, direction);
192}
193
194static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
195 size_t size, int direction)
196{
197 dma_unmap_single(dev, addr, size, direction);
198}
199
200static inline void
201dma_cache_sync(struct device *dev, void *vaddr, size_t size,
202 enum dma_data_direction dir)
203{
204 flush_write_buffers();
205}
206
207static inline int dma_get_cache_alignment(void)
208{
209 /* no easy way to get cache size on all x86, so return the
210 * maximum possible, to be safe */
211 return boot_cpu_data.x86_clflush_size;
212}
213
214#define dma_is_consistent(d, h) (1)
215
1#ifdef CONFIG_X86_32 216#ifdef CONFIG_X86_32
2# include "dma-mapping_32.h" 217# define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
3#else 218struct dma_coherent_mem {
4# include "dma-mapping_64.h" 219 void *virt_base;
220 u32 device_base;
221 int size;
222 int flags;
223 unsigned long *bitmap;
224};
225
226extern int
227dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
228 dma_addr_t device_addr, size_t size, int flags);
229
230extern void
231dma_release_declared_memory(struct device *dev);
232
233extern void *
234dma_mark_declared_memory_occupied(struct device *dev,
235 dma_addr_t device_addr, size_t size);
236#endif /* CONFIG_X86_32 */
5#endif 237#endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
deleted file mode 100644
index 55f01bd9e556..000000000000
--- a/include/asm-x86/dma-mapping_32.h
+++ /dev/null
@@ -1,187 +0,0 @@
1#ifndef _ASM_I386_DMA_MAPPING_H
2#define _ASM_I386_DMA_MAPPING_H
3
4#include <linux/mm.h>
5#include <linux/scatterlist.h>
6
7#include <asm/cache.h>
8#include <asm/io.h>
9#include <asm/bug.h>
10
11#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
12#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
13
14void *dma_alloc_coherent(struct device *dev, size_t size,
15 dma_addr_t *dma_handle, gfp_t flag);
16
17void dma_free_coherent(struct device *dev, size_t size,
18 void *vaddr, dma_addr_t dma_handle);
19
20static inline dma_addr_t
21dma_map_single(struct device *dev, void *ptr, size_t size,
22 enum dma_data_direction direction)
23{
24 BUG_ON(!valid_dma_direction(direction));
25 WARN_ON(size == 0);
26 flush_write_buffers();
27 return virt_to_phys(ptr);
28}
29
30static inline void
31dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
32 enum dma_data_direction direction)
33{
34 BUG_ON(!valid_dma_direction(direction));
35}
36
37static inline int
38dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
39 enum dma_data_direction direction)
40{
41 struct scatterlist *sg;
42 int i;
43
44 BUG_ON(!valid_dma_direction(direction));
45 WARN_ON(nents == 0 || sglist[0].length == 0);
46
47 for_each_sg(sglist, sg, nents, i) {
48 BUG_ON(!sg_page(sg));
49
50 sg->dma_address = sg_phys(sg);
51 }
52
53 flush_write_buffers();
54 return nents;
55}
56
57static inline dma_addr_t
58dma_map_page(struct device *dev, struct page *page, unsigned long offset,
59 size_t size, enum dma_data_direction direction)
60{
61 BUG_ON(!valid_dma_direction(direction));
62 return page_to_phys(page) + offset;
63}
64
65static inline void
66dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
67 enum dma_data_direction direction)
68{
69 BUG_ON(!valid_dma_direction(direction));
70}
71
72
73static inline void
74dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
75 enum dma_data_direction direction)
76{
77 BUG_ON(!valid_dma_direction(direction));
78}
79
80static inline void
81dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
82 enum dma_data_direction direction)
83{
84}
85
86static inline void
87dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
88 enum dma_data_direction direction)
89{
90 flush_write_buffers();
91}
92
93static inline void
94dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
95 unsigned long offset, size_t size,
96 enum dma_data_direction direction)
97{
98}
99
100static inline void
101dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
102 unsigned long offset, size_t size,
103 enum dma_data_direction direction)
104{
105 flush_write_buffers();
106}
107
108static inline void
109dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
110 enum dma_data_direction direction)
111{
112}
113
114static inline void
115dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
116 enum dma_data_direction direction)
117{
118 flush_write_buffers();
119}
120
121static inline int
122dma_mapping_error(dma_addr_t dma_addr)
123{
124 return 0;
125}
126
127extern int forbid_dac;
128
129static inline int
130dma_supported(struct device *dev, u64 mask)
131{
132 /*
133 * we fall back to GFP_DMA when the mask isn't all 1s,
134 * so we can't guarantee allocations that must be
135 * within a tighter range than GFP_DMA..
136 */
137 if(mask < 0x00ffffff)
138 return 0;
139
140 /* Work around chipset bugs */
141 if (forbid_dac > 0 && mask > 0xffffffffULL)
142 return 0;
143
144 return 1;
145}
146
147static inline int
148dma_set_mask(struct device *dev, u64 mask)
149{
150 if(!dev->dma_mask || !dma_supported(dev, mask))
151 return -EIO;
152
153 *dev->dma_mask = mask;
154
155 return 0;
156}
157
158static inline int
159dma_get_cache_alignment(void)
160{
161 /* no easy way to get cache size on all x86, so return the
162 * maximum possible, to be safe */
163 return (1 << INTERNODE_CACHE_SHIFT);
164}
165
166#define dma_is_consistent(d, h) (1)
167
168static inline void
169dma_cache_sync(struct device *dev, void *vaddr, size_t size,
170 enum dma_data_direction direction)
171{
172 flush_write_buffers();
173}
174
175#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
176extern int
177dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
178 dma_addr_t device_addr, size_t size, int flags);
179
180extern void
181dma_release_declared_memory(struct device *dev);
182
183extern void *
184dma_mark_declared_memory_occupied(struct device *dev,
185 dma_addr_t device_addr, size_t size);
186
187#endif
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
deleted file mode 100644
index ecd0f6125ba3..000000000000
--- a/include/asm-x86/dma-mapping_64.h
+++ /dev/null
@@ -1,202 +0,0 @@
1#ifndef _X8664_DMA_MAPPING_H
2#define _X8664_DMA_MAPPING_H 1
3
4/*
5 * IOMMU interface. See Documentation/DMA-mapping.txt and DMA-API.txt for
6 * documentation.
7 */
8
9#include <linux/scatterlist.h>
10#include <asm/io.h>
11#include <asm/swiotlb.h>
12
13struct dma_mapping_ops {
14 int (*mapping_error)(dma_addr_t dma_addr);
15 void* (*alloc_coherent)(struct device *dev, size_t size,
16 dma_addr_t *dma_handle, gfp_t gfp);
17 void (*free_coherent)(struct device *dev, size_t size,
18 void *vaddr, dma_addr_t dma_handle);
19 dma_addr_t (*map_single)(struct device *hwdev, void *ptr,
20 size_t size, int direction);
21 /* like map_single, but doesn't check the device mask */
22 dma_addr_t (*map_simple)(struct device *hwdev, char *ptr,
23 size_t size, int direction);
24 void (*unmap_single)(struct device *dev, dma_addr_t addr,
25 size_t size, int direction);
26 void (*sync_single_for_cpu)(struct device *hwdev,
27 dma_addr_t dma_handle, size_t size,
28 int direction);
29 void (*sync_single_for_device)(struct device *hwdev,
30 dma_addr_t dma_handle, size_t size,
31 int direction);
32 void (*sync_single_range_for_cpu)(struct device *hwdev,
33 dma_addr_t dma_handle, unsigned long offset,
34 size_t size, int direction);
35 void (*sync_single_range_for_device)(struct device *hwdev,
36 dma_addr_t dma_handle, unsigned long offset,
37 size_t size, int direction);
38 void (*sync_sg_for_cpu)(struct device *hwdev,
39 struct scatterlist *sg, int nelems,
40 int direction);
41 void (*sync_sg_for_device)(struct device *hwdev,
42 struct scatterlist *sg, int nelems,
43 int direction);
44 int (*map_sg)(struct device *hwdev, struct scatterlist *sg,
45 int nents, int direction);
46 void (*unmap_sg)(struct device *hwdev,
47 struct scatterlist *sg, int nents,
48 int direction);
49 int (*dma_supported)(struct device *hwdev, u64 mask);
50 int is_phys;
51};
52
53extern dma_addr_t bad_dma_address;
54extern const struct dma_mapping_ops* dma_ops;
55extern int iommu_merge;
56
57static inline int dma_mapping_error(dma_addr_t dma_addr)
58{
59 if (dma_ops->mapping_error)
60 return dma_ops->mapping_error(dma_addr);
61
62 return (dma_addr == bad_dma_address);
63}
64
65#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
66#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
67
68#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
69#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
70
71extern void *dma_alloc_coherent(struct device *dev, size_t size,
72 dma_addr_t *dma_handle, gfp_t gfp);
73extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
74 dma_addr_t dma_handle);
75
76static inline dma_addr_t
77dma_map_single(struct device *hwdev, void *ptr, size_t size,
78 int direction)
79{
80 BUG_ON(!valid_dma_direction(direction));
81 return dma_ops->map_single(hwdev, ptr, size, direction);
82}
83
84static inline void
85dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
86 int direction)
87{
88 BUG_ON(!valid_dma_direction(direction));
89 dma_ops->unmap_single(dev, addr, size, direction);
90}
91
92#define dma_map_page(dev,page,offset,size,dir) \
93 dma_map_single((dev), page_address(page)+(offset), (size), (dir))
94
95#define dma_unmap_page dma_unmap_single
96
97static inline void
98dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
99 size_t size, int direction)
100{
101 BUG_ON(!valid_dma_direction(direction));
102 if (dma_ops->sync_single_for_cpu)
103 dma_ops->sync_single_for_cpu(hwdev, dma_handle, size,
104 direction);
105 flush_write_buffers();
106}
107
108static inline void
109dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
110 size_t size, int direction)
111{
112 BUG_ON(!valid_dma_direction(direction));
113 if (dma_ops->sync_single_for_device)
114 dma_ops->sync_single_for_device(hwdev, dma_handle, size,
115 direction);
116 flush_write_buffers();
117}
118
119static inline void
120dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
121 unsigned long offset, size_t size, int direction)
122{
123 BUG_ON(!valid_dma_direction(direction));
124 if (dma_ops->sync_single_range_for_cpu) {
125 dma_ops->sync_single_range_for_cpu(hwdev, dma_handle, offset, size, direction);
126 }
127
128 flush_write_buffers();
129}
130
131static inline void
132dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
133 unsigned long offset, size_t size, int direction)
134{
135 BUG_ON(!valid_dma_direction(direction));
136 if (dma_ops->sync_single_range_for_device)
137 dma_ops->sync_single_range_for_device(hwdev, dma_handle,
138 offset, size, direction);
139
140 flush_write_buffers();
141}
142
143static inline void
144dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
145 int nelems, int direction)
146{
147 BUG_ON(!valid_dma_direction(direction));
148 if (dma_ops->sync_sg_for_cpu)
149 dma_ops->sync_sg_for_cpu(hwdev, sg, nelems, direction);
150 flush_write_buffers();
151}
152
153static inline void
154dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
155 int nelems, int direction)
156{
157 BUG_ON(!valid_dma_direction(direction));
158 if (dma_ops->sync_sg_for_device) {
159 dma_ops->sync_sg_for_device(hwdev, sg, nelems, direction);
160 }
161
162 flush_write_buffers();
163}
164
165static inline int
166dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, int direction)
167{
168 BUG_ON(!valid_dma_direction(direction));
169 return dma_ops->map_sg(hwdev, sg, nents, direction);
170}
171
172static inline void
173dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
174 int direction)
175{
176 BUG_ON(!valid_dma_direction(direction));
177 dma_ops->unmap_sg(hwdev, sg, nents, direction);
178}
179
180extern int dma_supported(struct device *hwdev, u64 mask);
181
182/* same for gart, swiotlb, and nommu */
183static inline int dma_get_cache_alignment(void)
184{
185 return boot_cpu_data.x86_clflush_size;
186}
187
188#define dma_is_consistent(d, h) 1
189
190extern int dma_set_mask(struct device *dev, u64 mask);
191
192static inline void
193dma_cache_sync(struct device *dev, void *vaddr, size_t size,
194 enum dma_data_direction dir)
195{
196 flush_write_buffers();
197}
198
199extern struct device fallback_dev;
200extern int panic_on_overflow;
201
202#endif /* _X8664_DMA_MAPPING_H */
diff --git a/include/asm-x86/dma.h b/include/asm-x86/dma.h
index e9733ce89880..ca1098a7e580 100644
--- a/include/asm-x86/dma.h
+++ b/include/asm-x86/dma.h
@@ -12,7 +12,6 @@
12#include <asm/io.h> /* need byte IO */ 12#include <asm/io.h> /* need byte IO */
13#include <linux/delay.h> 13#include <linux/delay.h>
14 14
15
16#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER 15#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
17#define dma_outb outb_p 16#define dma_outb outb_p
18#else 17#else
@@ -74,15 +73,15 @@
74#ifdef CONFIG_X86_32 73#ifdef CONFIG_X86_32
75 74
76/* The maximum address that we can perform a DMA transfer to on this platform */ 75/* The maximum address that we can perform a DMA transfer to on this platform */
77#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000) 76#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x1000000)
78 77
79#else 78#else
80 79
81/* 16MB ISA DMA zone */ 80/* 16MB ISA DMA zone */
82#define MAX_DMA_PFN ((16*1024*1024) >> PAGE_SHIFT) 81#define MAX_DMA_PFN ((16 * 1024 * 1024) >> PAGE_SHIFT)
83 82
84/* 4GB broken PCI/AGP hardware bus master zone */ 83/* 4GB broken PCI/AGP hardware bus master zone */
85#define MAX_DMA32_PFN ((4UL*1024*1024*1024) >> PAGE_SHIFT) 84#define MAX_DMA32_PFN ((4UL * 1024 * 1024 * 1024) >> PAGE_SHIFT)
86 85
87/* Compat define for old dma zone */ 86/* Compat define for old dma zone */
88#define MAX_DMA_ADDRESS ((unsigned long)__va(MAX_DMA_PFN << PAGE_SHIFT)) 87#define MAX_DMA_ADDRESS ((unsigned long)__va(MAX_DMA_PFN << PAGE_SHIFT))
@@ -154,20 +153,20 @@
154 153
155extern spinlock_t dma_spin_lock; 154extern spinlock_t dma_spin_lock;
156 155
157static __inline__ unsigned long claim_dma_lock(void) 156static inline unsigned long claim_dma_lock(void)
158{ 157{
159 unsigned long flags; 158 unsigned long flags;
160 spin_lock_irqsave(&dma_spin_lock, flags); 159 spin_lock_irqsave(&dma_spin_lock, flags);
161 return flags; 160 return flags;
162} 161}
163 162
164static __inline__ void release_dma_lock(unsigned long flags) 163static inline void release_dma_lock(unsigned long flags)
165{ 164{
166 spin_unlock_irqrestore(&dma_spin_lock, flags); 165 spin_unlock_irqrestore(&dma_spin_lock, flags);
167} 166}
168 167
169/* enable/disable a specific DMA channel */ 168/* enable/disable a specific DMA channel */
170static __inline__ void enable_dma(unsigned int dmanr) 169static inline void enable_dma(unsigned int dmanr)
171{ 170{
172 if (dmanr <= 3) 171 if (dmanr <= 3)
173 dma_outb(dmanr, DMA1_MASK_REG); 172 dma_outb(dmanr, DMA1_MASK_REG);
@@ -175,7 +174,7 @@ static __inline__ void enable_dma(unsigned int dmanr)
175 dma_outb(dmanr & 3, DMA2_MASK_REG); 174 dma_outb(dmanr & 3, DMA2_MASK_REG);
176} 175}
177 176
178static __inline__ void disable_dma(unsigned int dmanr) 177static inline void disable_dma(unsigned int dmanr)
179{ 178{
180 if (dmanr <= 3) 179 if (dmanr <= 3)
181 dma_outb(dmanr | 4, DMA1_MASK_REG); 180 dma_outb(dmanr | 4, DMA1_MASK_REG);
@@ -190,7 +189,7 @@ static __inline__ void disable_dma(unsigned int dmanr)
190 * --- In order to do that, the DMA routines below should --- 189 * --- In order to do that, the DMA routines below should ---
191 * --- only be used while holding the DMA lock ! --- 190 * --- only be used while holding the DMA lock ! ---
192 */ 191 */
193static __inline__ void clear_dma_ff(unsigned int dmanr) 192static inline void clear_dma_ff(unsigned int dmanr)
194{ 193{
195 if (dmanr <= 3) 194 if (dmanr <= 3)
196 dma_outb(0, DMA1_CLEAR_FF_REG); 195 dma_outb(0, DMA1_CLEAR_FF_REG);
@@ -199,7 +198,7 @@ static __inline__ void clear_dma_ff(unsigned int dmanr)
199} 198}
200 199
201/* set mode (above) for a specific DMA channel */ 200/* set mode (above) for a specific DMA channel */
202static __inline__ void set_dma_mode(unsigned int dmanr, char mode) 201static inline void set_dma_mode(unsigned int dmanr, char mode)
203{ 202{
204 if (dmanr <= 3) 203 if (dmanr <= 3)
205 dma_outb(mode | dmanr, DMA1_MODE_REG); 204 dma_outb(mode | dmanr, DMA1_MODE_REG);
@@ -212,7 +211,7 @@ static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
212 * the lower 16 bits of the DMA current address register, but a 64k boundary 211 * the lower 16 bits of the DMA current address register, but a 64k boundary
213 * may have been crossed. 212 * may have been crossed.
214 */ 213 */
215static __inline__ void set_dma_page(unsigned int dmanr, char pagenr) 214static inline void set_dma_page(unsigned int dmanr, char pagenr)
216{ 215{
217 switch (dmanr) { 216 switch (dmanr) {
218 case 0: 217 case 0:
@@ -243,15 +242,15 @@ static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
243/* Set transfer address & page bits for specific DMA channel. 242/* Set transfer address & page bits for specific DMA channel.
244 * Assumes dma flipflop is clear. 243 * Assumes dma flipflop is clear.
245 */ 244 */
246static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a) 245static inline void set_dma_addr(unsigned int dmanr, unsigned int a)
247{ 246{
248 set_dma_page(dmanr, a>>16); 247 set_dma_page(dmanr, a>>16);
249 if (dmanr <= 3) { 248 if (dmanr <= 3) {
250 dma_outb(a & 0xff, ((dmanr & 3) << 1) + IO_DMA1_BASE); 249 dma_outb(a & 0xff, ((dmanr & 3) << 1) + IO_DMA1_BASE);
251 dma_outb((a >> 8) & 0xff, ((dmanr & 3) << 1) + IO_DMA1_BASE); 250 dma_outb((a >> 8) & 0xff, ((dmanr & 3) << 1) + IO_DMA1_BASE);
252 } else { 251 } else {
253 dma_outb((a >> 1) & 0xff, ((dmanr & 3) << 2) + IO_DMA2_BASE); 252 dma_outb((a >> 1) & 0xff, ((dmanr & 3) << 2) + IO_DMA2_BASE);
254 dma_outb((a >> 9) & 0xff, ((dmanr & 3) << 2) + IO_DMA2_BASE); 253 dma_outb((a >> 9) & 0xff, ((dmanr & 3) << 2) + IO_DMA2_BASE);
255 } 254 }
256} 255}
257 256
@@ -264,18 +263,18 @@ static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
264 * Assumes dma flip-flop is clear. 263 * Assumes dma flip-flop is clear.
265 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7. 264 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
266 */ 265 */
267static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count) 266static inline void set_dma_count(unsigned int dmanr, unsigned int count)
268{ 267{
269 count--; 268 count--;
270 if (dmanr <= 3) { 269 if (dmanr <= 3) {
271 dma_outb(count & 0xff, ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE); 270 dma_outb(count & 0xff, ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE);
272 dma_outb((count >> 8) & 0xff, 271 dma_outb((count >> 8) & 0xff,
273 ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE); 272 ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE);
274 } else { 273 } else {
275 dma_outb((count >> 1) & 0xff, 274 dma_outb((count >> 1) & 0xff,
276 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE); 275 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE);
277 dma_outb((count >> 9) & 0xff, 276 dma_outb((count >> 9) & 0xff,
278 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE); 277 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE);
279 } 278 }
280} 279}
281 280
@@ -288,7 +287,7 @@ static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
288 * 287 *
289 * Assumes DMA flip-flop is clear. 288 * Assumes DMA flip-flop is clear.
290 */ 289 */
291static __inline__ int get_dma_residue(unsigned int dmanr) 290static inline int get_dma_residue(unsigned int dmanr)
292{ 291{
293 unsigned int io_port; 292 unsigned int io_port;
294 /* using short to get 16-bit wrap around */ 293 /* using short to get 16-bit wrap around */
diff --git a/include/asm-x86/dmi.h b/include/asm-x86/dmi.h
index 1241e6ad1935..4edf7514a750 100644
--- a/include/asm-x86/dmi.h
+++ b/include/asm-x86/dmi.h
@@ -27,6 +27,7 @@ static inline void *dmi_alloc(unsigned len)
27 27
28#endif 28#endif
29 29
30/* Use early IO mappings for DMI because it's initialized early */
30#define dmi_ioremap early_ioremap 31#define dmi_ioremap early_ioremap
31#define dmi_iounmap early_iounmap 32#define dmi_iounmap early_iounmap
32 33
diff --git a/include/asm-x86/dwarf2_64.h b/include/asm-x86/dwarf2_64.h
index eedc08526b0b..c950519a264d 100644
--- a/include/asm-x86/dwarf2_64.h
+++ b/include/asm-x86/dwarf2_64.h
@@ -1,16 +1,15 @@
1#ifndef _DWARF2_H 1#ifndef _DWARF2_H
2#define _DWARF2_H 1 2#define _DWARF2_H 1
3 3
4
5#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
6#warning "asm/dwarf2.h should be only included in pure assembly files" 5#warning "asm/dwarf2.h should be only included in pure assembly files"
7#endif 6#endif
8 7
9/* 8/*
10 Macros for dwarf2 CFI unwind table entries. 9 Macros for dwarf2 CFI unwind table entries.
11 See "as.info" for details on these pseudo ops. Unfortunately 10 See "as.info" for details on these pseudo ops. Unfortunately
12 they are only supported in very new binutils, so define them 11 they are only supported in very new binutils, so define them
13 away for older version. 12 away for older version.
14 */ 13 */
15 14
16#ifdef CONFIG_AS_CFI 15#ifdef CONFIG_AS_CFI
diff --git a/include/asm-x86/e820_32.h b/include/asm-x86/e820_32.h
index e7207a6de3e0..a9f7c6ec32bf 100644
--- a/include/asm-x86/e820_32.h
+++ b/include/asm-x86/e820_32.h
@@ -24,7 +24,7 @@ extern void update_e820(void);
24extern int e820_all_mapped(unsigned long start, unsigned long end, 24extern int e820_all_mapped(unsigned long start, unsigned long end,
25 unsigned type); 25 unsigned type);
26extern int e820_any_mapped(u64 start, u64 end, unsigned type); 26extern int e820_any_mapped(u64 start, u64 end, unsigned type);
27extern void find_max_pfn(void); 27extern void propagate_e820_map(void);
28extern 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, 29extern void add_memory_region(unsigned long long start,
30 unsigned long long size, int type); 30 unsigned long long size, int type);
@@ -34,8 +34,8 @@ extern void e820_register_memory(void);
34extern void limit_regions(unsigned long long size); 34extern void limit_regions(unsigned long long size);
35extern void print_memory_map(char *who); 35extern void print_memory_map(char *who);
36extern void init_iomem_resources(struct resource *code_resource, 36extern void init_iomem_resources(struct resource *code_resource,
37 struct resource *data_resource, 37 struct resource *data_resource,
38 struct resource *bss_resource); 38 struct resource *bss_resource);
39 39
40#if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION) 40#if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION)
41extern void e820_mark_nosave_regions(void); 41extern void e820_mark_nosave_regions(void);
diff --git a/include/asm-x86/e820_64.h b/include/asm-x86/e820_64.h
index 22ede73ae724..71c4d685d30d 100644
--- a/include/asm-x86/e820_64.h
+++ b/include/asm-x86/e820_64.h
@@ -14,20 +14,24 @@
14#include <linux/ioport.h> 14#include <linux/ioport.h>
15 15
16#ifndef __ASSEMBLY__ 16#ifndef __ASSEMBLY__
17extern unsigned long find_e820_area(unsigned long start, unsigned long end, 17extern unsigned long find_e820_area(unsigned long start, unsigned long end,
18 unsigned size, unsigned long align); 18 unsigned long size, unsigned long align);
19extern void add_memory_region(unsigned long start, unsigned long size, 19extern unsigned long find_e820_area_size(unsigned long start,
20 unsigned long *sizep,
21 unsigned long align);
22extern void add_memory_region(unsigned long start, unsigned long size,
20 int type); 23 int type);
21extern void update_memory_range(u64 start, u64 size, unsigned old_type, 24extern void update_memory_range(u64 start, u64 size, unsigned old_type,
22 unsigned new_type); 25 unsigned new_type);
23extern void setup_memory_region(void); 26extern void setup_memory_region(void);
24extern void contig_e820_setup(void); 27extern void contig_e820_setup(void);
25extern unsigned long e820_end_of_ram(void); 28extern unsigned long e820_end_of_ram(void);
26extern void e820_reserve_resources(struct resource *code_resource, 29extern void e820_reserve_resources(void);
27 struct resource *data_resource, struct resource *bss_resource);
28extern void e820_mark_nosave_regions(void); 30extern void e820_mark_nosave_regions(void);
29extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type); 31extern int e820_any_mapped(unsigned long start, unsigned long end,
30extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type); 32 unsigned type);
33extern int e820_all_mapped(unsigned long start, unsigned long end,
34 unsigned type);
31extern int e820_any_non_reserved(unsigned long start, unsigned long end); 35extern int e820_any_non_reserved(unsigned long start, unsigned long end);
32extern int is_memory_any_valid(unsigned long start, unsigned long end); 36extern int is_memory_any_valid(unsigned long start, unsigned long end);
33extern int e820_all_non_reserved(unsigned long start, unsigned long end); 37extern int e820_all_non_reserved(unsigned long start, unsigned long end);
@@ -35,8 +39,8 @@ extern int is_memory_all_valid(unsigned long start, unsigned long end);
35extern unsigned long e820_hole_size(unsigned long start, unsigned long end); 39extern unsigned long e820_hole_size(unsigned long start, unsigned long end);
36 40
37extern void e820_setup_gap(void); 41extern void e820_setup_gap(void);
38extern void e820_register_active_regions(int nid, 42extern void e820_register_active_regions(int nid, unsigned long start_pfn,
39 unsigned long start_pfn, unsigned long end_pfn); 43 unsigned long end_pfn);
40 44
41extern void finish_e820_parsing(void); 45extern void finish_e820_parsing(void);
42 46
@@ -44,7 +48,8 @@ extern struct e820map e820;
44extern void update_e820(void); 48extern void update_e820(void);
45 49
46extern void reserve_early(unsigned long start, unsigned long end, char *name); 50extern void reserve_early(unsigned long start, unsigned long end, char *name);
47extern void early_res_to_bootmem(void); 51extern void free_early(unsigned long start, unsigned long end);
52extern void early_res_to_bootmem(unsigned long start, unsigned long end);
48 53
49#endif/*!__ASSEMBLY__*/ 54#endif/*!__ASSEMBLY__*/
50 55
diff --git a/include/asm-x86/edac.h b/include/asm-x86/edac.h
index cf3200a745ad..a8088f63a30e 100644
--- a/include/asm-x86/edac.h
+++ b/include/asm-x86/edac.h
@@ -3,7 +3,7 @@
3 3
4/* ECC atomic, DMA, SMP and interrupt safe scrub function */ 4/* ECC atomic, DMA, SMP and interrupt safe scrub function */
5 5
6static __inline__ void atomic_scrub(void *va, u32 size) 6static inline void atomic_scrub(void *va, u32 size)
7{ 7{
8 u32 i, *virt_addr = va; 8 u32 i, *virt_addr = va;
9 9
@@ -12,7 +12,7 @@ static __inline__ void atomic_scrub(void *va, u32 size)
12 * are interrupt, DMA and SMP safe. 12 * are interrupt, DMA and SMP safe.
13 */ 13 */
14 for (i = 0; i < size / 4; i++, virt_addr++) 14 for (i = 0; i < size / 4; i++, virt_addr++)
15 __asm__ __volatile__("lock; addl $0, %0"::"m"(*virt_addr)); 15 asm volatile("lock; addl $0, %0"::"m" (*virt_addr));
16} 16}
17 17
18#endif 18#endif
diff --git a/include/asm-x86/efi.h b/include/asm-x86/efi.h
index ea9734b74aca..d53004b855cc 100644
--- a/include/asm-x86/efi.h
+++ b/include/asm-x86/efi.h
@@ -20,7 +20,7 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...);
20 */ 20 */
21 21
22#define efi_call_virt(f, args...) \ 22#define efi_call_virt(f, args...) \
23 ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args) 23 ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args)
24 24
25#define efi_call_virt0(f) efi_call_virt(f) 25#define efi_call_virt0(f) efi_call_virt(f)
26#define efi_call_virt1(f, a1) efi_call_virt(f, a1) 26#define efi_call_virt1(f, a1) efi_call_virt(f, a1)
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h
index fb62f9941e38..8f232dc5b5fe 100644
--- a/include/asm-x86/elf.h
+++ b/include/asm-x86/elf.h
@@ -11,7 +11,7 @@
11 11
12typedef unsigned long elf_greg_t; 12typedef unsigned long elf_greg_t;
13 13
14#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) 14#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
15typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 15typedef elf_greg_t elf_gregset_t[ELF_NGREG];
16 16
17typedef struct user_i387_struct elf_fpregset_t; 17typedef struct user_i387_struct elf_fpregset_t;
@@ -82,8 +82,9 @@ extern unsigned int vdso_enabled;
82#define elf_check_arch_ia32(x) \ 82#define elf_check_arch_ia32(x) \
83 (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) 83 (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486))
84 84
85#ifdef CONFIG_X86_32
86#include <asm/processor.h> 85#include <asm/processor.h>
86
87#ifdef CONFIG_X86_32
87#include <asm/system.h> /* for savesegment */ 88#include <asm/system.h> /* for savesegment */
88#include <asm/desc.h> 89#include <asm/desc.h>
89 90
@@ -99,10 +100,11 @@ extern unsigned int vdso_enabled;
99 We might as well make sure everything else is cleared too (except for %esp), 100 We might as well make sure everything else is cleared too (except for %esp),
100 just to make things more deterministic. 101 just to make things more deterministic.
101 */ 102 */
102#define ELF_PLAT_INIT(_r, load_addr) do { \ 103#define ELF_PLAT_INIT(_r, load_addr) \
103 _r->bx = 0; _r->cx = 0; _r->dx = 0; \ 104 do { \
104 _r->si = 0; _r->di = 0; _r->bp = 0; \ 105 _r->bx = 0; _r->cx = 0; _r->dx = 0; \
105 _r->ax = 0; \ 106 _r->si = 0; _r->di = 0; _r->bp = 0; \
107 _r->ax = 0; \
106} while (0) 108} while (0)
107 109
108/* 110/*
@@ -110,24 +112,25 @@ extern unsigned int vdso_enabled;
110 * now struct_user_regs, they are different) 112 * now struct_user_regs, they are different)
111 */ 113 */
112 114
113#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ 115#define ELF_CORE_COPY_REGS(pr_reg, regs) \
114 pr_reg[0] = regs->bx; \ 116do { \
115 pr_reg[1] = regs->cx; \ 117 pr_reg[0] = regs->bx; \
116 pr_reg[2] = regs->dx; \ 118 pr_reg[1] = regs->cx; \
117 pr_reg[3] = regs->si; \ 119 pr_reg[2] = regs->dx; \
118 pr_reg[4] = regs->di; \ 120 pr_reg[3] = regs->si; \
119 pr_reg[5] = regs->bp; \ 121 pr_reg[4] = regs->di; \
120 pr_reg[6] = regs->ax; \ 122 pr_reg[5] = regs->bp; \
121 pr_reg[7] = regs->ds & 0xffff; \ 123 pr_reg[6] = regs->ax; \
122 pr_reg[8] = regs->es & 0xffff; \ 124 pr_reg[7] = regs->ds & 0xffff; \
123 pr_reg[9] = regs->fs & 0xffff; \ 125 pr_reg[8] = regs->es & 0xffff; \
124 savesegment(gs, pr_reg[10]); \ 126 pr_reg[9] = regs->fs & 0xffff; \
125 pr_reg[11] = regs->orig_ax; \ 127 savesegment(gs, pr_reg[10]); \
126 pr_reg[12] = regs->ip; \ 128 pr_reg[11] = regs->orig_ax; \
127 pr_reg[13] = regs->cs & 0xffff; \ 129 pr_reg[12] = regs->ip; \
128 pr_reg[14] = regs->flags; \ 130 pr_reg[13] = regs->cs & 0xffff; \
129 pr_reg[15] = regs->sp; \ 131 pr_reg[14] = regs->flags; \
130 pr_reg[16] = regs->ss & 0xffff; \ 132 pr_reg[15] = regs->sp; \
133 pr_reg[16] = regs->ss & 0xffff; \
131} while (0); 134} while (0);
132 135
133#define ELF_PLATFORM (utsname()->machine) 136#define ELF_PLATFORM (utsname()->machine)
@@ -135,12 +138,10 @@ extern unsigned int vdso_enabled;
135 138
136#else /* CONFIG_X86_32 */ 139#else /* CONFIG_X86_32 */
137 140
138#include <asm/processor.h>
139
140/* 141/*
141 * This is used to ensure we don't load something for the wrong architecture. 142 * This is used to ensure we don't load something for the wrong architecture.
142 */ 143 */
143#define elf_check_arch(x) \ 144#define elf_check_arch(x) \
144 ((x)->e_machine == EM_X86_64) 145 ((x)->e_machine == EM_X86_64)
145 146
146#define compat_elf_check_arch(x) elf_check_arch_ia32(x) 147#define compat_elf_check_arch(x) elf_check_arch_ia32(x)
@@ -169,24 +170,30 @@ static inline void elf_common_init(struct thread_struct *t,
169 t->ds = t->es = ds; 170 t->ds = t->es = ds;
170} 171}
171 172
172#define ELF_PLAT_INIT(_r, load_addr) do { \ 173#define ELF_PLAT_INIT(_r, load_addr) \
173 elf_common_init(&current->thread, _r, 0); \ 174do { \
174 clear_thread_flag(TIF_IA32); \ 175 elf_common_init(&current->thread, _r, 0); \
176 clear_thread_flag(TIF_IA32); \
175} while (0) 177} while (0)
176 178
177#define COMPAT_ELF_PLAT_INIT(regs, load_addr) \ 179#define COMPAT_ELF_PLAT_INIT(regs, load_addr) \
178 elf_common_init(&current->thread, regs, __USER_DS) 180 elf_common_init(&current->thread, regs, __USER_DS)
179#define compat_start_thread(regs, ip, sp) do { \ 181
180 start_ia32_thread(regs, ip, sp); \ 182#define compat_start_thread(regs, ip, sp) \
181 set_fs(USER_DS); \ 183do { \
182 } while (0) 184 start_ia32_thread(regs, ip, sp); \
183#define COMPAT_SET_PERSONALITY(ex, ibcs2) do { \ 185 set_fs(USER_DS); \
184 if (test_thread_flag(TIF_IA32)) \ 186} while (0)
185 clear_thread_flag(TIF_ABI_PENDING); \ 187
186 else \ 188#define COMPAT_SET_PERSONALITY(ex, ibcs2) \
187 set_thread_flag(TIF_ABI_PENDING); \ 189do { \
188 current->personality |= force_personality32; \ 190 if (test_thread_flag(TIF_IA32)) \
189 } while (0) 191 clear_thread_flag(TIF_ABI_PENDING); \
192 else \
193 set_thread_flag(TIF_ABI_PENDING); \
194 current->personality |= force_personality32; \
195} while (0)
196
190#define COMPAT_ELF_PLATFORM ("i686") 197#define COMPAT_ELF_PLATFORM ("i686")
191 198
192/* 199/*
@@ -195,7 +202,8 @@ static inline void elf_common_init(struct thread_struct *t,
195 * getting dumped. 202 * getting dumped.
196 */ 203 */
197 204
198#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ 205#define ELF_CORE_COPY_REGS(pr_reg, regs) \
206do { \
199 unsigned v; \ 207 unsigned v; \
200 (pr_reg)[0] = (regs)->r15; \ 208 (pr_reg)[0] = (regs)->r15; \
201 (pr_reg)[1] = (regs)->r14; \ 209 (pr_reg)[1] = (regs)->r14; \
@@ -269,10 +277,12 @@ extern int force_personality32;
269 277
270struct task_struct; 278struct task_struct;
271 279
272#define ARCH_DLINFO_IA32(vdso_enabled) \ 280#define ARCH_DLINFO_IA32(vdso_enabled) \
273do if (vdso_enabled) { \ 281do { \
282 if (vdso_enabled) { \
274 NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ 283 NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \
275 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ 284 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \
285 } \
276} while (0) 286} while (0)
277 287
278#ifdef CONFIG_X86_32 288#ifdef CONFIG_X86_32
@@ -290,9 +300,11 @@ do if (vdso_enabled) { \
290/* 1GB for 64bit, 8MB for 32bit */ 300/* 1GB for 64bit, 8MB for 32bit */
291#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff) 301#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff)
292 302
293#define ARCH_DLINFO \ 303#define ARCH_DLINFO \
294do if (vdso_enabled) { \ 304do { \
295 NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\ 305 if (vdso_enabled) \
306 NEW_AUX_ENT(AT_SYSINFO_EHDR, \
307 (unsigned long)current->mm->context.vdso); \
296} while (0) 308} while (0)
297 309
298#define AT_SYSINFO 32 310#define AT_SYSINFO 32
@@ -305,8 +317,8 @@ do if (vdso_enabled) { \
305 317
306#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso) 318#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
307 319
308#define VDSO_ENTRY \ 320#define VDSO_ENTRY \
309 ((unsigned long) VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall)) 321 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
310 322
311struct linux_binprm; 323struct linux_binprm;
312 324
diff --git a/include/asm-x86/fixmap.h b/include/asm-x86/fixmap.h
index 382eb271a892..5bd206973dca 100644
--- a/include/asm-x86/fixmap.h
+++ b/include/asm-x86/fixmap.h
@@ -1,5 +1,13 @@
1#ifndef _ASM_FIXMAP_H
2#define _ASM_FIXMAP_H
3
1#ifdef CONFIG_X86_32 4#ifdef CONFIG_X86_32
2# include "fixmap_32.h" 5# include "fixmap_32.h"
3#else 6#else
4# include "fixmap_64.h" 7# include "fixmap_64.h"
5#endif 8#endif
9
10#define clear_fixmap(idx) \
11 __set_fixmap(idx, 0, __pgprot(0))
12
13#endif
diff --git a/include/asm-x86/fixmap_32.h b/include/asm-x86/fixmap_32.h
index a7404d50686b..4b96148e90c1 100644
--- a/include/asm-x86/fixmap_32.h
+++ b/include/asm-x86/fixmap_32.h
@@ -10,8 +10,8 @@
10 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 10 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
11 */ 11 */
12 12
13#ifndef _ASM_FIXMAP_H 13#ifndef _ASM_FIXMAP_32_H
14#define _ASM_FIXMAP_H 14#define _ASM_FIXMAP_32_H
15 15
16 16
17/* used by vmalloc.c, vsyscall.lds.S. 17/* used by vmalloc.c, vsyscall.lds.S.
@@ -99,8 +99,7 @@ enum fixed_addresses {
99 */ 99 */
100#define NR_FIX_BTMAPS 64 100#define NR_FIX_BTMAPS 64
101#define FIX_BTMAPS_NESTING 4 101#define FIX_BTMAPS_NESTING 4
102 FIX_BTMAP_END = 102 FIX_BTMAP_END = __end_of_permanent_fixed_addresses + 512 -
103 __end_of_permanent_fixed_addresses + 512 -
104 (__end_of_permanent_fixed_addresses & 511), 103 (__end_of_permanent_fixed_addresses & 511),
105 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_NESTING - 1, 104 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_NESTING - 1,
106 FIX_WP_TEST, 105 FIX_WP_TEST,
@@ -110,20 +109,17 @@ enum fixed_addresses {
110 __end_of_fixed_addresses 109 __end_of_fixed_addresses
111}; 110};
112 111
113extern void __set_fixmap (enum fixed_addresses idx, 112extern void __set_fixmap(enum fixed_addresses idx,
114 unsigned long phys, pgprot_t flags); 113 unsigned long phys, pgprot_t flags);
115extern void reserve_top_address(unsigned long reserve); 114extern void reserve_top_address(unsigned long reserve);
116 115
117#define set_fixmap(idx, phys) \ 116#define set_fixmap(idx, phys) \
118 __set_fixmap(idx, phys, PAGE_KERNEL) 117 __set_fixmap(idx, phys, PAGE_KERNEL)
119/* 118/*
120 * Some hardware wants to get fixmapped without caching. 119 * Some hardware wants to get fixmapped without caching.
121 */ 120 */
122#define set_fixmap_nocache(idx, phys) \ 121#define set_fixmap_nocache(idx, phys) \
123 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE) 122 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
124
125#define clear_fixmap(idx) \
126 __set_fixmap(idx, 0, __pgprot(0))
127 123
128#define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP) 124#define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP)
129 125
@@ -156,7 +152,7 @@ static __always_inline unsigned long fix_to_virt(const unsigned int idx)
156 if (idx >= __end_of_fixed_addresses) 152 if (idx >= __end_of_fixed_addresses)
157 __this_fixmap_does_not_exist(); 153 __this_fixmap_does_not_exist();
158 154
159 return __fix_to_virt(idx); 155 return __fix_to_virt(idx);
160} 156}
161 157
162static inline unsigned long virt_to_fix(const unsigned long vaddr) 158static inline unsigned long virt_to_fix(const unsigned long vaddr)
diff --git a/include/asm-x86/fixmap_64.h b/include/asm-x86/fixmap_64.h
index 70ddb21e6458..355d26a75a82 100644
--- a/include/asm-x86/fixmap_64.h
+++ b/include/asm-x86/fixmap_64.h
@@ -8,8 +8,8 @@
8 * Copyright (C) 1998 Ingo Molnar 8 * Copyright (C) 1998 Ingo Molnar
9 */ 9 */
10 10
11#ifndef _ASM_FIXMAP_H 11#ifndef _ASM_FIXMAP_64_H
12#define _ASM_FIXMAP_H 12#define _ASM_FIXMAP_64_H
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <asm/apicdef.h> 15#include <asm/apicdef.h>
@@ -34,32 +34,34 @@
34 34
35enum fixed_addresses { 35enum fixed_addresses {
36 VSYSCALL_LAST_PAGE, 36 VSYSCALL_LAST_PAGE,
37 VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1, 37 VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE
38 + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1,
38 VSYSCALL_HPET, 39 VSYSCALL_HPET,
39 FIX_DBGP_BASE, 40 FIX_DBGP_BASE,
40 FIX_EARLYCON_MEM_BASE, 41 FIX_EARLYCON_MEM_BASE,
41 FIX_HPET_BASE, 42 FIX_HPET_BASE,
42 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ 43 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
43 FIX_IO_APIC_BASE_0, 44 FIX_IO_APIC_BASE_0,
44 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, 45 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_LAST_PAGE,
46 FIX_EFI_IO_MAP_FIRST_PAGE = FIX_EFI_IO_MAP_LAST_PAGE+MAX_EFI_IO_PAGES-1, 47 FIX_EFI_IO_MAP_FIRST_PAGE = FIX_EFI_IO_MAP_LAST_PAGE
48 + MAX_EFI_IO_PAGES - 1,
47#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT 49#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
48 FIX_OHCI1394_BASE, 50 FIX_OHCI1394_BASE,
49#endif 51#endif
50 __end_of_fixed_addresses 52 __end_of_fixed_addresses
51}; 53};
52 54
53extern void __set_fixmap (enum fixed_addresses idx, 55extern void __set_fixmap(enum fixed_addresses idx,
54 unsigned long phys, pgprot_t flags); 56 unsigned long phys, pgprot_t flags);
55 57
56#define set_fixmap(idx, phys) \ 58#define set_fixmap(idx, phys) \
57 __set_fixmap(idx, phys, PAGE_KERNEL) 59 __set_fixmap(idx, phys, PAGE_KERNEL)
58/* 60/*
59 * Some hardware wants to get fixmapped without caching. 61 * Some hardware wants to get fixmapped without caching.
60 */ 62 */
61#define set_fixmap_nocache(idx, phys) \ 63#define set_fixmap_nocache(idx, phys) \
62 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE) 64 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
63 65
64#define FIXADDR_TOP (VSYSCALL_END-PAGE_SIZE) 66#define FIXADDR_TOP (VSYSCALL_END-PAGE_SIZE)
65#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 67#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
diff --git a/include/asm-x86/floppy.h b/include/asm-x86/floppy.h
index a48d7153c097..dbe82a5c5eac 100644
--- a/include/asm-x86/floppy.h
+++ b/include/asm-x86/floppy.h
@@ -20,20 +20,21 @@
20 * driver otherwise. It doesn't matter much for performance anyway, as most 20 * driver otherwise. It doesn't matter much for performance anyway, as most
21 * floppy accesses go through the track buffer. 21 * floppy accesses go through the track buffer.
22 */ 22 */
23#define _CROSS_64KB(a,s,vdma) \ 23#define _CROSS_64KB(a, s, vdma) \
24(!(vdma) && ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64)) 24 (!(vdma) && \
25 ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64))
25 26
26#define CROSS_64KB(a,s) _CROSS_64KB(a,s,use_virtual_dma & 1) 27#define CROSS_64KB(a, s) _CROSS_64KB(a, s, use_virtual_dma & 1)
27 28
28 29
29#define SW fd_routine[use_virtual_dma&1] 30#define SW fd_routine[use_virtual_dma & 1]
30#define CSW fd_routine[can_use_virtual_dma & 1] 31#define CSW fd_routine[can_use_virtual_dma & 1]
31 32
32 33
33#define fd_inb(port) inb_p(port) 34#define fd_inb(port) inb_p(port)
34#define fd_outb(value,port) outb_p(value,port) 35#define fd_outb(value, port) outb_p(value, port)
35 36
36#define fd_request_dma() CSW._request_dma(FLOPPY_DMA,"floppy") 37#define fd_request_dma() CSW._request_dma(FLOPPY_DMA, "floppy")
37#define fd_free_dma() CSW._free_dma(FLOPPY_DMA) 38#define fd_free_dma() CSW._free_dma(FLOPPY_DMA)
38#define fd_enable_irq() enable_irq(FLOPPY_IRQ) 39#define fd_enable_irq() enable_irq(FLOPPY_IRQ)
39#define fd_disable_irq() disable_irq(FLOPPY_IRQ) 40#define fd_disable_irq() disable_irq(FLOPPY_IRQ)
@@ -52,64 +53,64 @@ static int doing_pdma;
52 53
53static irqreturn_t floppy_hardint(int irq, void *dev_id) 54static irqreturn_t floppy_hardint(int irq, void *dev_id)
54{ 55{
55 register unsigned char st; 56 unsigned char st;
56 57
57#undef TRACE_FLPY_INT 58#undef TRACE_FLPY_INT
58 59
59#ifdef TRACE_FLPY_INT 60#ifdef TRACE_FLPY_INT
60 static int calls=0; 61 static int calls;
61 static int bytes=0; 62 static int bytes;
62 static int dma_wait=0; 63 static int dma_wait;
63#endif 64#endif
64 if (!doing_pdma) 65 if (!doing_pdma)
65 return floppy_interrupt(irq, dev_id); 66 return floppy_interrupt(irq, dev_id);
66 67
67#ifdef TRACE_FLPY_INT 68#ifdef TRACE_FLPY_INT
68 if(!calls) 69 if (!calls)
69 bytes = virtual_dma_count; 70 bytes = virtual_dma_count;
70#endif 71#endif
71 72
72 { 73 {
73 register int lcount; 74 int lcount;
74 register char *lptr; 75 char *lptr;
75 76
76 st = 1; 77 st = 1;
77 for(lcount=virtual_dma_count, lptr=virtual_dma_addr; 78 for (lcount = virtual_dma_count, lptr = virtual_dma_addr;
78 lcount; lcount--, lptr++) { 79 lcount; lcount--, lptr++) {
79 st=inb(virtual_dma_port+4) & 0xa0 ; 80 st = inb(virtual_dma_port + 4) & 0xa0;
80 if(st != 0xa0) 81 if (st != 0xa0)
81 break; 82 break;
82 if(virtual_dma_mode) 83 if (virtual_dma_mode)
83 outb_p(*lptr, virtual_dma_port+5); 84 outb_p(*lptr, virtual_dma_port + 5);
84 else 85 else
85 *lptr = inb_p(virtual_dma_port+5); 86 *lptr = inb_p(virtual_dma_port + 5);
86 } 87 }
87 virtual_dma_count = lcount; 88 virtual_dma_count = lcount;
88 virtual_dma_addr = lptr; 89 virtual_dma_addr = lptr;
89 st = inb(virtual_dma_port+4); 90 st = inb(virtual_dma_port + 4);
90 } 91 }
91 92
92#ifdef TRACE_FLPY_INT 93#ifdef TRACE_FLPY_INT
93 calls++; 94 calls++;
94#endif 95#endif
95 if(st == 0x20) 96 if (st == 0x20)
96 return IRQ_HANDLED; 97 return IRQ_HANDLED;
97 if(!(st & 0x20)) { 98 if (!(st & 0x20)) {
98 virtual_dma_residue += virtual_dma_count; 99 virtual_dma_residue += virtual_dma_count;
99 virtual_dma_count=0; 100 virtual_dma_count = 0;
100#ifdef TRACE_FLPY_INT 101#ifdef TRACE_FLPY_INT
101 printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n", 102 printk("count=%x, residue=%x calls=%d bytes=%d dma_wait=%d\n",
102 virtual_dma_count, virtual_dma_residue, calls, bytes, 103 virtual_dma_count, virtual_dma_residue, calls, bytes,
103 dma_wait); 104 dma_wait);
104 calls = 0; 105 calls = 0;
105 dma_wait=0; 106 dma_wait = 0;
106#endif 107#endif
107 doing_pdma = 0; 108 doing_pdma = 0;
108 floppy_interrupt(irq, dev_id); 109 floppy_interrupt(irq, dev_id);
109 return IRQ_HANDLED; 110 return IRQ_HANDLED;
110 } 111 }
111#ifdef TRACE_FLPY_INT 112#ifdef TRACE_FLPY_INT
112 if(!virtual_dma_count) 113 if (!virtual_dma_count)
113 dma_wait++; 114 dma_wait++;
114#endif 115#endif
115 return IRQ_HANDLED; 116 return IRQ_HANDLED;
@@ -117,14 +118,14 @@ static irqreturn_t floppy_hardint(int irq, void *dev_id)
117 118
118static void fd_disable_dma(void) 119static void fd_disable_dma(void)
119{ 120{
120 if(! (can_use_virtual_dma & 1)) 121 if (!(can_use_virtual_dma & 1))
121 disable_dma(FLOPPY_DMA); 122 disable_dma(FLOPPY_DMA);
122 doing_pdma = 0; 123 doing_pdma = 0;
123 virtual_dma_residue += virtual_dma_count; 124 virtual_dma_residue += virtual_dma_count;
124 virtual_dma_count=0; 125 virtual_dma_count = 0;
125} 126}
126 127
127static int vdma_request_dma(unsigned int dmanr, const char * device_id) 128static int vdma_request_dma(unsigned int dmanr, const char *device_id)
128{ 129{
129 return 0; 130 return 0;
130} 131}
@@ -142,7 +143,7 @@ static int vdma_get_dma_residue(unsigned int dummy)
142 143
143static int fd_request_irq(void) 144static int fd_request_irq(void)
144{ 145{
145 if(can_use_virtual_dma) 146 if (can_use_virtual_dma)
146 return request_irq(FLOPPY_IRQ, floppy_hardint, 147 return request_irq(FLOPPY_IRQ, floppy_hardint,
147 IRQF_DISABLED, "floppy", NULL); 148 IRQF_DISABLED, "floppy", NULL);
148 else 149 else
@@ -152,13 +153,13 @@ static int fd_request_irq(void)
152 153
153static unsigned long dma_mem_alloc(unsigned long size) 154static unsigned long dma_mem_alloc(unsigned long size)
154{ 155{
155 return __get_dma_pages(GFP_KERNEL|__GFP_NORETRY,get_order(size)); 156 return __get_dma_pages(GFP_KERNEL|__GFP_NORETRY, get_order(size));
156} 157}
157 158
158 159
159static unsigned long vdma_mem_alloc(unsigned long size) 160static unsigned long vdma_mem_alloc(unsigned long size)
160{ 161{
161 return (unsigned long) vmalloc(size); 162 return (unsigned long)vmalloc(size);
162 163
163} 164}
164 165
@@ -166,7 +167,7 @@ static unsigned long vdma_mem_alloc(unsigned long size)
166 167
167static void _fd_dma_mem_free(unsigned long addr, unsigned long size) 168static void _fd_dma_mem_free(unsigned long addr, unsigned long size)
168{ 169{
169 if((unsigned long) addr >= (unsigned long) high_memory) 170 if ((unsigned long)addr >= (unsigned long)high_memory)
170 vfree((void *)addr); 171 vfree((void *)addr);
171 else 172 else
172 free_pages(addr, get_order(size)); 173 free_pages(addr, get_order(size));
@@ -176,10 +177,10 @@ static void _fd_dma_mem_free(unsigned long addr, unsigned long size)
176 177
177static void _fd_chose_dma_mode(char *addr, unsigned long size) 178static void _fd_chose_dma_mode(char *addr, unsigned long size)
178{ 179{
179 if(can_use_virtual_dma == 2) { 180 if (can_use_virtual_dma == 2) {
180 if((unsigned long) addr >= (unsigned long) high_memory || 181 if ((unsigned long)addr >= (unsigned long)high_memory ||
181 isa_virt_to_bus(addr) >= 0x1000000 || 182 isa_virt_to_bus(addr) >= 0x1000000 ||
182 _CROSS_64KB(addr, size, 0)) 183 _CROSS_64KB(addr, size, 0))
183 use_virtual_dma = 1; 184 use_virtual_dma = 1;
184 else 185 else
185 use_virtual_dma = 0; 186 use_virtual_dma = 0;
@@ -195,7 +196,7 @@ static int vdma_dma_setup(char *addr, unsigned long size, int mode, int io)
195{ 196{
196 doing_pdma = 1; 197 doing_pdma = 1;
197 virtual_dma_port = io; 198 virtual_dma_port = io;
198 virtual_dma_mode = (mode == DMA_MODE_WRITE); 199 virtual_dma_mode = (mode == DMA_MODE_WRITE);
199 virtual_dma_addr = addr; 200 virtual_dma_addr = addr;
200 virtual_dma_count = size; 201 virtual_dma_count = size;
201 virtual_dma_residue = 0; 202 virtual_dma_residue = 0;
@@ -213,18 +214,18 @@ static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
213 /* actual, physical DMA */ 214 /* actual, physical DMA */
214 doing_pdma = 0; 215 doing_pdma = 0;
215 clear_dma_ff(FLOPPY_DMA); 216 clear_dma_ff(FLOPPY_DMA);
216 set_dma_mode(FLOPPY_DMA,mode); 217 set_dma_mode(FLOPPY_DMA, mode);
217 set_dma_addr(FLOPPY_DMA,isa_virt_to_bus(addr)); 218 set_dma_addr(FLOPPY_DMA, isa_virt_to_bus(addr));
218 set_dma_count(FLOPPY_DMA,size); 219 set_dma_count(FLOPPY_DMA, size);
219 enable_dma(FLOPPY_DMA); 220 enable_dma(FLOPPY_DMA);
220 return 0; 221 return 0;
221} 222}
222 223
223static struct fd_routine_l { 224static struct fd_routine_l {
224 int (*_request_dma)(unsigned int dmanr, const char * device_id); 225 int (*_request_dma)(unsigned int dmanr, const char *device_id);
225 void (*_free_dma)(unsigned int dmanr); 226 void (*_free_dma)(unsigned int dmanr);
226 int (*_get_dma_residue)(unsigned int dummy); 227 int (*_get_dma_residue)(unsigned int dummy);
227 unsigned long (*_dma_mem_alloc) (unsigned long size); 228 unsigned long (*_dma_mem_alloc)(unsigned long size);
228 int (*_dma_setup)(char *addr, unsigned long size, int mode, int io); 229 int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
229} fd_routine[] = { 230} fd_routine[] = {
230 { 231 {
@@ -252,7 +253,8 @@ static int FDC2 = -1;
252 * is needed to prevent corrupted CMOS RAM in case "insmod floppy" 253 * is needed to prevent corrupted CMOS RAM in case "insmod floppy"
253 * coincides with another rtc CMOS user. Paul G. 254 * coincides with another rtc CMOS user. Paul G.
254 */ 255 */
255#define FLOPPY0_TYPE ({ \ 256#define FLOPPY0_TYPE \
257({ \
256 unsigned long flags; \ 258 unsigned long flags; \
257 unsigned char val; \ 259 unsigned char val; \
258 spin_lock_irqsave(&rtc_lock, flags); \ 260 spin_lock_irqsave(&rtc_lock, flags); \
@@ -261,7 +263,8 @@ static int FDC2 = -1;
261 val; \ 263 val; \
262}) 264})
263 265
264#define FLOPPY1_TYPE ({ \ 266#define FLOPPY1_TYPE \
267({ \
265 unsigned long flags; \ 268 unsigned long flags; \
266 unsigned char val; \ 269 unsigned char val; \
267 spin_lock_irqsave(&rtc_lock, flags); \ 270 spin_lock_irqsave(&rtc_lock, flags); \
diff --git a/include/asm-x86/futex.h b/include/asm-x86/futex.h
index c9952ea9f698..e7a76b37b333 100644
--- a/include/asm-x86/futex.h
+++ b/include/asm-x86/futex.h
@@ -4,43 +4,40 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/futex.h> 6#include <linux/futex.h>
7#include <linux/uaccess.h>
7 8
8#include <asm/asm.h> 9#include <asm/asm.h>
9#include <asm/errno.h> 10#include <asm/errno.h>
10#include <asm/processor.h> 11#include <asm/processor.h>
11#include <asm/system.h> 12#include <asm/system.h>
12#include <asm/uaccess.h>
13 13
14#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \ 14#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15 __asm__ __volatile( \ 15 asm volatile("1:\t" insn "\n" \
16"1: " insn "\n" \ 16 "2:\t.section .fixup,\"ax\"\n" \
17"2: .section .fixup,\"ax\"\n \ 17 "3:\tmov\t%3, %1\n" \
183: mov %3, %1\n \ 18 "\tjmp\t2b\n" \
19 jmp 2b\n \ 19 "\t.previous\n" \
20 .previous\n" \ 20 _ASM_EXTABLE(1b, 3b) \
21 _ASM_EXTABLE(1b,3b) \ 21 : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
22 : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \ 22 : "i" (-EFAULT), "0" (oparg), "1" (0))
23 : "i" (-EFAULT), "0" (oparg), "1" (0))
24 23
25#define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \ 24#define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
26 __asm__ __volatile( \ 25 asm volatile("1:\tmovl %2, %0\n" \
27"1: movl %2, %0\n \ 26 "\tmovl\t%0, %3\n" \
28 movl %0, %3\n" \ 27 "\t" insn "\n" \
29 insn "\n" \ 28 "2:\tlock; cmpxchgl %3, %2\n" \
30"2: lock; cmpxchgl %3, %2\n \ 29 "\tjnz\t1b\n" \
31 jnz 1b\n \ 30 "3:\t.section .fixup,\"ax\"\n" \
323: .section .fixup,\"ax\"\n \ 31 "4:\tmov\t%5, %1\n" \
334: mov %5, %1\n \ 32 "\tjmp\t3b\n" \
34 jmp 3b\n \ 33 "\t.previous\n" \
35 .previous\n" \ 34 _ASM_EXTABLE(1b, 4b) \
36 _ASM_EXTABLE(1b,4b) \ 35 _ASM_EXTABLE(2b, 4b) \
37 _ASM_EXTABLE(2b,4b) \ 36 : "=&a" (oldval), "=&r" (ret), \
38 : "=&a" (oldval), "=&r" (ret), "+m" (*uaddr), \ 37 "+m" (*uaddr), "=&r" (tem) \
39 "=&r" (tem) \ 38 : "r" (oparg), "i" (-EFAULT), "1" (0))
40 : "r" (oparg), "i" (-EFAULT), "1" (0)) 39
41 40static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
42static inline int
43futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
44{ 41{
45 int op = (encoded_op >> 28) & 7; 42 int op = (encoded_op >> 28) & 7;
46 int cmp = (encoded_op >> 24) & 15; 43 int cmp = (encoded_op >> 24) & 15;
@@ -87,20 +84,33 @@ futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
87 84
88 if (!ret) { 85 if (!ret) {
89 switch (cmp) { 86 switch (cmp) {
90 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break; 87 case FUTEX_OP_CMP_EQ:
91 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break; 88 ret = (oldval == cmparg);
92 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break; 89 break;
93 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break; 90 case FUTEX_OP_CMP_NE:
94 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break; 91 ret = (oldval != cmparg);
95 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break; 92 break;
96 default: ret = -ENOSYS; 93 case FUTEX_OP_CMP_LT:
94 ret = (oldval < cmparg);
95 break;
96 case FUTEX_OP_CMP_GE:
97 ret = (oldval >= cmparg);
98 break;
99 case FUTEX_OP_CMP_LE:
100 ret = (oldval <= cmparg);
101 break;
102 case FUTEX_OP_CMP_GT:
103 ret = (oldval > cmparg);
104 break;
105 default:
106 ret = -ENOSYS;
97 } 107 }
98 } 108 }
99 return ret; 109 return ret;
100} 110}
101 111
102static inline int 112static inline int futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval,
103futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) 113 int newval)
104{ 114{
105 115
106#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_BSWAP) 116#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_BSWAP)
@@ -112,16 +122,15 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
112 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) 122 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
113 return -EFAULT; 123 return -EFAULT;
114 124
115 __asm__ __volatile__( 125 asm volatile("1:\tlock; cmpxchgl %3, %1\n"
116 "1: lock; cmpxchgl %3, %1 \n" 126 "2:\t.section .fixup, \"ax\"\n"
117 "2: .section .fixup, \"ax\" \n" 127 "3:\tmov %2, %0\n"
118 "3: mov %2, %0 \n" 128 "\tjmp 2b\n"
119 " jmp 2b \n" 129 "\t.previous\n"
120 " .previous \n" 130 _ASM_EXTABLE(1b, 3b)
121 _ASM_EXTABLE(1b,3b) 131 : "=a" (oldval), "+m" (*uaddr)
122 : "=a" (oldval), "+m" (*uaddr) 132 : "i" (-EFAULT), "r" (newval), "0" (oldval)
123 : "i" (-EFAULT), "r" (newval), "0" (oldval) 133 : "memory"
124 : "memory"
125 ); 134 );
126 135
127 return oldval; 136 return oldval;
diff --git a/include/asm-x86/genapic_32.h b/include/asm-x86/genapic_32.h
index 33e3ffe1766c..b02ea6e17de8 100644
--- a/include/asm-x86/genapic_32.h
+++ b/include/asm-x86/genapic_32.h
@@ -14,23 +14,22 @@
14 * Copyright 2003 Andi Kleen, SuSE Labs. 14 * Copyright 2003 Andi Kleen, SuSE Labs.
15 */ 15 */
16 16
17struct mpc_config_translation;
18struct mpc_config_bus; 17struct mpc_config_bus;
19struct mp_config_table; 18struct mp_config_table;
20struct mpc_config_processor; 19struct mpc_config_processor;
21 20
22struct genapic { 21struct genapic {
23 char *name; 22 char *name;
24 int (*probe)(void); 23 int (*probe)(void);
25 24
26 int (*apic_id_registered)(void); 25 int (*apic_id_registered)(void);
27 cpumask_t (*target_cpus)(void); 26 cpumask_t (*target_cpus)(void);
28 int int_delivery_mode; 27 int int_delivery_mode;
29 int int_dest_mode; 28 int int_dest_mode;
30 int ESR_DISABLE; 29 int ESR_DISABLE;
31 int apic_destination_logical; 30 int apic_destination_logical;
32 unsigned long (*check_apicid_used)(physid_mask_t bitmap, int apicid); 31 unsigned long (*check_apicid_used)(physid_mask_t bitmap, int apicid);
33 unsigned long (*check_apicid_present)(int apicid); 32 unsigned long (*check_apicid_present)(int apicid);
34 int no_balance_irq; 33 int no_balance_irq;
35 int no_ioapic_check; 34 int no_ioapic_check;
36 void (*init_apic_ldr)(void); 35 void (*init_apic_ldr)(void);
@@ -38,28 +37,21 @@ struct genapic {
38 37
39 void (*setup_apic_routing)(void); 38 void (*setup_apic_routing)(void);
40 int (*multi_timer_check)(int apic, int irq); 39 int (*multi_timer_check)(int apic, int irq);
41 int (*apicid_to_node)(int logical_apicid); 40 int (*apicid_to_node)(int logical_apicid);
42 int (*cpu_to_logical_apicid)(int cpu); 41 int (*cpu_to_logical_apicid)(int cpu);
43 int (*cpu_present_to_apicid)(int mps_cpu); 42 int (*cpu_present_to_apicid)(int mps_cpu);
44 physid_mask_t (*apicid_to_cpu_present)(int phys_apicid); 43 physid_mask_t (*apicid_to_cpu_present)(int phys_apicid);
45 int (*mpc_apic_id)(struct mpc_config_processor *m, 44 void (*setup_portio_remap)(void);
46 struct mpc_config_translation *t);
47 void (*setup_portio_remap)(void);
48 int (*check_phys_apicid_present)(int boot_cpu_physical_apicid); 45 int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
49 void (*enable_apic_mode)(void); 46 void (*enable_apic_mode)(void);
50 u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb); 47 u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
51 48
52 /* mpparse */ 49 /* mpparse */
53 void (*mpc_oem_bus_info)(struct mpc_config_bus *, char *,
54 struct mpc_config_translation *);
55 void (*mpc_oem_pci_bus)(struct mpc_config_bus *,
56 struct mpc_config_translation *);
57
58 /* When one of the next two hooks returns 1 the genapic 50 /* When one of the next two hooks returns 1 the genapic
59 is switched to this. Essentially they are additional probe 51 is switched to this. Essentially they are additional probe
60 functions. */ 52 functions. */
61 int (*mps_oem_check)(struct mp_config_table *mpc, char *oem, 53 int (*mps_oem_check)(struct mp_config_table *mpc, char *oem,
62 char *productid); 54 char *productid);
63 int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id); 55 int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
64 56
65 unsigned (*get_apic_id)(unsigned long x); 57 unsigned (*get_apic_id)(unsigned long x);
@@ -72,7 +64,7 @@ struct genapic {
72 void (*send_IPI_allbutself)(int vector); 64 void (*send_IPI_allbutself)(int vector);
73 void (*send_IPI_all)(int vector); 65 void (*send_IPI_all)(int vector);
74#endif 66#endif
75}; 67};
76 68
77#define APICFUNC(x) .x = x, 69#define APICFUNC(x) .x = x,
78 70
@@ -85,43 +77,47 @@ struct genapic {
85#define IPIFUNC(x) 77#define IPIFUNC(x)
86#endif 78#endif
87 79
88#define APIC_INIT(aname, aprobe) { \ 80#define APIC_INIT(aname, aprobe) \
89 .name = aname, \ 81{ \
90 .probe = aprobe, \ 82 .name = aname, \
91 .int_delivery_mode = INT_DELIVERY_MODE, \ 83 .probe = aprobe, \
92 .int_dest_mode = INT_DEST_MODE, \ 84 .int_delivery_mode = INT_DELIVERY_MODE, \
93 .no_balance_irq = NO_BALANCE_IRQ, \ 85 .int_dest_mode = INT_DEST_MODE, \
94 .ESR_DISABLE = esr_disable, \ 86 .no_balance_irq = NO_BALANCE_IRQ, \
95 .apic_destination_logical = APIC_DEST_LOGICAL, \ 87 .ESR_DISABLE = esr_disable, \
96 APICFUNC(apic_id_registered) \ 88 .apic_destination_logical = APIC_DEST_LOGICAL, \
97 APICFUNC(target_cpus) \ 89 APICFUNC(apic_id_registered) \
98 APICFUNC(check_apicid_used) \ 90 APICFUNC(target_cpus) \
99 APICFUNC(check_apicid_present) \ 91 APICFUNC(check_apicid_used) \
100 APICFUNC(init_apic_ldr) \ 92 APICFUNC(check_apicid_present) \
101 APICFUNC(ioapic_phys_id_map) \ 93 APICFUNC(init_apic_ldr) \
102 APICFUNC(setup_apic_routing) \ 94 APICFUNC(ioapic_phys_id_map) \
103 APICFUNC(multi_timer_check) \ 95 APICFUNC(setup_apic_routing) \
104 APICFUNC(apicid_to_node) \ 96 APICFUNC(multi_timer_check) \
105 APICFUNC(cpu_to_logical_apicid) \ 97 APICFUNC(apicid_to_node) \
106 APICFUNC(cpu_present_to_apicid) \ 98 APICFUNC(cpu_to_logical_apicid) \
107 APICFUNC(apicid_to_cpu_present) \ 99 APICFUNC(cpu_present_to_apicid) \
108 APICFUNC(mpc_apic_id) \ 100 APICFUNC(apicid_to_cpu_present) \
109 APICFUNC(setup_portio_remap) \ 101 APICFUNC(setup_portio_remap) \
110 APICFUNC(check_phys_apicid_present) \ 102 APICFUNC(check_phys_apicid_present) \
111 APICFUNC(mpc_oem_bus_info) \ 103 APICFUNC(mps_oem_check) \
112 APICFUNC(mpc_oem_pci_bus) \ 104 APICFUNC(get_apic_id) \
113 APICFUNC(mps_oem_check) \ 105 .apic_id_mask = APIC_ID_MASK, \
114 APICFUNC(get_apic_id) \ 106 APICFUNC(cpu_mask_to_apicid) \
115 .apic_id_mask = APIC_ID_MASK, \ 107 APICFUNC(acpi_madt_oem_check) \
116 APICFUNC(cpu_mask_to_apicid) \ 108 IPIFUNC(send_IPI_mask) \
117 APICFUNC(acpi_madt_oem_check) \ 109 IPIFUNC(send_IPI_allbutself) \
118 IPIFUNC(send_IPI_mask) \ 110 IPIFUNC(send_IPI_all) \
119 IPIFUNC(send_IPI_allbutself) \ 111 APICFUNC(enable_apic_mode) \
120 IPIFUNC(send_IPI_all) \ 112 APICFUNC(phys_pkg_id) \
121 APICFUNC(enable_apic_mode) \ 113}
122 APICFUNC(phys_pkg_id) \
123 }
124 114
125extern struct genapic *genapic; 115extern struct genapic *genapic;
126 116
117enum uv_system_type {UV_NONE, UV_LEGACY_APIC, UV_X2APIC, UV_NON_UNIQUE_APIC};
118#define get_uv_system_type() UV_NONE
119#define is_uv_system() 0
120#define uv_wakeup_secondary(a, b) 1
121
122
127#endif 123#endif
diff --git a/include/asm-x86/genapic_64.h b/include/asm-x86/genapic_64.h
index d7e516ccbaa4..1de931b263ce 100644
--- a/include/asm-x86/genapic_64.h
+++ b/include/asm-x86/genapic_64.h
@@ -33,5 +33,15 @@ extern struct genapic *genapic;
33 33
34extern struct genapic apic_flat; 34extern struct genapic apic_flat;
35extern struct genapic apic_physflat; 35extern struct genapic apic_physflat;
36extern int acpi_madt_oem_check(char *, char *);
37
38enum uv_system_type {UV_NONE, UV_LEGACY_APIC, UV_X2APIC, UV_NON_UNIQUE_APIC};
39extern enum uv_system_type get_uv_system_type(void);
40extern int is_uv_system(void);
41
42extern struct genapic apic_x2apic_uv_x;
43DECLARE_PER_CPU(int, x2apic_extra_bits);
44extern void uv_cpu_init(void);
45extern int uv_wakeup_secondary(int phys_apicid, unsigned int start_rip);
36 46
37#endif 47#endif
diff --git a/include/asm-x86/geode.h b/include/asm-x86/geode.h
index 9e7280092a48..7154dc4de951 100644
--- a/include/asm-x86/geode.h
+++ b/include/asm-x86/geode.h
@@ -30,7 +30,13 @@ extern int geode_get_dev_base(unsigned int dev);
30 30
31/* MSRS */ 31/* MSRS */
32 32
33#define GX_GLCP_SYS_RSTPLL 0x4C000014 33#define MSR_GLIU_P2D_RO0 0x10000029
34
35#define MSR_LX_GLD_MSR_CONFIG 0x48002001
36#define MSR_LX_MSR_PADSEL 0x48002011 /* NOT 0x48000011; the data
37 * sheet has the wrong value */
38#define MSR_GLCP_SYS_RSTPLL 0x4C000014
39#define MSR_GLCP_DOTPLL 0x4C000015
34 40
35#define MSR_LBAR_SMB 0x5140000B 41#define MSR_LBAR_SMB 0x5140000B
36#define MSR_LBAR_GPIO 0x5140000C 42#define MSR_LBAR_GPIO 0x5140000C
@@ -45,8 +51,14 @@ extern int geode_get_dev_base(unsigned int dev);
45#define MSR_PIC_ZSEL_LOW 0x51400022 51#define MSR_PIC_ZSEL_LOW 0x51400022
46#define MSR_PIC_ZSEL_HIGH 0x51400023 52#define MSR_PIC_ZSEL_HIGH 0x51400023
47 53
48#define MFGPT_IRQ_MSR 0x51400028 54#define MSR_MFGPT_IRQ 0x51400028
49#define MFGPT_NR_MSR 0x51400029 55#define MSR_MFGPT_NR 0x51400029
56#define MSR_MFGPT_SETUP 0x5140002B
57
58#define MSR_LX_SPARE_MSR 0x80000011 /* DC-specific */
59
60#define MSR_GX_GLD_MSR_CONFIG 0xC0002001
61#define MSR_GX_MSR_PADSEL 0xC0002011
50 62
51/* Resource Sizes */ 63/* Resource Sizes */
52 64
@@ -93,6 +105,15 @@ extern int geode_get_dev_base(unsigned int dev);
93#define PM_AWKD 0x50 105#define PM_AWKD 0x50
94#define PM_SSC 0x54 106#define PM_SSC 0x54
95 107
108/* VSA2 magic values */
109
110#define VSA_VRC_INDEX 0xAC1C
111#define VSA_VRC_DATA 0xAC1E
112#define VSA_VR_UNLOCK 0xFC53 /* unlock virtual register */
113#define VSA_VR_SIGNATURE 0x0003
114#define VSA_VR_MEM_SIZE 0x0200
115#define VSA_SIG 0x4132 /* signature is ascii 'VSA2' */
116
96/* GPIO */ 117/* GPIO */
97 118
98#define GPIO_OUTPUT_VAL 0x00 119#define GPIO_OUTPUT_VAL 0x00
@@ -164,10 +185,21 @@ static inline int is_geode(void)
164 return (is_geode_gx() || is_geode_lx()); 185 return (is_geode_gx() || is_geode_lx());
165} 186}
166 187
188/*
189 * The VSA has virtual registers that we can query for a signature.
190 */
191static inline int geode_has_vsa2(void)
192{
193 outw(VSA_VR_UNLOCK, VSA_VRC_INDEX);
194 outw(VSA_VR_SIGNATURE, VSA_VRC_INDEX);
195
196 return (inw(VSA_VRC_DATA) == VSA_SIG);
197}
198
167/* MFGPTs */ 199/* MFGPTs */
168 200
169#define MFGPT_MAX_TIMERS 8 201#define MFGPT_MAX_TIMERS 8
170#define MFGPT_TIMER_ANY -1 202#define MFGPT_TIMER_ANY (-1)
171 203
172#define MFGPT_DOMAIN_WORKING 1 204#define MFGPT_DOMAIN_WORKING 1
173#define MFGPT_DOMAIN_STANDBY 2 205#define MFGPT_DOMAIN_STANDBY 2
diff --git a/include/asm-x86/highmem.h b/include/asm-x86/highmem.h
index 479767c9195f..e153f3b44774 100644
--- a/include/asm-x86/highmem.h
+++ b/include/asm-x86/highmem.h
@@ -8,7 +8,7 @@
8 * Gerhard.Wichert@pdb.siemens.de 8 * Gerhard.Wichert@pdb.siemens.de
9 * 9 *
10 * 10 *
11 * Redesigned the x86 32-bit VM architecture to deal with 11 * Redesigned the x86 32-bit VM architecture to deal with
12 * up to 16 Terabyte physical memory. With current x86 CPUs 12 * up to 16 Terabyte physical memory. With current x86 CPUs
13 * we now support up to 64 Gigabytes physical RAM. 13 * we now support up to 64 Gigabytes physical RAM.
14 * 14 *
diff --git a/include/asm-x86/hugetlb.h b/include/asm-x86/hugetlb.h
new file mode 100644
index 000000000000..14171a4924f6
--- /dev/null
+++ b/include/asm-x86/hugetlb.h
@@ -0,0 +1,91 @@
1#ifndef _ASM_X86_HUGETLB_H
2#define _ASM_X86_HUGETLB_H
3
4#include <asm/page.h>
5
6
7static inline int is_hugepage_only_range(struct mm_struct *mm,
8 unsigned long addr,
9 unsigned long len) {
10 return 0;
11}
12
13/*
14 * If the arch doesn't supply something else, assume that hugepage
15 * size aligned regions are ok without further preparation.
16 */
17static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
18{
19 if (len & ~HPAGE_MASK)
20 return -EINVAL;
21 if (addr & ~HPAGE_MASK)
22 return -EINVAL;
23 return 0;
24}
25
26static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm) {
27}
28
29static inline void hugetlb_free_pgd_range(struct mmu_gather **tlb,
30 unsigned long addr, unsigned long end,
31 unsigned long floor,
32 unsigned long ceiling)
33{
34 free_pgd_range(tlb, addr, end, floor, ceiling);
35}
36
37static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
38 pte_t *ptep, pte_t pte)
39{
40 set_pte_at(mm, addr, ptep, pte);
41}
42
43static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
44 unsigned long addr, pte_t *ptep)
45{
46 return ptep_get_and_clear(mm, addr, ptep);
47}
48
49static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
50 unsigned long addr, pte_t *ptep)
51{
52}
53
54static inline int huge_pte_none(pte_t pte)
55{
56 return pte_none(pte);
57}
58
59static inline pte_t huge_pte_wrprotect(pte_t pte)
60{
61 return pte_wrprotect(pte);
62}
63
64static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
65 unsigned long addr, pte_t *ptep)
66{
67 ptep_set_wrprotect(mm, addr, ptep);
68}
69
70static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
71 unsigned long addr, pte_t *ptep,
72 pte_t pte, int dirty)
73{
74 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
75}
76
77static inline pte_t huge_ptep_get(pte_t *ptep)
78{
79 return *ptep;
80}
81
82static inline int arch_prepare_hugepage(struct page *page)
83{
84 return 0;
85}
86
87static inline void arch_release_hugepage(struct page *page)
88{
89}
90
91#endif /* _ASM_X86_HUGETLB_H */
diff --git a/include/asm-x86/hw_irq_64.h b/include/asm-x86/hw_irq_64.h
index 312a58d6dac6..0062ef390f67 100644
--- a/include/asm-x86/hw_irq_64.h
+++ b/include/asm-x86/hw_irq_64.h
@@ -36,7 +36,7 @@
36 * cleanup after irq migration. 36 * cleanup after irq migration.
37 */ 37 */
38#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR 38#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR
39 39
40/* 40/*
41 * Vectors 0x30-0x3f are used for ISA interrupts. 41 * Vectors 0x30-0x3f are used for ISA interrupts.
42 */ 42 */
@@ -159,13 +159,12 @@ extern atomic_t irq_mis_count;
159 * SMP has a few special interrupts for IPI messages 159 * SMP has a few special interrupts for IPI messages
160 */ 160 */
161 161
162#define BUILD_IRQ(nr) \ 162#define BUILD_IRQ(nr) \
163asmlinkage void IRQ_NAME(nr); \ 163 asmlinkage void IRQ_NAME(nr); \
164__asm__( \ 164 asm("\n.p2align\n" \
165"\n.p2align\n" \ 165 "IRQ" #nr "_interrupt:\n\t" \
166"IRQ" #nr "_interrupt:\n\t" \ 166 "push $~(" #nr ") ; " \
167 "push $~(" #nr ") ; " \ 167 "jmp common_interrupt");
168 "jmp common_interrupt");
169 168
170#define platform_legacy_irq(irq) ((irq) < 16) 169#define platform_legacy_irq(irq) ((irq) < 16)
171 170
diff --git a/include/asm-x86/hypertransport.h b/include/asm-x86/hypertransport.h
index c16c6ff4bdd7..d2bbd238b3e1 100644
--- a/include/asm-x86/hypertransport.h
+++ b/include/asm-x86/hypertransport.h
@@ -8,12 +8,14 @@
8#define HT_IRQ_LOW_BASE 0xf8000000 8#define HT_IRQ_LOW_BASE 0xf8000000
9 9
10#define HT_IRQ_LOW_VECTOR_SHIFT 16 10#define HT_IRQ_LOW_VECTOR_SHIFT 16
11#define HT_IRQ_LOW_VECTOR_MASK 0x00ff0000 11#define HT_IRQ_LOW_VECTOR_MASK 0x00ff0000
12#define HT_IRQ_LOW_VECTOR(v) (((v) << HT_IRQ_LOW_VECTOR_SHIFT) & HT_IRQ_LOW_VECTOR_MASK) 12#define HT_IRQ_LOW_VECTOR(v) \
13 (((v) << HT_IRQ_LOW_VECTOR_SHIFT) & HT_IRQ_LOW_VECTOR_MASK)
13 14
14#define HT_IRQ_LOW_DEST_ID_SHIFT 8 15#define HT_IRQ_LOW_DEST_ID_SHIFT 8
15#define HT_IRQ_LOW_DEST_ID_MASK 0x0000ff00 16#define HT_IRQ_LOW_DEST_ID_MASK 0x0000ff00
16#define HT_IRQ_LOW_DEST_ID(v) (((v) << HT_IRQ_LOW_DEST_ID_SHIFT) & HT_IRQ_LOW_DEST_ID_MASK) 17#define HT_IRQ_LOW_DEST_ID(v) \
18 (((v) << HT_IRQ_LOW_DEST_ID_SHIFT) & HT_IRQ_LOW_DEST_ID_MASK)
17 19
18#define HT_IRQ_LOW_DM_PHYSICAL 0x0000000 20#define HT_IRQ_LOW_DM_PHYSICAL 0x0000000
19#define HT_IRQ_LOW_DM_LOGICAL 0x0000040 21#define HT_IRQ_LOW_DM_LOGICAL 0x0000040
@@ -36,7 +38,8 @@
36 38
37 39
38#define HT_IRQ_HIGH_DEST_ID_SHIFT 0 40#define HT_IRQ_HIGH_DEST_ID_SHIFT 0
39#define HT_IRQ_HIGH_DEST_ID_MASK 0x00ffffff 41#define HT_IRQ_HIGH_DEST_ID_MASK 0x00ffffff
40#define HT_IRQ_HIGH_DEST_ID(v) ((((v) >> 8) << HT_IRQ_HIGH_DEST_ID_SHIFT) & HT_IRQ_HIGH_DEST_ID_MASK) 42#define HT_IRQ_HIGH_DEST_ID(v) \
43 ((((v) >> 8) << HT_IRQ_HIGH_DEST_ID_SHIFT) & HT_IRQ_HIGH_DEST_ID_MASK)
41 44
42#endif /* ASM_HYPERTRANSPORT_H */ 45#endif /* ASM_HYPERTRANSPORT_H */
diff --git a/include/asm-x86/i387.h b/include/asm-x86/i387.h
index f377b76b2f34..da2adb45f6e3 100644
--- a/include/asm-x86/i387.h
+++ b/include/asm-x86/i387.h
@@ -21,8 +21,9 @@
21 21
22extern void fpu_init(void); 22extern void fpu_init(void);
23extern void mxcsr_feature_mask_init(void); 23extern void mxcsr_feature_mask_init(void);
24extern void init_fpu(struct task_struct *child); 24extern int init_fpu(struct task_struct *child);
25extern asmlinkage void math_state_restore(void); 25extern asmlinkage void math_state_restore(void);
26extern void init_thread_xstate(void);
26 27
27extern user_regset_active_fn fpregs_active, xfpregs_active; 28extern user_regset_active_fn fpregs_active, xfpregs_active;
28extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get; 29extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get;
@@ -41,7 +42,7 @@ static inline void tolerant_fwait(void)
41{ 42{
42 asm volatile("1: fwait\n" 43 asm volatile("1: fwait\n"
43 "2:\n" 44 "2:\n"
44 _ASM_EXTABLE(1b,2b)); 45 _ASM_EXTABLE(1b, 2b));
45} 46}
46 47
47static inline int restore_fpu_checking(struct i387_fxsave_struct *fx) 48static inline int restore_fpu_checking(struct i387_fxsave_struct *fx)
@@ -54,7 +55,7 @@ static inline int restore_fpu_checking(struct i387_fxsave_struct *fx)
54 "3: movl $-1,%[err]\n" 55 "3: movl $-1,%[err]\n"
55 " jmp 2b\n" 56 " jmp 2b\n"
56 ".previous\n" 57 ".previous\n"
57 _ASM_EXTABLE(1b,3b) 58 _ASM_EXTABLE(1b, 3b)
58 : [err] "=r" (err) 59 : [err] "=r" (err)
59#if 0 /* See comment in __save_init_fpu() below. */ 60#if 0 /* See comment in __save_init_fpu() below. */
60 : [fx] "r" (fx), "m" (*fx), "0" (0)); 61 : [fx] "r" (fx), "m" (*fx), "0" (0));
@@ -76,11 +77,11 @@ static inline int restore_fpu_checking(struct i387_fxsave_struct *fx)
76static inline void clear_fpu_state(struct i387_fxsave_struct *fx) 77static inline void clear_fpu_state(struct i387_fxsave_struct *fx)
77{ 78{
78 if (unlikely(fx->swd & X87_FSW_ES)) 79 if (unlikely(fx->swd & X87_FSW_ES))
79 asm volatile("fnclex"); 80 asm volatile("fnclex");
80 alternative_input(ASM_NOP8 ASM_NOP2, 81 alternative_input(ASM_NOP8 ASM_NOP2,
81 " emms\n" /* clear stack tags */ 82 " emms\n" /* clear stack tags */
82 " fildl %%gs:0", /* load to clear state */ 83 " fildl %%gs:0", /* load to clear state */
83 X86_FEATURE_FXSAVE_LEAK); 84 X86_FEATURE_FXSAVE_LEAK);
84} 85}
85 86
86static inline int save_i387_checking(struct i387_fxsave_struct __user *fx) 87static inline int save_i387_checking(struct i387_fxsave_struct __user *fx)
@@ -93,14 +94,15 @@ static inline int save_i387_checking(struct i387_fxsave_struct __user *fx)
93 "3: movl $-1,%[err]\n" 94 "3: movl $-1,%[err]\n"
94 " jmp 2b\n" 95 " jmp 2b\n"
95 ".previous\n" 96 ".previous\n"
96 _ASM_EXTABLE(1b,3b) 97 _ASM_EXTABLE(1b, 3b)
97 : [err] "=r" (err), "=m" (*fx) 98 : [err] "=r" (err), "=m" (*fx)
98#if 0 /* See comment in __fxsave_clear() below. */ 99#if 0 /* See comment in __fxsave_clear() below. */
99 : [fx] "r" (fx), "0" (0)); 100 : [fx] "r" (fx), "0" (0));
100#else 101#else
101 : [fx] "cdaSDb" (fx), "0" (0)); 102 : [fx] "cdaSDb" (fx), "0" (0));
102#endif 103#endif
103 if (unlikely(err) && __clear_user(fx, sizeof(struct i387_fxsave_struct))) 104 if (unlikely(err) &&
105 __clear_user(fx, sizeof(struct i387_fxsave_struct)))
104 err = -EFAULT; 106 err = -EFAULT;
105 /* No need to clear here because the caller clears USED_MATH */ 107 /* No need to clear here because the caller clears USED_MATH */
106 return err; 108 return err;
@@ -116,24 +118,22 @@ static inline void __save_init_fpu(struct task_struct *tsk)
116 /* Using "fxsaveq %0" would be the ideal choice, but is only supported 118 /* Using "fxsaveq %0" would be the ideal choice, but is only supported
117 starting with gas 2.16. */ 119 starting with gas 2.16. */
118 __asm__ __volatile__("fxsaveq %0" 120 __asm__ __volatile__("fxsaveq %0"
119 : "=m" (tsk->thread.i387.fxsave)); 121 : "=m" (tsk->thread.xstate->fxsave));
120#elif 0 122#elif 0
121 /* Using, as a workaround, the properly prefixed form below isn't 123 /* Using, as a workaround, the properly prefixed form below isn't
122 accepted by any binutils version so far released, complaining that 124 accepted by any binutils version so far released, complaining that
123 the same type of prefix is used twice if an extended register is 125 the same type of prefix is used twice if an extended register is
124 needed for addressing (fix submitted to mainline 2005-11-21). */ 126 needed for addressing (fix submitted to mainline 2005-11-21). */
125 __asm__ __volatile__("rex64/fxsave %0" 127 __asm__ __volatile__("rex64/fxsave %0"
126 : "=m" (tsk->thread.i387.fxsave)); 128 : "=m" (tsk->thread.xstate->fxsave));
127#else 129#else
128 /* This, however, we can work around by forcing the compiler to select 130 /* This, however, we can work around by forcing the compiler to select
129 an addressing mode that doesn't require extended registers. */ 131 an addressing mode that doesn't require extended registers. */
130 __asm__ __volatile__("rex64/fxsave %P2(%1)" 132 __asm__ __volatile__("rex64/fxsave (%1)"
131 : "=m" (tsk->thread.i387.fxsave) 133 : "=m" (tsk->thread.xstate->fxsave)
132 : "cdaSDb" (tsk), 134 : "cdaSDb" (&tsk->thread.xstate->fxsave));
133 "i" (offsetof(__typeof__(*tsk),
134 thread.i387.fxsave)));
135#endif 135#endif
136 clear_fpu_state(&tsk->thread.i387.fxsave); 136 clear_fpu_state(&tsk->thread.xstate->fxsave);
137 task_thread_info(tsk)->status &= ~TS_USEDFPU; 137 task_thread_info(tsk)->status &= ~TS_USEDFPU;
138} 138}
139 139
@@ -147,7 +147,7 @@ static inline int save_i387(struct _fpstate __user *buf)
147 int err = 0; 147 int err = 0;
148 148
149 BUILD_BUG_ON(sizeof(struct user_i387_struct) != 149 BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
150 sizeof(tsk->thread.i387.fxsave)); 150 sizeof(tsk->thread.xstate->fxsave));
151 151
152 if ((unsigned long)buf % 16) 152 if ((unsigned long)buf % 16)
153 printk("save_i387: bad fpstate %p\n", buf); 153 printk("save_i387: bad fpstate %p\n", buf);
@@ -156,12 +156,14 @@ static inline int save_i387(struct _fpstate __user *buf)
156 return 0; 156 return 0;
157 clear_used_math(); /* trigger finit */ 157 clear_used_math(); /* trigger finit */
158 if (task_thread_info(tsk)->status & TS_USEDFPU) { 158 if (task_thread_info(tsk)->status & TS_USEDFPU) {
159 err = save_i387_checking((struct i387_fxsave_struct __user *)buf); 159 err = save_i387_checking((struct i387_fxsave_struct __user *)
160 if (err) return err; 160 buf);
161 if (err)
162 return err;
161 task_thread_info(tsk)->status &= ~TS_USEDFPU; 163 task_thread_info(tsk)->status &= ~TS_USEDFPU;
162 stts(); 164 stts();
163 } else { 165 } else {
164 if (__copy_to_user(buf, &tsk->thread.i387.fxsave, 166 if (__copy_to_user(buf, &tsk->thread.xstate->fxsave,
165 sizeof(struct i387_fxsave_struct))) 167 sizeof(struct i387_fxsave_struct)))
166 return -1; 168 return -1;
167 } 169 }
@@ -198,7 +200,7 @@ static inline void restore_fpu(struct task_struct *tsk)
198 "nop ; frstor %1", 200 "nop ; frstor %1",
199 "fxrstor %1", 201 "fxrstor %1",
200 X86_FEATURE_FXSR, 202 X86_FEATURE_FXSR,
201 "m" ((tsk)->thread.i387.fxsave)); 203 "m" (tsk->thread.xstate->fxsave));
202} 204}
203 205
204/* We need a safe address that is cheap to find and that is already 206/* We need a safe address that is cheap to find and that is already
@@ -222,8 +224,8 @@ static inline void __save_init_fpu(struct task_struct *tsk)
222 "fxsave %[fx]\n" 224 "fxsave %[fx]\n"
223 "bt $7,%[fsw] ; jnc 1f ; fnclex\n1:", 225 "bt $7,%[fsw] ; jnc 1f ; fnclex\n1:",
224 X86_FEATURE_FXSR, 226 X86_FEATURE_FXSR,
225 [fx] "m" (tsk->thread.i387.fxsave), 227 [fx] "m" (tsk->thread.xstate->fxsave),
226 [fsw] "m" (tsk->thread.i387.fxsave.swd) : "memory"); 228 [fsw] "m" (tsk->thread.xstate->fxsave.swd) : "memory");
227 /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception 229 /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
228 is pending. Clear the x87 state here by setting it to fixed 230 is pending. Clear the x87 state here by setting it to fixed
229 values. safe_address is a random variable that should be in L1 */ 231 values. safe_address is a random variable that should be in L1 */
@@ -324,25 +326,25 @@ static inline void clear_fpu(struct task_struct *tsk)
324static inline unsigned short get_fpu_cwd(struct task_struct *tsk) 326static inline unsigned short get_fpu_cwd(struct task_struct *tsk)
325{ 327{
326 if (cpu_has_fxsr) { 328 if (cpu_has_fxsr) {
327 return tsk->thread.i387.fxsave.cwd; 329 return tsk->thread.xstate->fxsave.cwd;
328 } else { 330 } else {
329 return (unsigned short)tsk->thread.i387.fsave.cwd; 331 return (unsigned short)tsk->thread.xstate->fsave.cwd;
330 } 332 }
331} 333}
332 334
333static inline unsigned short get_fpu_swd(struct task_struct *tsk) 335static inline unsigned short get_fpu_swd(struct task_struct *tsk)
334{ 336{
335 if (cpu_has_fxsr) { 337 if (cpu_has_fxsr) {
336 return tsk->thread.i387.fxsave.swd; 338 return tsk->thread.xstate->fxsave.swd;
337 } else { 339 } else {
338 return (unsigned short)tsk->thread.i387.fsave.swd; 340 return (unsigned short)tsk->thread.xstate->fsave.swd;
339 } 341 }
340} 342}
341 343
342static inline unsigned short get_fpu_mxcsr(struct task_struct *tsk) 344static inline unsigned short get_fpu_mxcsr(struct task_struct *tsk)
343{ 345{
344 if (cpu_has_xmm) { 346 if (cpu_has_xmm) {
345 return tsk->thread.i387.fxsave.mxcsr; 347 return tsk->thread.xstate->fxsave.mxcsr;
346 } else { 348 } else {
347 return MXCSR_DEFAULT; 349 return MXCSR_DEFAULT;
348 } 350 }
diff --git a/include/asm-x86/i8259.h b/include/asm-x86/i8259.h
index 67c319e0efc7..45d4df3e51e6 100644
--- a/include/asm-x86/i8259.h
+++ b/include/asm-x86/i8259.h
@@ -1,9 +1,11 @@
1#ifndef __ASM_I8259_H__ 1#ifndef __ASM_I8259_H__
2#define __ASM_I8259_H__ 2#define __ASM_I8259_H__
3 3
4#include <linux/delay.h>
5
4extern unsigned int cached_irq_mask; 6extern unsigned int cached_irq_mask;
5 7
6#define __byte(x,y) (((unsigned char *) &(y))[x]) 8#define __byte(x, y) (((unsigned char *)&(y))[x])
7#define cached_master_mask (__byte(0, cached_irq_mask)) 9#define cached_master_mask (__byte(0, cached_irq_mask))
8#define cached_slave_mask (__byte(1, cached_irq_mask)) 10#define cached_slave_mask (__byte(1, cached_irq_mask))
9 11
@@ -29,7 +31,28 @@ extern void enable_8259A_irq(unsigned int irq);
29extern void disable_8259A_irq(unsigned int irq); 31extern void disable_8259A_irq(unsigned int irq);
30extern unsigned int startup_8259A_irq(unsigned int irq); 32extern unsigned int startup_8259A_irq(unsigned int irq);
31 33
32#define inb_pic inb_p 34/* the PIC may need a careful delay on some platforms, hence specific calls */
33#define outb_pic outb_p 35static inline unsigned char inb_pic(unsigned int port)
36{
37 unsigned char value = inb(port);
38
39 /*
40 * delay for some accesses to PIC on motherboard or in chipset
41 * must be at least one microsecond, so be safe here:
42 */
43 udelay(2);
44
45 return value;
46}
47
48static inline void outb_pic(unsigned char value, unsigned int port)
49{
50 outb(value, port);
51 /*
52 * delay for some accesses to PIC on motherboard or in chipset
53 * must be at least one microsecond, so be safe here:
54 */
55 udelay(2);
56}
34 57
35#endif /* __ASM_I8259_H__ */ 58#endif /* __ASM_I8259_H__ */
diff --git a/include/asm-x86/ia32.h b/include/asm-x86/ia32.h
index aa9733206e29..55d3abe5276f 100644
--- a/include/asm-x86/ia32.h
+++ b/include/asm-x86/ia32.h
@@ -14,19 +14,19 @@
14 14
15/* signal.h */ 15/* signal.h */
16struct sigaction32 { 16struct sigaction32 {
17 unsigned int sa_handler; /* Really a pointer, but need to deal 17 unsigned int sa_handler; /* Really a pointer, but need to deal
18 with 32 bits */ 18 with 32 bits */
19 unsigned int sa_flags; 19 unsigned int sa_flags;
20 unsigned int sa_restorer; /* Another 32 bit pointer */ 20 unsigned int sa_restorer; /* Another 32 bit pointer */
21 compat_sigset_t sa_mask; /* A 32 bit mask */ 21 compat_sigset_t sa_mask; /* A 32 bit mask */
22}; 22};
23 23
24struct old_sigaction32 { 24struct old_sigaction32 {
25 unsigned int sa_handler; /* Really a pointer, but need to deal 25 unsigned int sa_handler; /* Really a pointer, but need to deal
26 with 32 bits */ 26 with 32 bits */
27 compat_old_sigset_t sa_mask; /* A 32 bit mask */ 27 compat_old_sigset_t sa_mask; /* A 32 bit mask */
28 unsigned int sa_flags; 28 unsigned int sa_flags;
29 unsigned int sa_restorer; /* Another 32 bit pointer */ 29 unsigned int sa_restorer; /* Another 32 bit pointer */
30}; 30};
31 31
32typedef struct sigaltstack_ia32 { 32typedef struct sigaltstack_ia32 {
@@ -65,7 +65,7 @@ struct stat64 {
65 long long st_size; 65 long long st_size;
66 unsigned int st_blksize; 66 unsigned int st_blksize;
67 67
68 long long st_blocks;/* Number 512-byte blocks allocated. */ 68 long long st_blocks;/* Number 512-byte blocks allocated */
69 69
70 unsigned st_atime; 70 unsigned st_atime;
71 unsigned st_atime_nsec; 71 unsigned st_atime_nsec;
@@ -77,13 +77,13 @@ struct stat64 {
77 unsigned long long st_ino; 77 unsigned long long st_ino;
78} __attribute__((packed)); 78} __attribute__((packed));
79 79
80typedef struct compat_siginfo{ 80typedef struct compat_siginfo {
81 int si_signo; 81 int si_signo;
82 int si_errno; 82 int si_errno;
83 int si_code; 83 int si_code;
84 84
85 union { 85 union {
86 int _pad[((128/sizeof(int)) - 3)]; 86 int _pad[((128 / sizeof(int)) - 3)];
87 87
88 /* kill() */ 88 /* kill() */
89 struct { 89 struct {
@@ -129,28 +129,26 @@ typedef struct compat_siginfo{
129 } _sifields; 129 } _sifields;
130} compat_siginfo_t; 130} compat_siginfo_t;
131 131
132struct sigframe32 132struct sigframe32 {
133{ 133 u32 pretcode;
134 u32 pretcode; 134 int sig;
135 int sig; 135 struct sigcontext_ia32 sc;
136 struct sigcontext_ia32 sc; 136 struct _fpstate_ia32 fpstate;
137 struct _fpstate_ia32 fpstate; 137 unsigned int extramask[_COMPAT_NSIG_WORDS-1];
138 unsigned int extramask[_COMPAT_NSIG_WORDS-1];
139}; 138};
140 139
141struct rt_sigframe32 140struct rt_sigframe32 {
142{ 141 u32 pretcode;
143 u32 pretcode; 142 int sig;
144 int sig; 143 u32 pinfo;
145 u32 pinfo; 144 u32 puc;
146 u32 puc; 145 compat_siginfo_t info;
147 compat_siginfo_t info; 146 struct ucontext_ia32 uc;
148 struct ucontext_ia32 uc; 147 struct _fpstate_ia32 fpstate;
149 struct _fpstate_ia32 fpstate;
150}; 148};
151 149
152struct ustat32 { 150struct ustat32 {
153 __u32 f_tfree; 151 __u32 f_tfree;
154 compat_ino_t f_tinode; 152 compat_ino_t f_tinode;
155 char f_fname[6]; 153 char f_fname[6];
156 char f_fpack[6]; 154 char f_fpack[6];
@@ -168,5 +166,5 @@ extern void ia32_pick_mmap_layout(struct mm_struct *mm);
168#endif 166#endif
169 167
170#endif /* !CONFIG_IA32_SUPPORT */ 168#endif /* !CONFIG_IA32_SUPPORT */
171 169
172#endif 170#endif
diff --git a/include/asm-x86/ide.h b/include/asm-x86/ide.h
index c2552d8bebf7..cf9c98e5bdb5 100644
--- a/include/asm-x86/ide.h
+++ b/include/asm-x86/ide.h
@@ -20,8 +20,6 @@
20# endif 20# endif
21#endif 21#endif
22 22
23#define IDE_ARCH_OBSOLETE_DEFAULTS
24
25static __inline__ int ide_default_irq(unsigned long base) 23static __inline__ int ide_default_irq(unsigned long base)
26{ 24{
27 switch (base) { 25 switch (base) {
@@ -60,14 +58,6 @@ static __inline__ unsigned long ide_default_io_base(int index)
60 } 58 }
61} 59}
62 60
63#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
64
65#ifdef CONFIG_BLK_DEV_IDEPCI
66#define ide_init_default_irq(base) (0)
67#else
68#define ide_init_default_irq(base) ide_default_irq(base)
69#endif
70
71#include <asm-generic/ide_iops.h> 61#include <asm-generic/ide_iops.h>
72 62
73#endif /* __KERNEL__ */ 63#endif /* __KERNEL__ */
diff --git a/include/asm-x86/io.h b/include/asm-x86/io.h
index 5a58b176dd61..d5b11f60dbd0 100644
--- a/include/asm-x86/io.h
+++ b/include/asm-x86/io.h
@@ -1,5 +1,19 @@
1#ifndef _ASM_X86_IO_H
2#define _ASM_X86_IO_H
3
4#define ARCH_HAS_IOREMAP_WC
5
1#ifdef CONFIG_X86_32 6#ifdef CONFIG_X86_32
2# include "io_32.h" 7# include "io_32.h"
3#else 8#else
4# include "io_64.h" 9# include "io_64.h"
5#endif 10#endif
11
12extern void *xlate_dev_mem_ptr(unsigned long phys);
13extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
14
15extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
16 unsigned long prot_val);
17extern void __iomem *ioremap_wc(unsigned long offset, unsigned long size);
18
19#endif /* _ASM_X86_IO_H */
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h
index d4d8fbd9378c..049e81e797a0 100644
--- a/include/asm-x86/io_32.h
+++ b/include/asm-x86/io_32.h
@@ -49,12 +49,6 @@
49#include <linux/vmalloc.h> 49#include <linux/vmalloc.h>
50 50
51/* 51/*
52 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
53 * access
54 */
55#define xlate_dev_mem_ptr(p) __va(p)
56
57/*
58 * Convert a virtual cached pointer to an uncached pointer 52 * Convert a virtual cached pointer to an uncached pointer
59 */ 53 */
60#define xlate_dev_kmem_ptr(p) p 54#define xlate_dev_kmem_ptr(p) p
@@ -65,14 +59,14 @@
65 * 59 *
66 * The returned physical address is the physical (CPU) mapping for 60 * The returned physical address is the physical (CPU) mapping for
67 * the memory address given. It is only valid to use this function on 61 * the memory address given. It is only valid to use this function on
68 * addresses directly mapped or allocated via kmalloc. 62 * addresses directly mapped or allocated via kmalloc.
69 * 63 *
70 * This function does not give bus mappings for DMA transfers. In 64 * This function does not give bus mappings for DMA transfers. In
71 * almost all conceivable cases a device driver should not be using 65 * almost all conceivable cases a device driver should not be using
72 * this function 66 * this function
73 */ 67 */
74 68
75static inline unsigned long virt_to_phys(volatile void * address) 69static inline unsigned long virt_to_phys(volatile void *address)
76{ 70{
77 return __pa(address); 71 return __pa(address);
78} 72}
@@ -90,7 +84,7 @@ static inline unsigned long virt_to_phys(volatile void * address)
90 * this function 84 * this function
91 */ 85 */
92 86
93static inline void * phys_to_virt(unsigned long address) 87static inline void *phys_to_virt(unsigned long address)
94{ 88{
95 return __va(address); 89 return __va(address);
96} 90}
@@ -139,11 +133,6 @@ extern void *early_ioremap(unsigned long offset, unsigned long size);
139extern void early_iounmap(void *addr, unsigned long size); 133extern void early_iounmap(void *addr, unsigned long size);
140extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); 134extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
141 135
142/* Use early IO mappings for DMI because it's initialized early */
143#define dmi_ioremap early_ioremap
144#define dmi_iounmap early_iounmap
145#define dmi_alloc alloc_bootmem
146
147/* 136/*
148 * ISA I/O bus memory addresses are 1:1 with the physical address. 137 * ISA I/O bus memory addresses are 1:1 with the physical address.
149 */ 138 */
@@ -169,16 +158,19 @@ extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
169 158
170static inline unsigned char readb(const volatile void __iomem *addr) 159static inline unsigned char readb(const volatile void __iomem *addr)
171{ 160{
172 return *(volatile unsigned char __force *) addr; 161 return *(volatile unsigned char __force *)addr;
173} 162}
163
174static inline unsigned short readw(const volatile void __iomem *addr) 164static inline unsigned short readw(const volatile void __iomem *addr)
175{ 165{
176 return *(volatile unsigned short __force *) addr; 166 return *(volatile unsigned short __force *)addr;
177} 167}
168
178static inline unsigned int readl(const volatile void __iomem *addr) 169static inline unsigned int readl(const volatile void __iomem *addr)
179{ 170{
180 return *(volatile unsigned int __force *) addr; 171 return *(volatile unsigned int __force *) addr;
181} 172}
173
182#define readb_relaxed(addr) readb(addr) 174#define readb_relaxed(addr) readb(addr)
183#define readw_relaxed(addr) readw(addr) 175#define readw_relaxed(addr) readw(addr)
184#define readl_relaxed(addr) readl(addr) 176#define readl_relaxed(addr) readl(addr)
@@ -188,15 +180,17 @@ static inline unsigned int readl(const volatile void __iomem *addr)
188 180
189static inline void writeb(unsigned char b, volatile void __iomem *addr) 181static inline void writeb(unsigned char b, volatile void __iomem *addr)
190{ 182{
191 *(volatile unsigned char __force *) addr = b; 183 *(volatile unsigned char __force *)addr = b;
192} 184}
185
193static inline void writew(unsigned short b, volatile void __iomem *addr) 186static inline void writew(unsigned short b, volatile void __iomem *addr)
194{ 187{
195 *(volatile unsigned short __force *) addr = b; 188 *(volatile unsigned short __force *)addr = b;
196} 189}
190
197static inline void writel(unsigned int b, volatile void __iomem *addr) 191static inline void writel(unsigned int b, volatile void __iomem *addr)
198{ 192{
199 *(volatile unsigned int __force *) addr = b; 193 *(volatile unsigned int __force *)addr = b;
200} 194}
201#define __raw_writeb writeb 195#define __raw_writeb writeb
202#define __raw_writew writew 196#define __raw_writew writew
@@ -239,12 +233,12 @@ memcpy_toio(volatile void __iomem *dst, const void *src, int count)
239 * 1. Out of order aware processors 233 * 1. Out of order aware processors
240 * 2. Accidentally out of order processors (PPro errata #51) 234 * 2. Accidentally out of order processors (PPro errata #51)
241 */ 235 */
242 236
243#if defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE) 237#if defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE)
244 238
245static inline void flush_write_buffers(void) 239static inline void flush_write_buffers(void)
246{ 240{
247 __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory"); 241 asm volatile("lock; addl $0,0(%%esp)": : :"memory");
248} 242}
249 243
250#else 244#else
@@ -264,7 +258,8 @@ extern void io_delay_init(void);
264#include <asm/paravirt.h> 258#include <asm/paravirt.h>
265#else 259#else
266 260
267static inline void slow_down_io(void) { 261static inline void slow_down_io(void)
262{
268 native_io_delay(); 263 native_io_delay();
269#ifdef REALLY_SLOW_IO 264#ifdef REALLY_SLOW_IO
270 native_io_delay(); 265 native_io_delay();
@@ -275,51 +270,74 @@ static inline void slow_down_io(void) {
275 270
276#endif 271#endif
277 272
278#define __BUILDIO(bwl,bw,type) \ 273#define __BUILDIO(bwl, bw, type) \
279static inline void out##bwl(unsigned type value, int port) { \ 274static inline void out##bwl(unsigned type value, int port) \
280 out##bwl##_local(value, port); \ 275{ \
281} \ 276 out##bwl##_local(value, port); \
282static inline unsigned type in##bwl(int port) { \ 277} \
283 return in##bwl##_local(port); \ 278 \
279static inline unsigned type in##bwl(int port) \
280{ \
281 return in##bwl##_local(port); \
284} 282}
285 283
286#define BUILDIO(bwl,bw,type) \ 284#define BUILDIO(bwl, bw, type) \
287static inline void out##bwl##_local(unsigned type value, int port) { \ 285static inline void out##bwl##_local(unsigned type value, int port) \
288 __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \ 286{ \
289} \ 287 asm volatile("out" #bwl " %" #bw "0, %w1" \
290static inline unsigned type in##bwl##_local(int port) { \ 288 : : "a"(value), "Nd"(port)); \
291 unsigned type value; \ 289} \
292 __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \ 290 \
293 return value; \ 291static inline unsigned type in##bwl##_local(int port) \
294} \ 292{ \
295static inline void out##bwl##_local_p(unsigned type value, int port) { \ 293 unsigned type value; \
296 out##bwl##_local(value, port); \ 294 asm volatile("in" #bwl " %w1, %" #bw "0" \
297 slow_down_io(); \ 295 : "=a"(value) : "Nd"(port)); \
298} \ 296 return value; \
299static inline unsigned type in##bwl##_local_p(int port) { \ 297} \
300 unsigned type value = in##bwl##_local(port); \ 298 \
301 slow_down_io(); \ 299static inline void out##bwl##_local_p(unsigned type value, int port) \
302 return value; \ 300{ \
303} \ 301 out##bwl##_local(value, port); \
304__BUILDIO(bwl,bw,type) \ 302 slow_down_io(); \
305static inline void out##bwl##_p(unsigned type value, int port) { \ 303} \
306 out##bwl(value, port); \ 304 \
307 slow_down_io(); \ 305static inline unsigned type in##bwl##_local_p(int port) \
308} \ 306{ \
309static inline unsigned type in##bwl##_p(int port) { \ 307 unsigned type value = in##bwl##_local(port); \
310 unsigned type value = in##bwl(port); \ 308 slow_down_io(); \
311 slow_down_io(); \ 309 return value; \
312 return value; \ 310} \
313} \ 311 \
314static inline void outs##bwl(int port, const void *addr, unsigned long count) { \ 312__BUILDIO(bwl, bw, type) \
315 __asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); \ 313 \
316} \ 314static inline void out##bwl##_p(unsigned type value, int port) \
317static inline void ins##bwl(int port, void *addr, unsigned long count) { \ 315{ \
318 __asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); \ 316 out##bwl(value, port); \
317 slow_down_io(); \
318} \
319 \
320static inline unsigned type in##bwl##_p(int port) \
321{ \
322 unsigned type value = in##bwl(port); \
323 slow_down_io(); \
324 return value; \
325} \
326 \
327static inline void outs##bwl(int port, const void *addr, unsigned long count) \
328{ \
329 asm volatile("rep; outs" #bwl \
330 : "+S"(addr), "+c"(count) : "d"(port)); \
331} \
332 \
333static inline void ins##bwl(int port, void *addr, unsigned long count) \
334{ \
335 asm volatile("rep; ins" #bwl \
336 : "+D"(addr), "+c"(count) : "d"(port)); \
319} 337}
320 338
321BUILDIO(b,b,char) 339BUILDIO(b, b, char)
322BUILDIO(w,w,short) 340BUILDIO(w, w, short)
323BUILDIO(l,,int) 341BUILDIO(l, , int)
324 342
325#endif 343#endif
diff --git a/include/asm-x86/io_64.h b/include/asm-x86/io_64.h
index db0be2011a3c..0930bedf9e4d 100644
--- a/include/asm-x86/io_64.h
+++ b/include/asm-x86/io_64.h
@@ -58,60 +58,75 @@ static inline void slow_down_io(void)
58/* 58/*
59 * Talk about misusing macros.. 59 * Talk about misusing macros..
60 */ 60 */
61#define __OUT1(s,x) \ 61#define __OUT1(s, x) \
62static inline void out##s(unsigned x value, unsigned short port) { 62static inline void out##s(unsigned x value, unsigned short port) {
63 63
64#define __OUT2(s,s1,s2) \ 64#define __OUT2(s, s1, s2) \
65__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1" 65asm volatile ("out" #s " %" s1 "0,%" s2 "1"
66 66
67#ifndef REALLY_SLOW_IO 67#ifndef REALLY_SLOW_IO
68#define REALLY_SLOW_IO 68#define REALLY_SLOW_IO
69#define UNSET_REALLY_SLOW_IO 69#define UNSET_REALLY_SLOW_IO
70#endif 70#endif
71 71
72#define __OUT(s,s1,x) \ 72#define __OUT(s, s1, x) \
73__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "Nd" (port)); } \ 73 __OUT1(s, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \
74__OUT1(s##_p, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \ 74 } \
75 slow_down_io(); } 75 __OUT1(s##_p, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \
76 slow_down_io(); \
77}
76 78
77#define __IN1(s) \ 79#define __IN1(s) \
78static inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v; 80static inline RETURN_TYPE in##s(unsigned short port) \
81{ \
82 RETURN_TYPE _v;
79 83
80#define __IN2(s,s1,s2) \ 84#define __IN2(s, s1, s2) \
81__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0" 85 asm volatile ("in" #s " %" s2 "1,%" s1 "0"
82 86
83#define __IN(s,s1,i...) \ 87#define __IN(s, s1, i...) \
84__IN1(s) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); return _v; } \ 88 __IN1(s) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \
85__IN1(s##_p) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \ 89 return _v; \
86 slow_down_io(); return _v; } 90 } \
91 __IN1(s##_p) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \
92 slow_down_io(); \
93 return _v; }
87 94
88#ifdef UNSET_REALLY_SLOW_IO 95#ifdef UNSET_REALLY_SLOW_IO
89#undef REALLY_SLOW_IO 96#undef REALLY_SLOW_IO
90#endif 97#endif
91 98
92#define __INS(s) \ 99#define __INS(s) \
93static inline void ins##s(unsigned short port, void * addr, unsigned long count) \ 100static inline void ins##s(unsigned short port, void *addr, \
94{ __asm__ __volatile__ ("rep ; ins" #s \ 101 unsigned long count) \
95: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } 102{ \
103 asm volatile ("rep ; ins" #s \
104 : "=D" (addr), "=c" (count) \
105 : "d" (port), "0" (addr), "1" (count)); \
106}
96 107
97#define __OUTS(s) \ 108#define __OUTS(s) \
98static inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ 109static inline void outs##s(unsigned short port, const void *addr, \
99{ __asm__ __volatile__ ("rep ; outs" #s \ 110 unsigned long count) \
100: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } 111{ \
112 asm volatile ("rep ; outs" #s \
113 : "=S" (addr), "=c" (count) \
114 : "d" (port), "0" (addr), "1" (count)); \
115}
101 116
102#define RETURN_TYPE unsigned char 117#define RETURN_TYPE unsigned char
103__IN(b,"") 118__IN(b, "")
104#undef RETURN_TYPE 119#undef RETURN_TYPE
105#define RETURN_TYPE unsigned short 120#define RETURN_TYPE unsigned short
106__IN(w,"") 121__IN(w, "")
107#undef RETURN_TYPE 122#undef RETURN_TYPE
108#define RETURN_TYPE unsigned int 123#define RETURN_TYPE unsigned int
109__IN(l,"") 124__IN(l, "")
110#undef RETURN_TYPE 125#undef RETURN_TYPE
111 126
112__OUT(b,"b",char) 127__OUT(b, "b", char)
113__OUT(w,"w",short) 128__OUT(w, "w", short)
114__OUT(l,,int) 129__OUT(l, , int)
115 130
116__INS(b) 131__INS(b)
117__INS(w) 132__INS(w)
@@ -132,12 +147,12 @@ __OUTS(l)
132 * Change virtual addresses to physical addresses and vv. 147 * Change virtual addresses to physical addresses and vv.
133 * These are pretty trivial 148 * These are pretty trivial
134 */ 149 */
135static inline unsigned long virt_to_phys(volatile void * address) 150static inline unsigned long virt_to_phys(volatile void *address)
136{ 151{
137 return __pa(address); 152 return __pa(address);
138} 153}
139 154
140static inline void * phys_to_virt(unsigned long address) 155static inline void *phys_to_virt(unsigned long address)
141{ 156{
142 return __va(address); 157 return __va(address);
143} 158}
@@ -200,18 +215,22 @@ static inline __u8 __readb(const volatile void __iomem *addr)
200{ 215{
201 return *(__force volatile __u8 *)addr; 216 return *(__force volatile __u8 *)addr;
202} 217}
218
203static inline __u16 __readw(const volatile void __iomem *addr) 219static inline __u16 __readw(const volatile void __iomem *addr)
204{ 220{
205 return *(__force volatile __u16 *)addr; 221 return *(__force volatile __u16 *)addr;
206} 222}
223
207static __always_inline __u32 __readl(const volatile void __iomem *addr) 224static __always_inline __u32 __readl(const volatile void __iomem *addr)
208{ 225{
209 return *(__force volatile __u32 *)addr; 226 return *(__force volatile __u32 *)addr;
210} 227}
228
211static inline __u64 __readq(const volatile void __iomem *addr) 229static inline __u64 __readq(const volatile void __iomem *addr)
212{ 230{
213 return *(__force volatile __u64 *)addr; 231 return *(__force volatile __u64 *)addr;
214} 232}
233
215#define readb(x) __readb(x) 234#define readb(x) __readb(x)
216#define readw(x) __readw(x) 235#define readw(x) __readw(x)
217#define readl(x) __readl(x) 236#define readl(x) __readl(x)
@@ -231,37 +250,44 @@ static inline void __writel(__u32 b, volatile void __iomem *addr)
231{ 250{
232 *(__force volatile __u32 *)addr = b; 251 *(__force volatile __u32 *)addr = b;
233} 252}
253
234static inline void __writeq(__u64 b, volatile void __iomem *addr) 254static inline void __writeq(__u64 b, volatile void __iomem *addr)
235{ 255{
236 *(__force volatile __u64 *)addr = b; 256 *(__force volatile __u64 *)addr = b;
237} 257}
258
238static inline void __writeb(__u8 b, volatile void __iomem *addr) 259static inline void __writeb(__u8 b, volatile void __iomem *addr)
239{ 260{
240 *(__force volatile __u8 *)addr = b; 261 *(__force volatile __u8 *)addr = b;
241} 262}
263
242static inline void __writew(__u16 b, volatile void __iomem *addr) 264static inline void __writew(__u16 b, volatile void __iomem *addr)
243{ 265{
244 *(__force volatile __u16 *)addr = b; 266 *(__force volatile __u16 *)addr = b;
245} 267}
246#define writeq(val,addr) __writeq((val),(addr)) 268
247#define writel(val,addr) __writel((val),(addr)) 269#define writeq(val, addr) __writeq((val), (addr))
248#define writew(val,addr) __writew((val),(addr)) 270#define writel(val, addr) __writel((val), (addr))
249#define writeb(val,addr) __writeb((val),(addr)) 271#define writew(val, addr) __writew((val), (addr))
272#define writeb(val, addr) __writeb((val), (addr))
250#define __raw_writeb writeb 273#define __raw_writeb writeb
251#define __raw_writew writew 274#define __raw_writew writew
252#define __raw_writel writel 275#define __raw_writel writel
253#define __raw_writeq writeq 276#define __raw_writeq writeq
254 277
255void __memcpy_fromio(void*,unsigned long,unsigned); 278void __memcpy_fromio(void *, unsigned long, unsigned);
256void __memcpy_toio(unsigned long,const void*,unsigned); 279void __memcpy_toio(unsigned long, const void *, unsigned);
257 280
258static inline void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned len) 281static inline void memcpy_fromio(void *to, const volatile void __iomem *from,
282 unsigned len)
259{ 283{
260 __memcpy_fromio(to,(unsigned long)from,len); 284 __memcpy_fromio(to, (unsigned long)from, len);
261} 285}
262static inline void memcpy_toio(volatile void __iomem *to, const void *from, unsigned len) 286
287static inline void memcpy_toio(volatile void __iomem *to, const void *from,
288 unsigned len)
263{ 289{
264 __memcpy_toio((unsigned long)to,from,len); 290 __memcpy_toio((unsigned long)to, from, len);
265} 291}
266 292
267void memset_io(volatile void __iomem *a, int b, size_t c); 293void memset_io(volatile void __iomem *a, int b, size_t c);
@@ -276,18 +302,12 @@ void memset_io(volatile void __iomem *a, int b, size_t c);
276 */ 302 */
277#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET)) 303#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
278 304
279#define flush_write_buffers() 305#define flush_write_buffers()
280 306
281extern int iommu_bio_merge; 307extern int iommu_bio_merge;
282#define BIO_VMERGE_BOUNDARY iommu_bio_merge 308#define BIO_VMERGE_BOUNDARY iommu_bio_merge
283 309
284/* 310/*
285 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
286 * access
287 */
288#define xlate_dev_mem_ptr(p) __va(p)
289
290/*
291 * Convert a virtual cached pointer to an uncached pointer 311 * Convert a virtual cached pointer to an uncached pointer
292 */ 312 */
293#define xlate_dev_kmem_ptr(p) p 313#define xlate_dev_kmem_ptr(p) p
diff --git a/include/asm-x86/io_apic.h b/include/asm-x86/io_apic.h
index 0f5b3fef0b08..d593e14f0341 100644
--- a/include/asm-x86/io_apic.h
+++ b/include/asm-x86/io_apic.h
@@ -1,7 +1,7 @@
1#ifndef __ASM_IO_APIC_H 1#ifndef __ASM_IO_APIC_H
2#define __ASM_IO_APIC_H 2#define __ASM_IO_APIC_H
3 3
4#include <asm/types.h> 4#include <linux/types.h>
5#include <asm/mpspec.h> 5#include <asm/mpspec.h>
6#include <asm/apicdef.h> 6#include <asm/apicdef.h>
7 7
@@ -110,6 +110,15 @@ extern int nr_ioapic_registers[MAX_IO_APICS];
110 * MP-BIOS irq configuration table structures: 110 * MP-BIOS irq configuration table structures:
111 */ 111 */
112 112
113#define MP_MAX_IOAPIC_PIN 127
114
115struct mp_ioapic_routing {
116 int apic_id;
117 int gsi_base;
118 int gsi_end;
119 DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1);
120};
121
113/* I/O APIC entries */ 122/* I/O APIC entries */
114extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS]; 123extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
115 124
@@ -146,7 +155,6 @@ extern int io_apic_get_version(int ioapic);
146extern int io_apic_get_redir_entries(int ioapic); 155extern int io_apic_get_redir_entries(int ioapic);
147extern int io_apic_set_pci_routing(int ioapic, int pin, int irq, 156extern int io_apic_set_pci_routing(int ioapic, int pin, int irq,
148 int edge_level, int active_high_low); 157 int edge_level, int active_high_low);
149extern int timer_uses_ioapic_pin_0;
150#endif /* CONFIG_ACPI */ 158#endif /* CONFIG_ACPI */
151 159
152extern int (*ioapic_renumber_irq)(int ioapic, int irq); 160extern int (*ioapic_renumber_irq)(int ioapic, int irq);
diff --git a/include/asm-x86/ioctls.h b/include/asm-x86/ioctls.h
index 93c894dc5154..c0c338bd4068 100644
--- a/include/asm-x86/ioctls.h
+++ b/include/asm-x86/ioctls.h
@@ -47,12 +47,13 @@
47#define TIOCSBRK 0x5427 /* BSD compatibility */ 47#define TIOCSBRK 0x5427 /* BSD compatibility */
48#define TIOCCBRK 0x5428 /* BSD compatibility */ 48#define TIOCCBRK 0x5428 /* BSD compatibility */
49#define TIOCGSID 0x5429 /* Return the session ID of FD */ 49#define TIOCGSID 0x5429 /* Return the session ID of FD */
50#define TCGETS2 _IOR('T',0x2A, struct termios2) 50#define TCGETS2 _IOR('T', 0x2A, struct termios2)
51#define TCSETS2 _IOW('T',0x2B, struct termios2) 51#define TCSETS2 _IOW('T', 0x2B, struct termios2)
52#define TCSETSW2 _IOW('T',0x2C, struct termios2) 52#define TCSETSW2 _IOW('T', 0x2C, struct termios2)
53#define TCSETSF2 _IOW('T',0x2D, struct termios2) 53#define TCSETSF2 _IOW('T', 0x2D, struct termios2)
54#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 54#define TIOCGPTN _IOR('T', 0x30, unsigned int)
55#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 55 /* Get Pty Number (of pty-mux device) */
56#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */
56 57
57#define FIONCLEX 0x5450 58#define FIONCLEX 0x5450
58#define FIOCLEX 0x5451 59#define FIOCLEX 0x5451
diff --git a/include/asm-x86/ipcbuf.h b/include/asm-x86/ipcbuf.h
index 2adf8b39a40b..ee678fd51594 100644
--- a/include/asm-x86/ipcbuf.h
+++ b/include/asm-x86/ipcbuf.h
@@ -11,8 +11,7 @@
11 * - 2 miscellaneous 32-bit values 11 * - 2 miscellaneous 32-bit values
12 */ 12 */
13 13
14struct ipc64_perm 14struct ipc64_perm {
15{
16 __kernel_key_t key; 15 __kernel_key_t key;
17 __kernel_uid32_t uid; 16 __kernel_uid32_t uid;
18 __kernel_gid32_t gid; 17 __kernel_gid32_t gid;
diff --git a/include/asm-x86/ipi.h b/include/asm-x86/ipi.h
index 6d011bd6067d..ecc80f341f37 100644
--- a/include/asm-x86/ipi.h
+++ b/include/asm-x86/ipi.h
@@ -27,7 +27,8 @@
27 * We use 'broadcast', CPU->CPU IPIs and self-IPIs too. 27 * We use 'broadcast', CPU->CPU IPIs and self-IPIs too.
28 */ 28 */
29 29
30static inline unsigned int __prepare_ICR (unsigned int shortcut, int vector, unsigned int dest) 30static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
31 unsigned int dest)
31{ 32{
32 unsigned int icr = shortcut | dest; 33 unsigned int icr = shortcut | dest;
33 34
@@ -42,12 +43,13 @@ static inline unsigned int __prepare_ICR (unsigned int shortcut, int vector, uns
42 return icr; 43 return icr;
43} 44}
44 45
45static inline int __prepare_ICR2 (unsigned int mask) 46static inline int __prepare_ICR2(unsigned int mask)
46{ 47{
47 return SET_APIC_DEST_FIELD(mask); 48 return SET_APIC_DEST_FIELD(mask);
48} 49}
49 50
50static inline void __send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest) 51static inline void __send_IPI_shortcut(unsigned int shortcut, int vector,
52 unsigned int dest)
51{ 53{
52 /* 54 /*
53 * Subtle. In the case of the 'never do double writes' workaround 55 * Subtle. In the case of the 'never do double writes' workaround
@@ -78,7 +80,8 @@ static inline void __send_IPI_shortcut(unsigned int shortcut, int vector, unsign
78 * This is used to send an IPI with no shorthand notation (the destination is 80 * This is used to send an IPI with no shorthand notation (the destination is
79 * specified in bits 56 to 63 of the ICR). 81 * specified in bits 56 to 63 of the ICR).
80 */ 82 */
81static inline void __send_IPI_dest_field(unsigned int mask, int vector, unsigned int dest) 83static inline void __send_IPI_dest_field(unsigned int mask, int vector,
84 unsigned int dest)
82{ 85{
83 unsigned long cfg; 86 unsigned long cfg;
84 87
diff --git a/include/asm-x86/irq_32.h b/include/asm-x86/irq_32.h
index aca9c96e8e6b..0b79f3185243 100644
--- a/include/asm-x86/irq_32.h
+++ b/include/asm-x86/irq_32.h
@@ -15,7 +15,7 @@
15#include "irq_vectors.h" 15#include "irq_vectors.h"
16#include <asm/thread_info.h> 16#include <asm/thread_info.h>
17 17
18static __inline__ int irq_canonicalize(int irq) 18static inline int irq_canonicalize(int irq)
19{ 19{
20 return ((irq == 2) ? 9 : irq); 20 return ((irq == 2) ? 9 : irq);
21} 21}
diff --git a/include/asm-x86/irq_64.h b/include/asm-x86/irq_64.h
index 5006c6e75656..083d35a62c94 100644
--- a/include/asm-x86/irq_64.h
+++ b/include/asm-x86/irq_64.h
@@ -31,10 +31,10 @@
31 31
32#define FIRST_SYSTEM_VECTOR 0xef /* duplicated in hw_irq.h */ 32#define FIRST_SYSTEM_VECTOR 0xef /* duplicated in hw_irq.h */
33 33
34#define NR_IRQS (NR_VECTORS + (32 *NR_CPUS)) 34#define NR_IRQS (NR_VECTORS + (32 * NR_CPUS))
35#define NR_IRQ_VECTORS NR_IRQS 35#define NR_IRQ_VECTORS NR_IRQS
36 36
37static __inline__ int irq_canonicalize(int irq) 37static inline int irq_canonicalize(int irq)
38{ 38{
39 return ((irq == 2) ? 9 : irq); 39 return ((irq == 2) ? 9 : irq);
40} 40}
diff --git a/include/asm-x86/irqflags.h b/include/asm-x86/irqflags.h
index 0e2292483b35..c242527f970e 100644
--- a/include/asm-x86/irqflags.h
+++ b/include/asm-x86/irqflags.h
@@ -12,25 +12,21 @@ static inline unsigned long native_save_fl(void)
12{ 12{
13 unsigned long flags; 13 unsigned long flags;
14 14
15 __asm__ __volatile__( 15 asm volatile("# __raw_save_flags\n\t"
16 "# __raw_save_flags\n\t" 16 "pushf ; pop %0"
17 "pushf ; pop %0" 17 : "=g" (flags)
18 : "=g" (flags) 18 : /* no input */
19 : /* no input */ 19 : "memory");
20 : "memory"
21 );
22 20
23 return flags; 21 return flags;
24} 22}
25 23
26static inline void native_restore_fl(unsigned long flags) 24static inline void native_restore_fl(unsigned long flags)
27{ 25{
28 __asm__ __volatile__( 26 asm volatile("push %0 ; popf"
29 "push %0 ; popf" 27 : /* no output */
30 : /* no output */ 28 :"g" (flags)
31 :"g" (flags) 29 :"memory", "cc");
32 :"memory", "cc"
33 );
34} 30}
35 31
36static inline void native_irq_disable(void) 32static inline void native_irq_disable(void)
@@ -70,26 +66,6 @@ static inline void raw_local_irq_restore(unsigned long flags)
70 native_restore_fl(flags); 66 native_restore_fl(flags);
71} 67}
72 68
73#ifdef CONFIG_X86_VSMP
74
75/*
76 * Interrupt control for the VSMP architecture:
77 */
78
79static inline void raw_local_irq_disable(void)
80{
81 unsigned long flags = __raw_local_save_flags();
82 raw_local_irq_restore((flags & ~X86_EFLAGS_IF) | X86_EFLAGS_AC);
83}
84
85static inline void raw_local_irq_enable(void)
86{
87 unsigned long flags = __raw_local_save_flags();
88 raw_local_irq_restore((flags | X86_EFLAGS_IF) & (~X86_EFLAGS_AC));
89}
90
91#else
92
93static inline void raw_local_irq_disable(void) 69static inline void raw_local_irq_disable(void)
94{ 70{
95 native_irq_disable(); 71 native_irq_disable();
@@ -100,8 +76,6 @@ static inline void raw_local_irq_enable(void)
100 native_irq_enable(); 76 native_irq_enable();
101} 77}
102 78
103#endif
104
105/* 79/*
106 * Used in the idle loop; sti takes one instruction cycle 80 * Used in the idle loop; sti takes one instruction cycle
107 * to complete: 81 * to complete:
@@ -153,23 +127,16 @@ static inline unsigned long __raw_local_irq_save(void)
153#endif /* CONFIG_PARAVIRT */ 127#endif /* CONFIG_PARAVIRT */
154 128
155#ifndef __ASSEMBLY__ 129#ifndef __ASSEMBLY__
156#define raw_local_save_flags(flags) \ 130#define raw_local_save_flags(flags) \
157 do { (flags) = __raw_local_save_flags(); } while (0) 131 do { (flags) = __raw_local_save_flags(); } while (0)
158 132
159#define raw_local_irq_save(flags) \ 133#define raw_local_irq_save(flags) \
160 do { (flags) = __raw_local_irq_save(); } while (0) 134 do { (flags) = __raw_local_irq_save(); } while (0)
161 135
162#ifdef CONFIG_X86_VSMP
163static inline int raw_irqs_disabled_flags(unsigned long flags)
164{
165 return !(flags & X86_EFLAGS_IF) || (flags & X86_EFLAGS_AC);
166}
167#else
168static inline int raw_irqs_disabled_flags(unsigned long flags) 136static inline int raw_irqs_disabled_flags(unsigned long flags)
169{ 137{
170 return !(flags & X86_EFLAGS_IF); 138 return !(flags & X86_EFLAGS_IF);
171} 139}
172#endif
173 140
174static inline int raw_irqs_disabled(void) 141static inline int raw_irqs_disabled(void)
175{ 142{
diff --git a/include/asm-x86/kdebug.h b/include/asm-x86/kdebug.h
index 99dcbafa1511..96651bb59ba1 100644
--- a/include/asm-x86/kdebug.h
+++ b/include/asm-x86/kdebug.h
@@ -20,15 +20,16 @@ enum die_val {
20 DIE_CALL, 20 DIE_CALL,
21 DIE_NMI_IPI, 21 DIE_NMI_IPI,
22 DIE_PAGE_FAULT, 22 DIE_PAGE_FAULT,
23 DIE_NMIUNKNOWN,
23}; 24};
24 25
25extern void printk_address(unsigned long address, int reliable); 26extern void printk_address(unsigned long address, int reliable);
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 int __must_check __die(const char *, struct pt_regs *, long);
28extern void show_registers(struct pt_regs *regs); 29extern void show_registers(struct pt_regs *regs);
29extern void __show_registers(struct pt_regs *, int all); 30extern void __show_registers(struct pt_regs *, int all);
30extern void show_trace(struct task_struct *t, struct pt_regs *regs, 31extern void show_trace(struct task_struct *t, struct pt_regs *regs,
31 unsigned long *sp, unsigned long bp); 32 unsigned long *sp, unsigned long bp);
32extern void __show_regs(struct pt_regs *regs); 33extern void __show_regs(struct pt_regs *regs);
33extern void show_regs(struct pt_regs *regs); 34extern void show_regs(struct pt_regs *regs);
34extern unsigned long oops_begin(void); 35extern unsigned long oops_begin(void);
diff --git a/include/asm-x86/kexec.h b/include/asm-x86/kexec.h
index c90d3c77afc2..8f855a15f64d 100644
--- a/include/asm-x86/kexec.h
+++ b/include/asm-x86/kexec.h
@@ -94,10 +94,9 @@ static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
94{ 94{
95#ifdef CONFIG_X86_32 95#ifdef CONFIG_X86_32
96 newregs->sp = (unsigned long)&(oldregs->sp); 96 newregs->sp = (unsigned long)&(oldregs->sp);
97 __asm__ __volatile__( 97 asm volatile("xorl %%eax, %%eax\n\t"
98 "xorl %%eax, %%eax\n\t" 98 "movw %%ss, %%ax\n\t"
99 "movw %%ss, %%ax\n\t" 99 :"=a"(newregs->ss));
100 :"=a"(newregs->ss));
101#endif 100#endif
102} 101}
103 102
@@ -114,39 +113,39 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
114 crash_fixup_ss_esp(newregs, oldregs); 113 crash_fixup_ss_esp(newregs, oldregs);
115 } else { 114 } else {
116#ifdef CONFIG_X86_32 115#ifdef CONFIG_X86_32
117 __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->bx)); 116 asm volatile("movl %%ebx,%0" : "=m"(newregs->bx));
118 __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->cx)); 117 asm volatile("movl %%ecx,%0" : "=m"(newregs->cx));
119 __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->dx)); 118 asm volatile("movl %%edx,%0" : "=m"(newregs->dx));
120 __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->si)); 119 asm volatile("movl %%esi,%0" : "=m"(newregs->si));
121 __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->di)); 120 asm volatile("movl %%edi,%0" : "=m"(newregs->di));
122 __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->bp)); 121 asm volatile("movl %%ebp,%0" : "=m"(newregs->bp));
123 __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->ax)); 122 asm volatile("movl %%eax,%0" : "=m"(newregs->ax));
124 __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->sp)); 123 asm volatile("movl %%esp,%0" : "=m"(newregs->sp));
125 __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss)); 124 asm volatile("movl %%ss, %%eax;" :"=a"(newregs->ss));
126 __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs)); 125 asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs));
127 __asm__ __volatile__("movl %%ds, %%eax;" :"=a"(newregs->ds)); 126 asm volatile("movl %%ds, %%eax;" :"=a"(newregs->ds));
128 __asm__ __volatile__("movl %%es, %%eax;" :"=a"(newregs->es)); 127 asm volatile("movl %%es, %%eax;" :"=a"(newregs->es));
129 __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->flags)); 128 asm volatile("pushfl; popl %0" :"=m"(newregs->flags));
130#else 129#else
131 __asm__ __volatile__("movq %%rbx,%0" : "=m"(newregs->bx)); 130 asm volatile("movq %%rbx,%0" : "=m"(newregs->bx));
132 __asm__ __volatile__("movq %%rcx,%0" : "=m"(newregs->cx)); 131 asm volatile("movq %%rcx,%0" : "=m"(newregs->cx));
133 __asm__ __volatile__("movq %%rdx,%0" : "=m"(newregs->dx)); 132 asm volatile("movq %%rdx,%0" : "=m"(newregs->dx));
134 __asm__ __volatile__("movq %%rsi,%0" : "=m"(newregs->si)); 133 asm volatile("movq %%rsi,%0" : "=m"(newregs->si));
135 __asm__ __volatile__("movq %%rdi,%0" : "=m"(newregs->di)); 134 asm volatile("movq %%rdi,%0" : "=m"(newregs->di));
136 __asm__ __volatile__("movq %%rbp,%0" : "=m"(newregs->bp)); 135 asm volatile("movq %%rbp,%0" : "=m"(newregs->bp));
137 __asm__ __volatile__("movq %%rax,%0" : "=m"(newregs->ax)); 136 asm volatile("movq %%rax,%0" : "=m"(newregs->ax));
138 __asm__ __volatile__("movq %%rsp,%0" : "=m"(newregs->sp)); 137 asm volatile("movq %%rsp,%0" : "=m"(newregs->sp));
139 __asm__ __volatile__("movq %%r8,%0" : "=m"(newregs->r8)); 138 asm volatile("movq %%r8,%0" : "=m"(newregs->r8));
140 __asm__ __volatile__("movq %%r9,%0" : "=m"(newregs->r9)); 139 asm volatile("movq %%r9,%0" : "=m"(newregs->r9));
141 __asm__ __volatile__("movq %%r10,%0" : "=m"(newregs->r10)); 140 asm volatile("movq %%r10,%0" : "=m"(newregs->r10));
142 __asm__ __volatile__("movq %%r11,%0" : "=m"(newregs->r11)); 141 asm volatile("movq %%r11,%0" : "=m"(newregs->r11));
143 __asm__ __volatile__("movq %%r12,%0" : "=m"(newregs->r12)); 142 asm volatile("movq %%r12,%0" : "=m"(newregs->r12));
144 __asm__ __volatile__("movq %%r13,%0" : "=m"(newregs->r13)); 143 asm volatile("movq %%r13,%0" : "=m"(newregs->r13));
145 __asm__ __volatile__("movq %%r14,%0" : "=m"(newregs->r14)); 144 asm volatile("movq %%r14,%0" : "=m"(newregs->r14));
146 __asm__ __volatile__("movq %%r15,%0" : "=m"(newregs->r15)); 145 asm volatile("movq %%r15,%0" : "=m"(newregs->r15));
147 __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss)); 146 asm volatile("movl %%ss, %%eax;" :"=a"(newregs->ss));
148 __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs)); 147 asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs));
149 __asm__ __volatile__("pushfq; popq %0" :"=m"(newregs->flags)); 148 asm volatile("pushfq; popq %0" :"=m"(newregs->flags));
150#endif 149#endif
151 newregs->ip = (unsigned long)current_text_addr(); 150 newregs->ip = (unsigned long)current_text_addr();
152 } 151 }
diff --git a/include/asm-x86/kgdb.h b/include/asm-x86/kgdb.h
new file mode 100644
index 000000000000..484c47554f3b
--- /dev/null
+++ b/include/asm-x86/kgdb.h
@@ -0,0 +1,81 @@
1#ifndef _ASM_KGDB_H_
2#define _ASM_KGDB_H_
3
4/*
5 * Copyright (C) 2001-2004 Amit S. Kale
6 * Copyright (C) 2008 Wind River Systems, Inc.
7 */
8
9/*
10 * BUFMAX defines the maximum number of characters in inbound/outbound
11 * buffers at least NUMREGBYTES*2 are needed for register packets
12 * Longer buffer is needed to list all threads
13 */
14#define BUFMAX 1024
15
16/*
17 * Note that this register image is in a different order than
18 * the register image that Linux produces at interrupt time.
19 *
20 * Linux's register image is defined by struct pt_regs in ptrace.h.
21 * Just why GDB uses a different order is a historical mystery.
22 */
23#ifdef CONFIG_X86_32
24enum regnames {
25 GDB_AX, /* 0 */
26 GDB_CX, /* 1 */
27 GDB_DX, /* 2 */
28 GDB_BX, /* 3 */
29 GDB_SP, /* 4 */
30 GDB_BP, /* 5 */
31 GDB_SI, /* 6 */
32 GDB_DI, /* 7 */
33 GDB_PC, /* 8 also known as eip */
34 GDB_PS, /* 9 also known as eflags */
35 GDB_CS, /* 10 */
36 GDB_SS, /* 11 */
37 GDB_DS, /* 12 */
38 GDB_ES, /* 13 */
39 GDB_FS, /* 14 */
40 GDB_GS, /* 15 */
41};
42#else /* ! CONFIG_X86_32 */
43enum regnames {
44 GDB_AX, /* 0 */
45 GDB_DX, /* 1 */
46 GDB_CX, /* 2 */
47 GDB_BX, /* 3 */
48 GDB_SI, /* 4 */
49 GDB_DI, /* 5 */
50 GDB_BP, /* 6 */
51 GDB_SP, /* 7 */
52 GDB_R8, /* 8 */
53 GDB_R9, /* 9 */
54 GDB_R10, /* 10 */
55 GDB_R11, /* 11 */
56 GDB_R12, /* 12 */
57 GDB_R13, /* 13 */
58 GDB_R14, /* 14 */
59 GDB_R15, /* 15 */
60 GDB_PC, /* 16 */
61 GDB_PS, /* 17 */
62};
63#endif /* CONFIG_X86_32 */
64
65/*
66 * Number of bytes of registers:
67 */
68#ifdef CONFIG_X86_32
69# define NUMREGBYTES 64
70#else
71# define NUMREGBYTES ((GDB_PS+1)*8)
72#endif
73
74static inline void arch_kgdb_breakpoint(void)
75{
76 asm(" int $3");
77}
78#define BREAK_INSTR_SIZE 1
79#define CACHE_FLUSH_IS_SAFE 1
80
81#endif /* _ASM_KGDB_H_ */
diff --git a/include/asm-x86/kprobes.h b/include/asm-x86/kprobes.h
index 61ad7b5d142e..54980b0b3892 100644
--- a/include/asm-x86/kprobes.h
+++ b/include/asm-x86/kprobes.h
@@ -35,12 +35,12 @@ typedef u8 kprobe_opcode_t;
35#define RELATIVEJUMP_INSTRUCTION 0xe9 35#define RELATIVEJUMP_INSTRUCTION 0xe9
36#define MAX_INSN_SIZE 16 36#define MAX_INSN_SIZE 16
37#define MAX_STACK_SIZE 64 37#define MAX_STACK_SIZE 64
38#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \ 38#define MIN_STACK_SIZE(ADDR) \
39 (((unsigned long)current_thread_info()) + THREAD_SIZE \ 39 (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
40 - (unsigned long)(ADDR))) \ 40 THREAD_SIZE - (unsigned long)(ADDR))) \
41 ? (MAX_STACK_SIZE) \ 41 ? (MAX_STACK_SIZE) \
42 : (((unsigned long)current_thread_info()) + THREAD_SIZE \ 42 : (((unsigned long)current_thread_info()) + \
43 - (unsigned long)(ADDR))) 43 THREAD_SIZE - (unsigned long)(ADDR)))
44 44
45#define flush_insn_slot(p) do { } while (0) 45#define flush_insn_slot(p) do { } while (0)
46 46
diff --git a/include/asm-x86/kvm.h b/include/asm-x86/kvm.h
index 7a71120426a3..80eefef2cc76 100644
--- a/include/asm-x86/kvm.h
+++ b/include/asm-x86/kvm.h
@@ -188,4 +188,45 @@ struct kvm_cpuid2 {
188 struct kvm_cpuid_entry2 entries[0]; 188 struct kvm_cpuid_entry2 entries[0];
189}; 189};
190 190
191/* for KVM_GET_PIT and KVM_SET_PIT */
192struct kvm_pit_channel_state {
193 __u32 count; /* can be 65536 */
194 __u16 latched_count;
195 __u8 count_latched;
196 __u8 status_latched;
197 __u8 status;
198 __u8 read_state;
199 __u8 write_state;
200 __u8 write_latch;
201 __u8 rw_mode;
202 __u8 mode;
203 __u8 bcd;
204 __u8 gate;
205 __s64 count_load_time;
206};
207
208struct kvm_pit_state {
209 struct kvm_pit_channel_state channels[3];
210};
211
212#define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
213#define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
214#define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
215#define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05)
216#define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06)
217#define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07)
218#define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08)
219#define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09)
220#define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A)
221#define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B)
222#define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C)
223#define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D)
224#define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E)
225#define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F)
226#define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10)
227#define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11)
228#define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
229#define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
230#define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)
231
191#endif 232#endif
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index 4702b04b979a..9d963cd6533c 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -20,17 +20,25 @@
20 20
21#include <asm/desc.h> 21#include <asm/desc.h>
22 22
23#define KVM_MAX_VCPUS 16
24#define KVM_MEMORY_SLOTS 32
25/* memory slots that does not exposed to userspace */
26#define KVM_PRIVATE_MEM_SLOTS 4
27
28#define KVM_PIO_PAGE_OFFSET 1
29
23#define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1) 30#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)) 31#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) 32#define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS | \
33 0xFFFFFF0000000000ULL)
26 34
27#define KVM_GUEST_CR0_MASK \ 35#define KVM_GUEST_CR0_MASK \
28 (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP | X86_CR0_NE \ 36 (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP | X86_CR0_NE \
29 | X86_CR0_NW | X86_CR0_CD) 37 | X86_CR0_NW | X86_CR0_CD)
30#define KVM_VM_CR0_ALWAYS_ON \ 38#define KVM_VM_CR0_ALWAYS_ON \
31 (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP | X86_CR0_NE | X86_CR0_TS \ 39 (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP | X86_CR0_NE | X86_CR0_TS \
32 | X86_CR0_MP) 40 | X86_CR0_MP)
33#define KVM_GUEST_CR4_MASK \ 41#define KVM_GUEST_CR4_MASK \
34 (X86_CR4_VME | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE | X86_CR4_VMXE) 42 (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) 43#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) 44#define KVM_RMODE_VM_CR4_ALWAYS_ON (X86_CR4_VME | X86_CR4_PAE | X86_CR4_VMXE)
@@ -38,6 +46,13 @@
38#define INVALID_PAGE (~(hpa_t)0) 46#define INVALID_PAGE (~(hpa_t)0)
39#define UNMAPPED_GVA (~(gpa_t)0) 47#define UNMAPPED_GVA (~(gpa_t)0)
40 48
49/* shadow tables are PAE even on non-PAE hosts */
50#define KVM_HPAGE_SHIFT 21
51#define KVM_HPAGE_SIZE (1UL << KVM_HPAGE_SHIFT)
52#define KVM_HPAGE_MASK (~(KVM_HPAGE_SIZE - 1))
53
54#define KVM_PAGES_PER_HPAGE (KVM_HPAGE_SIZE / PAGE_SIZE)
55
41#define DE_VECTOR 0 56#define DE_VECTOR 0
42#define UD_VECTOR 6 57#define UD_VECTOR 6
43#define NM_VECTOR 7 58#define NM_VECTOR 7
@@ -47,6 +62,7 @@
47#define SS_VECTOR 12 62#define SS_VECTOR 12
48#define GP_VECTOR 13 63#define GP_VECTOR 13
49#define PF_VECTOR 14 64#define PF_VECTOR 14
65#define MC_VECTOR 18
50 66
51#define SELECTOR_TI_MASK (1 << 2) 67#define SELECTOR_TI_MASK (1 << 2)
52#define SELECTOR_RPL_MASK 0x03 68#define SELECTOR_RPL_MASK 0x03
@@ -57,7 +73,8 @@
57 73
58#define KVM_PERMILLE_MMU_PAGES 20 74#define KVM_PERMILLE_MMU_PAGES 20
59#define KVM_MIN_ALLOC_MMU_PAGES 64 75#define KVM_MIN_ALLOC_MMU_PAGES 64
60#define KVM_NUM_MMU_PAGES 1024 76#define KVM_MMU_HASH_SHIFT 10
77#define KVM_NUM_MMU_PAGES (1 << KVM_MMU_HASH_SHIFT)
61#define KVM_MIN_FREE_MMU_PAGES 5 78#define KVM_MIN_FREE_MMU_PAGES 5
62#define KVM_REFILL_PAGES 25 79#define KVM_REFILL_PAGES 25
63#define KVM_MAX_CPUID_ENTRIES 40 80#define KVM_MAX_CPUID_ENTRIES 40
@@ -105,6 +122,12 @@ enum {
105 122
106#define KVM_NR_MEM_OBJS 40 123#define KVM_NR_MEM_OBJS 40
107 124
125struct kvm_guest_debug {
126 int enabled;
127 unsigned long bp[4];
128 int singlestep;
129};
130
108/* 131/*
109 * We don't want allocation failures within the mmu code, so we preallocate 132 * We don't want allocation failures within the mmu code, so we preallocate
110 * enough memory for a single page fault in a cache. 133 * enough memory for a single page fault in a cache.
@@ -133,12 +156,13 @@ struct kvm_pte_chain {
133union kvm_mmu_page_role { 156union kvm_mmu_page_role {
134 unsigned word; 157 unsigned word;
135 struct { 158 struct {
136 unsigned glevels : 4; 159 unsigned glevels:4;
137 unsigned level : 4; 160 unsigned level:4;
138 unsigned quadrant : 2; 161 unsigned quadrant:2;
139 unsigned pad_for_nice_hex_output : 6; 162 unsigned pad_for_nice_hex_output:6;
140 unsigned metaphysical : 1; 163 unsigned metaphysical:1;
141 unsigned access : 3; 164 unsigned access:3;
165 unsigned invalid:1;
142 }; 166 };
143}; 167};
144 168
@@ -203,11 +227,6 @@ struct kvm_vcpu_arch {
203 u64 shadow_efer; 227 u64 shadow_efer;
204 u64 apic_base; 228 u64 apic_base;
205 struct kvm_lapic *apic; /* kernel irqchip context */ 229 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; 230 int mp_state;
212 int sipi_vector; 231 int sipi_vector;
213 u64 ia32_misc_enable_msr; 232 u64 ia32_misc_enable_msr;
@@ -225,8 +244,9 @@ struct kvm_vcpu_arch {
225 u64 *last_pte_updated; 244 u64 *last_pte_updated;
226 245
227 struct { 246 struct {
228 gfn_t gfn; /* presumed gfn during guest pte update */ 247 gfn_t gfn; /* presumed gfn during guest pte update */
229 struct page *page; /* page corresponding to that gfn */ 248 pfn_t pfn; /* pfn corresponding to that gfn */
249 int largepage;
230 } update_pte; 250 } update_pte;
231 251
232 struct i387_fxsave_struct host_fx_image; 252 struct i387_fxsave_struct host_fx_image;
@@ -260,6 +280,11 @@ struct kvm_vcpu_arch {
260 /* emulate context */ 280 /* emulate context */
261 281
262 struct x86_emulate_ctxt emulate_ctxt; 282 struct x86_emulate_ctxt emulate_ctxt;
283
284 gpa_t time;
285 struct kvm_vcpu_time_info hv_clock;
286 unsigned int time_offset;
287 struct page *time_page;
263}; 288};
264 289
265struct kvm_mem_alias { 290struct kvm_mem_alias {
@@ -282,10 +307,13 @@ struct kvm_arch{
282 struct list_head active_mmu_pages; 307 struct list_head active_mmu_pages;
283 struct kvm_pic *vpic; 308 struct kvm_pic *vpic;
284 struct kvm_ioapic *vioapic; 309 struct kvm_ioapic *vioapic;
310 struct kvm_pit *vpit;
285 311
286 int round_robin_prev_vcpu; 312 int round_robin_prev_vcpu;
287 unsigned int tss_addr; 313 unsigned int tss_addr;
288 struct page *apic_access_page; 314 struct page *apic_access_page;
315
316 gpa_t wall_clock;
289}; 317};
290 318
291struct kvm_vm_stat { 319struct kvm_vm_stat {
@@ -297,6 +325,7 @@ struct kvm_vm_stat {
297 u32 mmu_recycled; 325 u32 mmu_recycled;
298 u32 mmu_cache_miss; 326 u32 mmu_cache_miss;
299 u32 remote_tlb_flush; 327 u32 remote_tlb_flush;
328 u32 lpages;
300}; 329};
301 330
302struct kvm_vcpu_stat { 331struct kvm_vcpu_stat {
@@ -319,6 +348,7 @@ struct kvm_vcpu_stat {
319 u32 fpu_reload; 348 u32 fpu_reload;
320 u32 insn_emulation; 349 u32 insn_emulation;
321 u32 insn_emulation_fail; 350 u32 insn_emulation_fail;
351 u32 hypercalls;
322}; 352};
323 353
324struct descriptor_table { 354struct descriptor_table {
@@ -354,6 +384,7 @@ struct kvm_x86_ops {
354 u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg); 384 u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg);
355 void (*get_segment)(struct kvm_vcpu *vcpu, 385 void (*get_segment)(struct kvm_vcpu *vcpu,
356 struct kvm_segment *var, int seg); 386 struct kvm_segment *var, int seg);
387 int (*get_cpl)(struct kvm_vcpu *vcpu);
357 void (*set_segment)(struct kvm_vcpu *vcpu, 388 void (*set_segment)(struct kvm_vcpu *vcpu,
358 struct kvm_segment *var, int seg); 389 struct kvm_segment *var, int seg);
359 void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l); 390 void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l);
@@ -409,6 +440,15 @@ void kvm_mmu_zap_all(struct kvm *kvm);
409unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm); 440unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm);
410void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages); 441void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
411 442
443int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
444
445int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
446 const void *val, int bytes);
447int kvm_pv_mmu_op(struct kvm_vcpu *vcpu, unsigned long bytes,
448 gpa_t addr, unsigned long *ret);
449
450extern bool tdp_enabled;
451
412enum emulation_result { 452enum emulation_result {
413 EMULATE_DONE, /* no further processing */ 453 EMULATE_DONE, /* no further processing */
414 EMULATE_DO_MMIO, /* kvm_run filled with mmio request */ 454 EMULATE_DO_MMIO, /* kvm_run filled with mmio request */
@@ -428,6 +468,7 @@ void realmode_lmsw(struct kvm_vcpu *vcpu, unsigned long msw,
428unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr); 468unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr);
429void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long value, 469void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long value,
430 unsigned long *rflags); 470 unsigned long *rflags);
471void kvm_enable_efer_bits(u64);
431int kvm_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *data); 472int 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); 473int kvm_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data);
433 474
@@ -447,12 +488,14 @@ int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr,
447int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, 488int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr,
448 unsigned long value); 489 unsigned long value);
449 490
450void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); 491int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason);
451void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr0); 492
452void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr0); 493void kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);
453void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0); 494void kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3);
454unsigned long get_cr8(struct kvm_vcpu *vcpu); 495void kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4);
455void lmsw(struct kvm_vcpu *vcpu, unsigned long msw); 496void kvm_set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8);
497unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu);
498void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw);
456void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l); 499void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l);
457 500
458int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata); 501int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata);
@@ -490,6 +533,8 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
490 533
491int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code); 534int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code);
492 535
536void kvm_enable_tdp(void);
537
493int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); 538int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
494int complete_pio(struct kvm_vcpu *vcpu); 539int complete_pio(struct kvm_vcpu *vcpu);
495 540
@@ -599,6 +644,7 @@ static inline void kvm_inject_gp(struct kvm_vcpu *vcpu, u32 error_code)
599#define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4" 644#define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4"
600#define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4" 645#define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4"
601#define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30" 646#define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30"
647#define ASM_VMX_INVVPID ".byte 0x66, 0x0f, 0x38, 0x81, 0x08"
602 648
603#define MSR_IA32_TIME_STAMP_COUNTER 0x010 649#define MSR_IA32_TIME_STAMP_COUNTER 0x010
604 650
@@ -606,6 +652,33 @@ static inline void kvm_inject_gp(struct kvm_vcpu *vcpu, u32 error_code)
606#define TSS_BASE_SIZE 0x68 652#define TSS_BASE_SIZE 0x68
607#define TSS_IOPB_SIZE (65536 / 8) 653#define TSS_IOPB_SIZE (65536 / 8)
608#define TSS_REDIRECTION_SIZE (256 / 8) 654#define TSS_REDIRECTION_SIZE (256 / 8)
609#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) 655#define RMODE_TSS_SIZE \
656 (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
657
658enum {
659 TASK_SWITCH_CALL = 0,
660 TASK_SWITCH_IRET = 1,
661 TASK_SWITCH_JMP = 2,
662 TASK_SWITCH_GATE = 3,
663};
664
665#define KVMTRACE_5D(evt, vcpu, d1, d2, d3, d4, d5, name) \
666 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
667 vcpu, 5, d1, d2, d3, d4, d5)
668#define KVMTRACE_4D(evt, vcpu, d1, d2, d3, d4, name) \
669 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
670 vcpu, 4, d1, d2, d3, d4, 0)
671#define KVMTRACE_3D(evt, vcpu, d1, d2, d3, name) \
672 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
673 vcpu, 3, d1, d2, d3, 0, 0)
674#define KVMTRACE_2D(evt, vcpu, d1, d2, name) \
675 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
676 vcpu, 2, d1, d2, 0, 0, 0)
677#define KVMTRACE_1D(evt, vcpu, d1, name) \
678 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
679 vcpu, 1, d1, 0, 0, 0, 0)
680#define KVMTRACE_0D(evt, vcpu, name) \
681 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
682 vcpu, 0, 0, 0, 0, 0, 0)
610 683
611#endif 684#endif
diff --git a/include/asm-x86/kvm_para.h b/include/asm-x86/kvm_para.h
index c6f3fd8d8c53..509845942070 100644
--- a/include/asm-x86/kvm_para.h
+++ b/include/asm-x86/kvm_para.h
@@ -10,10 +10,65 @@
10 * paravirtualization, the appropriate feature bit should be checked. 10 * paravirtualization, the appropriate feature bit should be checked.
11 */ 11 */
12#define KVM_CPUID_FEATURES 0x40000001 12#define KVM_CPUID_FEATURES 0x40000001
13#define KVM_FEATURE_CLOCKSOURCE 0
14#define KVM_FEATURE_NOP_IO_DELAY 1
15#define KVM_FEATURE_MMU_OP 2
16
17#define MSR_KVM_WALL_CLOCK 0x11
18#define MSR_KVM_SYSTEM_TIME 0x12
19
20#define KVM_MAX_MMU_OP_BATCH 32
21
22/* Operations for KVM_HC_MMU_OP */
23#define KVM_MMU_OP_WRITE_PTE 1
24#define KVM_MMU_OP_FLUSH_TLB 2
25#define KVM_MMU_OP_RELEASE_PT 3
26
27/* Payload for KVM_HC_MMU_OP */
28struct kvm_mmu_op_header {
29 __u32 op;
30 __u32 pad;
31};
32
33struct kvm_mmu_op_write_pte {
34 struct kvm_mmu_op_header header;
35 __u64 pte_phys;
36 __u64 pte_val;
37};
38
39struct kvm_mmu_op_flush_tlb {
40 struct kvm_mmu_op_header header;
41};
42
43struct kvm_mmu_op_release_pt {
44 struct kvm_mmu_op_header header;
45 __u64 pt_phys;
46};
13 47
14#ifdef __KERNEL__ 48#ifdef __KERNEL__
15#include <asm/processor.h> 49#include <asm/processor.h>
16 50
51/* xen binary-compatible interface. See xen headers for details */
52struct kvm_vcpu_time_info {
53 uint32_t version;
54 uint32_t pad0;
55 uint64_t tsc_timestamp;
56 uint64_t system_time;
57 uint32_t tsc_to_system_mul;
58 int8_t tsc_shift;
59 int8_t pad[3];
60} __attribute__((__packed__)); /* 32 bytes */
61
62struct kvm_wall_clock {
63 uint32_t wc_version;
64 uint32_t wc_sec;
65 uint32_t wc_nsec;
66} __attribute__((__packed__));
67
68
69extern void kvmclock_init(void);
70
71
17/* This instruction is vmcall. On non-VT architectures, it will generate a 72/* This instruction is vmcall. On non-VT architectures, it will generate a
18 * trap that we will then rewrite to the appropriate instruction. 73 * trap that we will then rewrite to the appropriate instruction.
19 */ 74 */
diff --git a/include/asm-x86/kvm_x86_emulate.h b/include/asm-x86/kvm_x86_emulate.h
index 7db91b9bdcd4..d6337f941c98 100644
--- a/include/asm-x86/kvm_x86_emulate.h
+++ b/include/asm-x86/kvm_x86_emulate.h
@@ -68,10 +68,10 @@ struct x86_emulate_ops {
68 * @val: [OUT] Value read from memory, zero-extended to 'u_long'. 68 * @val: [OUT] Value read from memory, zero-extended to 'u_long'.
69 * @bytes: [IN ] Number of bytes to read from memory. 69 * @bytes: [IN ] Number of bytes to read from memory.
70 */ 70 */
71 int (*read_emulated) (unsigned long addr, 71 int (*read_emulated)(unsigned long addr,
72 void *val, 72 void *val,
73 unsigned int bytes, 73 unsigned int bytes,
74 struct kvm_vcpu *vcpu); 74 struct kvm_vcpu *vcpu);
75 75
76 /* 76 /*
77 * write_emulated: Read bytes from emulated/special memory area. 77 * write_emulated: Read bytes from emulated/special memory area.
@@ -80,10 +80,10 @@ struct x86_emulate_ops {
80 * required). 80 * required).
81 * @bytes: [IN ] Number of bytes to write to memory. 81 * @bytes: [IN ] Number of bytes to write to memory.
82 */ 82 */
83 int (*write_emulated) (unsigned long addr, 83 int (*write_emulated)(unsigned long addr,
84 const void *val, 84 const void *val,
85 unsigned int bytes, 85 unsigned int bytes,
86 struct kvm_vcpu *vcpu); 86 struct kvm_vcpu *vcpu);
87 87
88 /* 88 /*
89 * cmpxchg_emulated: Emulate an atomic (LOCKed) CMPXCHG operation on an 89 * cmpxchg_emulated: Emulate an atomic (LOCKed) CMPXCHG operation on an
@@ -93,11 +93,11 @@ struct x86_emulate_ops {
93 * @new: [IN ] Value to write to @addr. 93 * @new: [IN ] Value to write to @addr.
94 * @bytes: [IN ] Number of bytes to access using CMPXCHG. 94 * @bytes: [IN ] Number of bytes to access using CMPXCHG.
95 */ 95 */
96 int (*cmpxchg_emulated) (unsigned long addr, 96 int (*cmpxchg_emulated)(unsigned long addr,
97 const void *old, 97 const void *old,
98 const void *new, 98 const void *new,
99 unsigned int bytes, 99 unsigned int bytes,
100 struct kvm_vcpu *vcpu); 100 struct kvm_vcpu *vcpu);
101 101
102}; 102};
103 103
@@ -143,7 +143,7 @@ struct x86_emulate_ctxt {
143 /* Register state before/after emulation. */ 143 /* Register state before/after emulation. */
144 struct kvm_vcpu *vcpu; 144 struct kvm_vcpu *vcpu;
145 145
146 /* Linear faulting address (if emulating a page-faulting instruction). */ 146 /* Linear faulting address (if emulating a page-faulting instruction) */
147 unsigned long eflags; 147 unsigned long eflags;
148 148
149 /* Emulated execution mode, represented by an X86EMUL_MODE value. */ 149 /* Emulated execution mode, represented by an X86EMUL_MODE value. */
diff --git a/include/asm-x86/lguest.h b/include/asm-x86/lguest.h
index 9b17571e9bc3..be4a7247fa2b 100644
--- a/include/asm-x86/lguest.h
+++ b/include/asm-x86/lguest.h
@@ -34,8 +34,7 @@ extern const char lgstart_iret[], lgend_iret[];
34extern void lguest_iret(void); 34extern void lguest_iret(void);
35extern void lguest_init(void); 35extern void lguest_init(void);
36 36
37struct lguest_regs 37struct lguest_regs {
38{
39 /* Manually saved part. */ 38 /* Manually saved part. */
40 unsigned long eax, ebx, ecx, edx; 39 unsigned long eax, ebx, ecx, edx;
41 unsigned long esi, edi, ebp; 40 unsigned long esi, edi, ebp;
@@ -51,8 +50,7 @@ struct lguest_regs
51}; 50};
52 51
53/* This is a guest-specific page (mapped ro) into the guest. */ 52/* This is a guest-specific page (mapped ro) into the guest. */
54struct lguest_ro_state 53struct lguest_ro_state {
55{
56 /* Host information we need to restore when we switch back. */ 54 /* Host information we need to restore when we switch back. */
57 u32 host_cr3; 55 u32 host_cr3;
58 struct desc_ptr host_idt_desc; 56 struct desc_ptr host_idt_desc;
@@ -67,8 +65,7 @@ struct lguest_ro_state
67 struct desc_struct guest_gdt[GDT_ENTRIES]; 65 struct desc_struct guest_gdt[GDT_ENTRIES];
68}; 66};
69 67
70struct lg_cpu_arch 68struct lg_cpu_arch {
71{
72 /* The GDT entries copied into lguest_ro_state when running. */ 69 /* The GDT entries copied into lguest_ro_state when running. */
73 struct desc_struct gdt[GDT_ENTRIES]; 70 struct desc_struct gdt[GDT_ENTRIES];
74 71
@@ -85,7 +82,7 @@ static inline void lguest_set_ts(void)
85 82
86 cr0 = read_cr0(); 83 cr0 = read_cr0();
87 if (!(cr0 & 8)) 84 if (!(cr0 & 8))
88 write_cr0(cr0|8); 85 write_cr0(cr0 | 8);
89} 86}
90 87
91/* Full 4G segment descriptors, suitable for CS and DS. */ 88/* Full 4G segment descriptors, suitable for CS and DS. */
diff --git a/include/asm-x86/lguest_hcall.h b/include/asm-x86/lguest_hcall.h
index f239e7069cab..a3241f28e34a 100644
--- a/include/asm-x86/lguest_hcall.h
+++ b/include/asm-x86/lguest_hcall.h
@@ -46,7 +46,7 @@ hcall(unsigned long call,
46{ 46{
47 /* "int" is the Intel instruction to trigger a trap. */ 47 /* "int" is the Intel instruction to trigger a trap. */
48 asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY) 48 asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY)
49 /* The call in %eax (aka "a") might be overwritten */ 49 /* The call in %eax (aka "a") might be overwritten */
50 : "=a"(call) 50 : "=a"(call)
51 /* The arguments are in %eax, %edx, %ebx & %ecx */ 51 /* The arguments are in %eax, %edx, %ebx & %ecx */
52 : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3) 52 : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3)
@@ -62,8 +62,7 @@ hcall(unsigned long call,
62#define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32) 62#define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32)
63 63
64#define LHCALL_RING_SIZE 64 64#define LHCALL_RING_SIZE 64
65struct hcall_args 65struct hcall_args {
66{
67 /* These map directly onto eax, ebx, ecx, edx in struct lguest_regs */ 66 /* These map directly onto eax, ebx, ecx, edx in struct lguest_regs */
68 unsigned long arg0, arg2, arg3, arg1; 67 unsigned long arg0, arg2, arg3, arg1;
69}; 68};
diff --git a/include/asm-x86/linkage.h b/include/asm-x86/linkage.h
index c048353f4b85..64e444f8e85b 100644
--- a/include/asm-x86/linkage.h
+++ b/include/asm-x86/linkage.h
@@ -1,6 +1,9 @@
1#ifndef __ASM_LINKAGE_H 1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H 2#define __ASM_LINKAGE_H
3 3
4#undef notrace
5#define notrace __attribute__((no_instrument_function))
6
4#ifdef CONFIG_X86_64 7#ifdef CONFIG_X86_64
5#define __ALIGN .p2align 4,,15 8#define __ALIGN .p2align 4,,15
6#define __ALIGN_STR ".p2align 4,,15" 9#define __ALIGN_STR ".p2align 4,,15"
diff --git a/include/asm-x86/local.h b/include/asm-x86/local.h
index f852c62b3319..330a72496abd 100644
--- a/include/asm-x86/local.h
+++ b/include/asm-x86/local.h
@@ -18,32 +18,28 @@ typedef struct {
18 18
19static inline void local_inc(local_t *l) 19static inline void local_inc(local_t *l)
20{ 20{
21 __asm__ __volatile__( 21 asm volatile(_ASM_INC "%0"
22 _ASM_INC "%0" 22 : "+m" (l->a.counter));
23 :"+m" (l->a.counter));
24} 23}
25 24
26static inline void local_dec(local_t *l) 25static inline void local_dec(local_t *l)
27{ 26{
28 __asm__ __volatile__( 27 asm volatile(_ASM_DEC "%0"
29 _ASM_DEC "%0" 28 : "+m" (l->a.counter));
30 :"+m" (l->a.counter));
31} 29}
32 30
33static inline void local_add(long i, local_t *l) 31static inline void local_add(long i, local_t *l)
34{ 32{
35 __asm__ __volatile__( 33 asm volatile(_ASM_ADD "%1,%0"
36 _ASM_ADD "%1,%0" 34 : "+m" (l->a.counter)
37 :"+m" (l->a.counter) 35 : "ir" (i));
38 :"ir" (i));
39} 36}
40 37
41static inline void local_sub(long i, local_t *l) 38static inline void local_sub(long i, local_t *l)
42{ 39{
43 __asm__ __volatile__( 40 asm volatile(_ASM_SUB "%1,%0"
44 _ASM_SUB "%1,%0" 41 : "+m" (l->a.counter)
45 :"+m" (l->a.counter) 42 : "ir" (i));
46 :"ir" (i));
47} 43}
48 44
49/** 45/**
@@ -59,10 +55,9 @@ static inline int local_sub_and_test(long i, local_t *l)
59{ 55{
60 unsigned char c; 56 unsigned char c;
61 57
62 __asm__ __volatile__( 58 asm volatile(_ASM_SUB "%2,%0; sete %1"
63 _ASM_SUB "%2,%0; sete %1" 59 : "+m" (l->a.counter), "=qm" (c)
64 :"+m" (l->a.counter), "=qm" (c) 60 : "ir" (i) : "memory");
65 :"ir" (i) : "memory");
66 return c; 61 return c;
67} 62}
68 63
@@ -78,10 +73,9 @@ static inline int local_dec_and_test(local_t *l)
78{ 73{
79 unsigned char c; 74 unsigned char c;
80 75
81 __asm__ __volatile__( 76 asm volatile(_ASM_DEC "%0; sete %1"
82 _ASM_DEC "%0; sete %1" 77 : "+m" (l->a.counter), "=qm" (c)
83 :"+m" (l->a.counter), "=qm" (c) 78 : : "memory");
84 : : "memory");
85 return c != 0; 79 return c != 0;
86} 80}
87 81
@@ -97,10 +91,9 @@ static inline int local_inc_and_test(local_t *l)
97{ 91{
98 unsigned char c; 92 unsigned char c;
99 93
100 __asm__ __volatile__( 94 asm volatile(_ASM_INC "%0; sete %1"
101 _ASM_INC "%0; sete %1" 95 : "+m" (l->a.counter), "=qm" (c)
102 :"+m" (l->a.counter), "=qm" (c) 96 : : "memory");
103 : : "memory");
104 return c != 0; 97 return c != 0;
105} 98}
106 99
@@ -117,10 +110,9 @@ static inline int local_add_negative(long i, local_t *l)
117{ 110{
118 unsigned char c; 111 unsigned char c;
119 112
120 __asm__ __volatile__( 113 asm volatile(_ASM_ADD "%2,%0; sets %1"
121 _ASM_ADD "%2,%0; sets %1" 114 : "+m" (l->a.counter), "=qm" (c)
122 :"+m" (l->a.counter), "=qm" (c) 115 : "ir" (i) : "memory");
123 :"ir" (i) : "memory");
124 return c; 116 return c;
125} 117}
126 118
@@ -141,10 +133,9 @@ static inline long local_add_return(long i, local_t *l)
141#endif 133#endif
142 /* Modern 486+ processor */ 134 /* Modern 486+ processor */
143 __i = i; 135 __i = i;
144 __asm__ __volatile__( 136 asm volatile(_ASM_XADD "%0, %1;"
145 _ASM_XADD "%0, %1;" 137 : "+r" (i), "+m" (l->a.counter)
146 :"+r" (i), "+m" (l->a.counter) 138 : : "memory");
147 : : "memory");
148 return i + __i; 139 return i + __i;
149 140
150#ifdef CONFIG_M386 141#ifdef CONFIG_M386
@@ -182,11 +173,11 @@ static inline long local_sub_return(long i, local_t *l)
182#define local_add_unless(l, a, u) \ 173#define local_add_unless(l, a, u) \
183({ \ 174({ \
184 long c, old; \ 175 long c, old; \
185 c = local_read(l); \ 176 c = local_read((l)); \
186 for (;;) { \ 177 for (;;) { \
187 if (unlikely(c == (u))) \ 178 if (unlikely(c == (u))) \
188 break; \ 179 break; \
189 old = local_cmpxchg((l), c, c + (a)); \ 180 old = local_cmpxchg((l), c, c + (a)); \
190 if (likely(old == c)) \ 181 if (likely(old == c)) \
191 break; \ 182 break; \
192 c = old; \ 183 c = old; \
@@ -214,26 +205,30 @@ static inline long local_sub_return(long i, local_t *l)
214 205
215/* Need to disable preemption for the cpu local counters otherwise we could 206/* 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. */ 207 still access a variable of a previous CPU in a non atomic way. */
217#define cpu_local_wrap_v(l) \ 208#define cpu_local_wrap_v(l) \
218 ({ local_t res__; \ 209({ \
219 preempt_disable(); \ 210 local_t res__; \
220 res__ = (l); \ 211 preempt_disable(); \
221 preempt_enable(); \ 212 res__ = (l); \
222 res__; }) 213 preempt_enable(); \
214 res__; \
215})
223#define cpu_local_wrap(l) \ 216#define cpu_local_wrap(l) \
224 ({ preempt_disable(); \ 217({ \
225 l; \ 218 preempt_disable(); \
226 preempt_enable(); }) \ 219 (l); \
227 220 preempt_enable(); \
228#define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l))) 221}) \
229#define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i))) 222
230#define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l))) 223#define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var((l))))
231#define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l))) 224#define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var((l)), (i)))
232#define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l))) 225#define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var((l))))
233#define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l))) 226#define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var((l))))
234 227#define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var((l))))
235#define __cpu_local_inc(l) cpu_local_inc(l) 228#define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var((l))))
236#define __cpu_local_dec(l) cpu_local_dec(l) 229
230#define __cpu_local_inc(l) cpu_local_inc((l))
231#define __cpu_local_dec(l) cpu_local_dec((l))
237#define __cpu_local_add(i, l) cpu_local_add((i), (l)) 232#define __cpu_local_add(i, l) cpu_local_add((i), (l))
238#define __cpu_local_sub(i, l) cpu_local_sub((i), (l)) 233#define __cpu_local_sub(i, l) cpu_local_sub((i), (l))
239 234
diff --git a/include/asm-x86/mach-bigsmp/mach_apic.h b/include/asm-x86/mach-bigsmp/mach_apic.h
index 6df235e8ea91..8327907c79bf 100644
--- a/include/asm-x86/mach-bigsmp/mach_apic.h
+++ b/include/asm-x86/mach-bigsmp/mach_apic.h
@@ -1,10 +1,7 @@
1#ifndef __ASM_MACH_APIC_H 1#ifndef __ASM_MACH_APIC_H
2#define __ASM_MACH_APIC_H 2#define __ASM_MACH_APIC_H
3 3
4 4#define xapic_phys_to_log_apicid(cpu) (per_cpu(x86_bios_cpu_apicid, cpu))
5extern u8 bios_cpu_apicid[];
6
7#define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu])
8#define esr_disable (1) 5#define esr_disable (1)
9 6
10static inline int apic_id_registered(void) 7static inline int apic_id_registered(void)
@@ -90,7 +87,7 @@ static inline int apicid_to_node(int logical_apicid)
90static inline int cpu_present_to_apicid(int mps_cpu) 87static inline int cpu_present_to_apicid(int mps_cpu)
91{ 88{
92 if (mps_cpu < NR_CPUS) 89 if (mps_cpu < NR_CPUS)
93 return (int) bios_cpu_apicid[mps_cpu]; 90 return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
94 91
95 return BAD_APICID; 92 return BAD_APICID;
96} 93}
@@ -109,17 +106,6 @@ static inline int cpu_to_logical_apicid(int cpu)
109 return cpu_physical_id(cpu); 106 return cpu_physical_id(cpu);
110} 107}
111 108
112static inline int mpc_apic_id(struct mpc_config_processor *m,
113 struct mpc_config_translation *translation_record)
114{
115 printk("Processor #%d %u:%u APIC version %d\n",
116 m->mpc_apicid,
117 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
118 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
119 m->mpc_apicver);
120 return m->mpc_apicid;
121}
122
123static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) 109static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
124{ 110{
125 /* For clustered we don't have a good way to do this yet - hack */ 111 /* For clustered we don't have a good way to do this yet - hack */
diff --git a/include/asm-x86/mach-default/mach_apic.h b/include/asm-x86/mach-default/mach_apic.h
index e3c2c1012c1c..21003b56ae95 100644
--- a/include/asm-x86/mach-default/mach_apic.h
+++ b/include/asm-x86/mach-default/mach_apic.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_MACH_APIC_H 1#ifndef __ASM_MACH_APIC_H
2#define __ASM_MACH_APIC_H 2#define __ASM_MACH_APIC_H
3 3
4#ifdef CONFIG_X86_LOCAL_APIC
5
4#include <mach_apicdef.h> 6#include <mach_apicdef.h>
5#include <asm/smp.h> 7#include <asm/smp.h>
6 8
@@ -14,24 +16,25 @@ static inline cpumask_t target_cpus(void)
14 return cpumask_of_cpu(0); 16 return cpumask_of_cpu(0);
15#endif 17#endif
16} 18}
17#define TARGET_CPUS (target_cpus())
18 19
19#define NO_BALANCE_IRQ (0) 20#define NO_BALANCE_IRQ (0)
20#define esr_disable (0) 21#define esr_disable (0)
21 22
23#ifdef CONFIG_X86_64
24#include <asm/genapic.h>
25#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
26#define INT_DEST_MODE (genapic->int_dest_mode)
27#define TARGET_CPUS (genapic->target_cpus())
28#define apic_id_registered (genapic->apic_id_registered)
29#define init_apic_ldr (genapic->init_apic_ldr)
30#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
31#define phys_pkg_id (genapic->phys_pkg_id)
32#define vector_allocation_domain (genapic->vector_allocation_domain)
33extern void setup_apic_routing(void);
34#else
22#define INT_DELIVERY_MODE dest_LowestPrio 35#define INT_DELIVERY_MODE dest_LowestPrio
23#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */ 36#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */
24 37#define TARGET_CPUS (target_cpus())
25static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
26{
27 return physid_isset(apicid, bitmap);
28}
29
30static inline unsigned long check_apicid_present(int bit)
31{
32 return physid_isset(bit, phys_cpu_present_map);
33}
34
35/* 38/*
36 * Set up the logical destination ID. 39 * Set up the logical destination ID.
37 * 40 *
@@ -49,23 +52,51 @@ static inline void init_apic_ldr(void)
49 apic_write_around(APIC_LDR, val); 52 apic_write_around(APIC_LDR, val);
50} 53}
51 54
52static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) 55static inline int apic_id_registered(void)
53{ 56{
54 return phys_map; 57 return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map);
58}
59
60static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
61{
62 return cpus_addr(cpumask)[0];
63}
64
65static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
66{
67 return cpuid_apic >> index_msb;
55} 68}
56 69
57static inline void setup_apic_routing(void) 70static inline void setup_apic_routing(void)
58{ 71{
72#ifdef CONFIG_X86_IO_APIC
59 printk("Enabling APIC mode: %s. Using %d I/O APICs\n", 73 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
60 "Flat", nr_ioapics); 74 "Flat", nr_ioapics);
75#endif
61} 76}
62 77
63static inline int multi_timer_check(int apic, int irq) 78static inline int apicid_to_node(int logical_apicid)
64{ 79{
65 return 0; 80 return 0;
66} 81}
82#endif
67 83
68static inline int apicid_to_node(int logical_apicid) 84static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
85{
86 return physid_isset(apicid, bitmap);
87}
88
89static inline unsigned long check_apicid_present(int bit)
90{
91 return physid_isset(bit, phys_cpu_present_map);
92}
93
94static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
95{
96 return phys_map;
97}
98
99static inline int multi_timer_check(int apic, int irq)
69{ 100{
70 return 0; 101 return 0;
71} 102}
@@ -78,8 +109,8 @@ static inline int cpu_to_logical_apicid(int cpu)
78 109
79static inline int cpu_present_to_apicid(int mps_cpu) 110static inline int cpu_present_to_apicid(int mps_cpu)
80{ 111{
81 if (mps_cpu < get_physical_broadcast()) 112 if (mps_cpu < NR_CPUS && cpu_present(mps_cpu))
82 return mps_cpu; 113 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
83 else 114 else
84 return BAD_APICID; 115 return BAD_APICID;
85} 116}
@@ -89,17 +120,6 @@ static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
89 return physid_mask_of_physid(phys_apicid); 120 return physid_mask_of_physid(phys_apicid);
90} 121}
91 122
92static inline int mpc_apic_id(struct mpc_config_processor *m,
93 struct mpc_config_translation *translation_record)
94{
95 printk("Processor #%d %u:%u APIC version %d\n",
96 m->mpc_apicid,
97 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
98 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
99 m->mpc_apicver);
100 return m->mpc_apicid;
101}
102
103static inline void setup_portio_remap(void) 123static inline void setup_portio_remap(void)
104{ 124{
105} 125}
@@ -109,23 +129,9 @@ static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
109 return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map); 129 return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
110} 130}
111 131
112static inline int apic_id_registered(void)
113{
114 return physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map);
115}
116
117static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
118{
119 return cpus_addr(cpumask)[0];
120}
121
122static inline void enable_apic_mode(void) 132static inline void enable_apic_mode(void)
123{ 133{
124} 134}
125 135
126static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) 136#endif /* CONFIG_X86_LOCAL_APIC */
127{
128 return cpuid_apic >> index_msb;
129}
130
131#endif /* __ASM_MACH_APIC_H */ 137#endif /* __ASM_MACH_APIC_H */
diff --git a/include/asm-x86/mach-default/mach_apicdef.h b/include/asm-x86/mach-default/mach_apicdef.h
index ae9841319094..e4b29ba37de6 100644
--- a/include/asm-x86/mach-default/mach_apicdef.h
+++ b/include/asm-x86/mach-default/mach_apicdef.h
@@ -3,10 +3,14 @@
3 3
4#include <asm/apic.h> 4#include <asm/apic.h>
5 5
6#ifdef CONFIG_X86_64
7#define APIC_ID_MASK (0xFFu<<24)
8#define GET_APIC_ID(x) (((x)>>24)&0xFFu)
9#define SET_APIC_ID(x) (((x)<<24))
10#else
6#define APIC_ID_MASK (0xF<<24) 11#define APIC_ID_MASK (0xF<<24)
7
8static inline unsigned get_apic_id(unsigned long x) 12static inline unsigned get_apic_id(unsigned long x)
9{ 13{
10 unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR)); 14 unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
11 if (APIC_XAPIC(ver)) 15 if (APIC_XAPIC(ver))
12 return (((x)>>24)&0xFF); 16 return (((x)>>24)&0xFF);
@@ -15,5 +19,6 @@ static inline unsigned get_apic_id(unsigned long x)
15} 19}
16 20
17#define GET_APIC_ID(x) get_apic_id(x) 21#define GET_APIC_ID(x) get_apic_id(x)
22#endif
18 23
19#endif 24#endif
diff --git a/include/asm-x86/mach-default/mach_ipi.h b/include/asm-x86/mach-default/mach_ipi.h
index 0dba244c86db..be323364e68f 100644
--- a/include/asm-x86/mach-default/mach_ipi.h
+++ b/include/asm-x86/mach-default/mach_ipi.h
@@ -9,10 +9,15 @@ void __send_IPI_shortcut(unsigned int shortcut, int vector);
9 9
10extern int no_broadcast; 10extern int no_broadcast;
11 11
12#ifdef CONFIG_X86_64
13#include <asm/genapic.h>
14#define send_IPI_mask (genapic->send_IPI_mask)
15#else
12static inline void send_IPI_mask(cpumask_t mask, int vector) 16static inline void send_IPI_mask(cpumask_t mask, int vector)
13{ 17{
14 send_IPI_mask_bitmask(mask, vector); 18 send_IPI_mask_bitmask(mask, vector);
15} 19}
20#endif
16 21
17static inline void __local_send_IPI_allbutself(int vector) 22static inline void __local_send_IPI_allbutself(int vector)
18{ 23{
@@ -33,6 +38,10 @@ static inline void __local_send_IPI_all(int vector)
33 __send_IPI_shortcut(APIC_DEST_ALLINC, vector); 38 __send_IPI_shortcut(APIC_DEST_ALLINC, vector);
34} 39}
35 40
41#ifdef CONFIG_X86_64
42#define send_IPI_allbutself (genapic->send_IPI_allbutself)
43#define send_IPI_all (genapic->send_IPI_all)
44#else
36static inline void send_IPI_allbutself(int vector) 45static inline void send_IPI_allbutself(int vector)
37{ 46{
38 /* 47 /*
@@ -50,5 +59,6 @@ static inline void send_IPI_all(int vector)
50{ 59{
51 __local_send_IPI_all(vector); 60 __local_send_IPI_all(vector);
52} 61}
62#endif
53 63
54#endif /* __ASM_MACH_IPI_H */ 64#endif /* __ASM_MACH_IPI_H */
diff --git a/include/asm-x86/mach-default/mach_mpparse.h b/include/asm-x86/mach-default/mach_mpparse.h
index 1d3832482580..d14108505bb8 100644
--- a/include/asm-x86/mach-default/mach_mpparse.h
+++ b/include/asm-x86/mach-default/mach_mpparse.h
@@ -1,17 +1,6 @@
1#ifndef __ASM_MACH_MPPARSE_H 1#ifndef __ASM_MACH_MPPARSE_H
2#define __ASM_MACH_MPPARSE_H 2#define __ASM_MACH_MPPARSE_H
3 3
4static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name,
5 struct mpc_config_translation *translation)
6{
7// Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
8}
9
10static inline void mpc_oem_pci_bus(struct mpc_config_bus *m,
11 struct mpc_config_translation *translation)
12{
13}
14
15static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 4static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
16 char *productid) 5 char *productid)
17{ 6{
diff --git a/include/asm-x86/mach-default/mach_reboot.h b/include/asm-x86/mach-default/mach_reboot.h
deleted file mode 100644
index 6adee6a97dec..000000000000
--- a/include/asm-x86/mach-default/mach_reboot.h
+++ /dev/null
@@ -1,61 +0,0 @@
1/*
2 * arch/i386/mach-generic/mach_reboot.h
3 *
4 * Machine specific reboot functions for generic.
5 * Split out from reboot.c by Osamu Tomita <tomita@cinet.co.jp>
6 */
7#ifndef _MACH_REBOOT_H
8#define _MACH_REBOOT_H
9
10static inline void kb_wait(void)
11{
12 int i;
13
14 for (i = 0; i < 0x10000; i++)
15 if ((inb_p(0x64) & 0x02) == 0)
16 break;
17}
18
19static inline void mach_reboot(void)
20{
21 int i;
22
23 /* old method, works on most machines */
24 for (i = 0; i < 10; i++) {
25 kb_wait();
26 udelay(50);
27 outb(0xfe, 0x64); /* pulse reset low */
28 udelay(50);
29 }
30
31 /* New method: sets the "System flag" which, when set, indicates
32 * successful completion of the keyboard controller self-test (Basic
33 * Assurance Test, BAT). This is needed for some machines with no
34 * keyboard plugged in. This read-modify-write sequence sets only the
35 * system flag
36 */
37 for (i = 0; i < 10; i++) {
38 int cmd;
39
40 outb(0x20, 0x64); /* read Controller Command Byte */
41 udelay(50);
42 kb_wait();
43 udelay(50);
44 cmd = inb(0x60);
45 udelay(50);
46 kb_wait();
47 udelay(50);
48 outb(0x60, 0x64); /* write Controller Command Byte */
49 udelay(50);
50 kb_wait();
51 udelay(50);
52 outb(cmd | 0x14, 0x60); /* set "System flag" and "Keyboard Disabled" */
53 udelay(50);
54 kb_wait();
55 udelay(50);
56 outb(0xfe, 0x64); /* pulse reset low */
57 udelay(50);
58 }
59}
60
61#endif /* !_MACH_REBOOT_H */
diff --git a/include/asm-x86/mach-default/smpboot_hooks.h b/include/asm-x86/mach-default/smpboot_hooks.h
index 7f45f6311059..56d0e1fa0258 100644
--- a/include/asm-x86/mach-default/smpboot_hooks.h
+++ b/include/asm-x86/mach-default/smpboot_hooks.h
@@ -33,7 +33,7 @@ static inline void smpboot_restore_warm_reset_vector(void)
33 *((volatile long *) phys_to_virt(0x467)) = 0; 33 *((volatile long *) phys_to_virt(0x467)) = 0;
34} 34}
35 35
36static inline void smpboot_setup_io_apic(void) 36static inline void __init smpboot_setup_io_apic(void)
37{ 37{
38 /* 38 /*
39 * Here we can be sure that there is an IO-APIC in the system. Let's 39 * Here we can be sure that there is an IO-APIC in the system. Let's
@@ -41,4 +41,11 @@ static inline void smpboot_setup_io_apic(void)
41 */ 41 */
42 if (!skip_ioapic_setup && nr_ioapics) 42 if (!skip_ioapic_setup && nr_ioapics)
43 setup_IO_APIC(); 43 setup_IO_APIC();
44 else
45 nr_ioapics = 0;
46}
47
48static inline void smpboot_clear_io_apic(void)
49{
50 nr_ioapics = 0;
44} 51}
diff --git a/include/asm-x86/mach-es7000/mach_apic.h b/include/asm-x86/mach-es7000/mach_apic.h
index d23011fdf454..fbc8ad256f5a 100644
--- a/include/asm-x86/mach-es7000/mach_apic.h
+++ b/include/asm-x86/mach-es7000/mach_apic.h
@@ -1,9 +1,7 @@
1#ifndef __ASM_MACH_APIC_H 1#ifndef __ASM_MACH_APIC_H
2#define __ASM_MACH_APIC_H 2#define __ASM_MACH_APIC_H
3 3
4extern u8 bios_cpu_apicid[]; 4#define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu)
5
6#define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu])
7#define esr_disable (1) 5#define esr_disable (1)
8 6
9static inline int apic_id_registered(void) 7static inline int apic_id_registered(void)
@@ -80,7 +78,7 @@ extern void enable_apic_mode(void);
80extern int apic_version [MAX_APICS]; 78extern int apic_version [MAX_APICS];
81static inline void setup_apic_routing(void) 79static inline void setup_apic_routing(void)
82{ 80{
83 int apic = bios_cpu_apicid[smp_processor_id()]; 81 int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id());
84 printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", 82 printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n",
85 (apic_version[apic] == 0x14) ? 83 (apic_version[apic] == 0x14) ?
86 "Physical Cluster" : "Logical Cluster", nr_ioapics, cpus_addr(TARGET_CPUS)[0]); 84 "Physical Cluster" : "Logical Cluster", nr_ioapics, cpus_addr(TARGET_CPUS)[0]);
@@ -102,7 +100,7 @@ static inline int cpu_present_to_apicid(int mps_cpu)
102 if (!mps_cpu) 100 if (!mps_cpu)
103 return boot_cpu_physical_apicid; 101 return boot_cpu_physical_apicid;
104 else if (mps_cpu < NR_CPUS) 102 else if (mps_cpu < NR_CPUS)
105 return (int) bios_cpu_apicid[mps_cpu]; 103 return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
106 else 104 else
107 return BAD_APICID; 105 return BAD_APICID;
108} 106}
@@ -129,16 +127,6 @@ static inline int cpu_to_logical_apicid(int cpu)
129#endif 127#endif
130} 128}
131 129
132static inline int mpc_apic_id(struct mpc_config_processor *m, struct mpc_config_translation *unused)
133{
134 printk("Processor #%d %u:%u APIC version %d\n",
135 m->mpc_apicid,
136 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
137 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
138 m->mpc_apicver);
139 return (m->mpc_apicid);
140}
141
142static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) 130static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
143{ 131{
144 /* For clustered we don't have a good way to do this yet - hack */ 132 /* For clustered we don't have a good way to do this yet - hack */
@@ -153,7 +141,7 @@ static inline void setup_portio_remap(void)
153extern unsigned int boot_cpu_physical_apicid; 141extern unsigned int boot_cpu_physical_apicid;
154static inline int check_phys_apicid_present(int cpu_physical_apicid) 142static inline int check_phys_apicid_present(int cpu_physical_apicid)
155{ 143{
156 boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); 144 boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id());
157 return (1); 145 return (1);
158} 146}
159 147
diff --git a/include/asm-x86/mach-es7000/mach_mpparse.h b/include/asm-x86/mach-es7000/mach_mpparse.h
index 52ee75cd0fe1..ef26d3523625 100644
--- a/include/asm-x86/mach-es7000/mach_mpparse.h
+++ b/include/asm-x86/mach-es7000/mach_mpparse.h
@@ -3,17 +3,6 @@
3 3
4#include <linux/acpi.h> 4#include <linux/acpi.h>
5 5
6static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name,
7 struct mpc_config_translation *translation)
8{
9 Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
10}
11
12static inline void mpc_oem_pci_bus(struct mpc_config_bus *m,
13 struct mpc_config_translation *translation)
14{
15}
16
17extern int parse_unisys_oem (char *oemptr); 6extern int parse_unisys_oem (char *oemptr);
18extern int find_unisys_acpi_oem_table(unsigned long *oem_addr); 7extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
19extern void setup_unisys(void); 8extern void setup_unisys(void);
diff --git a/include/asm-x86/mach-generic/mach_apic.h b/include/asm-x86/mach-generic/mach_apic.h
index a236e7021528..6eff343e1233 100644
--- a/include/asm-x86/mach-generic/mach_apic.h
+++ b/include/asm-x86/mach-generic/mach_apic.h
@@ -19,7 +19,6 @@
19#define cpu_to_logical_apicid (genapic->cpu_to_logical_apicid) 19#define cpu_to_logical_apicid (genapic->cpu_to_logical_apicid)
20#define cpu_present_to_apicid (genapic->cpu_present_to_apicid) 20#define cpu_present_to_apicid (genapic->cpu_present_to_apicid)
21#define apicid_to_cpu_present (genapic->apicid_to_cpu_present) 21#define apicid_to_cpu_present (genapic->apicid_to_cpu_present)
22#define mpc_apic_id (genapic->mpc_apic_id)
23#define setup_portio_remap (genapic->setup_portio_remap) 22#define setup_portio_remap (genapic->setup_portio_remap)
24#define check_apicid_present (genapic->check_apicid_present) 23#define check_apicid_present (genapic->check_apicid_present)
25#define check_phys_apicid_present (genapic->check_phys_apicid_present) 24#define check_phys_apicid_present (genapic->check_phys_apicid_present)
diff --git a/include/asm-x86/mach-generic/mach_mpparse.h b/include/asm-x86/mach-generic/mach_mpparse.h
index dbd9fce54f4d..0d0b5ba2e9d1 100644
--- a/include/asm-x86/mach-generic/mach_mpparse.h
+++ b/include/asm-x86/mach-generic/mach_mpparse.h
@@ -1,11 +1,6 @@
1#ifndef _MACH_MPPARSE_H 1#ifndef _MACH_MPPARSE_H
2#define _MACH_MPPARSE_H 1 2#define _MACH_MPPARSE_H 1
3 3
4#include <asm/genapic.h>
5
6#define mpc_oem_bus_info (genapic->mpc_oem_bus_info)
7#define mpc_oem_pci_bus (genapic->mpc_oem_pci_bus)
8
9int mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid); 4int mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid);
10int acpi_madt_oem_check(char *oem_id, char *oem_table_id); 5int acpi_madt_oem_check(char *oem_id, char *oem_table_id);
11 6
diff --git a/include/asm-x86/mach-numaq/mach_apic.h b/include/asm-x86/mach-numaq/mach_apic.h
index 3b637fac890b..75a56e5afbe7 100644
--- a/include/asm-x86/mach-numaq/mach_apic.h
+++ b/include/asm-x86/mach-numaq/mach_apic.h
@@ -95,6 +95,16 @@ static inline physid_mask_t apicid_to_cpu_present(int logical_apicid)
95 return physid_mask_of_physid(cpu + 4*node); 95 return physid_mask_of_physid(cpu + 4*node);
96} 96}
97 97
98struct mpc_config_translation {
99 unsigned char mpc_type;
100 unsigned char trans_len;
101 unsigned char trans_type;
102 unsigned char trans_quad;
103 unsigned char trans_global;
104 unsigned char trans_local;
105 unsigned short trans_reserved;
106};
107
98static inline int mpc_apic_id(struct mpc_config_processor *m, 108static inline int mpc_apic_id(struct mpc_config_processor *m,
99 struct mpc_config_translation *translation_record) 109 struct mpc_config_translation *translation_record)
100{ 110{
diff --git a/include/asm-x86/mach-numaq/mach_mpparse.h b/include/asm-x86/mach-numaq/mach_mpparse.h
index 51bbac8fc0c2..459b12401187 100644
--- a/include/asm-x86/mach-numaq/mach_mpparse.h
+++ b/include/asm-x86/mach-numaq/mach_mpparse.h
@@ -1,25 +1,10 @@
1#ifndef __ASM_MACH_MPPARSE_H 1#ifndef __ASM_MACH_MPPARSE_H
2#define __ASM_MACH_MPPARSE_H 2#define __ASM_MACH_MPPARSE_H
3 3
4static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name, 4extern void mpc_oem_bus_info(struct mpc_config_bus *m, char *name,
5 struct mpc_config_translation *translation) 5 struct mpc_config_translation *translation);
6{ 6extern void mpc_oem_pci_bus(struct mpc_config_bus *m,
7 int quad = translation->trans_quad; 7 struct mpc_config_translation *translation);
8 int local = translation->trans_local;
9
10 mp_bus_id_to_node[m->mpc_busid] = quad;
11 mp_bus_id_to_local[m->mpc_busid] = local;
12 printk("Bus #%d is %s (node %d)\n", m->mpc_busid, name, quad);
13}
14
15static inline void mpc_oem_pci_bus(struct mpc_config_bus *m,
16 struct mpc_config_translation *translation)
17{
18 int quad = translation->trans_quad;
19 int local = translation->trans_local;
20
21 quad_local_to_mp_bus_id[quad][local] = m->mpc_busid;
22}
23 8
24/* Hook from generic ACPI tables.c */ 9/* Hook from generic ACPI tables.c */
25static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id) 10static inline void acpi_madt_oem_check(char *oem_id, char *oem_table_id)
diff --git a/include/asm-x86/mach-summit/mach_apic.h b/include/asm-x86/mach-summit/mach_apic.h
index 062c97f6100b..1f76c2e70232 100644
--- a/include/asm-x86/mach-summit/mach_apic.h
+++ b/include/asm-x86/mach-summit/mach_apic.h
@@ -40,7 +40,6 @@ static inline unsigned long check_apicid_present(int bit)
40 40
41#define apicid_cluster(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK) 41#define apicid_cluster(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK)
42 42
43extern u8 bios_cpu_apicid[];
44extern u8 cpu_2_logical_apicid[]; 43extern u8 cpu_2_logical_apicid[];
45 44
46static inline void init_apic_ldr(void) 45static inline void init_apic_ldr(void)
@@ -110,7 +109,7 @@ static inline int cpu_to_logical_apicid(int cpu)
110static inline int cpu_present_to_apicid(int mps_cpu) 109static inline int cpu_present_to_apicid(int mps_cpu)
111{ 110{
112 if (mps_cpu < NR_CPUS) 111 if (mps_cpu < NR_CPUS)
113 return (int)bios_cpu_apicid[mps_cpu]; 112 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
114 else 113 else
115 return BAD_APICID; 114 return BAD_APICID;
116} 115}
@@ -126,17 +125,6 @@ static inline physid_mask_t apicid_to_cpu_present(int apicid)
126 return physid_mask_of_physid(0); 125 return physid_mask_of_physid(0);
127} 126}
128 127
129static inline int mpc_apic_id(struct mpc_config_processor *m,
130 struct mpc_config_translation *translation_record)
131{
132 printk("Processor #%d %u:%u APIC version %d\n",
133 m->mpc_apicid,
134 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
135 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
136 m->mpc_apicver);
137 return m->mpc_apicid;
138}
139
140static inline void setup_portio_remap(void) 128static inline void setup_portio_remap(void)
141{ 129{
142} 130}
diff --git a/include/asm-x86/mach-summit/mach_mpparse.h b/include/asm-x86/mach-summit/mach_mpparse.h
index c2520539d934..fdf591701339 100644
--- a/include/asm-x86/mach-summit/mach_mpparse.h
+++ b/include/asm-x86/mach-summit/mach_mpparse.h
@@ -12,17 +12,6 @@ extern void setup_summit(void);
12#define setup_summit() {} 12#define setup_summit() {}
13#endif 13#endif
14 14
15static inline void mpc_oem_bus_info(struct mpc_config_bus *m, char *name,
16 struct mpc_config_translation *translation)
17{
18 Dprintk("Bus #%d is %s\n", m->mpc_busid, name);
19}
20
21static inline void mpc_oem_pci_bus(struct mpc_config_bus *m,
22 struct mpc_config_translation *translation)
23{
24}
25
26static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 15static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
27 char *productid) 16 char *productid)
28{ 17{
diff --git a/include/asm-x86/mach-visws/mach_apic.h b/include/asm-x86/mach-visws/mach_apic.h
index efac6f0d139f..a9ef33a8a995 100644
--- a/include/asm-x86/mach-visws/mach_apic.h
+++ b/include/asm-x86/mach-visws/mach_apic.h
@@ -23,7 +23,7 @@
23 23
24static inline int apic_id_registered(void) 24static inline int apic_id_registered(void)
25{ 25{
26 return physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map); 26 return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map);
27} 27}
28 28
29/* 29/*
diff --git a/include/asm-x86/mach-visws/smpboot_hooks.h b/include/asm-x86/mach-visws/smpboot_hooks.h
index d926471fa359..c9b83e395a2e 100644
--- a/include/asm-x86/mach-visws/smpboot_hooks.h
+++ b/include/asm-x86/mach-visws/smpboot_hooks.h
@@ -22,3 +22,7 @@ static inline void smpboot_restore_warm_reset_vector(void)
22static inline void smpboot_setup_io_apic(void) 22static inline void smpboot_setup_io_apic(void)
23{ 23{
24} 24}
25
26static inline void smpboot_clear_io_apic(void)
27{
28}
diff --git a/include/asm-x86/mach_apic.h b/include/asm-x86/mach_apic.h
deleted file mode 100644
index 7b7115a0c1c9..000000000000
--- a/include/asm-x86/mach_apic.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#ifndef __ASM_MACH_APIC_H
2#define __ASM_MACH_APIC_H
3
4/*
5 * Copyright 2004 James Cleverdon, IBM.
6 * Subject to the GNU Public License, v.2
7 *
8 * Generic APIC sub-arch defines.
9 *
10 * Hacked for x86-64 by James Cleverdon from i386 architecture code by
11 * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
12 * James Cleverdon.
13 */
14
15#include <asm/genapic.h>
16
17#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
18#define INT_DEST_MODE (genapic->int_dest_mode)
19#define TARGET_CPUS (genapic->target_cpus())
20#define vector_allocation_domain (genapic->vector_allocation_domain)
21#define apic_id_registered (genapic->apic_id_registered)
22#define init_apic_ldr (genapic->init_apic_ldr)
23#define send_IPI_mask (genapic->send_IPI_mask)
24#define send_IPI_allbutself (genapic->send_IPI_allbutself)
25#define send_IPI_all (genapic->send_IPI_all)
26#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
27#define phys_pkg_id (genapic->phys_pkg_id)
28
29#endif /* __ASM_MACH_APIC_H */
diff --git a/include/asm-x86/mc146818rtc.h b/include/asm-x86/mc146818rtc.h
index cdd9f965835a..daf1ccde77af 100644
--- a/include/asm-x86/mc146818rtc.h
+++ b/include/asm-x86/mc146818rtc.h
@@ -42,7 +42,7 @@ extern volatile unsigned long cmos_lock;
42static inline void lock_cmos(unsigned char reg) 42static inline void lock_cmos(unsigned char reg)
43{ 43{
44 unsigned long new; 44 unsigned long new;
45 new = ((smp_processor_id()+1) << 8) | reg; 45 new = ((smp_processor_id() + 1) << 8) | reg;
46 for (;;) { 46 for (;;) {
47 if (cmos_lock) { 47 if (cmos_lock) {
48 cpu_relax(); 48 cpu_relax();
@@ -57,22 +57,26 @@ static inline void unlock_cmos(void)
57{ 57{
58 cmos_lock = 0; 58 cmos_lock = 0;
59} 59}
60
60static inline int do_i_have_lock_cmos(void) 61static inline int do_i_have_lock_cmos(void)
61{ 62{
62 return (cmos_lock >> 8) == (smp_processor_id()+1); 63 return (cmos_lock >> 8) == (smp_processor_id() + 1);
63} 64}
65
64static inline unsigned char current_lock_cmos_reg(void) 66static inline unsigned char current_lock_cmos_reg(void)
65{ 67{
66 return cmos_lock & 0xff; 68 return cmos_lock & 0xff;
67} 69}
68#define lock_cmos_prefix(reg) \ 70
71#define lock_cmos_prefix(reg) \
69 do { \ 72 do { \
70 unsigned long cmos_flags; \ 73 unsigned long cmos_flags; \
71 local_irq_save(cmos_flags); \ 74 local_irq_save(cmos_flags); \
72 lock_cmos(reg) 75 lock_cmos(reg)
73#define lock_cmos_suffix(reg) \ 76
74 unlock_cmos(); \ 77#define lock_cmos_suffix(reg) \
75 local_irq_restore(cmos_flags); \ 78 unlock_cmos(); \
79 local_irq_restore(cmos_flags); \
76 } while (0) 80 } while (0)
77#else 81#else
78#define lock_cmos_prefix(reg) do {} while (0) 82#define lock_cmos_prefix(reg) do {} while (0)
diff --git a/include/asm-x86/mca_dma.h b/include/asm-x86/mca_dma.h
index fbb1f3b71279..c3dca6edc6b1 100644
--- a/include/asm-x86/mca_dma.h
+++ b/include/asm-x86/mca_dma.h
@@ -12,18 +12,18 @@
12 * count by 2 when using 16-bit dma; that is not handled by these functions. 12 * count by 2 when using 16-bit dma; that is not handled by these functions.
13 * 13 *
14 * Ramen Noodles are yummy. 14 * Ramen Noodles are yummy.
15 * 15 *
16 * 1998 Tymm Twillman <tymm@computer.org> 16 * 1998 Tymm Twillman <tymm@computer.org>
17 */ 17 */
18 18
19/* 19/*
20 * Registers that are used by the DMA controller; FN is the function register 20 * Registers that are used by the DMA controller; FN is the function register
21 * (tell the controller what to do) and EXE is the execution register (how 21 * (tell the controller what to do) and EXE is the execution register (how
22 * to do it) 22 * to do it)
23 */ 23 */
24 24
25#define MCA_DMA_REG_FN 0x18 25#define MCA_DMA_REG_FN 0x18
26#define MCA_DMA_REG_EXE 0x1A 26#define MCA_DMA_REG_EXE 0x1A
27 27
28/* 28/*
29 * Functions that the DMA controller can do 29 * Functions that the DMA controller can do
@@ -43,9 +43,9 @@
43 43
44/* 44/*
45 * Modes (used by setting MCA_DMA_FN_MODE in the function register) 45 * Modes (used by setting MCA_DMA_FN_MODE in the function register)
46 * 46 *
47 * Note that the MODE_READ is read from memory (write to device), and 47 * Note that the MODE_READ is read from memory (write to device), and
48 * MODE_WRITE is vice-versa. 48 * MODE_WRITE is vice-versa.
49 */ 49 */
50 50
51#define MCA_DMA_MODE_XFER 0x04 /* read by default */ 51#define MCA_DMA_MODE_XFER 0x04 /* read by default */
@@ -63,7 +63,7 @@
63 * IRQ context. 63 * IRQ context.
64 */ 64 */
65 65
66static __inline__ void mca_enable_dma(unsigned int dmanr) 66static inline void mca_enable_dma(unsigned int dmanr)
67{ 67{
68 outb(MCA_DMA_FN_RESET_MASK | dmanr, MCA_DMA_REG_FN); 68 outb(MCA_DMA_FN_RESET_MASK | dmanr, MCA_DMA_REG_FN);
69} 69}
@@ -76,7 +76,7 @@ static __inline__ void mca_enable_dma(unsigned int dmanr)
76 * IRQ context. 76 * IRQ context.
77 */ 77 */
78 78
79static __inline__ void mca_disable_dma(unsigned int dmanr) 79static inline void mca_disable_dma(unsigned int dmanr)
80{ 80{
81 outb(MCA_DMA_FN_MASK | dmanr, MCA_DMA_REG_FN); 81 outb(MCA_DMA_FN_MASK | dmanr, MCA_DMA_REG_FN);
82} 82}
@@ -87,10 +87,10 @@ static __inline__ void mca_disable_dma(unsigned int dmanr)
87 * @a: 24bit bus address 87 * @a: 24bit bus address
88 * 88 *
89 * Load the address register in the DMA controller. This has a 24bit 89 * Load the address register in the DMA controller. This has a 24bit
90 * limitation (16Mb). 90 * limitation (16Mb).
91 */ 91 */
92 92
93static __inline__ void mca_set_dma_addr(unsigned int dmanr, unsigned int a) 93static inline void mca_set_dma_addr(unsigned int dmanr, unsigned int a)
94{ 94{
95 outb(MCA_DMA_FN_SET_ADDR | dmanr, MCA_DMA_REG_FN); 95 outb(MCA_DMA_FN_SET_ADDR | dmanr, MCA_DMA_REG_FN);
96 outb(a & 0xff, MCA_DMA_REG_EXE); 96 outb(a & 0xff, MCA_DMA_REG_EXE);
@@ -106,14 +106,14 @@ static __inline__ void mca_set_dma_addr(unsigned int dmanr, unsigned int a)
106 * limitation (16Mb). The return is a bus address. 106 * limitation (16Mb). The return is a bus address.
107 */ 107 */
108 108
109static __inline__ unsigned int mca_get_dma_addr(unsigned int dmanr) 109static inline unsigned int mca_get_dma_addr(unsigned int dmanr)
110{ 110{
111 unsigned int addr; 111 unsigned int addr;
112 112
113 outb(MCA_DMA_FN_GET_ADDR | dmanr, MCA_DMA_REG_FN); 113 outb(MCA_DMA_FN_GET_ADDR | dmanr, MCA_DMA_REG_FN);
114 addr = inb(MCA_DMA_REG_EXE); 114 addr = inb(MCA_DMA_REG_EXE);
115 addr |= inb(MCA_DMA_REG_EXE) << 8; 115 addr |= inb(MCA_DMA_REG_EXE) << 8;
116 addr |= inb(MCA_DMA_REG_EXE) << 16; 116 addr |= inb(MCA_DMA_REG_EXE) << 16;
117 117
118 return addr; 118 return addr;
119} 119}
@@ -127,7 +127,7 @@ static __inline__ unsigned int mca_get_dma_addr(unsigned int dmanr)
127 * Setting a count of zero will not do what you expect. 127 * Setting a count of zero will not do what you expect.
128 */ 128 */
129 129
130static __inline__ void mca_set_dma_count(unsigned int dmanr, unsigned int count) 130static inline void mca_set_dma_count(unsigned int dmanr, unsigned int count)
131{ 131{
132 count--; /* transfers one more than count -- correct for this */ 132 count--; /* transfers one more than count -- correct for this */
133 133
@@ -144,7 +144,7 @@ static __inline__ void mca_set_dma_count(unsigned int dmanr, unsigned int count)
144 * on this DMA channel. 144 * on this DMA channel.
145 */ 145 */
146 146
147static __inline__ unsigned int mca_get_dma_residue(unsigned int dmanr) 147static inline unsigned int mca_get_dma_residue(unsigned int dmanr)
148{ 148{
149 unsigned short count; 149 unsigned short count;
150 150
@@ -164,12 +164,12 @@ static __inline__ unsigned int mca_get_dma_residue(unsigned int dmanr)
164 * with an I/O port target. 164 * with an I/O port target.
165 */ 165 */
166 166
167static __inline__ void mca_set_dma_io(unsigned int dmanr, unsigned int io_addr) 167static inline void mca_set_dma_io(unsigned int dmanr, unsigned int io_addr)
168{ 168{
169 /* 169 /*
170 * DMA from a port address -- set the io address 170 * DMA from a port address -- set the io address
171 */ 171 */
172 172
173 outb(MCA_DMA_FN_SET_IO | dmanr, MCA_DMA_REG_FN); 173 outb(MCA_DMA_FN_SET_IO | dmanr, MCA_DMA_REG_FN);
174 outb(io_addr & 0xff, MCA_DMA_REG_EXE); 174 outb(io_addr & 0xff, MCA_DMA_REG_EXE);
175 outb((io_addr >> 8) & 0xff, MCA_DMA_REG_EXE); 175 outb((io_addr >> 8) & 0xff, MCA_DMA_REG_EXE);
@@ -192,7 +192,7 @@ static __inline__ void mca_set_dma_io(unsigned int dmanr, unsigned int io_addr)
192 * %MCA_DMA_MODE_16 to do 16bit transfers. 192 * %MCA_DMA_MODE_16 to do 16bit transfers.
193 */ 193 */
194 194
195static __inline__ void mca_set_dma_mode(unsigned int dmanr, unsigned int mode) 195static inline void mca_set_dma_mode(unsigned int dmanr, unsigned int mode)
196{ 196{
197 outb(MCA_DMA_FN_SET_MODE | dmanr, MCA_DMA_REG_FN); 197 outb(MCA_DMA_FN_SET_MODE | dmanr, MCA_DMA_REG_FN);
198 outb(mode, MCA_DMA_REG_EXE); 198 outb(mode, MCA_DMA_REG_EXE);
diff --git a/include/asm-x86/mmu.h b/include/asm-x86/mmu.h
index efa962c38897..00e88679e11f 100644
--- a/include/asm-x86/mmu.h
+++ b/include/asm-x86/mmu.h
@@ -10,10 +10,10 @@
10 * 10 *
11 * cpu_vm_mask is used to optimize ldt flushing. 11 * cpu_vm_mask is used to optimize ldt flushing.
12 */ 12 */
13typedef struct { 13typedef struct {
14 void *ldt; 14 void *ldt;
15#ifdef CONFIG_X86_64 15#ifdef CONFIG_X86_64
16 rwlock_t ldtlock; 16 rwlock_t ldtlock;
17#endif 17#endif
18 int size; 18 int size;
19 struct mutex lock; 19 struct mutex lock;
diff --git a/include/asm-x86/mmu_context_32.h b/include/asm-x86/mmu_context_32.h
index 8198d1cca1f3..9756ae0f1dd3 100644
--- a/include/asm-x86/mmu_context_32.h
+++ b/include/asm-x86/mmu_context_32.h
@@ -62,7 +62,7 @@ static inline void switch_mm(struct mm_struct *prev,
62 BUG_ON(per_cpu(cpu_tlbstate, cpu).active_mm != next); 62 BUG_ON(per_cpu(cpu_tlbstate, cpu).active_mm != next);
63 63
64 if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { 64 if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) {
65 /* We were in lazy tlb mode and leave_mm disabled 65 /* We were in lazy tlb mode and leave_mm disabled
66 * tlb flush IPI delivery. We must reload %cr3. 66 * tlb flush IPI delivery. We must reload %cr3.
67 */ 67 */
68 load_cr3(next->pgd); 68 load_cr3(next->pgd);
@@ -75,10 +75,10 @@ static inline void switch_mm(struct mm_struct *prev,
75#define deactivate_mm(tsk, mm) \ 75#define deactivate_mm(tsk, mm) \
76 asm("movl %0,%%gs": :"r" (0)); 76 asm("movl %0,%%gs": :"r" (0));
77 77
78#define activate_mm(prev, next) \ 78#define activate_mm(prev, next) \
79 do { \ 79do { \
80 paravirt_activate_mm(prev, next); \ 80 paravirt_activate_mm((prev), (next)); \
81 switch_mm((prev),(next),NULL); \ 81 switch_mm((prev), (next), NULL); \
82 } while(0); 82} while (0);
83 83
84#endif 84#endif
diff --git a/include/asm-x86/mmu_context_64.h b/include/asm-x86/mmu_context_64.h
index ad6dc821ef9e..ca44c71e7fb3 100644
--- a/include/asm-x86/mmu_context_64.h
+++ b/include/asm-x86/mmu_context_64.h
@@ -20,12 +20,12 @@ void destroy_context(struct mm_struct *mm);
20static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) 20static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
21{ 21{
22#ifdef CONFIG_SMP 22#ifdef CONFIG_SMP
23 if (read_pda(mmu_state) == TLBSTATE_OK) 23 if (read_pda(mmu_state) == TLBSTATE_OK)
24 write_pda(mmu_state, TLBSTATE_LAZY); 24 write_pda(mmu_state, TLBSTATE_LAZY);
25#endif 25#endif
26} 26}
27 27
28static 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,
29 struct task_struct *tsk) 29 struct task_struct *tsk)
30{ 30{
31 unsigned cpu = smp_processor_id(); 31 unsigned cpu = smp_processor_id();
@@ -39,7 +39,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
39 cpu_set(cpu, next->cpu_vm_mask); 39 cpu_set(cpu, next->cpu_vm_mask);
40 load_cr3(next->pgd); 40 load_cr3(next->pgd);
41 41
42 if (unlikely(next->context.ldt != prev->context.ldt)) 42 if (unlikely(next->context.ldt != prev->context.ldt))
43 load_LDT_nolock(&next->context); 43 load_LDT_nolock(&next->context);
44 } 44 }
45#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
@@ -48,7 +48,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
48 if (read_pda(active_mm) != next) 48 if (read_pda(active_mm) != next)
49 BUG(); 49 BUG();
50 if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { 50 if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) {
51 /* We were in lazy tlb mode and leave_mm disabled 51 /* We were in lazy tlb mode and leave_mm disabled
52 * tlb flush IPI delivery. We must reload CR3 52 * tlb flush IPI delivery. We must reload CR3
53 * to make sure to use no freed page tables. 53 * to make sure to use no freed page tables.
54 */ 54 */
@@ -59,13 +59,14 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
59#endif 59#endif
60} 60}
61 61
62#define deactivate_mm(tsk,mm) do { \ 62#define deactivate_mm(tsk, mm) \
63 load_gs_index(0); \ 63do { \
64 asm volatile("movl %0,%%fs"::"r"(0)); \ 64 load_gs_index(0); \
65} while(0) 65 asm volatile("movl %0,%%fs"::"r"(0)); \
66} while (0)
66 67
67#define activate_mm(prev, next) \ 68#define activate_mm(prev, next) \
68 switch_mm((prev),(next),NULL) 69 switch_mm((prev), (next), NULL)
69 70
70 71
71#endif 72#endif
diff --git a/include/asm-x86/mmx.h b/include/asm-x86/mmx.h
index 46b71da99869..940881218ff8 100644
--- a/include/asm-x86/mmx.h
+++ b/include/asm-x86/mmx.h
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8#include <linux/types.h> 8#include <linux/types.h>
9 9
10extern void *_mmx_memcpy(void *to, const void *from, size_t size); 10extern void *_mmx_memcpy(void *to, const void *from, size_t size);
11extern void mmx_clear_page(void *page); 11extern void mmx_clear_page(void *page);
12extern void mmx_copy_page(void *to, void *from); 12extern void mmx_copy_page(void *to, void *from);
diff --git a/include/asm-x86/mmzone_32.h b/include/asm-x86/mmzone_32.h
index 274a59566c45..cb2cad0b65a7 100644
--- a/include/asm-x86/mmzone_32.h
+++ b/include/asm-x86/mmzone_32.h
@@ -18,7 +18,7 @@ extern struct pglist_data *node_data[];
18 #include <asm/srat.h> 18 #include <asm/srat.h>
19#endif 19#endif
20 20
21extern int get_memcfg_numa_flat(void ); 21extern int get_memcfg_numa_flat(void);
22/* 22/*
23 * This allows any one NUMA architecture to be compiled 23 * This allows any one NUMA architecture to be compiled
24 * for, and still fall back to the flat function if it 24 * for, and still fall back to the flat function if it
@@ -129,7 +129,7 @@ static inline int pfn_valid(int pfn)
129 struct pglist_data __maybe_unused \ 129 struct pglist_data __maybe_unused \
130 *__alloc_bootmem_node__pgdat = (pgdat); \ 130 *__alloc_bootmem_node__pgdat = (pgdat); \
131 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, \ 131 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, \
132 __pa(MAX_DMA_ADDRESS)) \ 132 __pa(MAX_DMA_ADDRESS)); \
133}) 133})
134#define alloc_bootmem_low_pages_node(pgdat, x) \ 134#define alloc_bootmem_low_pages_node(pgdat, x) \
135({ \ 135({ \
diff --git a/include/asm-x86/mmzone_64.h b/include/asm-x86/mmzone_64.h
index ebaf9663aa8a..594bd0dc1d08 100644
--- a/include/asm-x86/mmzone_64.h
+++ b/include/asm-x86/mmzone_64.h
@@ -7,7 +7,7 @@
7 7
8#ifdef CONFIG_NUMA 8#ifdef CONFIG_NUMA
9 9
10#define VIRTUAL_BUG_ON(x) 10#define VIRTUAL_BUG_ON(x)
11 11
12#include <asm/smp.h> 12#include <asm/smp.h>
13 13
@@ -16,7 +16,7 @@ struct memnode {
16 int shift; 16 int shift;
17 unsigned int mapsize; 17 unsigned int mapsize;
18 s16 *map; 18 s16 *map;
19 s16 embedded_map[64-8]; 19 s16 embedded_map[64 - 8];
20} ____cacheline_aligned; /* total size = 128 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
@@ -25,27 +25,27 @@ extern struct memnode memnode;
25 25
26extern struct pglist_data *node_data[]; 26extern struct pglist_data *node_data[];
27 27
28static inline __attribute__((pure)) int phys_to_nid(unsigned long addr) 28static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
29{ 29{
30 unsigned nid; 30 unsigned nid;
31 VIRTUAL_BUG_ON(!memnodemap); 31 VIRTUAL_BUG_ON(!memnodemap);
32 VIRTUAL_BUG_ON((addr >> memnode_shift) >= memnodemapsize); 32 VIRTUAL_BUG_ON((addr >> memnode_shift) >= memnodemapsize);
33 nid = memnodemap[addr >> memnode_shift]; 33 nid = memnodemap[addr >> memnode_shift];
34 VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]); 34 VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]);
35 return nid; 35 return nid;
36} 36}
37 37
38#define NODE_DATA(nid) (node_data[nid]) 38#define NODE_DATA(nid) (node_data[nid])
39 39
40#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 40#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
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
44extern int early_pfn_to_nid(unsigned long pfn); 44extern int early_pfn_to_nid(unsigned long pfn);
45 45
46#ifdef CONFIG_NUMA_EMU 46#ifdef CONFIG_NUMA_EMU
47#define FAKE_NODE_MIN_SIZE (64*1024*1024) 47#define FAKE_NODE_MIN_SIZE (64 * 1024 * 1024)
48#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1uL)) 48#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))
49#endif 49#endif
50 50
51#endif 51#endif
diff --git a/include/asm-x86/mpspec.h b/include/asm-x86/mpspec.h
index 781ad74ab9e9..57a991b9c053 100644
--- a/include/asm-x86/mpspec.h
+++ b/include/asm-x86/mpspec.h
@@ -1,16 +1,13 @@
1#ifndef _AM_X86_MPSPEC_H 1#ifndef _AM_X86_MPSPEC_H
2#define _AM_X86_MPSPEC_H 2#define _AM_X86_MPSPEC_H
3 3
4#include <linux/init.h>
5
4#include <asm/mpspec_def.h> 6#include <asm/mpspec_def.h>
5 7
6#ifdef CONFIG_X86_32 8#ifdef CONFIG_X86_32
7#include <mach_mpspec.h> 9#include <mach_mpspec.h>
8 10
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; 11extern unsigned int def_to_bigsmp;
15extern int apic_version[MAX_APICS]; 12extern int apic_version[MAX_APICS];
16extern u8 apicid_2_node[]; 13extern u8 apicid_2_node[];
@@ -24,27 +21,30 @@ extern int pic_mode;
24/* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */ 21/* 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) 22#define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4)
26 23
27extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES); 24extern void early_find_smp_config(void);
25extern void early_get_smp_config(void);
28 26
29#endif 27#endif
30 28
29#if defined(CONFIG_MCA) || defined(CONFIG_EISA)
30extern int mp_bus_id_to_type[MAX_MP_BUSSES];
31#endif
32
33extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
34
31extern int mp_bus_id_to_pci_bus[MAX_MP_BUSSES]; 35extern int mp_bus_id_to_pci_bus[MAX_MP_BUSSES];
32 36
33extern unsigned int boot_cpu_physical_apicid; 37extern unsigned int boot_cpu_physical_apicid;
34extern int smp_found_config; 38extern 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 int mpc_default_type;
39extern unsigned long mp_lapic_addr; 40extern unsigned long mp_lapic_addr;
40 41
41extern void find_smp_config(void); 42extern void find_smp_config(void);
42extern void get_smp_config(void); 43extern void get_smp_config(void);
43 44
45void __cpuinit generic_processor_info(int apicid, int version);
44#ifdef CONFIG_ACPI 46#ifdef CONFIG_ACPI
45extern void mp_register_lapic(u8 id, u8 enabled); 47extern void mp_register_ioapic(int id, u32 address, u32 gsi_base);
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, 48extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
49 u32 gsi); 49 u32 gsi);
50extern void mp_config_acpi_legacy_irqs(void); 50extern void mp_config_acpi_legacy_irqs(void);
@@ -53,8 +53,7 @@ extern int mp_register_gsi(u32 gsi, int edge_level, int active_high_low);
53 53
54#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS) 54#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS)
55 55
56struct physid_mask 56struct physid_mask {
57{
58 unsigned long mask[PHYSID_ARRAY_SIZE]; 57 unsigned long mask[PHYSID_ARRAY_SIZE];
59}; 58};
60 59
@@ -63,34 +62,34 @@ typedef struct physid_mask physid_mask_t;
63#define physid_set(physid, map) set_bit(physid, (map).mask) 62#define physid_set(physid, map) set_bit(physid, (map).mask)
64#define physid_clear(physid, map) clear_bit(physid, (map).mask) 63#define physid_clear(physid, map) clear_bit(physid, (map).mask)
65#define physid_isset(physid, map) test_bit(physid, (map).mask) 64#define physid_isset(physid, map) test_bit(physid, (map).mask)
66#define physid_test_and_set(physid, map) \ 65#define physid_test_and_set(physid, map) \
67 test_and_set_bit(physid, (map).mask) 66 test_and_set_bit(physid, (map).mask)
68 67
69#define physids_and(dst, src1, src2) \ 68#define physids_and(dst, src1, src2) \
70 bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS) 69 bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
71 70
72#define physids_or(dst, src1, src2) \ 71#define physids_or(dst, src1, src2) \
73 bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS) 72 bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
74 73
75#define physids_clear(map) \ 74#define physids_clear(map) \
76 bitmap_zero((map).mask, MAX_APICS) 75 bitmap_zero((map).mask, MAX_APICS)
77 76
78#define physids_complement(dst, src) \ 77#define physids_complement(dst, src) \
79 bitmap_complement((dst).mask, (src).mask, MAX_APICS) 78 bitmap_complement((dst).mask, (src).mask, MAX_APICS)
80 79
81#define physids_empty(map) \ 80#define physids_empty(map) \
82 bitmap_empty((map).mask, MAX_APICS) 81 bitmap_empty((map).mask, MAX_APICS)
83 82
84#define physids_equal(map1, map2) \ 83#define physids_equal(map1, map2) \
85 bitmap_equal((map1).mask, (map2).mask, MAX_APICS) 84 bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
86 85
87#define physids_weight(map) \ 86#define physids_weight(map) \
88 bitmap_weight((map).mask, MAX_APICS) 87 bitmap_weight((map).mask, MAX_APICS)
89 88
90#define physids_shift_right(d, s, n) \ 89#define physids_shift_right(d, s, n) \
91 bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS) 90 bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
92 91
93#define physids_shift_left(d, s, n) \ 92#define physids_shift_left(d, s, n) \
94 bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS) 93 bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
95 94
96#define physids_coerce(map) ((map).mask[0]) 95#define physids_coerce(map) ((map).mask[0])
diff --git a/include/asm-x86/mpspec_def.h b/include/asm-x86/mpspec_def.h
index 3504617fe648..dc6ef85e3624 100644
--- a/include/asm-x86/mpspec_def.h
+++ b/include/asm-x86/mpspec_def.h
@@ -11,7 +11,7 @@
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#ifdef CONFIG_X86_32 16#ifdef CONFIG_X86_32
17# define MAX_MPC_ENTRY 1024 17# define MAX_MPC_ENTRY 1024
@@ -23,8 +23,7 @@
23# define MAX_APICS 255 23# define MAX_APICS 255
24#endif 24#endif
25 25
26struct intel_mp_floating 26struct intel_mp_floating {
27{
28 char mpf_signature[4]; /* "_MP_" */ 27 char mpf_signature[4]; /* "_MP_" */
29 unsigned int mpf_physptr; /* Configuration table address */ 28 unsigned int mpf_physptr; /* Configuration table address */
30 unsigned char mpf_length; /* Our length (paragraphs) */ 29 unsigned char mpf_length; /* Our length (paragraphs) */
@@ -39,14 +38,13 @@ struct intel_mp_floating
39 38
40#define MPC_SIGNATURE "PCMP" 39#define MPC_SIGNATURE "PCMP"
41 40
42struct mp_config_table 41struct mp_config_table {
43{
44 char mpc_signature[4]; 42 char mpc_signature[4];
45 unsigned short mpc_length; /* Size of table */ 43 unsigned short mpc_length; /* Size of table */
46 char mpc_spec; /* 0x01 */ 44 char mpc_spec; /* 0x01 */
47 char mpc_checksum; 45 char mpc_checksum;
48 char mpc_oem[8]; 46 char mpc_oem[8];
49 char mpc_productid[12]; 47 char mpc_productid[12];
50 unsigned int mpc_oemptr; /* 0 if not present */ 48 unsigned int mpc_oemptr; /* 0 if not present */
51 unsigned short mpc_oemsize; /* 0 if not present */ 49 unsigned short mpc_oemsize; /* 0 if not present */
52 unsigned short mpc_oemcount; 50 unsigned short mpc_oemcount;
@@ -71,8 +69,7 @@ struct mp_config_table
71#define CPU_MODEL_MASK 0x00F0 69#define CPU_MODEL_MASK 0x00F0
72#define CPU_FAMILY_MASK 0x0F00 70#define CPU_FAMILY_MASK 0x0F00
73 71
74struct mpc_config_processor 72struct mpc_config_processor {
75{
76 unsigned char mpc_type; 73 unsigned char mpc_type;
77 unsigned char mpc_apicid; /* Local APIC number */ 74 unsigned char mpc_apicid; /* Local APIC number */
78 unsigned char mpc_apicver; /* Its versions */ 75 unsigned char mpc_apicver; /* Its versions */
@@ -82,8 +79,7 @@ struct mpc_config_processor
82 unsigned int mpc_reserved[2]; 79 unsigned int mpc_reserved[2];
83}; 80};
84 81
85struct mpc_config_bus 82struct mpc_config_bus {
86{
87 unsigned char mpc_type; 83 unsigned char mpc_type;
88 unsigned char mpc_busid; 84 unsigned char mpc_busid;
89 unsigned char mpc_bustype[6]; 85 unsigned char mpc_bustype[6];
@@ -111,8 +107,7 @@ struct mpc_config_bus
111 107
112#define MPC_APIC_USABLE 0x01 108#define MPC_APIC_USABLE 0x01
113 109
114struct mpc_config_ioapic 110struct mpc_config_ioapic {
115{
116 unsigned char mpc_type; 111 unsigned char mpc_type;
117 unsigned char mpc_apicid; 112 unsigned char mpc_apicid;
118 unsigned char mpc_apicver; 113 unsigned char mpc_apicver;
@@ -120,8 +115,7 @@ struct mpc_config_ioapic
120 unsigned int mpc_apicaddr; 115 unsigned int mpc_apicaddr;
121}; 116};
122 117
123struct mpc_config_intsrc 118struct mpc_config_intsrc {
124{
125 unsigned char mpc_type; 119 unsigned char mpc_type;
126 unsigned char mpc_irqtype; 120 unsigned char mpc_irqtype;
127 unsigned short mpc_irqflag; 121 unsigned short mpc_irqflag;
@@ -144,8 +138,7 @@ enum mp_irq_source_types {
144 138
145#define MP_APIC_ALL 0xFF 139#define MP_APIC_ALL 0xFF
146 140
147struct mpc_config_lintsrc 141struct mpc_config_lintsrc {
148{
149 unsigned char mpc_type; 142 unsigned char mpc_type;
150 unsigned char mpc_irqtype; 143 unsigned char mpc_irqtype;
151 unsigned short mpc_irqflag; 144 unsigned short mpc_irqflag;
@@ -157,8 +150,7 @@ struct mpc_config_lintsrc
157 150
158#define MPC_OEM_SIGNATURE "_OEM" 151#define MPC_OEM_SIGNATURE "_OEM"
159 152
160struct mp_config_oemtable 153struct mp_config_oemtable {
161{
162 char oem_signature[4]; 154 char oem_signature[4];
163 unsigned short oem_length; /* Size of table */ 155 unsigned short oem_length; /* Size of table */
164 char oem_rev; /* 0x01 */ 156 char oem_rev; /* 0x01 */
@@ -166,17 +158,6 @@ struct mp_config_oemtable
166 char mpc_oem[8]; 158 char mpc_oem[8];
167}; 159};
168 160
169struct mpc_config_translation
170{
171 unsigned char mpc_type;
172 unsigned char trans_len;
173 unsigned char trans_type;
174 unsigned char trans_quad;
175 unsigned char trans_global;
176 unsigned char trans_local;
177 unsigned short trans_reserved;
178};
179
180/* 161/*
181 * Default configurations 162 * Default configurations
182 * 163 *
@@ -196,4 +177,3 @@ enum mp_bustype {
196 MP_BUS_MCA, 177 MP_BUS_MCA,
197}; 178};
198#endif 179#endif
199
diff --git a/include/asm-x86/msidef.h b/include/asm-x86/msidef.h
index 5b8acddb70fb..296f29ce426d 100644
--- a/include/asm-x86/msidef.h
+++ b/include/asm-x86/msidef.h
@@ -11,7 +11,8 @@
11 11
12#define MSI_DATA_VECTOR_SHIFT 0 12#define MSI_DATA_VECTOR_SHIFT 0
13#define MSI_DATA_VECTOR_MASK 0x000000ff 13#define MSI_DATA_VECTOR_MASK 0x000000ff
14#define MSI_DATA_VECTOR(v) (((v) << MSI_DATA_VECTOR_SHIFT) & MSI_DATA_VECTOR_MASK) 14#define MSI_DATA_VECTOR(v) (((v) << MSI_DATA_VECTOR_SHIFT) & \
15 MSI_DATA_VECTOR_MASK)
15 16
16#define MSI_DATA_DELIVERY_MODE_SHIFT 8 17#define MSI_DATA_DELIVERY_MODE_SHIFT 8
17#define MSI_DATA_DELIVERY_FIXED (0 << MSI_DATA_DELIVERY_MODE_SHIFT) 18#define MSI_DATA_DELIVERY_FIXED (0 << MSI_DATA_DELIVERY_MODE_SHIFT)
@@ -37,11 +38,14 @@
37#define MSI_ADDR_DEST_MODE_LOGICAL (1 << MSI_ADDR_DEST_MODE_SHIFT) 38#define MSI_ADDR_DEST_MODE_LOGICAL (1 << MSI_ADDR_DEST_MODE_SHIFT)
38 39
39#define MSI_ADDR_REDIRECTION_SHIFT 3 40#define MSI_ADDR_REDIRECTION_SHIFT 3
40#define MSI_ADDR_REDIRECTION_CPU (0 << MSI_ADDR_REDIRECTION_SHIFT) /* dedicated cpu */ 41#define MSI_ADDR_REDIRECTION_CPU (0 << MSI_ADDR_REDIRECTION_SHIFT)
41#define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT) /* lowest priority */ 42 /* dedicated cpu */
43#define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT)
44 /* lowest priority */
42 45
43#define MSI_ADDR_DEST_ID_SHIFT 12 46#define MSI_ADDR_DEST_ID_SHIFT 12
44#define MSI_ADDR_DEST_ID_MASK 0x00ffff0 47#define MSI_ADDR_DEST_ID_MASK 0x00ffff0
45#define MSI_ADDR_DEST_ID(dest) (((dest) << MSI_ADDR_DEST_ID_SHIFT) & MSI_ADDR_DEST_ID_MASK) 48#define MSI_ADDR_DEST_ID(dest) (((dest) << MSI_ADDR_DEST_ID_SHIFT) & \
49 MSI_ADDR_DEST_ID_MASK)
46 50
47#endif /* ASM_MSIDEF_H */ 51#endif /* ASM_MSIDEF_H */
diff --git a/include/asm-x86/msr-index.h b/include/asm-x86/msr-index.h
index fae118a25278..09413ad39d3c 100644
--- a/include/asm-x86/msr-index.h
+++ b/include/asm-x86/msr-index.h
@@ -57,6 +57,8 @@
57#define MSR_MTRRfix4K_F8000 0x0000026f 57#define MSR_MTRRfix4K_F8000 0x0000026f
58#define MSR_MTRRdefType 0x000002ff 58#define MSR_MTRRdefType 0x000002ff
59 59
60#define MSR_IA32_CR_PAT 0x00000277
61
60#define MSR_IA32_DEBUGCTLMSR 0x000001d9 62#define MSR_IA32_DEBUGCTLMSR 0x000001d9
61#define MSR_IA32_LASTBRANCHFROMIP 0x000001db 63#define MSR_IA32_LASTBRANCHFROMIP 0x000001db
62#define MSR_IA32_LASTBRANCHTOIP 0x000001dc 64#define MSR_IA32_LASTBRANCHTOIP 0x000001dc
@@ -83,6 +85,7 @@
83/* AMD64 MSRs. Not complete. See the architecture manual for a more 85/* AMD64 MSRs. Not complete. See the architecture manual for a more
84 complete list. */ 86 complete list. */
85 87
88#define MSR_AMD64_NB_CFG 0xc001001f
86#define MSR_AMD64_IBSFETCHCTL 0xc0011030 89#define MSR_AMD64_IBSFETCHCTL 0xc0011030
87#define MSR_AMD64_IBSFETCHLINAD 0xc0011031 90#define MSR_AMD64_IBSFETCHLINAD 0xc0011031
88#define MSR_AMD64_IBSFETCHPHYSAD 0xc0011032 91#define MSR_AMD64_IBSFETCHPHYSAD 0xc0011032
@@ -109,6 +112,7 @@
109#define MSR_K8_SYSCFG 0xc0010010 112#define MSR_K8_SYSCFG 0xc0010010
110#define MSR_K8_HWCR 0xc0010015 113#define MSR_K8_HWCR 0xc0010015
111#define MSR_K8_ENABLE_C1E 0xc0010055 114#define MSR_K8_ENABLE_C1E 0xc0010055
115#define MSR_K8_TSEG_ADDR 0xc0010112
112#define K8_MTRRFIXRANGE_DRAM_ENABLE 0x00040000 /* MtrrFixDramEn bit */ 116#define K8_MTRRFIXRANGE_DRAM_ENABLE 0x00040000 /* MtrrFixDramEn bit */
113#define K8_MTRRFIXRANGE_DRAM_MODIFY 0x00080000 /* MtrrFixDramModEn bit */ 117#define K8_MTRRFIXRANGE_DRAM_MODIFY 0x00080000 /* MtrrFixDramModEn bit */
114#define K8_MTRR_RDMEM_WRMEM_MASK 0x18181818 /* Mask: RdMem|WrMem */ 118#define K8_MTRR_RDMEM_WRMEM_MASK 0x18181818 /* Mask: RdMem|WrMem */
diff --git a/include/asm-x86/msr.h b/include/asm-x86/msr.h
index 3ca29ebebbb1..3707650a169b 100644
--- a/include/asm-x86/msr.h
+++ b/include/asm-x86/msr.h
@@ -16,8 +16,8 @@
16static inline unsigned long long native_read_tscp(unsigned int *aux) 16static inline unsigned long long native_read_tscp(unsigned int *aux)
17{ 17{
18 unsigned long low, high; 18 unsigned long low, high;
19 asm volatile (".byte 0x0f,0x01,0xf9" 19 asm volatile(".byte 0x0f,0x01,0xf9"
20 : "=a" (low), "=d" (high), "=c" (*aux)); 20 : "=a" (low), "=d" (high), "=c" (*aux));
21 return low | ((u64)high >> 32); 21 return low | ((u64)high >> 32);
22} 22}
23 23
@@ -29,7 +29,7 @@ static inline unsigned long long native_read_tscp(unsigned int *aux)
29 */ 29 */
30#ifdef CONFIG_X86_64 30#ifdef CONFIG_X86_64
31#define DECLARE_ARGS(val, low, high) unsigned low, high 31#define DECLARE_ARGS(val, low, high) unsigned low, high
32#define EAX_EDX_VAL(val, low, high) (low | ((u64)(high) << 32)) 32#define EAX_EDX_VAL(val, low, high) ((low) | ((u64)(high) << 32))
33#define EAX_EDX_ARGS(val, low, high) "a" (low), "d" (high) 33#define EAX_EDX_ARGS(val, low, high) "a" (low), "d" (high)
34#define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high) 34#define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high)
35#else 35#else
@@ -57,7 +57,7 @@ static inline unsigned long long native_read_msr_safe(unsigned int msr,
57 ".section .fixup,\"ax\"\n\t" 57 ".section .fixup,\"ax\"\n\t"
58 "3: mov %3,%0 ; jmp 1b\n\t" 58 "3: mov %3,%0 ; jmp 1b\n\t"
59 ".previous\n\t" 59 ".previous\n\t"
60 _ASM_EXTABLE(2b,3b) 60 _ASM_EXTABLE(2b, 3b)
61 : "=r" (*err), EAX_EDX_RET(val, low, high) 61 : "=r" (*err), EAX_EDX_RET(val, low, high)
62 : "c" (msr), "i" (-EFAULT)); 62 : "c" (msr), "i" (-EFAULT));
63 return EAX_EDX_VAL(val, low, high); 63 return EAX_EDX_VAL(val, low, high);
@@ -78,10 +78,10 @@ static inline int native_write_msr_safe(unsigned int msr,
78 ".section .fixup,\"ax\"\n\t" 78 ".section .fixup,\"ax\"\n\t"
79 "3: mov %4,%0 ; jmp 1b\n\t" 79 "3: mov %4,%0 ; jmp 1b\n\t"
80 ".previous\n\t" 80 ".previous\n\t"
81 _ASM_EXTABLE(2b,3b) 81 _ASM_EXTABLE(2b, 3b)
82 : "=a" (err) 82 : "=a" (err)
83 : "c" (msr), "0" (low), "d" (high), 83 : "c" (msr), "0" (low), "d" (high),
84 "i" (-EFAULT)); 84 "i" (-EFAULT));
85 return err; 85 return err;
86} 86}
87 87
@@ -116,23 +116,23 @@ static inline unsigned long long native_read_pmc(int counter)
116 * pointer indirection), this allows gcc to optimize better 116 * pointer indirection), this allows gcc to optimize better
117 */ 117 */
118 118
119#define rdmsr(msr,val1,val2) \ 119#define rdmsr(msr, val1, val2) \
120 do { \ 120do { \
121 u64 __val = native_read_msr(msr); \ 121 u64 __val = native_read_msr((msr)); \
122 (val1) = (u32)__val; \ 122 (val1) = (u32)__val; \
123 (val2) = (u32)(__val >> 32); \ 123 (val2) = (u32)(__val >> 32); \
124 } while(0) 124} while (0)
125 125
126static inline void wrmsr(unsigned msr, unsigned low, unsigned high) 126static inline void wrmsr(unsigned msr, unsigned low, unsigned high)
127{ 127{
128 native_write_msr(msr, low, high); 128 native_write_msr(msr, low, high);
129} 129}
130 130
131#define rdmsrl(msr,val) \ 131#define rdmsrl(msr, val) \
132 ((val) = native_read_msr(msr)) 132 ((val) = native_read_msr((msr)))
133 133
134#define wrmsrl(msr, val) \ 134#define wrmsrl(msr, val) \
135 native_write_msr(msr, (u32)((u64)(val)), (u32)((u64)(val) >> 32)) 135 native_write_msr((msr), (u32)((u64)(val)), (u32)((u64)(val) >> 32))
136 136
137/* wrmsr with exception handling */ 137/* wrmsr with exception handling */
138static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high) 138static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high)
@@ -141,14 +141,22 @@ static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high)
141} 141}
142 142
143/* rdmsr with exception handling */ 143/* rdmsr with exception handling */
144#define rdmsr_safe(msr,p1,p2) \ 144#define rdmsr_safe(msr, p1, p2) \
145 ({ \ 145({ \
146 int __err; \ 146 int __err; \
147 u64 __val = native_read_msr_safe(msr, &__err); \ 147 u64 __val = native_read_msr_safe((msr), &__err); \
148 (*p1) = (u32)__val; \ 148 (*p1) = (u32)__val; \
149 (*p2) = (u32)(__val >> 32); \ 149 (*p2) = (u32)(__val >> 32); \
150 __err; \ 150 __err; \
151 }) 151})
152
153static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
154{
155 int err;
156
157 *p = native_read_msr_safe(msr, &err);
158 return err;
159}
152 160
153#define rdtscl(low) \ 161#define rdtscl(low) \
154 ((low) = (u32)native_read_tsc()) 162 ((low) = (u32)native_read_tsc())
@@ -156,35 +164,37 @@ static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high)
156#define rdtscll(val) \ 164#define rdtscll(val) \
157 ((val) = native_read_tsc()) 165 ((val) = native_read_tsc())
158 166
159#define rdpmc(counter,low,high) \ 167#define rdpmc(counter, low, high) \
160 do { \ 168do { \
161 u64 _l = native_read_pmc(counter); \ 169 u64 _l = native_read_pmc((counter)); \
162 (low) = (u32)_l; \ 170 (low) = (u32)_l; \
163 (high) = (u32)(_l >> 32); \ 171 (high) = (u32)(_l >> 32); \
164 } while(0) 172} while (0)
165 173
166#define rdtscp(low, high, aux) \ 174#define rdtscp(low, high, aux) \
167 do { \ 175do { \
168 unsigned long long _val = native_read_tscp(&(aux)); \ 176 unsigned long long _val = native_read_tscp(&(aux)); \
169 (low) = (u32)_val; \ 177 (low) = (u32)_val; \
170 (high) = (u32)(_val >> 32); \ 178 (high) = (u32)(_val >> 32); \
171 } while (0) 179} while (0)
172 180
173#define rdtscpll(val, aux) (val) = native_read_tscp(&(aux)) 181#define rdtscpll(val, aux) (val) = native_read_tscp(&(aux))
174 182
175#endif /* !CONFIG_PARAVIRT */ 183#endif /* !CONFIG_PARAVIRT */
176 184
177 185
178#define checking_wrmsrl(msr,val) wrmsr_safe(msr,(u32)(val),(u32)((val)>>32)) 186#define checking_wrmsrl(msr, val) wrmsr_safe((msr), (u32)(val), \
187 (u32)((val) >> 32))
179 188
180#define write_tsc(val1,val2) wrmsr(0x10, val1, val2) 189#define write_tsc(val1, val2) wrmsr(0x10, (val1), (val2))
181 190
182#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0) 191#define write_rdtscp_aux(val) wrmsr(0xc0000103, (val), 0)
183 192
184#ifdef CONFIG_SMP 193#ifdef CONFIG_SMP
185void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); 194void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
186void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); 195void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
187int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); 196int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
197
188int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); 198int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
189#else /* CONFIG_SMP */ 199#else /* CONFIG_SMP */
190static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) 200static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
@@ -195,7 +205,8 @@ static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
195{ 205{
196 wrmsr(msr_no, l, h); 206 wrmsr(msr_no, l, h);
197} 207}
198static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) 208static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no,
209 u32 *l, u32 *h)
199{ 210{
200 return rdmsr_safe(msr_no, l, h); 211 return rdmsr_safe(msr_no, l, h);
201} 212}
diff --git a/include/asm-x86/mtrr.h b/include/asm-x86/mtrr.h
index 319d065800be..a69a01a51729 100644
--- a/include/asm-x86/mtrr.h
+++ b/include/asm-x86/mtrr.h
@@ -28,8 +28,7 @@
28 28
29#define MTRR_IOCTL_BASE 'M' 29#define MTRR_IOCTL_BASE 'M'
30 30
31struct mtrr_sentry 31struct mtrr_sentry {
32{
33 unsigned long base; /* Base address */ 32 unsigned long base; /* Base address */
34 unsigned int size; /* Size of region */ 33 unsigned int size; /* Size of region */
35 unsigned int type; /* Type of region */ 34 unsigned int type; /* Type of region */
@@ -41,8 +40,7 @@ struct mtrr_sentry
41 will break. */ 40 will break. */
42 41
43#ifdef __i386__ 42#ifdef __i386__
44struct mtrr_gentry 43struct mtrr_gentry {
45{
46 unsigned int regnum; /* Register number */ 44 unsigned int regnum; /* Register number */
47 unsigned long base; /* Base address */ 45 unsigned long base; /* Base address */
48 unsigned int size; /* Size of region */ 46 unsigned int size; /* Size of region */
@@ -51,8 +49,7 @@ struct mtrr_gentry
51 49
52#else /* __i386__ */ 50#else /* __i386__ */
53 51
54struct mtrr_gentry 52struct mtrr_gentry {
55{
56 unsigned long base; /* Base address */ 53 unsigned long base; /* Base address */
57 unsigned int size; /* Size of region */ 54 unsigned int size; /* Size of region */
58 unsigned int regnum; /* Register number */ 55 unsigned int regnum; /* Register number */
@@ -86,38 +83,45 @@ struct mtrr_gentry
86 83
87/* The following functions are for use by other drivers */ 84/* The following functions are for use by other drivers */
88# ifdef CONFIG_MTRR 85# ifdef CONFIG_MTRR
86extern u8 mtrr_type_lookup(u64 addr, u64 end);
89extern void mtrr_save_fixed_ranges(void *); 87extern void mtrr_save_fixed_ranges(void *);
90extern void mtrr_save_state(void); 88extern void mtrr_save_state(void);
91extern int mtrr_add (unsigned long base, unsigned long size, 89extern int mtrr_add(unsigned long base, unsigned long size,
92 unsigned int type, bool increment); 90 unsigned int type, bool increment);
93extern int mtrr_add_page (unsigned long base, unsigned long size, 91extern int mtrr_add_page(unsigned long base, unsigned long size,
94 unsigned int type, bool increment); 92 unsigned int type, bool increment);
95extern int mtrr_del (int reg, unsigned long base, unsigned long size); 93extern int mtrr_del(int reg, unsigned long base, unsigned long size);
96extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); 94extern int mtrr_del_page(int reg, unsigned long base, unsigned long size);
97extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); 95extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
98extern void mtrr_ap_init(void); 96extern void mtrr_ap_init(void);
99extern void mtrr_bp_init(void); 97extern void mtrr_bp_init(void);
100extern int mtrr_trim_uncached_memory(unsigned long end_pfn); 98extern int mtrr_trim_uncached_memory(unsigned long end_pfn);
99extern int amd_special_default_mtrr(void);
101# else 100# else
101static inline u8 mtrr_type_lookup(u64 addr, u64 end)
102{
103 /*
104 * Return no-MTRRs:
105 */
106 return 0xff;
107}
102#define mtrr_save_fixed_ranges(arg) do {} while (0) 108#define mtrr_save_fixed_ranges(arg) do {} while (0)
103#define mtrr_save_state() do {} while (0) 109#define mtrr_save_state() do {} while (0)
104static __inline__ int mtrr_add (unsigned long base, unsigned long size, 110static inline int mtrr_add(unsigned long base, unsigned long size,
105 unsigned int type, bool increment) 111 unsigned int type, bool increment)
106{ 112{
107 return -ENODEV; 113 return -ENODEV;
108} 114}
109static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, 115static inline int mtrr_add_page(unsigned long base, unsigned long size,
110 unsigned int type, bool increment) 116 unsigned int type, bool increment)
111{ 117{
112 return -ENODEV; 118 return -ENODEV;
113} 119}
114static __inline__ int mtrr_del (int reg, unsigned long base, 120static inline int mtrr_del(int reg, unsigned long base, unsigned long size)
115 unsigned long size)
116{ 121{
117 return -ENODEV; 122 return -ENODEV;
118} 123}
119static __inline__ int mtrr_del_page (int reg, unsigned long base, 124static inline int mtrr_del_page(int reg, unsigned long base, unsigned long size)
120 unsigned long size)
121{ 125{
122 return -ENODEV; 126 return -ENODEV;
123} 127}
@@ -125,7 +129,9 @@ static inline int mtrr_trim_uncached_memory(unsigned long end_pfn)
125{ 129{
126 return 0; 130 return 0;
127} 131}
128static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;} 132static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
133{
134}
129 135
130#define mtrr_ap_init() do {} while (0) 136#define mtrr_ap_init() do {} while (0)
131#define mtrr_bp_init() do {} while (0) 137#define mtrr_bp_init() do {} while (0)
@@ -134,15 +140,13 @@ static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;}
134#ifdef CONFIG_COMPAT 140#ifdef CONFIG_COMPAT
135#include <linux/compat.h> 141#include <linux/compat.h>
136 142
137struct mtrr_sentry32 143struct mtrr_sentry32 {
138{
139 compat_ulong_t base; /* Base address */ 144 compat_ulong_t base; /* Base address */
140 compat_uint_t size; /* Size of region */ 145 compat_uint_t size; /* Size of region */
141 compat_uint_t type; /* Type of region */ 146 compat_uint_t type; /* Type of region */
142}; 147};
143 148
144struct mtrr_gentry32 149struct mtrr_gentry32 {
145{
146 compat_ulong_t regnum; /* Register number */ 150 compat_ulong_t regnum; /* Register number */
147 compat_uint_t base; /* Base address */ 151 compat_uint_t base; /* Base address */
148 compat_uint_t size; /* Size of region */ 152 compat_uint_t size; /* Size of region */
@@ -151,16 +155,17 @@ struct mtrr_gentry32
151 155
152#define MTRR_IOCTL_BASE 'M' 156#define MTRR_IOCTL_BASE 'M'
153 157
154#define MTRRIOC32_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry32) 158#define MTRRIOC32_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry32)
155#define MTRRIOC32_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry32) 159#define MTRRIOC32_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry32)
156#define MTRRIOC32_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry32) 160#define MTRRIOC32_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry32)
157#define MTRRIOC32_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry32) 161#define MTRRIOC32_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry32)
158#define MTRRIOC32_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry32) 162#define MTRRIOC32_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry32)
159#define MTRRIOC32_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry32) 163#define MTRRIOC32_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry32)
160#define MTRRIOC32_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry32) 164#define MTRRIOC32_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry32)
161#define MTRRIOC32_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry32) 165#define MTRRIOC32_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry32)
162#define MTRRIOC32_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry32) 166#define MTRRIOC32_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry32)
163#define MTRRIOC32_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry32) 167#define MTRRIOC32_KILL_PAGE_ENTRY \
168 _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry32)
164#endif /* CONFIG_COMPAT */ 169#endif /* CONFIG_COMPAT */
165 170
166#endif /* __KERNEL__ */ 171#endif /* __KERNEL__ */
diff --git a/include/asm-x86/mutex_32.h b/include/asm-x86/mutex_32.h
index bbeefb96ddfd..73e928ef5f03 100644
--- a/include/asm-x86/mutex_32.h
+++ b/include/asm-x86/mutex_32.h
@@ -9,7 +9,7 @@
9#ifndef _ASM_MUTEX_H 9#ifndef _ASM_MUTEX_H
10#define _ASM_MUTEX_H 10#define _ASM_MUTEX_H
11 11
12#include "asm/alternative.h" 12#include <asm/alternative.h>
13 13
14/** 14/**
15 * __mutex_fastpath_lock - try to take the lock by moving the count 15 * __mutex_fastpath_lock - try to take the lock by moving the count
@@ -21,22 +21,20 @@
21 * wasn't 1 originally. This function MUST leave the value lower than 1 21 * wasn't 1 originally. This function MUST leave the value lower than 1
22 * even when the "1" assertion wasn't true. 22 * even when the "1" assertion wasn't true.
23 */ 23 */
24#define __mutex_fastpath_lock(count, fail_fn) \ 24#define __mutex_fastpath_lock(count, fail_fn) \
25do { \ 25do { \
26 unsigned int dummy; \ 26 unsigned int dummy; \
27 \ 27 \
28 typecheck(atomic_t *, count); \ 28 typecheck(atomic_t *, count); \
29 typecheck_fn(void (*)(atomic_t *), fail_fn); \ 29 typecheck_fn(void (*)(atomic_t *), fail_fn); \
30 \ 30 \
31 __asm__ __volatile__( \ 31 asm volatile(LOCK_PREFIX " decl (%%eax)\n" \
32 LOCK_PREFIX " decl (%%eax) \n" \ 32 " jns 1f \n" \
33 " jns 1f \n" \ 33 " call " #fail_fn "\n" \
34 " call "#fail_fn" \n" \ 34 "1:\n" \
35 "1: \n" \ 35 : "=a" (dummy) \
36 \ 36 : "a" (count) \
37 :"=a" (dummy) \ 37 : "memory", "ecx", "edx"); \
38 : "a" (count) \
39 : "memory", "ecx", "edx"); \
40} while (0) 38} while (0)
41 39
42 40
@@ -50,8 +48,8 @@ do { \
50 * wasn't 1 originally. This function returns 0 if the fastpath succeeds, 48 * wasn't 1 originally. This function returns 0 if the fastpath succeeds,
51 * or anything the slow path function returns 49 * or anything the slow path function returns
52 */ 50 */
53static inline int 51static inline int __mutex_fastpath_lock_retval(atomic_t *count,
54__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) 52 int (*fail_fn)(atomic_t *))
55{ 53{
56 if (unlikely(atomic_dec_return(count) < 0)) 54 if (unlikely(atomic_dec_return(count) < 0))
57 return fail_fn(count); 55 return fail_fn(count);
@@ -72,22 +70,20 @@ __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
72 * __mutex_slowpath_needs_to_unlock() macro needs to return 1, it needs 70 * __mutex_slowpath_needs_to_unlock() macro needs to return 1, it needs
73 * to return 0 otherwise. 71 * to return 0 otherwise.
74 */ 72 */
75#define __mutex_fastpath_unlock(count, fail_fn) \ 73#define __mutex_fastpath_unlock(count, fail_fn) \
76do { \ 74do { \
77 unsigned int dummy; \ 75 unsigned int dummy; \
78 \ 76 \
79 typecheck(atomic_t *, count); \ 77 typecheck(atomic_t *, count); \
80 typecheck_fn(void (*)(atomic_t *), fail_fn); \ 78 typecheck_fn(void (*)(atomic_t *), fail_fn); \
81 \ 79 \
82 __asm__ __volatile__( \ 80 asm volatile(LOCK_PREFIX " incl (%%eax)\n" \
83 LOCK_PREFIX " incl (%%eax) \n" \ 81 " jg 1f\n" \
84 " jg 1f \n" \ 82 " call " #fail_fn "\n" \
85 " call "#fail_fn" \n" \ 83 "1:\n" \
86 "1: \n" \ 84 : "=a" (dummy) \
87 \ 85 : "a" (count) \
88 :"=a" (dummy) \ 86 : "memory", "ecx", "edx"); \
89 : "a" (count) \
90 : "memory", "ecx", "edx"); \
91} while (0) 87} while (0)
92 88
93#define __mutex_slowpath_needs_to_unlock() 1 89#define __mutex_slowpath_needs_to_unlock() 1
@@ -104,8 +100,8 @@ do { \
104 * Additionally, if the value was < 0 originally, this function must not leave 100 * Additionally, if the value was < 0 originally, this function must not leave
105 * it to 0 on failure. 101 * it to 0 on failure.
106 */ 102 */
107static inline int 103static inline int __mutex_fastpath_trylock(atomic_t *count,
108__mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *)) 104 int (*fail_fn)(atomic_t *))
109{ 105{
110 /* 106 /*
111 * We have two variants here. The cmpxchg based one is the best one 107 * We have two variants here. The cmpxchg based one is the best one
diff --git a/include/asm-x86/mutex_64.h b/include/asm-x86/mutex_64.h
index 6c2949a3c677..f3fae9becb38 100644
--- a/include/asm-x86/mutex_64.h
+++ b/include/asm-x86/mutex_64.h
@@ -16,23 +16,21 @@
16 * 16 *
17 * Atomically decrements @v and calls <fail_fn> if the result is negative. 17 * Atomically decrements @v and calls <fail_fn> if the result is negative.
18 */ 18 */
19#define __mutex_fastpath_lock(v, fail_fn) \ 19#define __mutex_fastpath_lock(v, fail_fn) \
20do { \ 20do { \
21 unsigned long dummy; \ 21 unsigned long dummy; \
22 \ 22 \
23 typecheck(atomic_t *, v); \ 23 typecheck(atomic_t *, v); \
24 typecheck_fn(void (*)(atomic_t *), fail_fn); \ 24 typecheck_fn(void (*)(atomic_t *), fail_fn); \
25 \ 25 \
26 __asm__ __volatile__( \ 26 asm volatile(LOCK_PREFIX " decl (%%rdi)\n" \
27 LOCK_PREFIX " decl (%%rdi) \n" \ 27 " jns 1f \n" \
28 " jns 1f \n" \ 28 " call " #fail_fn "\n" \
29 " call "#fail_fn" \n" \ 29 "1:" \
30 "1:" \ 30 : "=D" (dummy) \
31 \ 31 : "D" (v) \
32 :"=D" (dummy) \ 32 : "rax", "rsi", "rdx", "rcx", \
33 : "D" (v) \ 33 "r8", "r9", "r10", "r11", "memory"); \
34 : "rax", "rsi", "rdx", "rcx", \
35 "r8", "r9", "r10", "r11", "memory"); \
36} while (0) 34} while (0)
37 35
38/** 36/**
@@ -45,9 +43,8 @@ do { \
45 * it wasn't 1 originally. This function returns 0 if the fastpath succeeds, 43 * it wasn't 1 originally. This function returns 0 if the fastpath succeeds,
46 * or anything the slow path function returns 44 * or anything the slow path function returns
47 */ 45 */
48static inline int 46static inline int __mutex_fastpath_lock_retval(atomic_t *count,
49__mutex_fastpath_lock_retval(atomic_t *count, 47 int (*fail_fn)(atomic_t *))
50 int (*fail_fn)(atomic_t *))
51{ 48{
52 if (unlikely(atomic_dec_return(count) < 0)) 49 if (unlikely(atomic_dec_return(count) < 0))
53 return fail_fn(count); 50 return fail_fn(count);
@@ -62,23 +59,21 @@ __mutex_fastpath_lock_retval(atomic_t *count,
62 * 59 *
63 * Atomically increments @v and calls <fail_fn> if the result is nonpositive. 60 * Atomically increments @v and calls <fail_fn> if the result is nonpositive.
64 */ 61 */
65#define __mutex_fastpath_unlock(v, fail_fn) \ 62#define __mutex_fastpath_unlock(v, fail_fn) \
66do { \ 63do { \
67 unsigned long dummy; \ 64 unsigned long dummy; \
68 \ 65 \
69 typecheck(atomic_t *, v); \ 66 typecheck(atomic_t *, v); \
70 typecheck_fn(void (*)(atomic_t *), fail_fn); \ 67 typecheck_fn(void (*)(atomic_t *), fail_fn); \
71 \ 68 \
72 __asm__ __volatile__( \ 69 asm volatile(LOCK_PREFIX " incl (%%rdi)\n" \
73 LOCK_PREFIX " incl (%%rdi) \n" \ 70 " jg 1f\n" \
74 " jg 1f \n" \ 71 " call " #fail_fn "\n" \
75 " call "#fail_fn" \n" \ 72 "1:" \
76 "1: " \ 73 : "=D" (dummy) \
77 \ 74 : "D" (v) \
78 :"=D" (dummy) \ 75 : "rax", "rsi", "rdx", "rcx", \
79 : "D" (v) \ 76 "r8", "r9", "r10", "r11", "memory"); \
80 : "rax", "rsi", "rdx", "rcx", \
81 "r8", "r9", "r10", "r11", "memory"); \
82} while (0) 77} while (0)
83 78
84#define __mutex_slowpath_needs_to_unlock() 1 79#define __mutex_slowpath_needs_to_unlock() 1
@@ -93,8 +88,8 @@ do { \
93 * if it wasn't 1 originally. [the fallback function is never used on 88 * if it wasn't 1 originally. [the fallback function is never used on
94 * x86_64, because all x86_64 CPUs have a CMPXCHG instruction.] 89 * x86_64, because all x86_64 CPUs have a CMPXCHG instruction.]
95 */ 90 */
96static inline int 91static inline int __mutex_fastpath_trylock(atomic_t *count,
97__mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *)) 92 int (*fail_fn)(atomic_t *))
98{ 93{
99 if (likely(atomic_cmpxchg(count, 1, 0) == 1)) 94 if (likely(atomic_cmpxchg(count, 1, 0) == 1))
100 return 1; 95 return 1;
diff --git a/include/asm-x86/nmi.h b/include/asm-x86/nmi.h
index 53ccac14cead..1e363021e72f 100644
--- a/include/asm-x86/nmi.h
+++ b/include/asm-x86/nmi.h
@@ -1,5 +1,93 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_NMI_H_
2# include "nmi_32.h" 2#define _ASM_X86_NMI_H_
3
4#include <linux/pm.h>
5#include <asm/irq.h>
6#include <asm/io.h>
7
8#ifdef ARCH_HAS_NMI_WATCHDOG
9
10/**
11 * do_nmi_callback
12 *
13 * Check to see if a callback exists and execute it. Return 1
14 * if the handler exists and was handled successfully.
15 */
16int do_nmi_callback(struct pt_regs *regs, int cpu);
17
18#ifdef CONFIG_PM
19
20/** Replace the PM callback routine for NMI. */
21struct pm_dev *set_nmi_pm_callback(pm_callback callback);
22
23/** Unset the PM callback routine back to the default. */
24void unset_nmi_pm_callback(struct pm_dev *dev);
25
3#else 26#else
4# include "nmi_64.h" 27
28static inline struct pm_dev *set_nmi_pm_callback(pm_callback callback)
29{
30 return 0;
31}
32
33static inline void unset_nmi_pm_callback(struct pm_dev *dev)
34{
35}
36
37#endif /* CONFIG_PM */
38
39#ifdef CONFIG_X86_64
40extern void default_do_nmi(struct pt_regs *);
41extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
42extern void nmi_watchdog_default(void);
43#else
44#define nmi_watchdog_default() do {} while (0)
45#endif
46
47extern int check_nmi_watchdog(void);
48extern int nmi_watchdog_enabled;
49extern int unknown_nmi_panic;
50extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
51extern int avail_to_resrv_perfctr_nmi(unsigned int);
52extern int reserve_perfctr_nmi(unsigned int);
53extern void release_perfctr_nmi(unsigned int);
54extern int reserve_evntsel_nmi(unsigned int);
55extern void release_evntsel_nmi(unsigned int);
56
57extern void setup_apic_nmi_watchdog(void *);
58extern void stop_apic_nmi_watchdog(void *);
59extern void disable_timer_nmi_watchdog(void);
60extern void enable_timer_nmi_watchdog(void);
61extern int nmi_watchdog_tick(struct pt_regs *regs, unsigned reason);
62
63extern atomic_t nmi_active;
64extern unsigned int nmi_watchdog;
65#define NMI_DISABLED -1
66#define NMI_NONE 0
67#define NMI_IO_APIC 1
68#define NMI_LOCAL_APIC 2
69#define NMI_INVALID 3
70#define NMI_DEFAULT NMI_DISABLED
71
72struct ctl_table;
73struct file;
74extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
75 void __user *, size_t *, loff_t *);
76extern int unknown_nmi_panic;
77
78void __trigger_all_cpu_backtrace(void);
79#define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace()
80
81#endif
82
83void lapic_watchdog_stop(void);
84int lapic_watchdog_init(unsigned nmi_hz);
85int lapic_wd_event(unsigned nmi_hz);
86unsigned lapic_adjust_nmi_hz(unsigned hz);
87int lapic_watchdog_ok(void);
88void disable_lapic_nmi_watchdog(void);
89void enable_lapic_nmi_watchdog(void);
90void stop_nmi(void);
91void restart_nmi(void);
92
5#endif 93#endif
diff --git a/include/asm-x86/nmi_32.h b/include/asm-x86/nmi_32.h
deleted file mode 100644
index 7206c7e8a388..000000000000
--- a/include/asm-x86/nmi_32.h
+++ /dev/null
@@ -1,61 +0,0 @@
1#ifndef ASM_NMI_H
2#define ASM_NMI_H
3
4#include <linux/pm.h>
5#include <asm/irq.h>
6
7#ifdef ARCH_HAS_NMI_WATCHDOG
8
9/**
10 * do_nmi_callback
11 *
12 * Check to see if a callback exists and execute it. Return 1
13 * if the handler exists and was handled successfully.
14 */
15int do_nmi_callback(struct pt_regs *regs, int cpu);
16
17extern int nmi_watchdog_enabled;
18extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
19extern int avail_to_resrv_perfctr_nmi(unsigned int);
20extern int reserve_perfctr_nmi(unsigned int);
21extern void release_perfctr_nmi(unsigned int);
22extern int reserve_evntsel_nmi(unsigned int);
23extern void release_evntsel_nmi(unsigned int);
24
25extern void setup_apic_nmi_watchdog (void *);
26extern void stop_apic_nmi_watchdog (void *);
27extern void disable_timer_nmi_watchdog(void);
28extern void enable_timer_nmi_watchdog(void);
29extern int nmi_watchdog_tick (struct pt_regs * regs, unsigned reason);
30
31extern atomic_t nmi_active;
32extern unsigned int nmi_watchdog;
33#define NMI_DISABLED -1
34#define NMI_NONE 0
35#define NMI_IO_APIC 1
36#define NMI_LOCAL_APIC 2
37#define NMI_INVALID 3
38#define NMI_DEFAULT NMI_DISABLED
39
40struct ctl_table;
41struct file;
42extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
43 void __user *, size_t *, loff_t *);
44extern int unknown_nmi_panic;
45
46void __trigger_all_cpu_backtrace(void);
47#define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace()
48
49#endif
50
51void lapic_watchdog_stop(void);
52int lapic_watchdog_init(unsigned nmi_hz);
53int lapic_wd_event(unsigned nmi_hz);
54unsigned lapic_adjust_nmi_hz(unsigned hz);
55int lapic_watchdog_ok(void);
56void disable_lapic_nmi_watchdog(void);
57void enable_lapic_nmi_watchdog(void);
58void stop_nmi(void);
59void restart_nmi(void);
60
61#endif /* ASM_NMI_H */
diff --git a/include/asm-x86/nmi_64.h b/include/asm-x86/nmi_64.h
deleted file mode 100644
index 2eeb74e5f3ff..000000000000
--- a/include/asm-x86/nmi_64.h
+++ /dev/null
@@ -1,90 +0,0 @@
1#ifndef ASM_NMI_H
2#define ASM_NMI_H
3
4#include <linux/pm.h>
5#include <asm/io.h>
6
7/**
8 * do_nmi_callback
9 *
10 * Check to see if a callback exists and execute it. Return 1
11 * if the handler exists and was handled successfully.
12 */
13int do_nmi_callback(struct pt_regs *regs, int cpu);
14
15#ifdef CONFIG_PM
16
17/** Replace the PM callback routine for NMI. */
18struct pm_dev * set_nmi_pm_callback(pm_callback callback);
19
20/** Unset the PM callback routine back to the default. */
21void unset_nmi_pm_callback(struct pm_dev * dev);
22
23#else
24
25static inline struct pm_dev * set_nmi_pm_callback(pm_callback callback)
26{
27 return 0;
28}
29
30static inline void unset_nmi_pm_callback(struct pm_dev * dev)
31{
32}
33
34#endif /* CONFIG_PM */
35
36extern void default_do_nmi(struct pt_regs *);
37extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
38
39#define get_nmi_reason() inb(0x61)
40
41extern int unknown_nmi_panic;
42extern int nmi_watchdog_enabled;
43
44extern int check_nmi_watchdog(void);
45extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
46extern int avail_to_resrv_perfctr_nmi(unsigned int);
47extern int reserve_perfctr_nmi(unsigned int);
48extern void release_perfctr_nmi(unsigned int);
49extern int reserve_evntsel_nmi(unsigned int);
50extern void release_evntsel_nmi(unsigned int);
51
52extern void setup_apic_nmi_watchdog (void *);
53extern void stop_apic_nmi_watchdog (void *);
54extern void disable_timer_nmi_watchdog(void);
55extern void enable_timer_nmi_watchdog(void);
56extern int nmi_watchdog_tick (struct pt_regs * regs, unsigned reason);
57
58extern void nmi_watchdog_default(void);
59
60extern atomic_t nmi_active;
61extern unsigned int nmi_watchdog;
62#define NMI_DISABLED -1
63#define NMI_NONE 0
64#define NMI_IO_APIC 1
65#define NMI_LOCAL_APIC 2
66#define NMI_INVALID 3
67#define NMI_DEFAULT NMI_DISABLED
68
69struct ctl_table;
70struct file;
71extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
72 void __user *, size_t *, loff_t *);
73
74extern int unknown_nmi_panic;
75
76void __trigger_all_cpu_backtrace(void);
77#define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace()
78
79
80void lapic_watchdog_stop(void);
81int lapic_watchdog_init(unsigned nmi_hz);
82int lapic_wd_event(unsigned nmi_hz);
83unsigned lapic_adjust_nmi_hz(unsigned hz);
84int lapic_watchdog_ok(void);
85void disable_lapic_nmi_watchdog(void);
86void enable_lapic_nmi_watchdog(void);
87void stop_nmi(void);
88void restart_nmi(void);
89
90#endif /* ASM_NMI_H */
diff --git a/include/asm-x86/nops.h b/include/asm-x86/nops.h
index b3930ae539b3..ad0bedd10b89 100644
--- a/include/asm-x86/nops.h
+++ b/include/asm-x86/nops.h
@@ -5,6 +5,8 @@
5 5
6/* generic versions from gas 6/* generic versions from gas
7 1: nop 7 1: nop
8 the following instructions are NOT nops in 64-bit mode,
9 for 64-bit mode use K8 or P6 nops instead
8 2: movl %esi,%esi 10 2: movl %esi,%esi
9 3: leal 0x00(%esi),%esi 11 3: leal 0x00(%esi),%esi
10 4: leal 0x00(,%esi,1),%esi 12 4: leal 0x00(,%esi,1),%esi
diff --git a/include/asm-x86/numa_64.h b/include/asm-x86/numa_64.h
index 15fe07cde586..22e87c9f6a80 100644
--- a/include/asm-x86/numa_64.h
+++ b/include/asm-x86/numa_64.h
@@ -1,14 +1,16 @@
1#ifndef _ASM_X8664_NUMA_H 1#ifndef _ASM_X8664_NUMA_H
2#define _ASM_X8664_NUMA_H 1 2#define _ASM_X8664_NUMA_H 1
3 3
4#include <linux/nodemask.h> 4#include <linux/nodemask.h>
5#include <asm/apicdef.h> 5#include <asm/apicdef.h>
6 6
7struct bootnode { 7struct bootnode {
8 u64 start,end; 8 u64 start;
9 u64 end;
9}; 10};
10 11
11extern int compute_hash_shift(struct bootnode *nodes, int numnodes); 12extern int compute_hash_shift(struct bootnode *nodes, int numblks,
13 int *nodeids);
12 14
13#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT)) 15#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
14 16
diff --git a/include/asm-x86/numaq.h b/include/asm-x86/numaq.h
index 38f710dc37f2..94b86c31239a 100644
--- a/include/asm-x86/numaq.h
+++ b/include/asm-x86/numaq.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002, IBM Corp. 4 * Copyright (C) 2002, IBM Corp.
5 * 5 *
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 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 9 * it under the terms of the GNU General Public License as published by
@@ -33,7 +33,8 @@ extern int get_memcfg_numaq(void);
33/* 33/*
34 * SYS_CFG_DATA_PRIV_ADDR, struct eachquadmem, and struct sys_cfg_data are the 34 * SYS_CFG_DATA_PRIV_ADDR, struct eachquadmem, and struct sys_cfg_data are the
35 */ 35 */
36#define SYS_CFG_DATA_PRIV_ADDR 0x0009d000 /* place for scd in private quad space */ 36#define SYS_CFG_DATA_PRIV_ADDR 0x0009d000 /* place for scd in private
37 quad space */
37 38
38/* 39/*
39 * Communication area for each processor on lynxer-processor tests. 40 * Communication area for each processor on lynxer-processor tests.
@@ -139,7 +140,7 @@ struct sys_cfg_data {
139 unsigned int low_shrd_mem_base; /* 0 or 512MB or 1GB */ 140 unsigned int low_shrd_mem_base; /* 0 or 512MB or 1GB */
140 unsigned int low_shrd_mem_quad_offset; /* 0,128M,256M,512M,1G */ 141 unsigned int low_shrd_mem_quad_offset; /* 0,128M,256M,512M,1G */
141 /* may not be totally populated */ 142 /* may not be totally populated */
142 unsigned int split_mem_enbl; /* 0 for no low shared memory */ 143 unsigned int split_mem_enbl; /* 0 for no low shared memory */
143 unsigned int mmio_sz; /* Size of total system memory mapped I/O */ 144 unsigned int mmio_sz; /* Size of total system memory mapped I/O */
144 /* (in MB). */ 145 /* (in MB). */
145 unsigned int quad_spin_lock; /* Spare location used for quad */ 146 unsigned int quad_spin_lock; /* Spare location used for quad */
@@ -152,7 +153,7 @@ struct sys_cfg_data {
152 /* 153 /*
153 * memory configuration area for each quad 154 * memory configuration area for each quad
154 */ 155 */
155 struct eachquadmem eq[MAX_NUMNODES]; /* indexed by quad id */ 156 struct eachquadmem eq[MAX_NUMNODES]; /* indexed by quad id */
156}; 157};
157 158
158static inline unsigned long *get_zholes_size(int nid) 159static inline unsigned long *get_zholes_size(int nid)
diff --git a/include/asm-x86/olpc.h b/include/asm-x86/olpc.h
new file mode 100644
index 000000000000..97d47133486f
--- /dev/null
+++ b/include/asm-x86/olpc.h
@@ -0,0 +1,132 @@
1/* OLPC machine specific definitions */
2
3#ifndef ASM_OLPC_H_
4#define ASM_OLPC_H_
5
6#include <asm/geode.h>
7
8struct olpc_platform_t {
9 int flags;
10 uint32_t boardrev;
11 int ecver;
12};
13
14#define OLPC_F_PRESENT 0x01
15#define OLPC_F_DCON 0x02
16#define OLPC_F_VSA 0x04
17
18#ifdef CONFIG_OLPC
19
20extern struct olpc_platform_t olpc_platform_info;
21
22/*
23 * OLPC board IDs contain the major build number within the mask 0x0ff0,
24 * and the minor build number withing 0x000f. Pre-builds have a minor
25 * number less than 8, and normal builds start at 8. For example, 0x0B10
26 * is a PreB1, and 0x0C18 is a C1.
27 */
28
29static inline uint32_t olpc_board(uint8_t id)
30{
31 return (id << 4) | 0x8;
32}
33
34static inline uint32_t olpc_board_pre(uint8_t id)
35{
36 return id << 4;
37}
38
39static inline int machine_is_olpc(void)
40{
41 return (olpc_platform_info.flags & OLPC_F_PRESENT) ? 1 : 0;
42}
43
44/*
45 * The DCON is OLPC's Display Controller. It has a number of unique
46 * features that we might want to take advantage of..
47 */
48static inline int olpc_has_dcon(void)
49{
50 return (olpc_platform_info.flags & OLPC_F_DCON) ? 1 : 0;
51}
52
53/*
54 * The VSA is software from AMD that typical Geode bioses will include.
55 * It is used to emulate the PCI bus, VGA, etc. OLPC's Open Firmware does
56 * not include the VSA; instead, PCI is emulated by the kernel.
57 *
58 * The VSA is described further in arch/x86/pci/olpc.c.
59 */
60static inline int olpc_has_vsa(void)
61{
62 return (olpc_platform_info.flags & OLPC_F_VSA) ? 1 : 0;
63}
64
65/*
66 * The "Mass Production" version of OLPC's XO is identified as being model
67 * C2. During the prototype phase, the following models (in chronological
68 * order) were created: A1, B1, B2, B3, B4, C1. The A1 through B2 models
69 * were based on Geode GX CPUs, and models after that were based upon
70 * Geode LX CPUs. There were also some hand-assembled models floating
71 * around, referred to as PreB1, PreB2, etc.
72 */
73static inline int olpc_board_at_least(uint32_t rev)
74{
75 return olpc_platform_info.boardrev >= rev;
76}
77
78#else
79
80static inline int machine_is_olpc(void)
81{
82 return 0;
83}
84
85static inline int olpc_has_dcon(void)
86{
87 return 0;
88}
89
90static inline int olpc_has_vsa(void)
91{
92 return 0;
93}
94
95#endif
96
97/* EC related functions */
98
99extern int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
100 unsigned char *outbuf, size_t outlen);
101
102extern int olpc_ec_mask_set(uint8_t bits);
103extern int olpc_ec_mask_unset(uint8_t bits);
104
105/* EC commands */
106
107#define EC_FIRMWARE_REV 0x08
108
109/* SCI source values */
110
111#define EC_SCI_SRC_EMPTY 0x00
112#define EC_SCI_SRC_GAME 0x01
113#define EC_SCI_SRC_BATTERY 0x02
114#define EC_SCI_SRC_BATSOC 0x04
115#define EC_SCI_SRC_BATERR 0x08
116#define EC_SCI_SRC_EBOOK 0x10
117#define EC_SCI_SRC_WLAN 0x20
118#define EC_SCI_SRC_ACPWR 0x40
119#define EC_SCI_SRC_ALL 0x7F
120
121/* GPIO assignments */
122
123#define OLPC_GPIO_MIC_AC geode_gpio(1)
124#define OLPC_GPIO_DCON_IRQ geode_gpio(7)
125#define OLPC_GPIO_THRM_ALRM geode_gpio(10)
126#define OLPC_GPIO_SMB_CLK geode_gpio(14)
127#define OLPC_GPIO_SMB_DATA geode_gpio(15)
128#define OLPC_GPIO_WORKAUX geode_gpio(24)
129#define OLPC_GPIO_LID geode_gpio(26)
130#define OLPC_GPIO_ECSCI geode_gpio(27)
131
132#endif
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
index a05b2896492f..b381f4a5a0bd 100644
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -33,10 +33,8 @@
33 33
34#ifdef CONFIG_X86_64 34#ifdef CONFIG_X86_64
35#include <asm/page_64.h> 35#include <asm/page_64.h>
36#define max_pfn_mapped end_pfn_map
37#else 36#else
38#include <asm/page_32.h> 37#include <asm/page_32.h>
39#define max_pfn_mapped max_low_pfn
40#endif /* CONFIG_X86_64 */ 38#endif /* CONFIG_X86_64 */
41 39
42#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) 40#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
@@ -49,6 +47,9 @@
49#ifndef __ASSEMBLY__ 47#ifndef __ASSEMBLY__
50 48
51extern int page_is_ram(unsigned long pagenr); 49extern int page_is_ram(unsigned long pagenr);
50extern int devmem_is_allowed(unsigned long pagenr);
51
52extern unsigned long max_pfn_mapped;
52 53
53struct page; 54struct page;
54 55
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
index 5f7257fd589b..424e82f8ae27 100644
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -47,7 +47,10 @@ typedef unsigned long pgdval_t;
47typedef unsigned long pgprotval_t; 47typedef unsigned long pgprotval_t;
48typedef unsigned long phys_addr_t; 48typedef unsigned long phys_addr_t;
49 49
50typedef union { pteval_t pte, pte_low; } pte_t; 50typedef union {
51 pteval_t pte;
52 pteval_t pte_low;
53} pte_t;
51 54
52#endif /* __ASSEMBLY__ */ 55#endif /* __ASSEMBLY__ */
53#endif /* CONFIG_X86_PAE */ 56#endif /* CONFIG_X86_PAE */
@@ -61,7 +64,7 @@ typedef struct page *pgtable_t;
61#endif 64#endif
62 65
63#ifndef __ASSEMBLY__ 66#ifndef __ASSEMBLY__
64#define __phys_addr(x) ((x)-PAGE_OFFSET) 67#define __phys_addr(x) ((x) - PAGE_OFFSET)
65#define __phys_reloc_hide(x) RELOC_HIDE((x), 0) 68#define __phys_reloc_hide(x) RELOC_HIDE((x), 0)
66 69
67#ifdef CONFIG_FLATMEM 70#ifdef CONFIG_FLATMEM
@@ -78,7 +81,7 @@ extern unsigned int __VMALLOC_RESERVE;
78extern int sysctl_legacy_va_layout; 81extern int sysctl_legacy_va_layout;
79 82
80#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) 83#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
81#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) 84#define MAXMEM (-__PAGE_OFFSET - __VMALLOC_RESERVE)
82 85
83#ifdef CONFIG_X86_USE_3DNOW 86#ifdef CONFIG_X86_USE_3DNOW
84#include <asm/mmx.h> 87#include <asm/mmx.h>
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index 143546073b95..6ea72859c491 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -5,7 +5,7 @@
5 5
6#define THREAD_ORDER 1 6#define THREAD_ORDER 1
7#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) 7#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
8#define CURRENT_MASK (~(THREAD_SIZE-1)) 8#define CURRENT_MASK (~(THREAD_SIZE - 1))
9 9
10#define EXCEPTION_STACK_ORDER 0 10#define EXCEPTION_STACK_ORDER 0
11#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER) 11#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
@@ -48,10 +48,10 @@
48#define __VIRTUAL_MASK_SHIFT 48 48#define __VIRTUAL_MASK_SHIFT 48
49 49
50/* 50/*
51 * Kernel image size is limited to 128 MB (see level2_kernel_pgt in 51 * Kernel image size is limited to 512 MB (see level2_kernel_pgt in
52 * arch/x86/kernel/head_64.S), and it is mapped here: 52 * arch/x86/kernel/head_64.S), and it is mapped here:
53 */ 53 */
54#define KERNEL_IMAGE_SIZE (128*1024*1024) 54#define KERNEL_IMAGE_SIZE (512 * 1024 * 1024)
55#define KERNEL_IMAGE_START _AC(0xffffffff80000000, UL) 55#define KERNEL_IMAGE_START _AC(0xffffffff80000000, UL)
56 56
57#ifndef __ASSEMBLY__ 57#ifndef __ASSEMBLY__
@@ -59,7 +59,6 @@ void clear_page(void *page);
59void copy_page(void *to, void *from); 59void copy_page(void *to, void *from);
60 60
61extern unsigned long end_pfn; 61extern unsigned long end_pfn;
62extern unsigned long end_pfn_map;
63extern unsigned long phys_base; 62extern unsigned long phys_base;
64 63
65extern unsigned long __phys_addr(unsigned long); 64extern unsigned long __phys_addr(unsigned long);
@@ -81,6 +80,9 @@ typedef struct { pteval_t pte; } pte_t;
81 80
82#define vmemmap ((struct page *)VMEMMAP_START) 81#define vmemmap ((struct page *)VMEMMAP_START)
83 82
83extern unsigned long init_memory_mapping(unsigned long start,
84 unsigned long end);
85
84#endif /* !__ASSEMBLY__ */ 86#endif /* !__ASSEMBLY__ */
85 87
86#ifdef CONFIG_FLATMEM 88#ifdef CONFIG_FLATMEM
diff --git a/include/asm-x86/param.h b/include/asm-x86/param.h
index c996ec4da0c8..6f0d0422f4ca 100644
--- a/include/asm-x86/param.h
+++ b/include/asm-x86/param.h
@@ -3,8 +3,8 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5# define HZ CONFIG_HZ /* Internal kernel timer frequency */ 5# define HZ CONFIG_HZ /* Internal kernel timer frequency */
6# define USER_HZ 100 /* .. some user interfaces are in "ticks" */ 6# define USER_HZ 100 /* some user interfaces are */
7# define CLOCKS_PER_SEC (USER_HZ) /* like times() */ 7# define CLOCKS_PER_SEC (USER_HZ) /* in "ticks" like times() */
8#endif 8#endif
9 9
10#ifndef HZ 10#ifndef HZ
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index d6236eb46466..0f13b945e240 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -220,18 +220,21 @@ struct pv_mmu_ops {
220 unsigned long va); 220 unsigned long va);
221 221
222 /* Hooks for allocating/releasing pagetable pages */ 222 /* Hooks for allocating/releasing pagetable pages */
223 void (*alloc_pt)(struct mm_struct *mm, u32 pfn); 223 void (*alloc_pte)(struct mm_struct *mm, u32 pfn);
224 void (*alloc_pd)(struct mm_struct *mm, u32 pfn); 224 void (*alloc_pmd)(struct mm_struct *mm, u32 pfn);
225 void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count); 225 void (*alloc_pmd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count);
226 void (*release_pt)(u32 pfn); 226 void (*alloc_pud)(struct mm_struct *mm, u32 pfn);
227 void (*release_pd)(u32 pfn); 227 void (*release_pte)(u32 pfn);
228 void (*release_pmd)(u32 pfn);
229 void (*release_pud)(u32 pfn);
228 230
229 /* Pagetable manipulation functions */ 231 /* Pagetable manipulation functions */
230 void (*set_pte)(pte_t *ptep, pte_t pteval); 232 void (*set_pte)(pte_t *ptep, pte_t pteval);
231 void (*set_pte_at)(struct mm_struct *mm, unsigned long addr, 233 void (*set_pte_at)(struct mm_struct *mm, unsigned long addr,
232 pte_t *ptep, pte_t pteval); 234 pte_t *ptep, pte_t pteval);
233 void (*set_pmd)(pmd_t *pmdp, pmd_t pmdval); 235 void (*set_pmd)(pmd_t *pmdp, pmd_t pmdval);
234 void (*pte_update)(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 236 void (*pte_update)(struct mm_struct *mm, unsigned long addr,
237 pte_t *ptep);
235 void (*pte_update_defer)(struct mm_struct *mm, 238 void (*pte_update_defer)(struct mm_struct *mm,
236 unsigned long addr, pte_t *ptep); 239 unsigned long addr, pte_t *ptep);
237 240
@@ -246,7 +249,8 @@ struct pv_mmu_ops {
246 void (*set_pte_atomic)(pte_t *ptep, pte_t pteval); 249 void (*set_pte_atomic)(pte_t *ptep, pte_t pteval);
247 void (*set_pte_present)(struct mm_struct *mm, unsigned long addr, 250 void (*set_pte_present)(struct mm_struct *mm, unsigned long addr,
248 pte_t *ptep, pte_t pte); 251 pte_t *ptep, pte_t pte);
249 void (*pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 252 void (*pte_clear)(struct mm_struct *mm, unsigned long addr,
253 pte_t *ptep);
250 void (*pmd_clear)(pmd_t *pmdp); 254 void (*pmd_clear)(pmd_t *pmdp);
251 255
252#endif /* CONFIG_X86_PAE */ 256#endif /* CONFIG_X86_PAE */
@@ -274,8 +278,7 @@ struct pv_mmu_ops {
274/* This contains all the paravirt structures: we get a convenient 278/* This contains all the paravirt structures: we get a convenient
275 * number for each function using the offset which we use to indicate 279 * number for each function using the offset which we use to indicate
276 * what to patch. */ 280 * what to patch. */
277struct paravirt_patch_template 281struct paravirt_patch_template {
278{
279 struct pv_init_ops pv_init_ops; 282 struct pv_init_ops pv_init_ops;
280 struct pv_time_ops pv_time_ops; 283 struct pv_time_ops pv_time_ops;
281 struct pv_cpu_ops pv_cpu_ops; 284 struct pv_cpu_ops pv_cpu_ops;
@@ -660,43 +663,56 @@ static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high)
660} 663}
661 664
662/* These should all do BUG_ON(_err), but our headers are too tangled. */ 665/* These should all do BUG_ON(_err), but our headers are too tangled. */
663#define rdmsr(msr,val1,val2) do { \ 666#define rdmsr(msr, val1, val2) \
667do { \
664 int _err; \ 668 int _err; \
665 u64 _l = paravirt_read_msr(msr, &_err); \ 669 u64 _l = paravirt_read_msr(msr, &_err); \
666 val1 = (u32)_l; \ 670 val1 = (u32)_l; \
667 val2 = _l >> 32; \ 671 val2 = _l >> 32; \
668} while(0) 672} while (0)
669 673
670#define wrmsr(msr,val1,val2) do { \ 674#define wrmsr(msr, val1, val2) \
675do { \
671 paravirt_write_msr(msr, val1, val2); \ 676 paravirt_write_msr(msr, val1, val2); \
672} while(0) 677} while (0)
673 678
674#define rdmsrl(msr,val) do { \ 679#define rdmsrl(msr, val) \
680do { \
675 int _err; \ 681 int _err; \
676 val = paravirt_read_msr(msr, &_err); \ 682 val = paravirt_read_msr(msr, &_err); \
677} while(0) 683} while (0)
678 684
679#define wrmsrl(msr,val) wrmsr(msr, (u32)((u64)(val)), ((u64)(val))>>32) 685#define wrmsrl(msr, val) wrmsr(msr, (u32)((u64)(val)), ((u64)(val))>>32)
680#define wrmsr_safe(msr,a,b) paravirt_write_msr(msr, a, b) 686#define wrmsr_safe(msr, a, b) paravirt_write_msr(msr, a, b)
681 687
682/* rdmsr with exception handling */ 688/* rdmsr with exception handling */
683#define rdmsr_safe(msr,a,b) ({ \ 689#define rdmsr_safe(msr, a, b) \
690({ \
684 int _err; \ 691 int _err; \
685 u64 _l = paravirt_read_msr(msr, &_err); \ 692 u64 _l = paravirt_read_msr(msr, &_err); \
686 (*a) = (u32)_l; \ 693 (*a) = (u32)_l; \
687 (*b) = _l >> 32; \ 694 (*b) = _l >> 32; \
688 _err; }) 695 _err; \
696})
689 697
698static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
699{
700 int err;
701
702 *p = paravirt_read_msr(msr, &err);
703 return err;
704}
690 705
691static inline u64 paravirt_read_tsc(void) 706static inline u64 paravirt_read_tsc(void)
692{ 707{
693 return PVOP_CALL0(u64, pv_cpu_ops.read_tsc); 708 return PVOP_CALL0(u64, pv_cpu_ops.read_tsc);
694} 709}
695 710
696#define rdtscl(low) do { \ 711#define rdtscl(low) \
712do { \
697 u64 _l = paravirt_read_tsc(); \ 713 u64 _l = paravirt_read_tsc(); \
698 low = (int)_l; \ 714 low = (int)_l; \
699} while(0) 715} while (0)
700 716
701#define rdtscll(val) (val = paravirt_read_tsc()) 717#define rdtscll(val) (val = paravirt_read_tsc())
702 718
@@ -711,11 +727,12 @@ static inline unsigned long long paravirt_read_pmc(int counter)
711 return PVOP_CALL1(u64, pv_cpu_ops.read_pmc, counter); 727 return PVOP_CALL1(u64, pv_cpu_ops.read_pmc, counter);
712} 728}
713 729
714#define rdpmc(counter,low,high) do { \ 730#define rdpmc(counter, low, high) \
731do { \
715 u64 _l = paravirt_read_pmc(counter); \ 732 u64 _l = paravirt_read_pmc(counter); \
716 low = (u32)_l; \ 733 low = (u32)_l; \
717 high = _l >> 32; \ 734 high = _l >> 32; \
718} while(0) 735} while (0)
719 736
720static inline unsigned long long paravirt_rdtscp(unsigned int *aux) 737static inline unsigned long long paravirt_rdtscp(unsigned int *aux)
721{ 738{
@@ -794,7 +811,8 @@ static inline void set_iopl_mask(unsigned mask)
794} 811}
795 812
796/* The paravirtualized I/O functions */ 813/* The paravirtualized I/O functions */
797static inline void slow_down_io(void) { 814static inline void slow_down_io(void)
815{
798 pv_cpu_ops.io_delay(); 816 pv_cpu_ops.io_delay();
799#ifdef REALLY_SLOW_IO 817#ifdef REALLY_SLOW_IO
800 pv_cpu_ops.io_delay(); 818 pv_cpu_ops.io_delay();
@@ -894,28 +912,37 @@ static inline void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
894 PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, &cpumask, mm, va); 912 PVOP_VCALL3(pv_mmu_ops.flush_tlb_others, &cpumask, mm, va);
895} 913}
896 914
897static inline void paravirt_alloc_pt(struct mm_struct *mm, unsigned pfn) 915static inline void paravirt_alloc_pte(struct mm_struct *mm, unsigned pfn)
898{ 916{
899 PVOP_VCALL2(pv_mmu_ops.alloc_pt, mm, pfn); 917 PVOP_VCALL2(pv_mmu_ops.alloc_pte, mm, pfn);
900} 918}
901static inline void paravirt_release_pt(unsigned pfn) 919static inline void paravirt_release_pte(unsigned pfn)
902{ 920{
903 PVOP_VCALL1(pv_mmu_ops.release_pt, pfn); 921 PVOP_VCALL1(pv_mmu_ops.release_pte, pfn);
904} 922}
905 923
906static inline void paravirt_alloc_pd(struct mm_struct *mm, unsigned pfn) 924static inline void paravirt_alloc_pmd(struct mm_struct *mm, unsigned pfn)
925{
926 PVOP_VCALL2(pv_mmu_ops.alloc_pmd, mm, pfn);
927}
928
929static inline void paravirt_alloc_pmd_clone(unsigned pfn, unsigned clonepfn,
930 unsigned start, unsigned count)
931{
932 PVOP_VCALL4(pv_mmu_ops.alloc_pmd_clone, pfn, clonepfn, start, count);
933}
934static inline void paravirt_release_pmd(unsigned pfn)
907{ 935{
908 PVOP_VCALL2(pv_mmu_ops.alloc_pd, mm, pfn); 936 PVOP_VCALL1(pv_mmu_ops.release_pmd, pfn);
909} 937}
910 938
911static inline void paravirt_alloc_pd_clone(unsigned pfn, unsigned clonepfn, 939static inline void paravirt_alloc_pud(struct mm_struct *mm, unsigned pfn)
912 unsigned start, unsigned count)
913{ 940{
914 PVOP_VCALL4(pv_mmu_ops.alloc_pd_clone, pfn, clonepfn, start, count); 941 PVOP_VCALL2(pv_mmu_ops.alloc_pud, mm, pfn);
915} 942}
916static inline void paravirt_release_pd(unsigned pfn) 943static inline void paravirt_release_pud(unsigned pfn)
917{ 944{
918 PVOP_VCALL1(pv_mmu_ops.release_pd, pfn); 945 PVOP_VCALL1(pv_mmu_ops.release_pud, pfn);
919} 946}
920 947
921#ifdef CONFIG_HIGHPTE 948#ifdef CONFIG_HIGHPTE
diff --git a/include/asm-x86/parport.h b/include/asm-x86/parport.h
index 019cbca24a38..3c4ffeb467e9 100644
--- a/include/asm-x86/parport.h
+++ b/include/asm-x86/parport.h
@@ -1,10 +1,10 @@
1#ifndef _ASM_X86_PARPORT_H 1#ifndef _ASM_X86_PARPORT_H
2#define _ASM_X86_PARPORT_H 2#define _ASM_X86_PARPORT_H
3 3
4static int __devinit parport_pc_find_isa_ports (int autoirq, int autodma); 4static int __devinit parport_pc_find_isa_ports(int autoirq, int autodma);
5static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma) 5static int __devinit parport_pc_find_nonpci_ports(int autoirq, int autodma)
6{ 6{
7 return parport_pc_find_isa_ports (autoirq, autodma); 7 return parport_pc_find_isa_ports(autoirq, autodma);
8} 8}
9 9
10#endif /* _ASM_X86_PARPORT_H */ 10#endif /* _ASM_X86_PARPORT_H */
diff --git a/include/asm-x86/pat.h b/include/asm-x86/pat.h
new file mode 100644
index 000000000000..8b822b5a1786
--- /dev/null
+++ b/include/asm-x86/pat.h
@@ -0,0 +1,16 @@
1
2#ifndef _ASM_PAT_H
3#define _ASM_PAT_H 1
4
5#include <linux/types.h>
6
7extern int pat_wc_enabled;
8
9extern void pat_init(void);
10
11extern int reserve_memtype(u64 start, u64 end,
12 unsigned long req_type, unsigned long *ret_type);
13extern int free_memtype(u64 start, u64 end);
14
15#endif
16
diff --git a/include/asm-x86/pci-direct.h b/include/asm-x86/pci-direct.h
index 6823fa4f1afa..5b21485be573 100644
--- a/include/asm-x86/pci-direct.h
+++ b/include/asm-x86/pci-direct.h
@@ -4,7 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6/* Direct PCI access. This is used for PCI accesses in early boot before 6/* Direct PCI access. This is used for PCI accesses in early boot before
7 the PCI subsystem works. */ 7 the PCI subsystem works. */
8 8
9extern u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset); 9extern u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset);
10extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset); 10extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset);
diff --git a/include/asm-x86/pci.h b/include/asm-x86/pci.h
index c61190cb9e12..30bbde0cb34b 100644
--- a/include/asm-x86/pci.h
+++ b/include/asm-x86/pci.h
@@ -8,18 +8,19 @@
8#include <asm/scatterlist.h> 8#include <asm/scatterlist.h>
9#include <asm/io.h> 9#include <asm/io.h>
10 10
11
12#ifdef __KERNEL__ 11#ifdef __KERNEL__
13 12
14struct pci_sysdata { 13struct pci_sysdata {
15 int domain; /* PCI domain */ 14 int domain; /* PCI domain */
16 int node; /* NUMA node */ 15 int node; /* NUMA node */
17#ifdef CONFIG_X86_64 16#ifdef CONFIG_X86_64
18 void* iommu; /* IOMMU private data */ 17 void *iommu; /* IOMMU private data */
19#endif 18#endif
20}; 19};
21 20
22/* scan a bus after allocating a pci_sysdata for it */ 21/* scan a bus after allocating a pci_sysdata for it */
22extern struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops,
23 int node);
23extern struct pci_bus *pci_scan_bus_with_sysdata(int busno); 24extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
24 25
25static inline int pci_domain_nr(struct pci_bus *bus) 26static inline int pci_domain_nr(struct pci_bus *bus)
@@ -52,7 +53,7 @@ extern unsigned long pci_mem_start;
52#define PCIBIOS_MIN_CARDBUS_IO 0x4000 53#define PCIBIOS_MIN_CARDBUS_IO 0x4000
53 54
54void pcibios_config_init(void); 55void pcibios_config_init(void);
55struct pci_bus * pcibios_scan_root(int bus); 56struct pci_bus *pcibios_scan_root(int bus);
56 57
57void pcibios_set_master(struct pci_dev *dev); 58void pcibios_set_master(struct pci_dev *dev);
58void pcibios_penalize_isa_irq(int irq, int active); 59void pcibios_penalize_isa_irq(int irq, int active);
@@ -62,7 +63,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
62 63
63#define HAVE_PCI_MMAP 64#define HAVE_PCI_MMAP
64extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 65extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
65 enum pci_mmap_state mmap_state, int write_combine); 66 enum pci_mmap_state mmap_state,
67 int write_combine);
66 68
67 69
68#ifdef CONFIG_PCI 70#ifdef CONFIG_PCI
diff --git a/include/asm-x86/pci_64.h b/include/asm-x86/pci_64.h
index 374690314539..f330234ffa5c 100644
--- a/include/asm-x86/pci_64.h
+++ b/include/asm-x86/pci_64.h
@@ -1,12 +1,10 @@
1#ifndef __x8664_PCI_H 1#ifndef __x8664_PCI_H
2#define __x8664_PCI_H 2#define __x8664_PCI_H
3 3
4
5#ifdef __KERNEL__ 4#ifdef __KERNEL__
6 5
7
8#ifdef CONFIG_CALGARY_IOMMU 6#ifdef CONFIG_CALGARY_IOMMU
9static inline void* pci_iommu(struct pci_bus *bus) 7static inline void *pci_iommu(struct pci_bus *bus)
10{ 8{
11 struct pci_sysdata *sd = bus->sysdata; 9 struct pci_sysdata *sd = bus->sysdata;
12 return sd->iommu; 10 return sd->iommu;
@@ -19,12 +17,12 @@ static inline void set_pci_iommu(struct pci_bus *bus, void *val)
19} 17}
20#endif /* CONFIG_CALGARY_IOMMU */ 18#endif /* CONFIG_CALGARY_IOMMU */
21 19
20extern int (*pci_config_read)(int seg, int bus, int dev, int fn,
21 int reg, int len, u32 *value);
22extern int (*pci_config_write)(int seg, int bus, int dev, int fn,
23 int reg, int len, u32 value);
22 24
23extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value); 25extern void dma32_reserve_bootmem(void);
24extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
25
26
27
28extern void pci_iommu_alloc(void); 26extern void pci_iommu_alloc(void);
29 27
30/* The PCI address space does equal the physical memory 28/* The PCI address space does equal the physical memory
@@ -65,5 +63,4 @@ extern void pci_iommu_alloc(void);
65 63
66#endif /* __KERNEL__ */ 64#endif /* __KERNEL__ */
67 65
68
69#endif /* __x8664_PCI_H */ 66#endif /* __x8664_PCI_H */
diff --git a/include/asm-x86/pda.h b/include/asm-x86/pda.h
index c0305bff0f19..101fb9e11954 100644
--- a/include/asm-x86/pda.h
+++ b/include/asm-x86/pda.h
@@ -22,7 +22,6 @@ struct x8664_pda {
22 offset 40!!! */ 22 offset 40!!! */
23#endif 23#endif
24 char *irqstackptr; 24 char *irqstackptr;
25 unsigned int nodenumber; /* number of current node */
26 unsigned int __softirq_pending; 25 unsigned int __softirq_pending;
27 unsigned int __nmi_count; /* number of NMI on this CPUs */ 26 unsigned int __nmi_count; /* number of NMI on this CPUs */
28 short mmu_state; 27 short mmu_state;
@@ -58,34 +57,36 @@ extern struct x8664_pda _proxy_pda;
58 57
59#define pda_offset(field) offsetof(struct x8664_pda, field) 58#define pda_offset(field) offsetof(struct x8664_pda, field)
60 59
61#define pda_to_op(op, field, val) do { \ 60#define pda_to_op(op, field, val) \
62 typedef typeof(_proxy_pda.field) T__; \ 61do { \
63 if (0) { T__ tmp__; tmp__ = (val); } /* type checking */ \ 62 typedef typeof(_proxy_pda.field) T__; \
64 switch (sizeof(_proxy_pda.field)) { \ 63 if (0) { T__ tmp__; tmp__ = (val); } /* type checking */ \
65 case 2: \ 64 switch (sizeof(_proxy_pda.field)) { \
66 asm(op "w %1,%%gs:%c2" : \ 65 case 2: \
67 "+m" (_proxy_pda.field) : \ 66 asm(op "w %1,%%gs:%c2" : \
68 "ri" ((T__)val), \ 67 "+m" (_proxy_pda.field) : \
69 "i"(pda_offset(field))); \ 68 "ri" ((T__)val), \
70 break; \ 69 "i"(pda_offset(field))); \
71 case 4: \ 70 break; \
72 asm(op "l %1,%%gs:%c2" : \ 71 case 4: \
73 "+m" (_proxy_pda.field) : \ 72 asm(op "l %1,%%gs:%c2" : \
74 "ri" ((T__)val), \ 73 "+m" (_proxy_pda.field) : \
75 "i" (pda_offset(field))); \ 74 "ri" ((T__)val), \
76 break; \ 75 "i" (pda_offset(field))); \
77 case 8: \ 76 break; \
78 asm(op "q %1,%%gs:%c2": \ 77 case 8: \
79 "+m" (_proxy_pda.field) : \ 78 asm(op "q %1,%%gs:%c2": \
80 "ri" ((T__)val), \ 79 "+m" (_proxy_pda.field) : \
81 "i"(pda_offset(field))); \ 80 "ri" ((T__)val), \
82 break; \ 81 "i"(pda_offset(field))); \
83 default: \ 82 break; \
84 __bad_pda_field(); \ 83 default: \
85 } \ 84 __bad_pda_field(); \
86 } while (0) 85 } \
86} while (0)
87 87
88#define pda_from_op(op,field) ({ \ 88#define pda_from_op(op, field) \
89({ \
89 typeof(_proxy_pda.field) ret__; \ 90 typeof(_proxy_pda.field) ret__; \
90 switch (sizeof(_proxy_pda.field)) { \ 91 switch (sizeof(_proxy_pda.field)) { \
91 case 2: \ 92 case 2: \
@@ -93,23 +94,24 @@ extern struct x8664_pda _proxy_pda;
93 "=r" (ret__) : \ 94 "=r" (ret__) : \
94 "i" (pda_offset(field)), \ 95 "i" (pda_offset(field)), \
95 "m" (_proxy_pda.field)); \ 96 "m" (_proxy_pda.field)); \
96 break; \ 97 break; \
97 case 4: \ 98 case 4: \
98 asm(op "l %%gs:%c1,%0": \ 99 asm(op "l %%gs:%c1,%0": \
99 "=r" (ret__): \ 100 "=r" (ret__): \
100 "i" (pda_offset(field)), \ 101 "i" (pda_offset(field)), \
101 "m" (_proxy_pda.field)); \ 102 "m" (_proxy_pda.field)); \
102 break; \ 103 break; \
103 case 8: \ 104 case 8: \
104 asm(op "q %%gs:%c1,%0": \ 105 asm(op "q %%gs:%c1,%0": \
105 "=r" (ret__) : \ 106 "=r" (ret__) : \
106 "i" (pda_offset(field)), \ 107 "i" (pda_offset(field)), \
107 "m" (_proxy_pda.field)); \ 108 "m" (_proxy_pda.field)); \
108 break; \ 109 break; \
109 default: \ 110 default: \
110 __bad_pda_field(); \ 111 __bad_pda_field(); \
111 } \ 112 } \
112 ret__; }) 113 ret__; \
114})
113 115
114#define read_pda(field) pda_from_op("mov", field) 116#define read_pda(field) pda_from_op("mov", field)
115#define write_pda(field, val) pda_to_op("mov", field, val) 117#define write_pda(field, val) pda_to_op("mov", field, val)
@@ -118,12 +120,13 @@ extern struct x8664_pda _proxy_pda;
118#define or_pda(field, val) pda_to_op("or", field, val) 120#define or_pda(field, val) pda_to_op("or", field, val)
119 121
120/* This is not atomic against other CPUs -- CPU preemption needs to be off */ 122/* This is not atomic against other CPUs -- CPU preemption needs to be off */
121#define test_and_clear_bit_pda(bit, field) ({ \ 123#define test_and_clear_bit_pda(bit, field) \
122 int old__; \ 124({ \
123 asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" \ 125 int old__; \
124 : "=r" (old__), "+m" (_proxy_pda.field) \ 126 asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" \
125 : "dIr" (bit), "i" (pda_offset(field)) : "memory"); \ 127 : "=r" (old__), "+m" (_proxy_pda.field) \
126 old__; \ 128 : "dIr" (bit), "i" (pda_offset(field)) : "memory");\
129 old__; \
127}) 130})
128 131
129#endif 132#endif
diff --git a/include/asm-x86/percpu.h b/include/asm-x86/percpu.h
index 0dec00f27eb4..736fc3bb8e1e 100644
--- a/include/asm-x86/percpu.h
+++ b/include/asm-x86/percpu.h
@@ -85,58 +85,62 @@ DECLARE_PER_CPU(unsigned long, this_cpu_off);
85 * don't give an lvalue though). */ 85 * don't give an lvalue though). */
86extern void __bad_percpu_size(void); 86extern void __bad_percpu_size(void);
87 87
88#define percpu_to_op(op,var,val) \ 88#define percpu_to_op(op, var, val) \
89 do { \ 89do { \
90 typedef typeof(var) T__; \ 90 typedef typeof(var) T__; \
91 if (0) { T__ tmp__; tmp__ = (val); } \ 91 if (0) { \
92 switch (sizeof(var)) { \ 92 T__ tmp__; \
93 case 1: \ 93 tmp__ = (val); \
94 asm(op "b %1,"__percpu_seg"%0" \ 94 } \
95 : "+m" (var) \ 95 switch (sizeof(var)) { \
96 :"ri" ((T__)val)); \ 96 case 1: \
97 break; \ 97 asm(op "b %1,"__percpu_seg"%0" \
98 case 2: \ 98 : "+m" (var) \
99 asm(op "w %1,"__percpu_seg"%0" \ 99 : "ri" ((T__)val)); \
100 : "+m" (var) \ 100 break; \
101 :"ri" ((T__)val)); \ 101 case 2: \
102 break; \ 102 asm(op "w %1,"__percpu_seg"%0" \
103 case 4: \ 103 : "+m" (var) \
104 asm(op "l %1,"__percpu_seg"%0" \ 104 : "ri" ((T__)val)); \
105 : "+m" (var) \ 105 break; \
106 :"ri" ((T__)val)); \ 106 case 4: \
107 break; \ 107 asm(op "l %1,"__percpu_seg"%0" \
108 default: __bad_percpu_size(); \ 108 : "+m" (var) \
109 } \ 109 : "ri" ((T__)val)); \
110 } while (0) 110 break; \
111 111 default: __bad_percpu_size(); \
112#define percpu_from_op(op,var) \ 112 } \
113 ({ \ 113} while (0)
114 typeof(var) ret__; \ 114
115 switch (sizeof(var)) { \ 115#define percpu_from_op(op, var) \
116 case 1: \ 116({ \
117 asm(op "b "__percpu_seg"%1,%0" \ 117 typeof(var) ret__; \
118 : "=r" (ret__) \ 118 switch (sizeof(var)) { \
119 : "m" (var)); \ 119 case 1: \
120 break; \ 120 asm(op "b "__percpu_seg"%1,%0" \
121 case 2: \ 121 : "=r" (ret__) \
122 asm(op "w "__percpu_seg"%1,%0" \ 122 : "m" (var)); \
123 : "=r" (ret__) \ 123 break; \
124 : "m" (var)); \ 124 case 2: \
125 break; \ 125 asm(op "w "__percpu_seg"%1,%0" \
126 case 4: \ 126 : "=r" (ret__) \
127 asm(op "l "__percpu_seg"%1,%0" \ 127 : "m" (var)); \
128 : "=r" (ret__) \ 128 break; \
129 : "m" (var)); \ 129 case 4: \
130 break; \ 130 asm(op "l "__percpu_seg"%1,%0" \
131 default: __bad_percpu_size(); \ 131 : "=r" (ret__) \
132 } \ 132 : "m" (var)); \
133 ret__; }) 133 break; \
134 default: __bad_percpu_size(); \
135 } \
136 ret__; \
137})
134 138
135#define x86_read_percpu(var) percpu_from_op("mov", per_cpu__##var) 139#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) 140#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) 141#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) 142#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) 143#define x86_or_percpu(var, val) percpu_to_op("or", per_cpu__##var, val)
140#endif /* !__ASSEMBLY__ */ 144#endif /* !__ASSEMBLY__ */
141#endif /* !CONFIG_X86_64 */ 145#endif /* !CONFIG_X86_64 */
142#endif /* _ASM_X86_PERCPU_H_ */ 146#endif /* _ASM_X86_PERCPU_H_ */
diff --git a/include/asm-x86/pgalloc.h b/include/asm-x86/pgalloc.h
index 5886eed05886..91e4641f3f31 100644
--- a/include/asm-x86/pgalloc.h
+++ b/include/asm-x86/pgalloc.h
@@ -1,5 +1,110 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_PGALLOC_H
2# include "pgalloc_32.h" 2#define _ASM_X86_PGALLOC_H
3
4#include <linux/threads.h>
5#include <linux/mm.h> /* for struct page */
6#include <linux/pagemap.h>
7
8#ifdef CONFIG_PARAVIRT
9#include <asm/paravirt.h>
3#else 10#else
4# include "pgalloc_64.h" 11static inline void paravirt_alloc_pte(struct mm_struct *mm, unsigned long pfn) {}
12static inline void paravirt_alloc_pmd(struct mm_struct *mm, unsigned long pfn) {}
13static inline void paravirt_alloc_pmd_clone(unsigned long pfn, unsigned long clonepfn,
14 unsigned long start, unsigned long count) {}
15static inline void paravirt_alloc_pud(struct mm_struct *mm, unsigned long pfn) {}
16static inline void paravirt_release_pte(unsigned long pfn) {}
17static inline void paravirt_release_pmd(unsigned long pfn) {}
18static inline void paravirt_release_pud(unsigned long pfn) {}
5#endif 19#endif
20
21/*
22 * Allocate and free page tables.
23 */
24extern pgd_t *pgd_alloc(struct mm_struct *);
25extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
26
27extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long);
28extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long);
29
30/* Should really implement gc for free page table pages. This could be
31 done with a reference count in struct page. */
32
33static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
34{
35 BUG_ON((unsigned long)pte & (PAGE_SIZE-1));
36 free_page((unsigned long)pte);
37}
38
39static inline void pte_free(struct mm_struct *mm, struct page *pte)
40{
41 __free_page(pte);
42}
43
44extern void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte);
45
46static inline void pmd_populate_kernel(struct mm_struct *mm,
47 pmd_t *pmd, pte_t *pte)
48{
49 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
50 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
51}
52
53static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
54 struct page *pte)
55{
56 unsigned long pfn = page_to_pfn(pte);
57
58 paravirt_alloc_pte(mm, pfn);
59 set_pmd(pmd, __pmd(((pteval_t)pfn << PAGE_SHIFT) | _PAGE_TABLE));
60}
61
62#define pmd_pgtable(pmd) pmd_page(pmd)
63
64#if PAGETABLE_LEVELS > 2
65static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
66{
67 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
68}
69
70static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
71{
72 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
73 free_page((unsigned long)pmd);
74}
75
76extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd);
77
78#ifdef CONFIG_X86_PAE
79extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
80#else /* !CONFIG_X86_PAE */
81static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
82{
83 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
84 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
85}
86#endif /* CONFIG_X86_PAE */
87
88#if PAGETABLE_LEVELS > 3
89static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
90{
91 paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
92 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
93}
94
95static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
96{
97 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
98}
99
100static inline void pud_free(struct mm_struct *mm, pud_t *pud)
101{
102 BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
103 free_page((unsigned long)pud);
104}
105
106extern void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud);
107#endif /* PAGETABLE_LEVELS > 3 */
108#endif /* PAGETABLE_LEVELS > 2 */
109
110#endif /* _ASM_X86_PGALLOC_H */
diff --git a/include/asm-x86/pgalloc_32.h b/include/asm-x86/pgalloc_32.h
deleted file mode 100644
index 6bea6e5b5ee5..000000000000
--- a/include/asm-x86/pgalloc_32.h
+++ /dev/null
@@ -1,95 +0,0 @@
1#ifndef _I386_PGALLOC_H
2#define _I386_PGALLOC_H
3
4#include <linux/threads.h>
5#include <linux/mm.h> /* for struct page */
6#include <linux/pagemap.h>
7#include <asm/tlb.h>
8#include <asm-generic/tlb.h>
9
10#ifdef CONFIG_PARAVIRT
11#include <asm/paravirt.h>
12#else
13#define paravirt_alloc_pt(mm, pfn) do { } while (0)
14#define paravirt_alloc_pd(mm, pfn) do { } while (0)
15#define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0)
16#define paravirt_release_pt(pfn) do { } while (0)
17#define paravirt_release_pd(pfn) do { } while (0)
18#endif
19
20static inline void pmd_populate_kernel(struct mm_struct *mm,
21 pmd_t *pmd, pte_t *pte)
22{
23 paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT);
24 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
25}
26
27static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
28{
29 unsigned long pfn = page_to_pfn(pte);
30
31 paravirt_alloc_pt(mm, pfn);
32 set_pmd(pmd, __pmd(((pteval_t)pfn << PAGE_SHIFT) | _PAGE_TABLE));
33}
34#define pmd_pgtable(pmd) pmd_page(pmd)
35
36/*
37 * Allocate and free page tables.
38 */
39extern pgd_t *pgd_alloc(struct mm_struct *);
40extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
41
42extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long);
43extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long);
44
45static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
46{
47 free_page((unsigned long)pte);
48}
49
50static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
51{
52 pgtable_page_dtor(pte);
53 __free_page(pte);
54}
55
56
57extern void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte);
58
59#ifdef CONFIG_X86_PAE
60/*
61 * In the PAE case we free the pmds as part of the pgd.
62 */
63static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
64{
65 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
66}
67
68static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
69{
70 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
71 free_page((unsigned long)pmd);
72}
73
74extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd);
75
76static inline void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
77{
78 paravirt_alloc_pd(mm, __pa(pmd) >> PAGE_SHIFT);
79
80 /* Note: almost everything apart from _PAGE_PRESENT is
81 reserved at the pmd (PDPT) level. */
82 set_pud(pudp, __pud(__pa(pmd) | _PAGE_PRESENT));
83
84 /*
85 * According to Intel App note "TLBs, Paging-Structure Caches,
86 * and Their Invalidation", April 2007, document 317080-001,
87 * section 8.1: in PAE mode we explicitly have to flush the
88 * TLB via cr3 if the top-level pgd is changed...
89 */
90 if (mm == current->active_mm)
91 write_cr3(read_cr3());
92}
93#endif /* CONFIG_X86_PAE */
94
95#endif /* _I386_PGALLOC_H */
diff --git a/include/asm-x86/pgalloc_64.h b/include/asm-x86/pgalloc_64.h
deleted file mode 100644
index 8d6722320dcc..000000000000
--- a/include/asm-x86/pgalloc_64.h
+++ /dev/null
@@ -1,133 +0,0 @@
1#ifndef _X86_64_PGALLOC_H
2#define _X86_64_PGALLOC_H
3
4#include <asm/pda.h>
5#include <linux/threads.h>
6#include <linux/mm.h>
7
8#define pmd_populate_kernel(mm, pmd, pte) \
9 set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)))
10#define pud_populate(mm, pud, pmd) \
11 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)))
12#define pgd_populate(mm, pgd, pud) \
13 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)))
14
15#define pmd_pgtable(pmd) pmd_page(pmd)
16
17static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
18{
19 set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
20}
21
22static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
23{
24 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
25 free_page((unsigned long)pmd);
26}
27
28static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
29{
30 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
31}
32
33static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
34{
35 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
36}
37
38static inline void pud_free(struct mm_struct *mm, pud_t *pud)
39{
40 BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
41 free_page((unsigned long)pud);
42}
43
44static inline void pgd_list_add(pgd_t *pgd)
45{
46 struct page *page = virt_to_page(pgd);
47 unsigned long flags;
48
49 spin_lock_irqsave(&pgd_lock, flags);
50 list_add(&page->lru, &pgd_list);
51 spin_unlock_irqrestore(&pgd_lock, flags);
52}
53
54static inline void pgd_list_del(pgd_t *pgd)
55{
56 struct page *page = virt_to_page(pgd);
57 unsigned long flags;
58
59 spin_lock_irqsave(&pgd_lock, flags);
60 list_del(&page->lru);
61 spin_unlock_irqrestore(&pgd_lock, flags);
62}
63
64static inline pgd_t *pgd_alloc(struct mm_struct *mm)
65{
66 unsigned boundary;
67 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
68 if (!pgd)
69 return NULL;
70 pgd_list_add(pgd);
71 /*
72 * Copy kernel pointers in from init.
73 * Could keep a freelist or slab cache of those because the kernel
74 * part never changes.
75 */
76 boundary = pgd_index(__PAGE_OFFSET);
77 memset(pgd, 0, boundary * sizeof(pgd_t));
78 memcpy(pgd + boundary,
79 init_level4_pgt + boundary,
80 (PTRS_PER_PGD - boundary) * sizeof(pgd_t));
81 return pgd;
82}
83
84static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
85{
86 BUG_ON((unsigned long)pgd & (PAGE_SIZE-1));
87 pgd_list_del(pgd);
88 free_page((unsigned long)pgd);
89}
90
91static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
92{
93 return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
94}
95
96static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
97{
98 struct page *page;
99 void *p;
100
101 p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
102 if (!p)
103 return NULL;
104 page = virt_to_page(p);
105 pgtable_page_ctor(page);
106 return page;
107}
108
109/* Should really implement gc for free page table pages. This could be
110 done with a reference count in struct page. */
111
112static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
113{
114 BUG_ON((unsigned long)pte & (PAGE_SIZE-1));
115 free_page((unsigned long)pte);
116}
117
118static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
119{
120 pgtable_page_dtor(pte);
121 __free_page(pte);
122}
123
124#define __pte_free_tlb(tlb,pte) \
125do { \
126 pgtable_page_dtor((pte)); \
127 tlb_remove_page((tlb), (pte)); \
128} while (0)
129
130#define __pmd_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x))
131#define __pud_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x))
132
133#endif /* _X86_64_PGALLOC_H */
diff --git a/include/asm-x86/pgtable-2level.h b/include/asm-x86/pgtable-2level.h
index 701404fab308..46bc52c0eae1 100644
--- a/include/asm-x86/pgtable-2level.h
+++ b/include/asm-x86/pgtable-2level.h
@@ -26,7 +26,8 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
26 native_set_pte(ptep, pte); 26 native_set_pte(ptep, pte);
27} 27}
28 28
29static inline void native_set_pte_present(struct mm_struct *mm, unsigned long addr, 29static inline void native_set_pte_present(struct mm_struct *mm,
30 unsigned long addr,
30 pte_t *ptep, pte_t pte) 31 pte_t *ptep, pte_t pte)
31{ 32{
32 native_set_pte(ptep, pte); 33 native_set_pte(ptep, pte);
@@ -37,7 +38,8 @@ static inline void native_pmd_clear(pmd_t *pmdp)
37 native_set_pmd(pmdp, __pmd(0)); 38 native_set_pmd(pmdp, __pmd(0));
38} 39}
39 40
40static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *xp) 41static inline void native_pte_clear(struct mm_struct *mm,
42 unsigned long addr, pte_t *xp)
41{ 43{
42 *xp = native_make_pte(0); 44 *xp = native_make_pte(0);
43} 45}
@@ -61,16 +63,18 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp)
61 */ 63 */
62#define PTE_FILE_MAX_BITS 29 64#define PTE_FILE_MAX_BITS 29
63 65
64#define pte_to_pgoff(pte) \ 66#define pte_to_pgoff(pte) \
65 ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 )) 67 ((((pte).pte_low >> 1) & 0x1f) + (((pte).pte_low >> 8) << 5))
66 68
67#define pgoff_to_pte(off) \ 69#define pgoff_to_pte(off) \
68 ((pte_t) { .pte_low = (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE }) 70 ((pte_t) { .pte_low = (((off) & 0x1f) << 1) + \
71 (((off) >> 5) << 8) + _PAGE_FILE })
69 72
70/* Encode and de-code a swap entry */ 73/* Encode and de-code a swap entry */
71#define __swp_type(x) (((x).val >> 1) & 0x1f) 74#define __swp_type(x) (((x).val >> 1) & 0x1f)
72#define __swp_offset(x) ((x).val >> 8) 75#define __swp_offset(x) ((x).val >> 8)
73#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) 76#define __swp_entry(type, offset) \
77 ((swp_entry_t) { ((type) << 1) | ((offset) << 8) })
74#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low }) 78#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low })
75#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val }) 79#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val })
76 80
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h
index 1d763eec740f..8b4a9d44b7f4 100644
--- a/include/asm-x86/pgtable-3level.h
+++ b/include/asm-x86/pgtable-3level.h
@@ -8,22 +8,26 @@
8 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com> 8 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
9 */ 9 */
10 10
11#define pte_ERROR(e) \ 11#define pte_ERROR(e) \
12 printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) 12 printk("%s:%d: bad pte %p(%08lx%08lx).\n", \
13#define pmd_ERROR(e) \ 13 __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low)
14 printk("%s:%d: bad pmd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pmd_val(e)) 14#define pmd_ERROR(e) \
15#define pgd_ERROR(e) \ 15 printk("%s:%d: bad pmd %p(%016Lx).\n", \
16 printk("%s:%d: bad pgd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) 16 __FILE__, __LINE__, &(e), pmd_val(e))
17 17#define pgd_ERROR(e) \
18 printk("%s:%d: bad pgd %p(%016Lx).\n", \
19 __FILE__, __LINE__, &(e), pgd_val(e))
18 20
19static inline int pud_none(pud_t pud) 21static inline int pud_none(pud_t pud)
20{ 22{
21 return pud_val(pud) == 0; 23 return pud_val(pud) == 0;
22} 24}
25
23static inline int pud_bad(pud_t pud) 26static inline int pud_bad(pud_t pud)
24{ 27{
25 return (pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER)) != 0; 28 return (pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER)) != 0;
26} 29}
30
27static inline int pud_present(pud_t pud) 31static inline int pud_present(pud_t pud)
28{ 32{
29 return pud_val(pud) & _PAGE_PRESENT; 33 return pud_val(pud) & _PAGE_PRESENT;
@@ -48,7 +52,8 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)
48 * we are justified in merely clearing the PTE present bit, followed 52 * we are justified in merely clearing the PTE present bit, followed
49 * by a set. The ordering here is important. 53 * by a set. The ordering here is important.
50 */ 54 */
51static inline void native_set_pte_present(struct mm_struct *mm, unsigned long addr, 55static inline void native_set_pte_present(struct mm_struct *mm,
56 unsigned long addr,
52 pte_t *ptep, pte_t pte) 57 pte_t *ptep, pte_t pte)
53{ 58{
54 ptep->pte_low = 0; 59 ptep->pte_low = 0;
@@ -60,15 +65,17 @@ static inline void native_set_pte_present(struct mm_struct *mm, unsigned long ad
60 65
61static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) 66static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
62{ 67{
63 set_64bit((unsigned long long *)(ptep),native_pte_val(pte)); 68 set_64bit((unsigned long long *)(ptep), native_pte_val(pte));
64} 69}
70
65static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) 71static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
66{ 72{
67 set_64bit((unsigned long long *)(pmdp),native_pmd_val(pmd)); 73 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
68} 74}
75
69static inline void native_set_pud(pud_t *pudp, pud_t pud) 76static inline void native_set_pud(pud_t *pudp, pud_t pud)
70{ 77{
71 set_64bit((unsigned long long *)(pudp),native_pud_val(pud)); 78 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
72} 79}
73 80
74/* 81/*
@@ -76,7 +83,8 @@ static inline void native_set_pud(pud_t *pudp, pud_t pud)
76 * entry, so clear the bottom half first and enforce ordering with a compiler 83 * entry, so clear the bottom half first and enforce ordering with a compiler
77 * barrier. 84 * barrier.
78 */ 85 */
79static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 86static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
87 pte_t *ptep)
80{ 88{
81 ptep->pte_low = 0; 89 ptep->pte_low = 0;
82 smp_wmb(); 90 smp_wmb();
@@ -107,20 +115,19 @@ static inline void pud_clear(pud_t *pudp)
107 * current pgd to avoid unnecessary TLB flushes. 115 * current pgd to avoid unnecessary TLB flushes.
108 */ 116 */
109 pgd = read_cr3(); 117 pgd = read_cr3();
110 if (__pa(pudp) >= pgd && __pa(pudp) < (pgd + sizeof(pgd_t)*PTRS_PER_PGD)) 118 if (__pa(pudp) >= pgd && __pa(pudp) <
119 (pgd + sizeof(pgd_t)*PTRS_PER_PGD))
111 write_cr3(pgd); 120 write_cr3(pgd);
112} 121}
113 122
114#define pud_page(pud) \ 123#define pud_page(pud) ((struct page *) __va(pud_val(pud) & PAGE_MASK))
115((struct page *) __va(pud_val(pud) & PAGE_MASK))
116 124
117#define pud_page_vaddr(pud) \ 125#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK))
118((unsigned long) __va(pud_val(pud) & PAGE_MASK))
119 126
120 127
121/* Find an entry in the second-level page table.. */ 128/* Find an entry in the second-level page table.. */
122#define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \ 129#define pmd_offset(pud, address) ((pmd_t *)pud_page(*(pud)) + \
123 pmd_index(address)) 130 pmd_index(address))
124 131
125#ifdef CONFIG_SMP 132#ifdef CONFIG_SMP
126static inline pte_t native_ptep_get_and_clear(pte_t *ptep) 133static inline pte_t native_ptep_get_and_clear(pte_t *ptep)
@@ -161,7 +168,8 @@ static inline unsigned long pte_pfn(pte_t pte)
161 * put the 32 bits of offset into the high part. 168 * put the 32 bits of offset into the high part.
162 */ 169 */
163#define pte_to_pgoff(pte) ((pte).pte_high) 170#define pte_to_pgoff(pte) ((pte).pte_high)
164#define pgoff_to_pte(off) ((pte_t) { { .pte_low = _PAGE_FILE, .pte_high = (off) } }) 171#define pgoff_to_pte(off) \
172 ((pte_t) { { .pte_low = _PAGE_FILE, .pte_high = (off) } })
165#define PTE_FILE_MAX_BITS 32 173#define PTE_FILE_MAX_BITS 32
166 174
167/* Encode and de-code a swap entry */ 175/* Encode and de-code a swap entry */
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 9cf472aeb9ce..801b31f71452 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -1,16 +1,15 @@
1#ifndef _ASM_X86_PGTABLE_H 1#ifndef _ASM_X86_PGTABLE_H
2#define _ASM_X86_PGTABLE_H 2#define _ASM_X86_PGTABLE_H
3 3
4#define USER_PTRS_PER_PGD ((TASK_SIZE-1)/PGDIR_SIZE+1)
5#define FIRST_USER_ADDRESS 0 4#define FIRST_USER_ADDRESS 0
6 5
7#define _PAGE_BIT_PRESENT 0 6#define _PAGE_BIT_PRESENT 0 /* is present */
8#define _PAGE_BIT_RW 1 7#define _PAGE_BIT_RW 1 /* writeable */
9#define _PAGE_BIT_USER 2 8#define _PAGE_BIT_USER 2 /* userspace addressable */
10#define _PAGE_BIT_PWT 3 9#define _PAGE_BIT_PWT 3 /* page write through */
11#define _PAGE_BIT_PCD 4 10#define _PAGE_BIT_PCD 4 /* page cache disabled */
12#define _PAGE_BIT_ACCESSED 5 11#define _PAGE_BIT_ACCESSED 5 /* was accessed (raised by CPU) */
13#define _PAGE_BIT_DIRTY 6 12#define _PAGE_BIT_DIRTY 6 /* was written to (raised by CPU) */
14#define _PAGE_BIT_FILE 6 13#define _PAGE_BIT_FILE 6
15#define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */ 14#define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16#define _PAGE_BIT_PAT 7 /* on 4KB pages */ 15#define _PAGE_BIT_PAT 7 /* on 4KB pages */
@@ -48,24 +47,39 @@
48#endif 47#endif
49 48
50/* If _PAGE_PRESENT is clear, we use these: */ 49/* If _PAGE_PRESENT is clear, we use these: */
51#define _PAGE_FILE _PAGE_DIRTY /* nonlinear file mapping, saved PTE; unset:swap */ 50#define _PAGE_FILE _PAGE_DIRTY /* nonlinear file mapping,
51 * saved PTE; unset:swap */
52#define _PAGE_PROTNONE _PAGE_PSE /* if the user mapped it with PROT_NONE; 52#define _PAGE_PROTNONE _PAGE_PSE /* if the user mapped it with PROT_NONE;
53 pte_present gives true */ 53 pte_present gives true */
54 54
55#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) 55#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
56#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 56 _PAGE_ACCESSED | _PAGE_DIRTY)
57#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \
58 _PAGE_DIRTY)
57 59
58#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 60#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
59 61
60#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) 62#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT)
61#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) 63#define _PAGE_CACHE_WB (0)
64#define _PAGE_CACHE_WC (_PAGE_PWT)
65#define _PAGE_CACHE_UC_MINUS (_PAGE_PCD)
66#define _PAGE_CACHE_UC (_PAGE_PCD | _PAGE_PWT)
62 67
63#define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) 68#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
64#define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) 69#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
65#define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) 70 _PAGE_ACCESSED | _PAGE_NX)
71
72#define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | _PAGE_RW | \
73 _PAGE_USER | _PAGE_ACCESSED)
74#define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
75 _PAGE_ACCESSED | _PAGE_NX)
76#define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
77 _PAGE_ACCESSED)
66#define PAGE_COPY PAGE_COPY_NOEXEC 78#define PAGE_COPY PAGE_COPY_NOEXEC
67#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) 79#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | \
68#define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) 80 _PAGE_ACCESSED | _PAGE_NX)
81#define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
82 _PAGE_ACCESSED)
69 83
70#ifdef CONFIG_X86_32 84#ifdef CONFIG_X86_32
71#define _PAGE_KERNEL_EXEC \ 85#define _PAGE_KERNEL_EXEC \
@@ -84,6 +98,7 @@ extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
84#define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW) 98#define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
85#define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW) 99#define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
86#define __PAGE_KERNEL_EXEC_NOCACHE (__PAGE_KERNEL_EXEC | _PAGE_PCD | _PAGE_PWT) 100#define __PAGE_KERNEL_EXEC_NOCACHE (__PAGE_KERNEL_EXEC | _PAGE_PCD | _PAGE_PWT)
101#define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
87#define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT) 102#define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
88#define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD) 103#define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
89#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER) 104#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
@@ -101,6 +116,7 @@ extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
101#define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO) 116#define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO)
102#define PAGE_KERNEL_EXEC MAKE_GLOBAL(__PAGE_KERNEL_EXEC) 117#define PAGE_KERNEL_EXEC MAKE_GLOBAL(__PAGE_KERNEL_EXEC)
103#define PAGE_KERNEL_RX MAKE_GLOBAL(__PAGE_KERNEL_RX) 118#define PAGE_KERNEL_RX MAKE_GLOBAL(__PAGE_KERNEL_RX)
119#define PAGE_KERNEL_WC MAKE_GLOBAL(__PAGE_KERNEL_WC)
104#define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE) 120#define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE)
105#define PAGE_KERNEL_UC_MINUS MAKE_GLOBAL(__PAGE_KERNEL_UC_MINUS) 121#define PAGE_KERNEL_UC_MINUS MAKE_GLOBAL(__PAGE_KERNEL_UC_MINUS)
106#define PAGE_KERNEL_EXEC_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_EXEC_NOCACHE) 122#define PAGE_KERNEL_EXEC_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_EXEC_NOCACHE)
@@ -134,7 +150,7 @@ extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
134 * ZERO_PAGE is a global shared page that is always zero: used 150 * ZERO_PAGE is a global shared page that is always zero: used
135 * for zero-mapped memory areas etc.. 151 * for zero-mapped memory areas etc..
136 */ 152 */
137extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)]; 153extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
138#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 154#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
139 155
140extern spinlock_t pgd_lock; 156extern spinlock_t pgd_lock;
@@ -144,30 +160,111 @@ extern struct list_head pgd_list;
144 * The following only work if pte_present() is true. 160 * The following only work if pte_present() is true.
145 * Undefined behaviour if not.. 161 * Undefined behaviour if not..
146 */ 162 */
147static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 163static inline int pte_dirty(pte_t pte)
148static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 164{
149static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } 165 return pte_val(pte) & _PAGE_DIRTY;
150static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 166}
151static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; } 167
152static inline int pte_global(pte_t pte) { return pte_val(pte) & _PAGE_GLOBAL; } 168static inline int pte_young(pte_t pte)
153static inline int pte_exec(pte_t pte) { return !(pte_val(pte) & _PAGE_NX); } 169{
154 170 return pte_val(pte) & _PAGE_ACCESSED;
155static inline int pmd_large(pmd_t pte) {
156 return (pmd_val(pte) & (_PAGE_PSE|_PAGE_PRESENT)) ==
157 (_PAGE_PSE|_PAGE_PRESENT);
158} 171}
159 172
160static inline pte_t pte_mkclean(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_DIRTY); } 173static inline int pte_write(pte_t pte)
161static inline pte_t pte_mkold(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_ACCESSED); } 174{
162static inline pte_t pte_wrprotect(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_RW); } 175 return pte_val(pte) & _PAGE_RW;
163static inline pte_t pte_mkexec(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_NX); } 176}
164static inline pte_t pte_mkdirty(pte_t pte) { return __pte(pte_val(pte) | _PAGE_DIRTY); } 177
165static inline pte_t pte_mkyoung(pte_t pte) { return __pte(pte_val(pte) | _PAGE_ACCESSED); } 178static inline int pte_file(pte_t pte)
166static inline pte_t pte_mkwrite(pte_t pte) { return __pte(pte_val(pte) | _PAGE_RW); } 179{
167static inline pte_t pte_mkhuge(pte_t pte) { return __pte(pte_val(pte) | _PAGE_PSE); } 180 return pte_val(pte) & _PAGE_FILE;
168static inline pte_t pte_clrhuge(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_PSE); } 181}
169static inline pte_t pte_mkglobal(pte_t pte) { return __pte(pte_val(pte) | _PAGE_GLOBAL); } 182
170static inline pte_t pte_clrglobal(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_GLOBAL); } 183static inline int pte_huge(pte_t pte)
184{
185 return pte_val(pte) & _PAGE_PSE;
186}
187
188static inline int pte_global(pte_t pte)
189{
190 return pte_val(pte) & _PAGE_GLOBAL;
191}
192
193static inline int pte_exec(pte_t pte)
194{
195 return !(pte_val(pte) & _PAGE_NX);
196}
197
198static inline int pte_special(pte_t pte)
199{
200 return 0;
201}
202
203static inline int pmd_large(pmd_t pte)
204{
205 return (pmd_val(pte) & (_PAGE_PSE | _PAGE_PRESENT)) ==
206 (_PAGE_PSE | _PAGE_PRESENT);
207}
208
209static inline pte_t pte_mkclean(pte_t pte)
210{
211 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_DIRTY);
212}
213
214static inline pte_t pte_mkold(pte_t pte)
215{
216 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_ACCESSED);
217}
218
219static inline pte_t pte_wrprotect(pte_t pte)
220{
221 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_RW);
222}
223
224static inline pte_t pte_mkexec(pte_t pte)
225{
226 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_NX);
227}
228
229static inline pte_t pte_mkdirty(pte_t pte)
230{
231 return __pte(pte_val(pte) | _PAGE_DIRTY);
232}
233
234static inline pte_t pte_mkyoung(pte_t pte)
235{
236 return __pte(pte_val(pte) | _PAGE_ACCESSED);
237}
238
239static inline pte_t pte_mkwrite(pte_t pte)
240{
241 return __pte(pte_val(pte) | _PAGE_RW);
242}
243
244static inline pte_t pte_mkhuge(pte_t pte)
245{
246 return __pte(pte_val(pte) | _PAGE_PSE);
247}
248
249static inline pte_t pte_clrhuge(pte_t pte)
250{
251 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_PSE);
252}
253
254static inline pte_t pte_mkglobal(pte_t pte)
255{
256 return __pte(pte_val(pte) | _PAGE_GLOBAL);
257}
258
259static inline pte_t pte_clrglobal(pte_t pte)
260{
261 return __pte(pte_val(pte) & ~(pteval_t)_PAGE_GLOBAL);
262}
263
264static inline pte_t pte_mkspecial(pte_t pte)
265{
266 return pte;
267}
171 268
172extern pteval_t __supported_pte_mask; 269extern pteval_t __supported_pte_mask;
173 270
@@ -201,6 +298,15 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
201 298
202#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) 299#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask)
203 300
301#ifndef __ASSEMBLY__
302#define __HAVE_PHYS_MEM_ACCESS_PROT
303struct file;
304pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
305 unsigned long size, pgprot_t vma_prot);
306int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
307 unsigned long size, pgprot_t *vma_prot);
308#endif
309
204#ifdef CONFIG_PARAVIRT 310#ifdef CONFIG_PARAVIRT
205#include <asm/paravirt.h> 311#include <asm/paravirt.h>
206#else /* !CONFIG_PARAVIRT */ 312#else /* !CONFIG_PARAVIRT */
@@ -242,6 +348,9 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
242# include "pgtable_64.h" 348# include "pgtable_64.h"
243#endif 349#endif
244 350
351#define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
352#define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
353
245#ifndef __ASSEMBLY__ 354#ifndef __ASSEMBLY__
246 355
247enum { 356enum {
@@ -301,40 +410,21 @@ static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr,
301 * bit at the same time. 410 * bit at the same time.
302 */ 411 */
303#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS 412#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
304#define ptep_set_access_flags(vma, address, ptep, entry, dirty) \ 413extern int ptep_set_access_flags(struct vm_area_struct *vma,
305({ \ 414 unsigned long address, pte_t *ptep,
306 int __changed = !pte_same(*(ptep), entry); \ 415 pte_t entry, int dirty);
307 if (__changed && dirty) { \
308 *ptep = entry; \
309 pte_update_defer((vma)->vm_mm, (address), (ptep)); \
310 flush_tlb_page(vma, address); \
311 } \
312 __changed; \
313})
314 416
315#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 417#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
316#define ptep_test_and_clear_young(vma, addr, ptep) ({ \ 418extern int ptep_test_and_clear_young(struct vm_area_struct *vma,
317 int __ret = 0; \ 419 unsigned long addr, pte_t *ptep);
318 if (pte_young(*(ptep))) \
319 __ret = test_and_clear_bit(_PAGE_BIT_ACCESSED, \
320 &(ptep)->pte); \
321 if (__ret) \
322 pte_update((vma)->vm_mm, addr, ptep); \
323 __ret; \
324})
325 420
326#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 421#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
327#define ptep_clear_flush_young(vma, address, ptep) \ 422extern int ptep_clear_flush_young(struct vm_area_struct *vma,
328({ \ 423 unsigned long address, pte_t *ptep);
329 int __young; \
330 __young = ptep_test_and_clear_young((vma), (address), (ptep)); \
331 if (__young) \
332 flush_tlb_page(vma, address); \
333 __young; \
334})
335 424
336#define __HAVE_ARCH_PTEP_GET_AND_CLEAR 425#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
337static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 426static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
427 pte_t *ptep)
338{ 428{
339 pte_t pte = native_ptep_get_and_clear(ptep); 429 pte_t pte = native_ptep_get_and_clear(ptep);
340 pte_update(mm, addr, ptep); 430 pte_update(mm, addr, ptep);
@@ -342,7 +432,9 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
342} 432}
343 433
344#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL 434#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
345static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full) 435static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm,
436 unsigned long addr, pte_t *ptep,
437 int full)
346{ 438{
347 pte_t pte; 439 pte_t pte;
348 if (full) { 440 if (full) {
@@ -358,12 +450,29 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long
358} 450}
359 451
360#define __HAVE_ARCH_PTEP_SET_WRPROTECT 452#define __HAVE_ARCH_PTEP_SET_WRPROTECT
361static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 453static inline void ptep_set_wrprotect(struct mm_struct *mm,
454 unsigned long addr, pte_t *ptep)
362{ 455{
363 clear_bit(_PAGE_BIT_RW, (unsigned long *)&ptep->pte); 456 clear_bit(_PAGE_BIT_RW, (unsigned long *)&ptep->pte);
364 pte_update(mm, addr, ptep); 457 pte_update(mm, addr, ptep);
365} 458}
366 459
460/*
461 * clone_pgd_range(pgd_t *dst, pgd_t *src, int count);
462 *
463 * dst - pointer to pgd range anwhere on a pgd page
464 * src - ""
465 * count - the number of pgds to copy.
466 *
467 * dst and src can be on the same page, but the range must not overlap,
468 * and must not cross a page boundary.
469 */
470static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
471{
472 memcpy(dst, src, count * sizeof(pgd_t));
473}
474
475
367#include <asm-generic/pgtable.h> 476#include <asm-generic/pgtable.h>
368#endif /* __ASSEMBLY__ */ 477#endif /* __ASSEMBLY__ */
369 478
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index 4e6a0fca0b47..577ab79c4c27 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -40,16 +40,13 @@ void paging_init(void);
40#ifdef CONFIG_X86_PAE 40#ifdef CONFIG_X86_PAE
41# include <asm/pgtable-3level-defs.h> 41# include <asm/pgtable-3level-defs.h>
42# define PMD_SIZE (1UL << PMD_SHIFT) 42# define PMD_SIZE (1UL << PMD_SHIFT)
43# define PMD_MASK (~(PMD_SIZE-1)) 43# define PMD_MASK (~(PMD_SIZE - 1))
44#else 44#else
45# include <asm/pgtable-2level-defs.h> 45# include <asm/pgtable-2level-defs.h>
46#endif 46#endif
47 47
48#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 48#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
49#define PGDIR_MASK (~(PGDIR_SIZE-1)) 49#define PGDIR_MASK (~(PGDIR_SIZE - 1))
50
51#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
52#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
53 50
54/* Just any arbitrary offset to the start of the vmalloc VM area: the 51/* Just any arbitrary offset to the start of the vmalloc VM area: the
55 * current 8MB value just means that there will be a 8MB "hole" after the 52 * current 8MB value just means that there will be a 8MB "hole" after the
@@ -58,21 +55,22 @@ void paging_init(void);
58 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 55 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
59 * area for the same reason. ;) 56 * area for the same reason. ;)
60 */ 57 */
61#define VMALLOC_OFFSET (8*1024*1024) 58#define VMALLOC_OFFSET (8 * 1024 * 1024)
62#define VMALLOC_START (((unsigned long) high_memory + \ 59#define VMALLOC_START (((unsigned long)high_memory + 2 * VMALLOC_OFFSET - 1) \
63 2*VMALLOC_OFFSET-1) & ~(VMALLOC_OFFSET-1)) 60 & ~(VMALLOC_OFFSET - 1))
64#ifdef CONFIG_X86_PAE 61#ifdef CONFIG_X86_PAE
65#define LAST_PKMAP 512 62#define LAST_PKMAP 512
66#else 63#else
67#define LAST_PKMAP 1024 64#define LAST_PKMAP 1024
68#endif 65#endif
69 66
70#define PKMAP_BASE ((FIXADDR_BOOT_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK) 67#define PKMAP_BASE ((FIXADDR_BOOT_START - PAGE_SIZE * (LAST_PKMAP + 1)) \
68 & PMD_MASK)
71 69
72#ifdef CONFIG_HIGHMEM 70#ifdef CONFIG_HIGHMEM
73# define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE) 71# define VMALLOC_END (PKMAP_BASE - 2 * PAGE_SIZE)
74#else 72#else
75# define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) 73# define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
76#endif 74#endif
77 75
78/* 76/*
@@ -88,10 +86,16 @@ extern unsigned long pg0[];
88#define pte_present(x) ((x).pte_low & (_PAGE_PRESENT | _PAGE_PROTNONE)) 86#define pte_present(x) ((x).pte_low & (_PAGE_PRESENT | _PAGE_PROTNONE))
89 87
90/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */ 88/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */
91#define pmd_none(x) (!(unsigned long)pmd_val(x)) 89#define pmd_none(x) (!(unsigned long)pmd_val((x)))
92#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 90#define pmd_present(x) (pmd_val((x)) & _PAGE_PRESENT)
93#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) 91
92extern int pmd_bad(pmd_t pmd);
94 93
94#define pmd_bad_v1(x) \
95 (_KERNPG_TABLE != (pmd_val((x)) & ~(PAGE_MASK | _PAGE_USER)))
96#define pmd_bad_v2(x) \
97 (_KERNPG_TABLE != (pmd_val((x)) & ~(PAGE_MASK | _PAGE_USER | \
98 _PAGE_PSE | _PAGE_NX)))
95 99
96#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 100#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
97 101
@@ -102,32 +106,18 @@ extern unsigned long pg0[];
102#endif 106#endif
103 107
104/* 108/*
105 * clone_pgd_range(pgd_t *dst, pgd_t *src, int count); 109 * Macro to mark a page protection value as "uncacheable".
106 * 110 * On processors which do not support it, this is a no-op.
107 * dst - pointer to pgd range anwhere on a pgd page
108 * src - ""
109 * count - the number of pgds to copy.
110 *
111 * dst and src can be on the same page, but the range must not overlap,
112 * and must not cross a page boundary.
113 */
114static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
115{
116 memcpy(dst, src, count * sizeof(pgd_t));
117}
118
119/*
120 * Macro to mark a page protection value as "uncacheable". On processors which do not support
121 * it, this is a no-op.
122 */ 111 */
123#define pgprot_noncached(prot) ((boot_cpu_data.x86 > 3) \ 112#define pgprot_noncached(prot) \
124 ? (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT)) : (prot)) 113 ((boot_cpu_data.x86 > 3) \
114 ? (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT)) \
115 : (prot))
125 116
126/* 117/*
127 * Conversion functions: convert a page and protection to a page entry, 118 * Conversion functions: convert a page and protection to a page entry,
128 * and a page entry and page directory to the page they refer to. 119 * and a page entry and page directory to the page they refer to.
129 */ 120 */
130
131#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 121#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
132 122
133/* 123/*
@@ -136,20 +126,20 @@ static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
136 * this macro returns the index of the entry in the pgd page which would 126 * this macro returns the index of the entry in the pgd page which would
137 * control the given virtual address 127 * control the given virtual address
138 */ 128 */
139#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 129#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
140#define pgd_index_k(addr) pgd_index(addr) 130#define pgd_index_k(addr) pgd_index((addr))
141 131
142/* 132/*
143 * pgd_offset() returns a (pgd_t *) 133 * pgd_offset() returns a (pgd_t *)
144 * pgd_index() is used get the offset into the pgd page's array of pgd_t's; 134 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
145 */ 135 */
146#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) 136#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
147 137
148/* 138/*
149 * a shortcut which implies the use of the kernel's pgd, instead 139 * a shortcut which implies the use of the kernel's pgd, instead
150 * of a process's 140 * of a process's
151 */ 141 */
152#define pgd_offset_k(address) pgd_offset(&init_mm, address) 142#define pgd_offset_k(address) pgd_offset(&init_mm, (address))
153 143
154static inline int pud_large(pud_t pud) { return 0; } 144static inline int pud_large(pud_t pud) { return 0; }
155 145
@@ -159,8 +149,8 @@ static inline int pud_large(pud_t pud) { return 0; }
159 * this macro returns the index of the entry in the pmd page which would 149 * this macro returns the index of the entry in the pmd page which would
160 * control the given virtual address 150 * control the given virtual address
161 */ 151 */
162#define pmd_index(address) \ 152#define pmd_index(address) \
163 (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) 153 (((address) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
164 154
165/* 155/*
166 * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE] 156 * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
@@ -168,54 +158,56 @@ static inline int pud_large(pud_t pud) { return 0; }
168 * this macro returns the index of the entry in the pte page which would 158 * this macro returns the index of the entry in the pte page which would
169 * control the given virtual address 159 * control the given virtual address
170 */ 160 */
171#define pte_index(address) \ 161#define pte_index(address) \
172 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 162 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
173#define pte_offset_kernel(dir, address) \ 163#define pte_offset_kernel(dir, address) \
174 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address)) 164 ((pte_t *)pmd_page_vaddr(*(dir)) + pte_index((address)))
175 165
176#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) 166#define pmd_page(pmd) (pfn_to_page(pmd_val((pmd)) >> PAGE_SHIFT))
177 167
178#define pmd_page_vaddr(pmd) \ 168#define pmd_page_vaddr(pmd) \
179 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) 169 ((unsigned long)__va(pmd_val((pmd)) & PAGE_MASK))
180 170
181#if defined(CONFIG_HIGHPTE) 171#if defined(CONFIG_HIGHPTE)
182#define pte_offset_map(dir, address) \ 172#define pte_offset_map(dir, address) \
183 ((pte_t *)kmap_atomic_pte(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) 173 ((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE0) + \
184#define pte_offset_map_nested(dir, address) \ 174 pte_index((address)))
185 ((pte_t *)kmap_atomic_pte(pmd_page(*(dir)),KM_PTE1) + pte_index(address)) 175#define pte_offset_map_nested(dir, address) \
186#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0) 176 ((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE1) + \
187#define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1) 177 pte_index((address)))
178#define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0)
179#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
188#else 180#else
189#define pte_offset_map(dir, address) \ 181#define pte_offset_map(dir, address) \
190 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) 182 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address)))
191#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address) 183#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
192#define pte_unmap(pte) do { } while (0) 184#define pte_unmap(pte) do { } while (0)
193#define pte_unmap_nested(pte) do { } while (0) 185#define pte_unmap_nested(pte) do { } while (0)
194#endif 186#endif
195 187
196/* Clear a kernel PTE and flush it from the TLB */ 188/* Clear a kernel PTE and flush it from the TLB */
197#define kpte_clear_flush(ptep, vaddr) \ 189#define kpte_clear_flush(ptep, vaddr) \
198do { \ 190do { \
199 pte_clear(&init_mm, vaddr, ptep); \ 191 pte_clear(&init_mm, (vaddr), (ptep)); \
200 __flush_tlb_one(vaddr); \ 192 __flush_tlb_one((vaddr)); \
201} while (0) 193} while (0)
202 194
203/* 195/*
204 * The i386 doesn't have any external MMU info: the kernel page 196 * The i386 doesn't have any external MMU info: the kernel page
205 * tables contain all the necessary information. 197 * tables contain all the necessary information.
206 */ 198 */
207#define update_mmu_cache(vma,address,pte) do { } while (0) 199#define update_mmu_cache(vma, address, pte) do { } while (0)
208 200
209void native_pagetable_setup_start(pgd_t *base); 201extern void native_pagetable_setup_start(pgd_t *base);
210void native_pagetable_setup_done(pgd_t *base); 202extern void native_pagetable_setup_done(pgd_t *base);
211 203
212#ifndef CONFIG_PARAVIRT 204#ifndef CONFIG_PARAVIRT
213static inline void paravirt_pagetable_setup_start(pgd_t *base) 205static inline void __init paravirt_pagetable_setup_start(pgd_t *base)
214{ 206{
215 native_pagetable_setup_start(base); 207 native_pagetable_setup_start(base);
216} 208}
217 209
218static inline void paravirt_pagetable_setup_done(pgd_t *base) 210static inline void __init paravirt_pagetable_setup_done(pgd_t *base)
219{ 211{
220 native_pagetable_setup_done(base); 212 native_pagetable_setup_done(base);
221} 213}
@@ -233,7 +225,7 @@ static inline void paravirt_pagetable_setup_done(pgd_t *base)
233#define kern_addr_valid(kaddr) (0) 225#define kern_addr_valid(kaddr) (0)
234#endif 226#endif
235 227
236#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 228#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
237 remap_pfn_range(vma, vaddr, pfn, size, prot) 229 remap_pfn_range(vma, vaddr, pfn, size, prot)
238 230
239#endif /* _I386_PGTABLE_H */ 231#endif /* _I386_PGTABLE_H */
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 0a0b77bc736a..a3bbf8766c1d 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -24,7 +24,7 @@ extern void paging_init(void);
24 24
25#endif /* !__ASSEMBLY__ */ 25#endif /* !__ASSEMBLY__ */
26 26
27#define SHARED_KERNEL_PMD 1 27#define SHARED_KERNEL_PMD 0
28 28
29/* 29/*
30 * PGDIR_SHIFT determines what a top-level page table entry can map 30 * PGDIR_SHIFT determines what a top-level page table entry can map
@@ -52,14 +52,18 @@ extern void paging_init(void);
52 52
53#ifndef __ASSEMBLY__ 53#ifndef __ASSEMBLY__
54 54
55#define pte_ERROR(e) \ 55#define pte_ERROR(e) \
56 printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), pte_val(e)) 56 printk("%s:%d: bad pte %p(%016lx).\n", \
57#define pmd_ERROR(e) \ 57 __FILE__, __LINE__, &(e), pte_val(e))
58 printk("%s:%d: bad pmd %p(%016lx).\n", __FILE__, __LINE__, &(e), pmd_val(e)) 58#define pmd_ERROR(e) \
59#define pud_ERROR(e) \ 59 printk("%s:%d: bad pmd %p(%016lx).\n", \
60 printk("%s:%d: bad pud %p(%016lx).\n", __FILE__, __LINE__, &(e), pud_val(e)) 60 __FILE__, __LINE__, &(e), pmd_val(e))
61#define pgd_ERROR(e) \ 61#define pud_ERROR(e) \
62 printk("%s:%d: bad pgd %p(%016lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) 62 printk("%s:%d: bad pud %p(%016lx).\n", \
63 __FILE__, __LINE__, &(e), pud_val(e))
64#define pgd_ERROR(e) \
65 printk("%s:%d: bad pgd %p(%016lx).\n", \
66 __FILE__, __LINE__, &(e), pgd_val(e))
63 67
64#define pgd_none(x) (!pgd_val(x)) 68#define pgd_none(x) (!pgd_val(x))
65#define pud_none(x) (!pud_val(x)) 69#define pud_none(x) (!pud_val(x))
@@ -87,7 +91,8 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp)
87#ifdef CONFIG_SMP 91#ifdef CONFIG_SMP
88 return native_make_pte(xchg(&xp->pte, 0)); 92 return native_make_pte(xchg(&xp->pte, 0));
89#else 93#else
90 /* native_local_ptep_get_and_clear, but duplicated because of cyclic dependency */ 94 /* native_local_ptep_get_and_clear,
95 but duplicated because of cyclic dependency */
91 pte_t ret = *xp; 96 pte_t ret = *xp;
92 native_pte_clear(NULL, 0, xp); 97 native_pte_clear(NULL, 0, xp);
93 return ret; 98 return ret;
@@ -119,7 +124,7 @@ static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
119 *pgdp = pgd; 124 *pgdp = pgd;
120} 125}
121 126
122static inline void native_pgd_clear(pgd_t * pgd) 127static inline void native_pgd_clear(pgd_t *pgd)
123{ 128{
124 native_set_pgd(pgd, native_make_pgd(0)); 129 native_set_pgd(pgd, native_make_pgd(0));
125} 130}
@@ -128,19 +133,19 @@ static inline void native_pgd_clear(pgd_t * pgd)
128 133
129#endif /* !__ASSEMBLY__ */ 134#endif /* !__ASSEMBLY__ */
130 135
131#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT) 136#define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
132#define PMD_MASK (~(PMD_SIZE-1)) 137#define PMD_MASK (~(PMD_SIZE - 1))
133#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT) 138#define PUD_SIZE (_AC(1, UL) << PUD_SHIFT)
134#define PUD_MASK (~(PUD_SIZE-1)) 139#define PUD_MASK (~(PUD_SIZE - 1))
135#define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT) 140#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT)
136#define PGDIR_MASK (~(PGDIR_SIZE-1)) 141#define PGDIR_MASK (~(PGDIR_SIZE - 1))
137 142
138 143
139#define MAXMEM _AC(0x3fffffffffff, UL) 144#define MAXMEM _AC(0x00003fffffffffff, UL)
140#define VMALLOC_START _AC(0xffffc20000000000, UL) 145#define VMALLOC_START _AC(0xffffc20000000000, UL)
141#define VMALLOC_END _AC(0xffffe1ffffffffff, UL) 146#define VMALLOC_END _AC(0xffffe1ffffffffff, UL)
142#define VMEMMAP_START _AC(0xffffe20000000000, UL) 147#define VMEMMAP_START _AC(0xffffe20000000000, UL)
143#define MODULES_VADDR _AC(0xffffffff88000000, UL) 148#define MODULES_VADDR _AC(0xffffffffa0000000, UL)
144#define MODULES_END _AC(0xfffffffffff00000, UL) 149#define MODULES_END _AC(0xfffffffffff00000, UL)
145#define MODULES_LEN (MODULES_END - MODULES_VADDR) 150#define MODULES_LEN (MODULES_END - MODULES_VADDR)
146 151
@@ -153,26 +158,28 @@ static inline unsigned long pgd_bad(pgd_t pgd)
153 158
154static inline unsigned long pud_bad(pud_t pud) 159static inline unsigned long pud_bad(pud_t pud)
155{ 160{
156 return pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER); 161 return pud_val(pud) &
162 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
157} 163}
158 164
159static inline unsigned long pmd_bad(pmd_t pmd) 165static inline unsigned long pmd_bad(pmd_t pmd)
160{ 166{
161 return pmd_val(pmd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER); 167 return pmd_val(pmd) &
168 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
162} 169}
163 170
164#define pte_none(x) (!pte_val(x)) 171#define pte_none(x) (!pte_val((x)))
165#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) 172#define pte_present(x) (pte_val((x)) & (_PAGE_PRESENT | _PAGE_PROTNONE))
166 173
167#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) /* FIXME: is this right? */ 174#define pages_to_mb(x) ((x) >> (20 - PAGE_SHIFT)) /* FIXME: is this right? */
168#define pte_page(x) pfn_to_page(pte_pfn(x)) 175#define pte_page(x) pfn_to_page(pte_pfn((x)))
169#define pte_pfn(x) ((pte_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) 176#define pte_pfn(x) ((pte_val((x)) & __PHYSICAL_MASK) >> PAGE_SHIFT)
170 177
171/* 178/*
172 * Macro to mark a page protection value as "uncacheable". 179 * Macro to mark a page protection value as "uncacheable".
173 */ 180 */
174#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT)) 181#define pgprot_noncached(prot) \
175 182 (__pgprot(pgprot_val((prot)) | _PAGE_PCD | _PAGE_PWT))
176 183
177/* 184/*
178 * Conversion functions: convert a page and protection to a page entry, 185 * Conversion functions: convert a page and protection to a page entry,
@@ -182,75 +189,81 @@ static inline unsigned long pmd_bad(pmd_t pmd)
182/* 189/*
183 * Level 4 access. 190 * Level 4 access.
184 */ 191 */
185#define pgd_page_vaddr(pgd) ((unsigned long) __va((unsigned long)pgd_val(pgd) & PTE_MASK)) 192#define pgd_page_vaddr(pgd) \
186#define pgd_page(pgd) (pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)) 193 ((unsigned long)__va((unsigned long)pgd_val((pgd)) & PTE_MASK))
187#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 194#define pgd_page(pgd) (pfn_to_page(pgd_val((pgd)) >> PAGE_SHIFT))
188#define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr)) 195#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
189#define pgd_offset_k(address) (init_level4_pgt + pgd_index(address)) 196#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
197#define pgd_offset_k(address) (init_level4_pgt + pgd_index((address)))
190#define pgd_present(pgd) (pgd_val(pgd) & _PAGE_PRESENT) 198#define pgd_present(pgd) (pgd_val(pgd) & _PAGE_PRESENT)
191static inline int pgd_large(pgd_t pgd) { return 0; } 199static inline int pgd_large(pgd_t pgd) { return 0; }
192#define mk_kernel_pgd(address) ((pgd_t){ (address) | _KERNPG_TABLE }) 200#define mk_kernel_pgd(address) ((pgd_t){ (address) | _KERNPG_TABLE })
193 201
194/* PUD - Level3 access */ 202/* PUD - Level3 access */
195/* to find an entry in a page-table-directory. */ 203/* to find an entry in a page-table-directory. */
196#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PHYSICAL_PAGE_MASK)) 204#define pud_page_vaddr(pud) \
197#define pud_page(pud) (pfn_to_page(pud_val(pud) >> PAGE_SHIFT)) 205 ((unsigned long)__va(pud_val((pud)) & PHYSICAL_PAGE_MASK))
198#define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1)) 206#define pud_page(pud) (pfn_to_page(pud_val((pud)) >> PAGE_SHIFT))
199#define pud_offset(pgd, address) ((pud_t *) pgd_page_vaddr(*(pgd)) + pud_index(address)) 207#define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
200#define pud_present(pud) (pud_val(pud) & _PAGE_PRESENT) 208#define pud_offset(pgd, address) \
209 ((pud_t *)pgd_page_vaddr(*(pgd)) + pud_index((address)))
210#define pud_present(pud) (pud_val((pud)) & _PAGE_PRESENT)
201 211
202static inline int pud_large(pud_t pte) 212static inline int pud_large(pud_t pte)
203{ 213{
204 return (pud_val(pte) & (_PAGE_PSE|_PAGE_PRESENT)) == 214 return (pud_val(pte) & (_PAGE_PSE | _PAGE_PRESENT)) ==
205 (_PAGE_PSE|_PAGE_PRESENT); 215 (_PAGE_PSE | _PAGE_PRESENT);
206} 216}
207 217
208/* PMD - Level 2 access */ 218/* PMD - Level 2 access */
209#define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PTE_MASK)) 219#define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val((pmd)) & PTE_MASK))
210#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) 220#define pmd_page(pmd) (pfn_to_page(pmd_val((pmd)) >> PAGE_SHIFT))
211 221
212#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) 222#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
213#define pmd_offset(dir, address) ((pmd_t *) pud_page_vaddr(*(dir)) + \ 223#define pmd_offset(dir, address) ((pmd_t *)pud_page_vaddr(*(dir)) + \
214 pmd_index(address)) 224 pmd_index(address))
215#define pmd_none(x) (!pmd_val(x)) 225#define pmd_none(x) (!pmd_val((x)))
216#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 226#define pmd_present(x) (pmd_val((x)) & _PAGE_PRESENT)
217#define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot))) 227#define pfn_pmd(nr, prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val((prot))))
218#define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) 228#define pmd_pfn(x) ((pmd_val((x)) & __PHYSICAL_MASK) >> PAGE_SHIFT)
219 229
220#define pte_to_pgoff(pte) ((pte_val(pte) & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT) 230#define pte_to_pgoff(pte) ((pte_val((pte)) & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT)
221#define pgoff_to_pte(off) ((pte_t) { .pte = ((off) << PAGE_SHIFT) | _PAGE_FILE }) 231#define pgoff_to_pte(off) ((pte_t) { .pte = ((off) << PAGE_SHIFT) | \
232 _PAGE_FILE })
222#define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT 233#define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT
223 234
224/* PTE - Level 1 access. */ 235/* PTE - Level 1 access. */
225 236
226/* page, protection -> pte */ 237/* page, protection -> pte */
227#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 238#define mk_pte(page, pgprot) pfn_pte(page_to_pfn((page)), (pgprot))
228 239
229#define pte_index(address) \ 240#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
230 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
231#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \ 241#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \
232 pte_index(address)) 242 pte_index((address)))
233 243
234/* x86-64 always has all page tables mapped. */ 244/* x86-64 always has all page tables mapped. */
235#define pte_offset_map(dir,address) pte_offset_kernel(dir,address) 245#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
236#define pte_offset_map_nested(dir,address) pte_offset_kernel(dir,address) 246#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
237#define pte_unmap(pte) /* NOP */ 247#define pte_unmap(pte) /* NOP */
238#define pte_unmap_nested(pte) /* NOP */ 248#define pte_unmap_nested(pte) /* NOP */
249
250#define update_mmu_cache(vma, address, pte) do { } while (0)
239 251
240#define update_mmu_cache(vma,address,pte) do { } while (0) 252extern int direct_gbpages;
241 253
242/* Encode and de-code a swap entry */ 254/* Encode and de-code a swap entry */
243#define __swp_type(x) (((x).val >> 1) & 0x3f) 255#define __swp_type(x) (((x).val >> 1) & 0x3f)
244#define __swp_offset(x) ((x).val >> 8) 256#define __swp_offset(x) ((x).val >> 8)
245#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) 257#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | \
246#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 258 ((offset) << 8) })
259#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val((pte)) })
247#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val }) 260#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val })
248 261
249extern int kern_addr_valid(unsigned long addr); 262extern int kern_addr_valid(unsigned long addr);
250extern void cleanup_highmap(void); 263extern void cleanup_highmap(void);
251 264
252#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 265#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
253 remap_pfn_range(vma, vaddr, pfn, size, prot) 266 remap_pfn_range(vma, vaddr, pfn, size, prot)
254 267
255#define HAVE_ARCH_UNMAPPED_AREA 268#define HAVE_ARCH_UNMAPPED_AREA
256#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN 269#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
@@ -263,8 +276,10 @@ extern void cleanup_highmap(void);
263 276
264/* fs/proc/kcore.c */ 277/* fs/proc/kcore.c */
265#define kc_vaddr_to_offset(v) ((v) & __VIRTUAL_MASK) 278#define kc_vaddr_to_offset(v) ((v) & __VIRTUAL_MASK)
266#define kc_offset_to_vaddr(o) \ 279#define kc_offset_to_vaddr(o) \
267 (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o)) 280 (((o) & (1UL << (__VIRTUAL_MASK_SHIFT - 1))) \
281 ? ((o) | ~__VIRTUAL_MASK) \
282 : (o))
268 283
269#define __HAVE_ARCH_PTE_SAME 284#define __HAVE_ARCH_PTE_SAME
270#endif /* !__ASSEMBLY__ */ 285#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-x86/posix_types_32.h b/include/asm-x86/posix_types_32.h
index 015e539cdef5..b031efda37ec 100644
--- a/include/asm-x86/posix_types_32.h
+++ b/include/asm-x86/posix_types_32.h
@@ -45,32 +45,39 @@ typedef struct {
45#if defined(__KERNEL__) 45#if defined(__KERNEL__)
46 46
47#undef __FD_SET 47#undef __FD_SET
48#define __FD_SET(fd,fdsetp) \ 48#define __FD_SET(fd,fdsetp) \
49 __asm__ __volatile__("btsl %1,%0": \ 49 asm volatile("btsl %1,%0": \
50 "+m" (*(__kernel_fd_set *) (fdsetp)):"r" ((int) (fd))) 50 "+m" (*(__kernel_fd_set *)(fdsetp)) \
51 : "r" ((int)(fd)))
51 52
52#undef __FD_CLR 53#undef __FD_CLR
53#define __FD_CLR(fd,fdsetp) \ 54#define __FD_CLR(fd,fdsetp) \
54 __asm__ __volatile__("btrl %1,%0": \ 55 asm volatile("btrl %1,%0": \
55 "+m" (*(__kernel_fd_set *) (fdsetp)):"r" ((int) (fd))) 56 "+m" (*(__kernel_fd_set *)(fdsetp)) \
57 : "r" ((int) (fd)))
56 58
57#undef __FD_ISSET 59#undef __FD_ISSET
58#define __FD_ISSET(fd,fdsetp) (__extension__ ({ \ 60#define __FD_ISSET(fd,fdsetp) \
59 unsigned char __result; \ 61 (__extension__ \
60 __asm__ __volatile__("btl %1,%2 ; setb %0" \ 62 ({ \
61 :"=q" (__result) :"r" ((int) (fd)), \ 63 unsigned char __result; \
62 "m" (*(__kernel_fd_set *) (fdsetp))); \ 64 asm volatile("btl %1,%2 ; setb %0" \
63 __result; })) 65 : "=q" (__result) \
66 : "r" ((int)(fd)), \
67 "m" (*(__kernel_fd_set *)(fdsetp))); \
68 __result; \
69}))
64 70
65#undef __FD_ZERO 71#undef __FD_ZERO
66#define __FD_ZERO(fdsetp) \ 72#define __FD_ZERO(fdsetp) \
67do { \ 73do { \
68 int __d0, __d1; \ 74 int __d0, __d1; \
69 __asm__ __volatile__("cld ; rep ; stosl" \ 75 asm volatile("cld ; rep ; stosl" \
70 :"=m" (*(__kernel_fd_set *) (fdsetp)), \ 76 : "=m" (*(__kernel_fd_set *)(fdsetp)), \
71 "=&c" (__d0), "=&D" (__d1) \ 77 "=&c" (__d0), "=&D" (__d1) \
72 :"a" (0), "1" (__FDSET_LONGS), \ 78 : "a" (0), "1" (__FDSET_LONGS), \
73 "2" ((__kernel_fd_set *) (fdsetp)) : "memory"); \ 79 "2" ((__kernel_fd_set *)(fdsetp)) \
80 : "memory"); \
74} while (0) 81} while (0)
75 82
76#endif /* defined(__KERNEL__) */ 83#endif /* defined(__KERNEL__) */
diff --git a/include/asm-x86/posix_types_64.h b/include/asm-x86/posix_types_64.h
index 9926aa43775b..d6624c95854a 100644
--- a/include/asm-x86/posix_types_64.h
+++ b/include/asm-x86/posix_types_64.h
@@ -46,7 +46,7 @@ typedef unsigned long __kernel_old_dev_t;
46#ifdef __KERNEL__ 46#ifdef __KERNEL__
47 47
48#undef __FD_SET 48#undef __FD_SET
49static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) 49static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
50{ 50{
51 unsigned long _tmp = fd / __NFDBITS; 51 unsigned long _tmp = fd / __NFDBITS;
52 unsigned long _rem = fd % __NFDBITS; 52 unsigned long _rem = fd % __NFDBITS;
@@ -54,7 +54,7 @@ static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
54} 54}
55 55
56#undef __FD_CLR 56#undef __FD_CLR
57static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) 57static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
58{ 58{
59 unsigned long _tmp = fd / __NFDBITS; 59 unsigned long _tmp = fd / __NFDBITS;
60 unsigned long _rem = fd % __NFDBITS; 60 unsigned long _rem = fd % __NFDBITS;
@@ -62,7 +62,7 @@ static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
62} 62}
63 63
64#undef __FD_ISSET 64#undef __FD_ISSET
65static __inline__ int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p) 65static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p)
66{ 66{
67 unsigned long _tmp = fd / __NFDBITS; 67 unsigned long _tmp = fd / __NFDBITS;
68 unsigned long _rem = fd % __NFDBITS; 68 unsigned long _rem = fd % __NFDBITS;
@@ -74,36 +74,36 @@ static __inline__ int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p)
74 * for 256 and 1024-bit fd_sets respectively) 74 * for 256 and 1024-bit fd_sets respectively)
75 */ 75 */
76#undef __FD_ZERO 76#undef __FD_ZERO
77static __inline__ void __FD_ZERO(__kernel_fd_set *p) 77static inline void __FD_ZERO(__kernel_fd_set *p)
78{ 78{
79 unsigned long *tmp = p->fds_bits; 79 unsigned long *tmp = p->fds_bits;
80 int i; 80 int i;
81 81
82 if (__builtin_constant_p(__FDSET_LONGS)) { 82 if (__builtin_constant_p(__FDSET_LONGS)) {
83 switch (__FDSET_LONGS) { 83 switch (__FDSET_LONGS) {
84 case 32: 84 case 32:
85 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; 85 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
86 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; 86 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
87 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0; 87 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
88 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0; 88 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
89 tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0; 89 tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0;
90 tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0; 90 tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0;
91 tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0; 91 tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0;
92 tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0; 92 tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0;
93 return; 93 return;
94 case 16: 94 case 16:
95 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; 95 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
96 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; 96 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
97 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0; 97 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
98 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0; 98 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
99 return; 99 return;
100 case 8: 100 case 8:
101 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; 101 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
102 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0; 102 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
103 return; 103 return;
104 case 4: 104 case 4:
105 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0; 105 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
106 return; 106 return;
107 } 107 }
108 } 108 }
109 i = __FDSET_LONGS; 109 i = __FDSET_LONGS;
diff --git a/include/asm-x86/processor.h b/include/asm-x86/processor.h
index 45a2f0ab33d0..559105220a47 100644
--- a/include/asm-x86/processor.h
+++ b/include/asm-x86/processor.h
@@ -3,10 +3,6 @@
3 3
4#include <asm/processor-flags.h> 4#include <asm/processor-flags.h>
5 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 */ 6/* Forward declaration, a strange C thing */
11struct task_struct; 7struct task_struct;
12struct mm_struct; 8struct mm_struct;
@@ -24,6 +20,7 @@ struct mm_struct;
24#include <asm/msr.h> 20#include <asm/msr.h>
25#include <asm/desc_defs.h> 21#include <asm/desc_defs.h>
26#include <asm/nops.h> 22#include <asm/nops.h>
23
27#include <linux/personality.h> 24#include <linux/personality.h>
28#include <linux/cpumask.h> 25#include <linux/cpumask.h>
29#include <linux/cache.h> 26#include <linux/cache.h>
@@ -37,16 +34,18 @@ struct mm_struct;
37static inline void *current_text_addr(void) 34static inline void *current_text_addr(void)
38{ 35{
39 void *pc; 36 void *pc;
40 asm volatile("mov $1f,%0\n1:":"=r" (pc)); 37
38 asm volatile("mov $1f, %0; 1:":"=r" (pc));
39
41 return pc; 40 return pc;
42} 41}
43 42
44#ifdef CONFIG_X86_VSMP 43#ifdef CONFIG_X86_VSMP
45#define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT) 44# define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT)
46#define ARCH_MIN_MMSTRUCT_ALIGN (1 << INTERNODE_CACHE_SHIFT) 45# define ARCH_MIN_MMSTRUCT_ALIGN (1 << INTERNODE_CACHE_SHIFT)
47#else 46#else
48#define ARCH_MIN_TASKALIGN 16 47# define ARCH_MIN_TASKALIGN 16
49#define ARCH_MIN_MMSTRUCT_ALIGN 0 48# define ARCH_MIN_MMSTRUCT_ALIGN 0
50#endif 49#endif
51 50
52/* 51/*
@@ -56,69 +55,81 @@ static inline void *current_text_addr(void)
56 */ 55 */
57 56
58struct cpuinfo_x86 { 57struct cpuinfo_x86 {
59 __u8 x86; /* CPU family */ 58 __u8 x86; /* CPU family */
60 __u8 x86_vendor; /* CPU vendor */ 59 __u8 x86_vendor; /* CPU vendor */
61 __u8 x86_model; 60 __u8 x86_model;
62 __u8 x86_mask; 61 __u8 x86_mask;
63#ifdef CONFIG_X86_32 62#ifdef CONFIG_X86_32
64 char wp_works_ok; /* It doesn't on 386's */ 63 char wp_works_ok; /* It doesn't on 386's */
65 char hlt_works_ok; /* Problems on some 486Dx4's and old 386's */ 64
66 char hard_math; 65 /* Problems on some 486Dx4's and old 386's: */
67 char rfu; 66 char hlt_works_ok;
68 char fdiv_bug; 67 char hard_math;
69 char f00f_bug; 68 char rfu;
70 char coma_bug; 69 char fdiv_bug;
71 char pad0; 70 char f00f_bug;
71 char coma_bug;
72 char pad0;
72#else 73#else
73 /* number of 4K pages in DTLB/ITLB combined(in pages)*/ 74 /* Number of 4K pages in DTLB/ITLB combined(in pages): */
74 int x86_tlbsize; 75 int x86_tlbsize;
75 __u8 x86_virt_bits, x86_phys_bits; 76 __u8 x86_virt_bits;
76 /* cpuid returned core id bits */ 77 __u8 x86_phys_bits;
77 __u8 x86_coreid_bits; 78 /* CPUID returned core id bits: */
78 /* Max extended CPUID function supported */ 79 __u8 x86_coreid_bits;
79 __u32 extended_cpuid_level; 80 /* Max extended CPUID function supported: */
81 __u32 extended_cpuid_level;
80#endif 82#endif
81 int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */ 83 /* Maximum supported CPUID level, -1=no CPUID: */
82 __u32 x86_capability[NCAPINTS]; 84 int cpuid_level;
83 char x86_vendor_id[16]; 85 __u32 x86_capability[NCAPINTS];
84 char x86_model_id[64]; 86 char x86_vendor_id[16];
85 int x86_cache_size; /* in KB - valid for CPUS which support this 87 char x86_model_id[64];
86 call */ 88 /* in KB - valid for CPUS which support this call: */
87 int x86_cache_alignment; /* In bytes */ 89 int x86_cache_size;
88 int x86_power; 90 int x86_cache_alignment; /* In bytes */
89 unsigned long loops_per_jiffy; 91 int x86_power;
92 unsigned long loops_per_jiffy;
90#ifdef CONFIG_SMP 93#ifdef CONFIG_SMP
91 cpumask_t llc_shared_map; /* cpus sharing the last level cache */ 94 /* cpus sharing the last level cache: */
95 cpumask_t llc_shared_map;
92#endif 96#endif
93 u16 x86_max_cores; /* cpuid returned max cores value */ 97 /* cpuid returned max cores value: */
94 u16 apicid; 98 u16 x86_max_cores;
95 u16 x86_clflush_size; 99 u16 apicid;
100 u16 initial_apicid;
101 u16 x86_clflush_size;
96#ifdef CONFIG_SMP 102#ifdef CONFIG_SMP
97 u16 booted_cores; /* number of cores as seen by OS */ 103 /* number of cores as seen by the OS: */
98 u16 phys_proc_id; /* Physical processor id. */ 104 u16 booted_cores;
99 u16 cpu_core_id; /* Core id */ 105 /* Physical processor id: */
100 u16 cpu_index; /* index into per_cpu list */ 106 u16 phys_proc_id;
107 /* Core id: */
108 u16 cpu_core_id;
109 /* Index into per_cpu list: */
110 u16 cpu_index;
101#endif 111#endif
102} __attribute__((__aligned__(SMP_CACHE_BYTES))); 112} __attribute__((__aligned__(SMP_CACHE_BYTES)));
103 113
104#define X86_VENDOR_INTEL 0 114#define X86_VENDOR_INTEL 0
105#define X86_VENDOR_CYRIX 1 115#define X86_VENDOR_CYRIX 1
106#define X86_VENDOR_AMD 2 116#define X86_VENDOR_AMD 2
107#define X86_VENDOR_UMC 3 117#define X86_VENDOR_UMC 3
108#define X86_VENDOR_NEXGEN 4 118#define X86_VENDOR_CENTAUR 5
109#define X86_VENDOR_CENTAUR 5 119#define X86_VENDOR_TRANSMETA 7
110#define X86_VENDOR_TRANSMETA 7 120#define X86_VENDOR_NSC 8
111#define X86_VENDOR_NSC 8 121#define X86_VENDOR_NUM 9
112#define X86_VENDOR_NUM 9 122
113#define X86_VENDOR_UNKNOWN 0xff 123#define X86_VENDOR_UNKNOWN 0xff
114 124
115/* 125/*
116 * capabilities of CPUs 126 * capabilities of CPUs
117 */ 127 */
118extern struct cpuinfo_x86 boot_cpu_data; 128extern struct cpuinfo_x86 boot_cpu_data;
119extern struct cpuinfo_x86 new_cpu_data; 129extern struct cpuinfo_x86 new_cpu_data;
120extern struct tss_struct doublefault_tss; 130
121extern __u32 cleared_cpu_caps[NCAPINTS]; 131extern struct tss_struct doublefault_tss;
132extern __u32 cleared_cpu_caps[NCAPINTS];
122 133
123#ifdef CONFIG_SMP 134#ifdef CONFIG_SMP
124DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info); 135DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
@@ -129,7 +140,18 @@ DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
129#define current_cpu_data boot_cpu_data 140#define current_cpu_data boot_cpu_data
130#endif 141#endif
131 142
132void cpu_detect(struct cpuinfo_x86 *c); 143static inline int hlt_works(int cpu)
144{
145#ifdef CONFIG_X86_32
146 return cpu_data(cpu).hlt_works_ok;
147#else
148 return 1;
149#endif
150}
151
152#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
153
154extern void cpu_detect(struct cpuinfo_x86 *c);
133 155
134extern void identify_cpu(struct cpuinfo_x86 *); 156extern void identify_cpu(struct cpuinfo_x86 *);
135extern void identify_boot_cpu(void); 157extern void identify_boot_cpu(void);
@@ -146,15 +168,15 @@ static inline void detect_ht(struct cpuinfo_x86 *c) {}
146#endif 168#endif
147 169
148static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, 170static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
149 unsigned int *ecx, unsigned int *edx) 171 unsigned int *ecx, unsigned int *edx)
150{ 172{
151 /* ecx is often an input as well as an output. */ 173 /* ecx is often an input as well as an output. */
152 __asm__("cpuid" 174 asm("cpuid"
153 : "=a" (*eax), 175 : "=a" (*eax),
154 "=b" (*ebx), 176 "=b" (*ebx),
155 "=c" (*ecx), 177 "=c" (*ecx),
156 "=d" (*edx) 178 "=d" (*edx)
157 : "0" (*eax), "2" (*ecx)); 179 : "0" (*eax), "2" (*ecx));
158} 180}
159 181
160static inline void load_cr3(pgd_t *pgdir) 182static inline void load_cr3(pgd_t *pgdir)
@@ -165,54 +187,67 @@ static inline void load_cr3(pgd_t *pgdir)
165#ifdef CONFIG_X86_32 187#ifdef CONFIG_X86_32
166/* This is the TSS defined by the hardware. */ 188/* This is the TSS defined by the hardware. */
167struct x86_hw_tss { 189struct x86_hw_tss {
168 unsigned short back_link, __blh; 190 unsigned short back_link, __blh;
169 unsigned long sp0; 191 unsigned long sp0;
170 unsigned short ss0, __ss0h; 192 unsigned short ss0, __ss0h;
171 unsigned long sp1; 193 unsigned long sp1;
172 unsigned short ss1, __ss1h; /* ss1 caches MSR_IA32_SYSENTER_CS */ 194 /* ss1 caches MSR_IA32_SYSENTER_CS: */
173 unsigned long sp2; 195 unsigned short ss1, __ss1h;
174 unsigned short ss2, __ss2h; 196 unsigned long sp2;
175 unsigned long __cr3; 197 unsigned short ss2, __ss2h;
176 unsigned long ip; 198 unsigned long __cr3;
177 unsigned long flags; 199 unsigned long ip;
178 unsigned long ax, cx, dx, bx; 200 unsigned long flags;
179 unsigned long sp, bp, si, di; 201 unsigned long ax;
180 unsigned short es, __esh; 202 unsigned long cx;
181 unsigned short cs, __csh; 203 unsigned long dx;
182 unsigned short ss, __ssh; 204 unsigned long bx;
183 unsigned short ds, __dsh; 205 unsigned long sp;
184 unsigned short fs, __fsh; 206 unsigned long bp;
185 unsigned short gs, __gsh; 207 unsigned long si;
186 unsigned short ldt, __ldth; 208 unsigned long di;
187 unsigned short trace, io_bitmap_base; 209 unsigned short es, __esh;
210 unsigned short cs, __csh;
211 unsigned short ss, __ssh;
212 unsigned short ds, __dsh;
213 unsigned short fs, __fsh;
214 unsigned short gs, __gsh;
215 unsigned short ldt, __ldth;
216 unsigned short trace;
217 unsigned short io_bitmap_base;
218
188} __attribute__((packed)); 219} __attribute__((packed));
189#else 220#else
190struct x86_hw_tss { 221struct x86_hw_tss {
191 u32 reserved1; 222 u32 reserved1;
192 u64 sp0; 223 u64 sp0;
193 u64 sp1; 224 u64 sp1;
194 u64 sp2; 225 u64 sp2;
195 u64 reserved2; 226 u64 reserved2;
196 u64 ist[7]; 227 u64 ist[7];
197 u32 reserved3; 228 u32 reserved3;
198 u32 reserved4; 229 u32 reserved4;
199 u16 reserved5; 230 u16 reserved5;
200 u16 io_bitmap_base; 231 u16 io_bitmap_base;
232
201} __attribute__((packed)) ____cacheline_aligned; 233} __attribute__((packed)) ____cacheline_aligned;
202#endif 234#endif
203 235
204/* 236/*
205 * Size of io_bitmap. 237 * IO-bitmap sizes:
206 */ 238 */
207#define IO_BITMAP_BITS 65536 239#define IO_BITMAP_BITS 65536
208#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8) 240#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
209#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long)) 241#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
210#define IO_BITMAP_OFFSET offsetof(struct tss_struct, io_bitmap) 242#define IO_BITMAP_OFFSET offsetof(struct tss_struct, io_bitmap)
211#define INVALID_IO_BITMAP_OFFSET 0x8000 243#define INVALID_IO_BITMAP_OFFSET 0x8000
212#define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000 244#define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000
213 245
214struct tss_struct { 246struct tss_struct {
215 struct x86_hw_tss x86_tss; 247 /*
248 * The hardware state:
249 */
250 struct x86_hw_tss x86_tss;
216 251
217 /* 252 /*
218 * The extra 1 is there because the CPU will access an 253 * The extra 1 is there because the CPU will access an
@@ -220,135 +255,164 @@ struct tss_struct {
220 * bitmap. The extra byte must be all 1 bits, and must 255 * bitmap. The extra byte must be all 1 bits, and must
221 * be within the limit. 256 * be within the limit.
222 */ 257 */
223 unsigned long io_bitmap[IO_BITMAP_LONGS + 1]; 258 unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
224 /* 259 /*
225 * Cache the current maximum and the last task that used the bitmap: 260 * Cache the current maximum and the last task that used the bitmap:
226 */ 261 */
227 unsigned long io_bitmap_max; 262 unsigned long io_bitmap_max;
228 struct thread_struct *io_bitmap_owner; 263 struct thread_struct *io_bitmap_owner;
264
229 /* 265 /*
230 * pads the TSS to be cacheline-aligned (size is 0x100) 266 * Pad the TSS to be cacheline-aligned (size is 0x100):
231 */ 267 */
232 unsigned long __cacheline_filler[35]; 268 unsigned long __cacheline_filler[35];
233 /* 269 /*
234 * .. and then another 0x100 bytes for emergency kernel stack 270 * .. and then another 0x100 bytes for the emergency kernel stack:
235 */ 271 */
236 unsigned long stack[64]; 272 unsigned long stack[64];
273
237} __attribute__((packed)); 274} __attribute__((packed));
238 275
239DECLARE_PER_CPU(struct tss_struct, init_tss); 276DECLARE_PER_CPU(struct tss_struct, init_tss);
240 277
241/* Save the original ist values for checking stack pointers during debugging */ 278/*
279 * Save the original ist values for checking stack pointers during debugging
280 */
242struct orig_ist { 281struct orig_ist {
243 unsigned long ist[7]; 282 unsigned long ist[7];
244}; 283};
245 284
246#define MXCSR_DEFAULT 0x1f80 285#define MXCSR_DEFAULT 0x1f80
247 286
248struct i387_fsave_struct { 287struct i387_fsave_struct {
249 u32 cwd; 288 u32 cwd; /* FPU Control Word */
250 u32 swd; 289 u32 swd; /* FPU Status Word */
251 u32 twd; 290 u32 twd; /* FPU Tag Word */
252 u32 fip; 291 u32 fip; /* FPU IP Offset */
253 u32 fcs; 292 u32 fcs; /* FPU IP Selector */
254 u32 foo; 293 u32 foo; /* FPU Operand Pointer Offset */
255 u32 fos; 294 u32 fos; /* FPU Operand Pointer Selector */
256 u32 st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ 295
257 u32 status; /* software status information */ 296 /* 8*10 bytes for each FP-reg = 80 bytes: */
297 u32 st_space[20];
298
299 /* Software status information [not touched by FSAVE ]: */
300 u32 status;
258}; 301};
259 302
260struct i387_fxsave_struct { 303struct i387_fxsave_struct {
261 u16 cwd; 304 u16 cwd; /* Control Word */
262 u16 swd; 305 u16 swd; /* Status Word */
263 u16 twd; 306 u16 twd; /* Tag Word */
264 u16 fop; 307 u16 fop; /* Last Instruction Opcode */
265 union { 308 union {
266 struct { 309 struct {
267 u64 rip; 310 u64 rip; /* Instruction Pointer */
268 u64 rdp; 311 u64 rdp; /* Data Pointer */
269 }; 312 };
270 struct { 313 struct {
271 u32 fip; 314 u32 fip; /* FPU IP Offset */
272 u32 fcs; 315 u32 fcs; /* FPU IP Selector */
273 u32 foo; 316 u32 foo; /* FPU Operand Offset */
274 u32 fos; 317 u32 fos; /* FPU Operand Selector */
275 }; 318 };
276 }; 319 };
277 u32 mxcsr; 320 u32 mxcsr; /* MXCSR Register State */
278 u32 mxcsr_mask; 321 u32 mxcsr_mask; /* MXCSR Mask */
279 u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ 322
280 u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */ 323 /* 8*16 bytes for each FP-reg = 128 bytes: */
281 u32 padding[24]; 324 u32 st_space[32];
325
326 /* 16*16 bytes for each XMM-reg = 256 bytes: */
327 u32 xmm_space[64];
328
329 u32 padding[24];
330
282} __attribute__((aligned(16))); 331} __attribute__((aligned(16)));
283 332
284struct i387_soft_struct { 333struct i387_soft_struct {
285 u32 cwd; 334 u32 cwd;
286 u32 swd; 335 u32 swd;
287 u32 twd; 336 u32 twd;
288 u32 fip; 337 u32 fip;
289 u32 fcs; 338 u32 fcs;
290 u32 foo; 339 u32 foo;
291 u32 fos; 340 u32 fos;
292 u32 st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ 341 /* 8*10 bytes for each FP-reg = 80 bytes: */
293 u8 ftop, changed, lookahead, no_update, rm, alimit; 342 u32 st_space[20];
294 struct info *info; 343 u8 ftop;
295 u32 entry_eip; 344 u8 changed;
345 u8 lookahead;
346 u8 no_update;
347 u8 rm;
348 u8 alimit;
349 struct info *info;
350 u32 entry_eip;
296}; 351};
297 352
298union i387_union { 353union thread_xstate {
299 struct i387_fsave_struct fsave; 354 struct i387_fsave_struct fsave;
300 struct i387_fxsave_struct fxsave; 355 struct i387_fxsave_struct fxsave;
301 struct i387_soft_struct soft; 356 struct i387_soft_struct soft;
302}; 357};
303 358
304#ifdef CONFIG_X86_32 359#ifdef CONFIG_X86_64
305DECLARE_PER_CPU(u8, cpu_llc_id);
306#else
307DECLARE_PER_CPU(struct orig_ist, orig_ist); 360DECLARE_PER_CPU(struct orig_ist, orig_ist);
308#endif 361#endif
309 362
310extern void print_cpu_info(struct cpuinfo_x86 *); 363extern void print_cpu_info(struct cpuinfo_x86 *);
364extern unsigned int xstate_size;
365extern void free_thread_xstate(struct task_struct *);
366extern struct kmem_cache *task_xstate_cachep;
311extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); 367extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
312extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); 368extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
313extern unsigned short num_cache_leaves; 369extern unsigned short num_cache_leaves;
314 370
315struct thread_struct { 371struct thread_struct {
316/* cached TLS descriptors. */ 372 /* Cached TLS descriptors: */
317 struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES]; 373 struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
318 unsigned long sp0; 374 unsigned long sp0;
319 unsigned long sp; 375 unsigned long sp;
320#ifdef CONFIG_X86_32 376#ifdef CONFIG_X86_32
321 unsigned long sysenter_cs; 377 unsigned long sysenter_cs;
322#else 378#else
323 unsigned long usersp; /* Copy from PDA */ 379 unsigned long usersp; /* Copy from PDA */
324 unsigned short es, ds, fsindex, gsindex; 380 unsigned short es;
381 unsigned short ds;
382 unsigned short fsindex;
383 unsigned short gsindex;
325#endif 384#endif
326 unsigned long ip; 385 unsigned long ip;
327 unsigned long fs; 386 unsigned long fs;
328 unsigned long gs; 387 unsigned long gs;
329/* Hardware debugging registers */ 388 /* Hardware debugging registers: */
330 unsigned long debugreg0; 389 unsigned long debugreg0;
331 unsigned long debugreg1; 390 unsigned long debugreg1;
332 unsigned long debugreg2; 391 unsigned long debugreg2;
333 unsigned long debugreg3; 392 unsigned long debugreg3;
334 unsigned long debugreg6; 393 unsigned long debugreg6;
335 unsigned long debugreg7; 394 unsigned long debugreg7;
336/* fault info */ 395 /* Fault info: */
337 unsigned long cr2, trap_no, error_code; 396 unsigned long cr2;
338/* floating point info */ 397 unsigned long trap_no;
339 union i387_union i387 __attribute__((aligned(16)));; 398 unsigned long error_code;
399 /* floating point and extended processor state */
400 union thread_xstate *xstate;
340#ifdef CONFIG_X86_32 401#ifdef CONFIG_X86_32
341/* virtual 86 mode info */ 402 /* Virtual 86 mode info */
342 struct vm86_struct __user *vm86_info; 403 struct vm86_struct __user *vm86_info;
343 unsigned long screen_bitmap; 404 unsigned long screen_bitmap;
344 unsigned long v86flags, v86mask, saved_sp0; 405 unsigned long v86flags;
345 unsigned int saved_fs, saved_gs; 406 unsigned long v86mask;
407 unsigned long saved_sp0;
408 unsigned int saved_fs;
409 unsigned int saved_gs;
346#endif 410#endif
347/* IO permissions */ 411 /* IO permissions: */
348 unsigned long *io_bitmap_ptr; 412 unsigned long *io_bitmap_ptr;
349 unsigned long iopl; 413 unsigned long iopl;
350/* max allowed port in the bitmap, in bytes: */ 414 /* Max allowed port in the bitmap, in bytes: */
351 unsigned io_bitmap_max; 415 unsigned io_bitmap_max;
352/* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set. */ 416/* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set. */
353 unsigned long debugctlmsr; 417 unsigned long debugctlmsr;
354/* Debug Store - if not 0 points to a DS Save Area configuration; 418/* Debug Store - if not 0 points to a DS Save Area configuration;
@@ -358,21 +422,27 @@ struct thread_struct {
358 422
359static inline unsigned long native_get_debugreg(int regno) 423static inline unsigned long native_get_debugreg(int regno)
360{ 424{
361 unsigned long val = 0; /* Damn you, gcc! */ 425 unsigned long val = 0; /* Damn you, gcc! */
362 426
363 switch (regno) { 427 switch (regno) {
364 case 0: 428 case 0:
365 asm("mov %%db0, %0" :"=r" (val)); break; 429 asm("mov %%db0, %0" :"=r" (val));
430 break;
366 case 1: 431 case 1:
367 asm("mov %%db1, %0" :"=r" (val)); break; 432 asm("mov %%db1, %0" :"=r" (val));
433 break;
368 case 2: 434 case 2:
369 asm("mov %%db2, %0" :"=r" (val)); break; 435 asm("mov %%db2, %0" :"=r" (val));
436 break;
370 case 3: 437 case 3:
371 asm("mov %%db3, %0" :"=r" (val)); break; 438 asm("mov %%db3, %0" :"=r" (val));
439 break;
372 case 6: 440 case 6:
373 asm("mov %%db6, %0" :"=r" (val)); break; 441 asm("mov %%db6, %0" :"=r" (val));
442 break;
374 case 7: 443 case 7:
375 asm("mov %%db7, %0" :"=r" (val)); break; 444 asm("mov %%db7, %0" :"=r" (val));
445 break;
376 default: 446 default:
377 BUG(); 447 BUG();
378 } 448 }
@@ -383,22 +453,22 @@ static inline void native_set_debugreg(int regno, unsigned long value)
383{ 453{
384 switch (regno) { 454 switch (regno) {
385 case 0: 455 case 0:
386 asm("mov %0,%%db0" : /* no output */ :"r" (value)); 456 asm("mov %0, %%db0" ::"r" (value));
387 break; 457 break;
388 case 1: 458 case 1:
389 asm("mov %0,%%db1" : /* no output */ :"r" (value)); 459 asm("mov %0, %%db1" ::"r" (value));
390 break; 460 break;
391 case 2: 461 case 2:
392 asm("mov %0,%%db2" : /* no output */ :"r" (value)); 462 asm("mov %0, %%db2" ::"r" (value));
393 break; 463 break;
394 case 3: 464 case 3:
395 asm("mov %0,%%db3" : /* no output */ :"r" (value)); 465 asm("mov %0, %%db3" ::"r" (value));
396 break; 466 break;
397 case 6: 467 case 6:
398 asm("mov %0,%%db6" : /* no output */ :"r" (value)); 468 asm("mov %0, %%db6" ::"r" (value));
399 break; 469 break;
400 case 7: 470 case 7:
401 asm("mov %0,%%db7" : /* no output */ :"r" (value)); 471 asm("mov %0, %%db7" ::"r" (value));
402 break; 472 break;
403 default: 473 default:
404 BUG(); 474 BUG();
@@ -412,23 +482,24 @@ static inline void native_set_iopl_mask(unsigned mask)
412{ 482{
413#ifdef CONFIG_X86_32 483#ifdef CONFIG_X86_32
414 unsigned int reg; 484 unsigned int reg;
415 __asm__ __volatile__ ("pushfl;" 485
416 "popl %0;" 486 asm volatile ("pushfl;"
417 "andl %1, %0;" 487 "popl %0;"
418 "orl %2, %0;" 488 "andl %1, %0;"
419 "pushl %0;" 489 "orl %2, %0;"
420 "popfl" 490 "pushl %0;"
421 : "=&r" (reg) 491 "popfl"
422 : "i" (~X86_EFLAGS_IOPL), "r" (mask)); 492 : "=&r" (reg)
493 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
423#endif 494#endif
424} 495}
425 496
426static inline void native_load_sp0(struct tss_struct *tss, 497static inline void
427 struct thread_struct *thread) 498native_load_sp0(struct tss_struct *tss, struct thread_struct *thread)
428{ 499{
429 tss->x86_tss.sp0 = thread->sp0; 500 tss->x86_tss.sp0 = thread->sp0;
430#ifdef CONFIG_X86_32 501#ifdef CONFIG_X86_32
431 /* Only happens when SEP is enabled, no need to test "SEP"arately */ 502 /* Only happens when SEP is enabled, no need to test "SEP"arately: */
432 if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) { 503 if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
433 tss->x86_tss.ss1 = thread->sysenter_cs; 504 tss->x86_tss.ss1 = thread->sysenter_cs;
434 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0); 505 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
@@ -446,8 +517,8 @@ static inline void native_swapgs(void)
446#ifdef CONFIG_PARAVIRT 517#ifdef CONFIG_PARAVIRT
447#include <asm/paravirt.h> 518#include <asm/paravirt.h>
448#else 519#else
449#define __cpuid native_cpuid 520#define __cpuid native_cpuid
450#define paravirt_enabled() 0 521#define paravirt_enabled() 0
451 522
452/* 523/*
453 * These special macros can be used to get or set a debugging register 524 * These special macros can be used to get or set a debugging register
@@ -473,11 +544,12 @@ static inline void load_sp0(struct tss_struct *tss,
473 * enable), so that any CPU's that boot up 544 * enable), so that any CPU's that boot up
474 * after us can get the correct flags. 545 * after us can get the correct flags.
475 */ 546 */
476extern unsigned long mmu_cr4_features; 547extern unsigned long mmu_cr4_features;
477 548
478static inline void set_in_cr4(unsigned long mask) 549static inline void set_in_cr4(unsigned long mask)
479{ 550{
480 unsigned cr4; 551 unsigned cr4;
552
481 mmu_cr4_features |= mask; 553 mmu_cr4_features |= mask;
482 cr4 = read_cr4(); 554 cr4 = read_cr4();
483 cr4 |= mask; 555 cr4 |= mask;
@@ -487,6 +559,7 @@ static inline void set_in_cr4(unsigned long mask)
487static inline void clear_in_cr4(unsigned long mask) 559static inline void clear_in_cr4(unsigned long mask)
488{ 560{
489 unsigned cr4; 561 unsigned cr4;
562
490 mmu_cr4_features &= ~mask; 563 mmu_cr4_features &= ~mask;
491 cr4 = read_cr4(); 564 cr4 = read_cr4();
492 cr4 &= ~mask; 565 cr4 &= ~mask;
@@ -494,42 +567,42 @@ static inline void clear_in_cr4(unsigned long mask)
494} 567}
495 568
496struct microcode_header { 569struct microcode_header {
497 unsigned int hdrver; 570 unsigned int hdrver;
498 unsigned int rev; 571 unsigned int rev;
499 unsigned int date; 572 unsigned int date;
500 unsigned int sig; 573 unsigned int sig;
501 unsigned int cksum; 574 unsigned int cksum;
502 unsigned int ldrver; 575 unsigned int ldrver;
503 unsigned int pf; 576 unsigned int pf;
504 unsigned int datasize; 577 unsigned int datasize;
505 unsigned int totalsize; 578 unsigned int totalsize;
506 unsigned int reserved[3]; 579 unsigned int reserved[3];
507}; 580};
508 581
509struct microcode { 582struct microcode {
510 struct microcode_header hdr; 583 struct microcode_header hdr;
511 unsigned int bits[0]; 584 unsigned int bits[0];
512}; 585};
513 586
514typedef struct microcode microcode_t; 587typedef struct microcode microcode_t;
515typedef struct microcode_header microcode_header_t; 588typedef struct microcode_header microcode_header_t;
516 589
517/* microcode format is extended from prescott processors */ 590/* microcode format is extended from prescott processors */
518struct extended_signature { 591struct extended_signature {
519 unsigned int sig; 592 unsigned int sig;
520 unsigned int pf; 593 unsigned int pf;
521 unsigned int cksum; 594 unsigned int cksum;
522}; 595};
523 596
524struct extended_sigtable { 597struct extended_sigtable {
525 unsigned int count; 598 unsigned int count;
526 unsigned int cksum; 599 unsigned int cksum;
527 unsigned int reserved[3]; 600 unsigned int reserved[3];
528 struct extended_signature sigs[0]; 601 struct extended_signature sigs[0];
529}; 602};
530 603
531typedef struct { 604typedef struct {
532 unsigned long seg; 605 unsigned long seg;
533} mm_segment_t; 606} mm_segment_t;
534 607
535 608
@@ -541,7 +614,7 @@ extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
541/* Free all resources held by a thread. */ 614/* Free all resources held by a thread. */
542extern void release_thread(struct task_struct *); 615extern void release_thread(struct task_struct *);
543 616
544/* Prepare to copy thread state - unlazy all lazy status */ 617/* Prepare to copy thread state - unlazy all lazy state */
545extern void prepare_to_copy(struct task_struct *tsk); 618extern void prepare_to_copy(struct task_struct *tsk);
546 619
547unsigned long get_wchan(struct task_struct *p); 620unsigned long get_wchan(struct task_struct *p);
@@ -578,118 +651,138 @@ static inline unsigned int cpuid_eax(unsigned int op)
578 unsigned int eax, ebx, ecx, edx; 651 unsigned int eax, ebx, ecx, edx;
579 652
580 cpuid(op, &eax, &ebx, &ecx, &edx); 653 cpuid(op, &eax, &ebx, &ecx, &edx);
654
581 return eax; 655 return eax;
582} 656}
657
583static inline unsigned int cpuid_ebx(unsigned int op) 658static inline unsigned int cpuid_ebx(unsigned int op)
584{ 659{
585 unsigned int eax, ebx, ecx, edx; 660 unsigned int eax, ebx, ecx, edx;
586 661
587 cpuid(op, &eax, &ebx, &ecx, &edx); 662 cpuid(op, &eax, &ebx, &ecx, &edx);
663
588 return ebx; 664 return ebx;
589} 665}
666
590static inline unsigned int cpuid_ecx(unsigned int op) 667static inline unsigned int cpuid_ecx(unsigned int op)
591{ 668{
592 unsigned int eax, ebx, ecx, edx; 669 unsigned int eax, ebx, ecx, edx;
593 670
594 cpuid(op, &eax, &ebx, &ecx, &edx); 671 cpuid(op, &eax, &ebx, &ecx, &edx);
672
595 return ecx; 673 return ecx;
596} 674}
675
597static inline unsigned int cpuid_edx(unsigned int op) 676static inline unsigned int cpuid_edx(unsigned int op)
598{ 677{
599 unsigned int eax, ebx, ecx, edx; 678 unsigned int eax, ebx, ecx, edx;
600 679
601 cpuid(op, &eax, &ebx, &ecx, &edx); 680 cpuid(op, &eax, &ebx, &ecx, &edx);
681
602 return edx; 682 return edx;
603} 683}
604 684
605/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ 685/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
606static inline void rep_nop(void) 686static inline void rep_nop(void)
607{ 687{
608 __asm__ __volatile__("rep;nop": : :"memory"); 688 asm volatile("rep; nop" ::: "memory");
689}
690
691static inline void cpu_relax(void)
692{
693 rep_nop();
609} 694}
610 695
611/* Stop speculative execution */ 696/* Stop speculative execution: */
612static inline void sync_core(void) 697static inline void sync_core(void)
613{ 698{
614 int tmp; 699 int tmp;
700
615 asm volatile("cpuid" : "=a" (tmp) : "0" (1) 701 asm volatile("cpuid" : "=a" (tmp) : "0" (1)
616 : "ebx", "ecx", "edx", "memory"); 702 : "ebx", "ecx", "edx", "memory");
617} 703}
618 704
619#define cpu_relax() rep_nop()
620
621static inline void __monitor(const void *eax, unsigned long ecx, 705static inline void __monitor(const void *eax, unsigned long ecx,
622 unsigned long edx) 706 unsigned long edx)
623{ 707{
624 /* "monitor %eax,%ecx,%edx;" */ 708 /* "monitor %eax, %ecx, %edx;" */
625 asm volatile( 709 asm volatile(".byte 0x0f, 0x01, 0xc8;"
626 ".byte 0x0f,0x01,0xc8;" 710 :: "a" (eax), "c" (ecx), "d"(edx));
627 : :"a" (eax), "c" (ecx), "d"(edx));
628} 711}
629 712
630static inline void __mwait(unsigned long eax, unsigned long ecx) 713static inline void __mwait(unsigned long eax, unsigned long ecx)
631{ 714{
632 /* "mwait %eax,%ecx;" */ 715 /* "mwait %eax, %ecx;" */
633 asm volatile( 716 asm volatile(".byte 0x0f, 0x01, 0xc9;"
634 ".byte 0x0f,0x01,0xc9;" 717 :: "a" (eax), "c" (ecx));
635 : :"a" (eax), "c" (ecx));
636} 718}
637 719
638static inline void __sti_mwait(unsigned long eax, unsigned long ecx) 720static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
639{ 721{
640 /* "mwait %eax,%ecx;" */ 722 trace_hardirqs_on();
641 asm volatile( 723 /* "mwait %eax, %ecx;" */
642 "sti; .byte 0x0f,0x01,0xc9;" 724 asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
643 : :"a" (eax), "c" (ecx)); 725 :: "a" (eax), "c" (ecx));
644} 726}
645 727
646extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx); 728extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
647 729
648extern int force_mwait; 730extern int force_mwait;
649 731
650extern void select_idle_routine(const struct cpuinfo_x86 *c); 732extern void select_idle_routine(const struct cpuinfo_x86 *c);
651 733
652extern unsigned long boot_option_idle_override; 734extern unsigned long boot_option_idle_override;
653 735
654extern void enable_sep_cpu(void); 736extern void enable_sep_cpu(void);
655extern int sysenter_setup(void); 737extern int sysenter_setup(void);
656 738
657/* Defined in head.S */ 739/* Defined in head.S */
658extern struct desc_ptr early_gdt_descr; 740extern struct desc_ptr early_gdt_descr;
659 741
660extern void cpu_set_gdt(int); 742extern void cpu_set_gdt(int);
661extern void switch_to_new_gdt(void); 743extern void switch_to_new_gdt(void);
662extern void cpu_init(void); 744extern void cpu_init(void);
663extern void init_gdt(int cpu); 745extern void init_gdt(int cpu);
664 746
665/* from system description table in BIOS. Mostly for MCA use, but 747static inline void update_debugctlmsr(unsigned long debugctlmsr)
666 * others may find it useful. */ 748{
667extern unsigned int machine_id; 749#ifndef CONFIG_X86_DEBUGCTLMSR
668extern unsigned int machine_submodel_id; 750 if (boot_cpu_data.x86 < 6)
669extern unsigned int BIOS_revision; 751 return;
752#endif
753 wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
754}
755
756/*
757 * from system description table in BIOS. Mostly for MCA use, but
758 * others may find it useful:
759 */
760extern unsigned int machine_id;
761extern unsigned int machine_submodel_id;
762extern unsigned int BIOS_revision;
670 763
671/* Boot loader type from the setup header */ 764/* Boot loader type from the setup header: */
672extern int bootloader_type; 765extern int bootloader_type;
673 766
674extern char ignore_fpu_irq; 767extern char ignore_fpu_irq;
675#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
676 768
677#define HAVE_ARCH_PICK_MMAP_LAYOUT 1 769#define HAVE_ARCH_PICK_MMAP_LAYOUT 1
678#define ARCH_HAS_PREFETCHW 770#define ARCH_HAS_PREFETCHW
679#define ARCH_HAS_SPINLOCK_PREFETCH 771#define ARCH_HAS_SPINLOCK_PREFETCH
680 772
681#ifdef CONFIG_X86_32 773#ifdef CONFIG_X86_32
682#define BASE_PREFETCH ASM_NOP4 774# define BASE_PREFETCH ASM_NOP4
683#define ARCH_HAS_PREFETCH 775# define ARCH_HAS_PREFETCH
684#else 776#else
685#define BASE_PREFETCH "prefetcht0 (%1)" 777# define BASE_PREFETCH "prefetcht0 (%1)"
686#endif 778#endif
687 779
688/* Prefetch instructions for Pentium III and AMD Athlon */ 780/*
689/* It's not worth to care about 3dnow! prefetches for the K6 781 * Prefetch instructions for Pentium III (+) and AMD Athlon (+)
690 because they are microcoded there and very slow. 782 *
691 However we don't do prefetches for pre XP Athlons currently 783 * It's not worth to care about 3dnow prefetches for the K6
692 That should be fixed. */ 784 * because they are microcoded there and very slow.
785 */
693static inline void prefetch(const void *x) 786static inline void prefetch(const void *x)
694{ 787{
695 alternative_input(BASE_PREFETCH, 788 alternative_input(BASE_PREFETCH,
@@ -698,8 +791,11 @@ static inline void prefetch(const void *x)
698 "r" (x)); 791 "r" (x));
699} 792}
700 793
701/* 3dnow! prefetch to get an exclusive cache line. Useful for 794/*
702 spinlocks to avoid one state transition in the cache coherency protocol. */ 795 * 3dnow prefetch to get an exclusive cache line.
796 * Useful for spinlocks to avoid one state transition in the
797 * cache coherency protocol:
798 */
703static inline void prefetchw(const void *x) 799static inline void prefetchw(const void *x)
704{ 800{
705 alternative_input(BASE_PREFETCH, 801 alternative_input(BASE_PREFETCH,
@@ -708,21 +804,25 @@ static inline void prefetchw(const void *x)
708 "r" (x)); 804 "r" (x));
709} 805}
710 806
711#define spin_lock_prefetch(x) prefetchw(x) 807static inline void spin_lock_prefetch(const void *x)
808{
809 prefetchw(x);
810}
811
712#ifdef CONFIG_X86_32 812#ifdef CONFIG_X86_32
713/* 813/*
714 * User space process size: 3GB (default). 814 * User space process size: 3GB (default).
715 */ 815 */
716#define TASK_SIZE (PAGE_OFFSET) 816#define TASK_SIZE PAGE_OFFSET
717#define STACK_TOP TASK_SIZE 817#define STACK_TOP TASK_SIZE
718#define STACK_TOP_MAX STACK_TOP 818#define STACK_TOP_MAX STACK_TOP
719 819
720#define INIT_THREAD { \ 820#define INIT_THREAD { \
721 .sp0 = sizeof(init_stack) + (long)&init_stack, \ 821 .sp0 = sizeof(init_stack) + (long)&init_stack, \
722 .vm86_info = NULL, \ 822 .vm86_info = NULL, \
723 .sysenter_cs = __KERNEL_CS, \ 823 .sysenter_cs = __KERNEL_CS, \
724 .io_bitmap_ptr = NULL, \ 824 .io_bitmap_ptr = NULL, \
725 .fs = __KERNEL_PERCPU, \ 825 .fs = __KERNEL_PERCPU, \
726} 826}
727 827
728/* 828/*
@@ -731,28 +831,15 @@ static inline void prefetchw(const void *x)
731 * permission bitmap. The extra byte must be all 1 bits, and must 831 * permission bitmap. The extra byte must be all 1 bits, and must
732 * be within the limit. 832 * be within the limit.
733 */ 833 */
734#define INIT_TSS { \ 834#define INIT_TSS { \
735 .x86_tss = { \ 835 .x86_tss = { \
736 .sp0 = sizeof(init_stack) + (long)&init_stack, \ 836 .sp0 = sizeof(init_stack) + (long)&init_stack, \
737 .ss0 = __KERNEL_DS, \ 837 .ss0 = __KERNEL_DS, \
738 .ss1 = __KERNEL_CS, \ 838 .ss1 = __KERNEL_CS, \
739 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \ 839 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
740 }, \ 840 }, \
741 .io_bitmap = { [0 ... IO_BITMAP_LONGS] = ~0 }, \ 841 .io_bitmap = { [0 ... IO_BITMAP_LONGS] = ~0 }, \
742} 842}
743
744#define start_thread(regs, new_eip, new_esp) do { \
745 __asm__("movl %0,%%gs": :"r" (0)); \
746 regs->fs = 0; \
747 set_fs(USER_DS); \
748 regs->ds = __USER_DS; \
749 regs->es = __USER_DS; \
750 regs->ss = __USER_DS; \
751 regs->cs = __USER_CS; \
752 regs->ip = new_eip; \
753 regs->sp = new_esp; \
754} while (0)
755
756 843
757extern unsigned long thread_saved_pc(struct task_struct *tsk); 844extern unsigned long thread_saved_pc(struct task_struct *tsk);
758 845
@@ -780,24 +867,24 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
780 __regs__ - 1; \ 867 __regs__ - 1; \
781}) 868})
782 869
783#define KSTK_ESP(task) (task_pt_regs(task)->sp) 870#define KSTK_ESP(task) (task_pt_regs(task)->sp)
784 871
785#else 872#else
786/* 873/*
787 * User space process size. 47bits minus one guard page. 874 * User space process size. 47bits minus one guard page.
788 */ 875 */
789#define TASK_SIZE64 (0x800000000000UL - 4096) 876#define TASK_SIZE64 ((1UL << 47) - PAGE_SIZE)
790 877
791/* This decides where the kernel will search for a free chunk of vm 878/* This decides where the kernel will search for a free chunk of vm
792 * space during mmap's. 879 * space during mmap's.
793 */ 880 */
794#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \ 881#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
795 0xc0000000 : 0xFFFFe000) 882 0xc0000000 : 0xFFFFe000)
796 883
797#define TASK_SIZE (test_thread_flag(TIF_IA32) ? \ 884#define TASK_SIZE (test_thread_flag(TIF_IA32) ? \
798 IA32_PAGE_OFFSET : TASK_SIZE64) 885 IA32_PAGE_OFFSET : TASK_SIZE64)
799#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? \ 886#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? \
800 IA32_PAGE_OFFSET : TASK_SIZE64) 887 IA32_PAGE_OFFSET : TASK_SIZE64)
801 888
802#define STACK_TOP TASK_SIZE 889#define STACK_TOP TASK_SIZE
803#define STACK_TOP_MAX TASK_SIZE64 890#define STACK_TOP_MAX TASK_SIZE64
@@ -810,33 +897,32 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
810 .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \ 897 .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
811} 898}
812 899
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/* 900/*
826 * Return saved PC of a blocked thread. 901 * Return saved PC of a blocked thread.
827 * What is this good for? it will be always the scheduler or ret_from_fork. 902 * What is this good for? it will be always the scheduler or ret_from_fork.
828 */ 903 */
829#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.sp - 8)) 904#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.sp - 8))
830 905
831#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1) 906#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
832#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */ 907#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
833#endif /* CONFIG_X86_64 */ 908#endif /* CONFIG_X86_64 */
834 909
835/* This decides where the kernel will search for a free chunk of vm 910extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
911 unsigned long new_sp);
912
913/*
914 * This decides where the kernel will search for a free chunk of vm
836 * space during mmap's. 915 * space during mmap's.
837 */ 916 */
838#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) 917#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
839 918
840#define KSTK_EIP(task) (task_pt_regs(task)->ip) 919#define KSTK_EIP(task) (task_pt_regs(task)->ip)
920
921/* Get/set a process' ability to use the timestamp counter instruction */
922#define GET_TSC_CTL(adr) get_tsc_mode((adr))
923#define SET_TSC_CTL(val) set_tsc_mode((val))
924
925extern int get_tsc_mode(unsigned long adr);
926extern int set_tsc_mode(unsigned int val);
841 927
842#endif 928#endif
diff --git a/include/asm-x86/proto.h b/include/asm-x86/proto.h
index 68563c0709ac..6c8b41b03f6d 100644
--- a/include/asm-x86/proto.h
+++ b/include/asm-x86/proto.h
@@ -7,8 +7,6 @@
7 7
8extern void early_idt_handler(void); 8extern void early_idt_handler(void);
9 9
10extern void init_memory_mapping(unsigned long start, unsigned long end);
11
12extern void system_call(void); 10extern void system_call(void);
13extern void syscall_init(void); 11extern void syscall_init(void);
14 12
@@ -22,11 +20,15 @@ extern void syscall32_cpu_init(void);
22 20
23extern void check_efer(void); 21extern void check_efer(void);
24 22
23#ifdef CONFIG_X86_BIOS_REBOOT
25extern int reboot_force; 24extern int reboot_force;
25#else
26static const int reboot_force = 0;
27#endif
26 28
27long do_arch_prctl(struct task_struct *task, int code, unsigned long addr); 29long do_arch_prctl(struct task_struct *task, int code, unsigned long addr);
28 30
29#define round_up(x,y) (((x) + (y) - 1) & ~((y)-1)) 31#define round_up(x, y) (((x) + (y) - 1) & ~((y) - 1))
30#define round_down(x,y) ((x) & ~((y)-1)) 32#define round_down(x, y) ((x) & ~((y) - 1))
31 33
32#endif 34#endif
diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h
index d9e04b46a440..9f922b0b95d6 100644
--- a/include/asm-x86/ptrace.h
+++ b/include/asm-x86/ptrace.h
@@ -36,23 +36,23 @@ struct pt_regs {
36#else /* __KERNEL__ */ 36#else /* __KERNEL__ */
37 37
38struct pt_regs { 38struct pt_regs {
39 long bx; 39 unsigned long bx;
40 long cx; 40 unsigned long cx;
41 long dx; 41 unsigned long dx;
42 long si; 42 unsigned long si;
43 long di; 43 unsigned long di;
44 long bp; 44 unsigned long bp;
45 long ax; 45 unsigned long ax;
46 int ds; 46 unsigned long ds;
47 int es; 47 unsigned long es;
48 int fs; 48 unsigned long fs;
49 /* int gs; */ 49 /* int gs; */
50 long orig_ax; 50 unsigned long orig_ax;
51 long ip; 51 unsigned long ip;
52 int cs; 52 unsigned long cs;
53 long flags; 53 unsigned long flags;
54 long sp; 54 unsigned long sp;
55 int ss; 55 unsigned long ss;
56}; 56};
57 57
58#include <asm/vm86.h> 58#include <asm/vm86.h>
@@ -140,12 +140,16 @@ extern unsigned long
140convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs); 140convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
141 141
142#ifdef CONFIG_X86_32 142#ifdef CONFIG_X86_32
143extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); 143extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
144 int error_code);
144#else 145#else
145void signal_fault(struct pt_regs *regs, void __user *frame, char *where); 146void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
146#endif 147#endif
147 148
148#define regs_return_value(regs) ((regs)->ax) 149static inline unsigned long regs_return_value(struct pt_regs *regs)
150{
151 return regs->ax;
152}
149 153
150/* 154/*
151 * user_mode_vm(regs) determines whether a register set came from user mode. 155 * user_mode_vm(regs) determines whether a register set came from user mode.
@@ -166,8 +170,8 @@ static inline int user_mode(struct pt_regs *regs)
166static inline int user_mode_vm(struct pt_regs *regs) 170static inline int user_mode_vm(struct pt_regs *regs)
167{ 171{
168#ifdef CONFIG_X86_32 172#ifdef CONFIG_X86_32
169 return ((regs->cs & SEGMENT_RPL_MASK) | 173 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
170 (regs->flags & VM_MASK)) >= USER_RPL; 174 USER_RPL;
171#else 175#else
172 return user_mode(regs); 176 return user_mode(regs);
173#endif 177#endif
@@ -176,7 +180,7 @@ static inline int user_mode_vm(struct pt_regs *regs)
176static inline int v8086_mode(struct pt_regs *regs) 180static inline int v8086_mode(struct pt_regs *regs)
177{ 181{
178#ifdef CONFIG_X86_32 182#ifdef CONFIG_X86_32
179 return (regs->flags & VM_MASK); 183 return (regs->flags & X86_VM_MASK);
180#else 184#else
181 return 0; /* No V86 mode support in long mode */ 185 return 0; /* No V86 mode support in long mode */
182#endif 186#endif
@@ -227,6 +231,8 @@ extern int do_get_thread_area(struct task_struct *p, int idx,
227extern int do_set_thread_area(struct task_struct *p, int idx, 231extern int do_set_thread_area(struct task_struct *p, int idx,
228 struct user_desc __user *info, int can_allocate); 232 struct user_desc __user *info, int can_allocate);
229 233
234#define __ARCH_WANT_COMPAT_SYS_PTRACE
235
230#endif /* __KERNEL__ */ 236#endif /* __KERNEL__ */
231 237
232#endif /* !__ASSEMBLY__ */ 238#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-x86/reboot.h b/include/asm-x86/reboot.h
index e9e3ffc22c07..e63741f19392 100644
--- a/include/asm-x86/reboot.h
+++ b/include/asm-x86/reboot.h
@@ -3,8 +3,7 @@
3 3
4struct pt_regs; 4struct pt_regs;
5 5
6struct machine_ops 6struct machine_ops {
7{
8 void (*restart)(char *cmd); 7 void (*restart)(char *cmd);
9 void (*halt)(void); 8 void (*halt)(void);
10 void (*power_off)(void); 9 void (*power_off)(void);
@@ -16,5 +15,7 @@ struct machine_ops
16extern struct machine_ops machine_ops; 15extern struct machine_ops machine_ops;
17 16
18void machine_real_restart(unsigned char *code, int length); 17void machine_real_restart(unsigned char *code, int length);
18void native_machine_crash_shutdown(struct pt_regs *regs);
19void native_machine_shutdown(void);
19 20
20#endif /* _ASM_REBOOT_H */ 21#endif /* _ASM_REBOOT_H */
diff --git a/include/asm-x86/resume-trace.h b/include/asm-x86/resume-trace.h
index 46f725b0bc82..2557514d7ef6 100644
--- a/include/asm-x86/resume-trace.h
+++ b/include/asm-x86/resume-trace.h
@@ -3,16 +3,17 @@
3 3
4#include <asm/asm.h> 4#include <asm/asm.h>
5 5
6#define TRACE_RESUME(user) do { \ 6#define TRACE_RESUME(user) \
7do { \
7 if (pm_trace_enabled) { \ 8 if (pm_trace_enabled) { \
8 void *tracedata; \ 9 void *tracedata; \
9 asm volatile(_ASM_MOV_UL " $1f,%0\n" \ 10 asm volatile(_ASM_MOV_UL " $1f,%0\n" \
10 ".section .tracedata,\"a\"\n" \ 11 ".section .tracedata,\"a\"\n" \
11 "1:\t.word %c1\n\t" \ 12 "1:\t.word %c1\n\t" \
12 _ASM_PTR " %c2\n" \ 13 _ASM_PTR " %c2\n" \
13 ".previous" \ 14 ".previous" \
14 :"=r" (tracedata) \ 15 :"=r" (tracedata) \
15 : "i" (__LINE__), "i" (__FILE__)); \ 16 : "i" (__LINE__), "i" (__FILE__)); \
16 generate_resume_trace(tracedata, user); \ 17 generate_resume_trace(tracedata, user); \
17 } \ 18 } \
18} while (0) 19} while (0)
diff --git a/include/asm-x86/rio.h b/include/asm-x86/rio.h
index 97cdcc9887ba..c9448bd8968f 100644
--- a/include/asm-x86/rio.h
+++ b/include/asm-x86/rio.h
@@ -11,64 +11,53 @@
11#define RIO_TABLE_VERSION 3 11#define RIO_TABLE_VERSION 3
12 12
13struct rio_table_hdr { 13struct rio_table_hdr {
14 u8 version; /* Version number of this data structure */ 14 u8 version; /* Version number of this data structure */
15 u8 num_scal_dev; /* # of Scalability devices */ 15 u8 num_scal_dev; /* # of Scalability devices */
16 u8 num_rio_dev; /* # of RIO I/O devices */ 16 u8 num_rio_dev; /* # of RIO I/O devices */
17} __attribute__((packed)); 17} __attribute__((packed));
18 18
19struct scal_detail { 19struct scal_detail {
20 u8 node_id; /* Scalability Node ID */ 20 u8 node_id; /* Scalability Node ID */
21 u32 CBAR; /* Address of 1MB register space */ 21 u32 CBAR; /* Address of 1MB register space */
22 u8 port0node; /* Node ID port connected to: 0xFF=None */ 22 u8 port0node; /* Node ID port connected to: 0xFF=None */
23 u8 port0port; /* Port num port connected to: 0,1,2, or */ 23 u8 port0port; /* Port num port connected to: 0,1,2, or */
24 /* 0xFF=None */ 24 /* 0xFF=None */
25 u8 port1node; /* Node ID port connected to: 0xFF = None */ 25 u8 port1node; /* Node ID port connected to: 0xFF = None */
26 u8 port1port; /* Port num port connected to: 0,1,2, or */ 26 u8 port1port; /* Port num port connected to: 0,1,2, or */
27 /* 0xFF=None */ 27 /* 0xFF=None */
28 u8 port2node; /* Node ID port connected to: 0xFF = None */ 28 u8 port2node; /* Node ID port connected to: 0xFF = None */
29 u8 port2port; /* Port num port connected to: 0,1,2, or */ 29 u8 port2port; /* Port num port connected to: 0,1,2, or */
30 /* 0xFF=None */ 30 /* 0xFF=None */
31 u8 chassis_num; /* 1 based Chassis number (1 = boot node) */ 31 u8 chassis_num; /* 1 based Chassis number (1 = boot node) */
32} __attribute__((packed)); 32} __attribute__((packed));
33 33
34struct rio_detail { 34struct rio_detail {
35 u8 node_id; /* RIO Node ID */ 35 u8 node_id; /* RIO Node ID */
36 u32 BBAR; /* Address of 1MB register space */ 36 u32 BBAR; /* Address of 1MB register space */
37 u8 type; /* Type of device */ 37 u8 type; /* Type of device */
38 u8 owner_id; /* Node ID of Hurricane that owns this */ 38 u8 owner_id; /* Node ID of Hurricane that owns this */
39 /* node */ 39 /* node */
40 u8 port0node; /* Node ID port connected to: 0xFF=None */ 40 u8 port0node; /* Node ID port connected to: 0xFF=None */
41 u8 port0port; /* Port num port connected to: 0,1,2, or */ 41 u8 port0port; /* Port num port connected to: 0,1,2, or */
42 /* 0xFF=None */ 42 /* 0xFF=None */
43 u8 port1node; /* Node ID port connected to: 0xFF=None */ 43 u8 port1node; /* Node ID port connected to: 0xFF=None */
44 u8 port1port; /* Port num port connected to: 0,1,2, or */ 44 u8 port1port; /* Port num port connected to: 0,1,2, or */
45 /* 0xFF=None */ 45 /* 0xFF=None */
46 u8 first_slot; /* Lowest slot number below this Calgary */ 46 u8 first_slot; /* Lowest slot number below this Calgary */
47 u8 status; /* Bit 0 = 1 : the XAPIC is used */ 47 u8 status; /* Bit 0 = 1 : the XAPIC is used */
48 /* = 0 : the XAPIC is not used, ie: */ 48 /* = 0 : the XAPIC is not used, ie: */
49 /* ints fwded to another XAPIC */ 49 /* ints fwded to another XAPIC */
50 /* Bits1:7 Reserved */ 50 /* Bits1:7 Reserved */
51 u8 WP_index; /* instance index - lower ones have */ 51 u8 WP_index; /* instance index - lower ones have */
52 /* lower slot numbers/PCI bus numbers */ 52 /* lower slot numbers/PCI bus numbers */
53 u8 chassis_num; /* 1 based Chassis number */ 53 u8 chassis_num; /* 1 based Chassis number */
54} __attribute__((packed)); 54} __attribute__((packed));
55 55
56enum { 56enum {
57 HURR_SCALABILTY = 0, /* Hurricane Scalability info */ 57 HURR_SCALABILTY = 0, /* Hurricane Scalability info */
58 HURR_RIOIB = 2, /* Hurricane RIOIB info */ 58 HURR_RIOIB = 2, /* Hurricane RIOIB info */
59 COMPAT_CALGARY = 4, /* Compatibility Calgary */ 59 COMPAT_CALGARY = 4, /* Compatibility Calgary */
60 ALT_CALGARY = 5, /* Second Planar Calgary */ 60 ALT_CALGARY = 5, /* Second Planar Calgary */
61}; 61};
62 62
63/*
64 * there is a real-mode segmented pointer pointing to the
65 * 4K EBDA area at 0x40E.
66 */
67static inline unsigned long get_bios_ebda(void)
68{
69 unsigned long address = *(unsigned short *)phys_to_virt(0x40EUL);
70 address <<= 4;
71 return address;
72}
73
74#endif /* __ASM_RIO_H */ 63#endif /* __ASM_RIO_H */
diff --git a/include/asm-x86/rwsem.h b/include/asm-x86/rwsem.h
index 520a379f4b80..750f2a3542b3 100644
--- a/include/asm-x86/rwsem.h
+++ b/include/asm-x86/rwsem.h
@@ -56,14 +56,16 @@ extern asmregparm struct rw_semaphore *
56/* 56/*
57 * the semaphore definition 57 * the semaphore definition
58 */ 58 */
59struct rw_semaphore { 59
60 signed long count;
61#define RWSEM_UNLOCKED_VALUE 0x00000000 60#define RWSEM_UNLOCKED_VALUE 0x00000000
62#define RWSEM_ACTIVE_BIAS 0x00000001 61#define RWSEM_ACTIVE_BIAS 0x00000001
63#define RWSEM_ACTIVE_MASK 0x0000ffff 62#define RWSEM_ACTIVE_MASK 0x0000ffff
64#define RWSEM_WAITING_BIAS (-0x00010000) 63#define RWSEM_WAITING_BIAS (-0x00010000)
65#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS 64#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
66#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) 65#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
66
67struct rw_semaphore {
68 signed long count;
67 spinlock_t wait_lock; 69 spinlock_t wait_lock;
68 struct list_head wait_list; 70 struct list_head wait_list;
69#ifdef CONFIG_DEBUG_LOCK_ALLOC 71#ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -78,11 +80,13 @@ struct rw_semaphore {
78#endif 80#endif
79 81
80 82
81#define __RWSEM_INITIALIZER(name) \ 83#define __RWSEM_INITIALIZER(name) \
82{ RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \ 84{ \
83 LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } 85 RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \
86 LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) \
87}
84 88
85#define DECLARE_RWSEM(name) \ 89#define DECLARE_RWSEM(name) \
86 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 90 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
87 91
88extern void __init_rwsem(struct rw_semaphore *sem, const char *name, 92extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
@@ -100,16 +104,16 @@ do { \
100 */ 104 */
101static inline void __down_read(struct rw_semaphore *sem) 105static inline void __down_read(struct rw_semaphore *sem)
102{ 106{
103 __asm__ __volatile__( 107 asm volatile("# beginning down_read\n\t"
104 "# beginning down_read\n\t" 108 LOCK_PREFIX " incl (%%eax)\n\t"
105LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value */ 109 /* adds 0x00000001, returns the old value */
106 " jns 1f\n" 110 " jns 1f\n"
107 " call call_rwsem_down_read_failed\n" 111 " call call_rwsem_down_read_failed\n"
108 "1:\n\t" 112 "1:\n\t"
109 "# ending down_read\n\t" 113 "# ending down_read\n\t"
110 : "+m" (sem->count) 114 : "+m" (sem->count)
111 : "a" (sem) 115 : "a" (sem)
112 : "memory", "cc"); 116 : "memory", "cc");
113} 117}
114 118
115/* 119/*
@@ -118,21 +122,20 @@ LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value
118static inline int __down_read_trylock(struct rw_semaphore *sem) 122static inline int __down_read_trylock(struct rw_semaphore *sem)
119{ 123{
120 __s32 result, tmp; 124 __s32 result, tmp;
121 __asm__ __volatile__( 125 asm volatile("# beginning __down_read_trylock\n\t"
122 "# beginning __down_read_trylock\n\t" 126 " movl %0,%1\n\t"
123 " movl %0,%1\n\t" 127 "1:\n\t"
124 "1:\n\t" 128 " movl %1,%2\n\t"
125 " movl %1,%2\n\t" 129 " addl %3,%2\n\t"
126 " addl %3,%2\n\t" 130 " jle 2f\n\t"
127 " jle 2f\n\t" 131 LOCK_PREFIX " cmpxchgl %2,%0\n\t"
128LOCK_PREFIX " cmpxchgl %2,%0\n\t" 132 " jnz 1b\n\t"
129 " jnz 1b\n\t" 133 "2:\n\t"
130 "2:\n\t" 134 "# ending __down_read_trylock\n\t"
131 "# ending __down_read_trylock\n\t" 135 : "+m" (sem->count), "=&a" (result), "=&r" (tmp)
132 : "+m" (sem->count), "=&a" (result), "=&r" (tmp) 136 : "i" (RWSEM_ACTIVE_READ_BIAS)
133 : "i" (RWSEM_ACTIVE_READ_BIAS) 137 : "memory", "cc");
134 : "memory", "cc"); 138 return result >= 0 ? 1 : 0;
135 return result>=0 ? 1 : 0;
136} 139}
137 140
138/* 141/*
@@ -143,17 +146,18 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
143 int tmp; 146 int tmp;
144 147
145 tmp = RWSEM_ACTIVE_WRITE_BIAS; 148 tmp = RWSEM_ACTIVE_WRITE_BIAS;
146 __asm__ __volatile__( 149 asm volatile("# beginning down_write\n\t"
147 "# beginning down_write\n\t" 150 LOCK_PREFIX " xadd %%edx,(%%eax)\n\t"
148LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */ 151 /* subtract 0x0000ffff, returns the old value */
149 " testl %%edx,%%edx\n\t" /* was the count 0 before? */ 152 " testl %%edx,%%edx\n\t"
150 " jz 1f\n" 153 /* was the count 0 before? */
151 " call call_rwsem_down_write_failed\n" 154 " jz 1f\n"
152 "1:\n" 155 " call call_rwsem_down_write_failed\n"
153 "# ending down_write" 156 "1:\n"
154 : "+m" (sem->count), "=d" (tmp) 157 "# ending down_write"
155 : "a" (sem), "1" (tmp) 158 : "+m" (sem->count), "=d" (tmp)
156 : "memory", "cc"); 159 : "a" (sem), "1" (tmp)
160 : "memory", "cc");
157} 161}
158 162
159static inline void __down_write(struct rw_semaphore *sem) 163static inline void __down_write(struct rw_semaphore *sem)
@@ -167,7 +171,7 @@ static inline void __down_write(struct rw_semaphore *sem)
167static inline int __down_write_trylock(struct rw_semaphore *sem) 171static inline int __down_write_trylock(struct rw_semaphore *sem)
168{ 172{
169 signed long ret = cmpxchg(&sem->count, 173 signed long ret = cmpxchg(&sem->count,
170 RWSEM_UNLOCKED_VALUE, 174 RWSEM_UNLOCKED_VALUE,
171 RWSEM_ACTIVE_WRITE_BIAS); 175 RWSEM_ACTIVE_WRITE_BIAS);
172 if (ret == RWSEM_UNLOCKED_VALUE) 176 if (ret == RWSEM_UNLOCKED_VALUE)
173 return 1; 177 return 1;
@@ -180,16 +184,16 @@ static inline int __down_write_trylock(struct rw_semaphore *sem)
180static inline void __up_read(struct rw_semaphore *sem) 184static inline void __up_read(struct rw_semaphore *sem)
181{ 185{
182 __s32 tmp = -RWSEM_ACTIVE_READ_BIAS; 186 __s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
183 __asm__ __volatile__( 187 asm volatile("# beginning __up_read\n\t"
184 "# beginning __up_read\n\t" 188 LOCK_PREFIX " xadd %%edx,(%%eax)\n\t"
185LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */ 189 /* subtracts 1, returns the old value */
186 " jns 1f\n\t" 190 " jns 1f\n\t"
187 " call call_rwsem_wake\n" 191 " call call_rwsem_wake\n"
188 "1:\n" 192 "1:\n"
189 "# ending __up_read\n" 193 "# ending __up_read\n"
190 : "+m" (sem->count), "=d" (tmp) 194 : "+m" (sem->count), "=d" (tmp)
191 : "a" (sem), "1" (tmp) 195 : "a" (sem), "1" (tmp)
192 : "memory", "cc"); 196 : "memory", "cc");
193} 197}
194 198
195/* 199/*
@@ -197,17 +201,18 @@ LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old valu
197 */ 201 */
198static inline void __up_write(struct rw_semaphore *sem) 202static inline void __up_write(struct rw_semaphore *sem)
199{ 203{
200 __asm__ __volatile__( 204 asm volatile("# beginning __up_write\n\t"
201 "# beginning __up_write\n\t" 205 " movl %2,%%edx\n\t"
202 " movl %2,%%edx\n\t" 206 LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t"
203LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */ 207 /* tries to transition
204 " jz 1f\n" 208 0xffff0001 -> 0x00000000 */
205 " call call_rwsem_wake\n" 209 " jz 1f\n"
206 "1:\n\t" 210 " call call_rwsem_wake\n"
207 "# ending __up_write\n" 211 "1:\n\t"
208 : "+m" (sem->count) 212 "# ending __up_write\n"
209 : "a" (sem), "i" (-RWSEM_ACTIVE_WRITE_BIAS) 213 : "+m" (sem->count)
210 : "memory", "cc", "edx"); 214 : "a" (sem), "i" (-RWSEM_ACTIVE_WRITE_BIAS)
215 : "memory", "cc", "edx");
211} 216}
212 217
213/* 218/*
@@ -215,16 +220,16 @@ LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 ->
215 */ 220 */
216static inline void __downgrade_write(struct rw_semaphore *sem) 221static inline void __downgrade_write(struct rw_semaphore *sem)
217{ 222{
218 __asm__ __volatile__( 223 asm volatile("# beginning __downgrade_write\n\t"
219 "# beginning __downgrade_write\n\t" 224 LOCK_PREFIX " addl %2,(%%eax)\n\t"
220LOCK_PREFIX " addl %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */ 225 /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
221 " jns 1f\n\t" 226 " jns 1f\n\t"
222 " call call_rwsem_downgrade_wake\n" 227 " call call_rwsem_downgrade_wake\n"
223 "1:\n\t" 228 "1:\n\t"
224 "# ending __downgrade_write\n" 229 "# ending __downgrade_write\n"
225 : "+m" (sem->count) 230 : "+m" (sem->count)
226 : "a" (sem), "i" (-RWSEM_WAITING_BIAS) 231 : "a" (sem), "i" (-RWSEM_WAITING_BIAS)
227 : "memory", "cc"); 232 : "memory", "cc");
228} 233}
229 234
230/* 235/*
@@ -232,10 +237,9 @@ LOCK_PREFIX " addl %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001
232 */ 237 */
233static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) 238static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
234{ 239{
235 __asm__ __volatile__( 240 asm volatile(LOCK_PREFIX "addl %1,%0"
236LOCK_PREFIX "addl %1,%0" 241 : "+m" (sem->count)
237 : "+m" (sem->count) 242 : "ir" (delta));
238 : "ir" (delta));
239} 243}
240 244
241/* 245/*
@@ -245,12 +249,11 @@ static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
245{ 249{
246 int tmp = delta; 250 int tmp = delta;
247 251
248 __asm__ __volatile__( 252 asm volatile(LOCK_PREFIX "xadd %0,%1"
249LOCK_PREFIX "xadd %0,%1" 253 : "+r" (tmp), "+m" (sem->count)
250 : "+r" (tmp), "+m" (sem->count) 254 : : "memory");
251 : : "memory");
252 255
253 return tmp+delta; 256 return tmp + delta;
254} 257}
255 258
256static inline int rwsem_is_locked(struct rw_semaphore *sem) 259static inline int rwsem_is_locked(struct rw_semaphore *sem)
diff --git a/include/asm-x86/scatterlist.h b/include/asm-x86/scatterlist.h
index d13c197866d6..c0432061f81a 100644
--- a/include/asm-x86/scatterlist.h
+++ b/include/asm-x86/scatterlist.h
@@ -11,9 +11,7 @@ struct scatterlist {
11 unsigned int offset; 11 unsigned int offset;
12 unsigned int length; 12 unsigned int length;
13 dma_addr_t dma_address; 13 dma_addr_t dma_address;
14#ifdef CONFIG_X86_64
15 unsigned int dma_length; 14 unsigned int dma_length;
16#endif
17}; 15};
18 16
19#define ARCH_HAS_SG_CHAIN 17#define ARCH_HAS_SG_CHAIN
diff --git a/include/asm-x86/segment.h b/include/asm-x86/segment.h
index 23f0535fec61..ed5131dd7d92 100644
--- a/include/asm-x86/segment.h
+++ b/include/asm-x86/segment.h
@@ -191,13 +191,14 @@
191#define SEGMENT_TI_MASK 0x4 191#define SEGMENT_TI_MASK 0x4
192 192
193#define IDT_ENTRIES 256 193#define IDT_ENTRIES 256
194#define NUM_EXCEPTION_VECTORS 32
194#define GDT_SIZE (GDT_ENTRIES * 8) 195#define GDT_SIZE (GDT_ENTRIES * 8)
195#define GDT_ENTRY_TLS_ENTRIES 3 196#define GDT_ENTRY_TLS_ENTRIES 3
196#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) 197#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
197 198
198#ifdef __KERNEL__ 199#ifdef __KERNEL__
199#ifndef __ASSEMBLY__ 200#ifndef __ASSEMBLY__
200extern const char early_idt_handlers[IDT_ENTRIES][10]; 201extern const char early_idt_handlers[NUM_EXCEPTION_VECTORS][10];
201#endif 202#endif
202#endif 203#endif
203 204
diff --git a/include/asm-x86/semaphore.h b/include/asm-x86/semaphore.h
index 572c0b67a6b0..d9b2034ed1d2 100644
--- a/include/asm-x86/semaphore.h
+++ b/include/asm-x86/semaphore.h
@@ -1,5 +1 @@
1#ifdef CONFIG_X86_32 #include <linux/semaphore.h>
2# include "semaphore_32.h"
3#else
4# include "semaphore_64.h"
5#endif
diff --git a/include/asm-x86/semaphore_32.h b/include/asm-x86/semaphore_32.h
deleted file mode 100644
index ac96d3804d0c..000000000000
--- a/include/asm-x86/semaphore_32.h
+++ /dev/null
@@ -1,175 +0,0 @@
1#ifndef _I386_SEMAPHORE_H
2#define _I386_SEMAPHORE_H
3
4#include <linux/linkage.h>
5
6#ifdef __KERNEL__
7
8/*
9 * SMP- and interrupt-safe semaphores..
10 *
11 * (C) Copyright 1996 Linus Torvalds
12 *
13 * Modified 1996-12-23 by Dave Grothe <dave@gcom.com> to fix bugs in
14 * the original code and to make semaphore waits
15 * interruptible so that processes waiting on
16 * semaphores can be killed.
17 * Modified 1999-02-14 by Andrea Arcangeli, split the sched.c helper
18 * functions in asm/sempahore-helper.h while fixing a
19 * potential and subtle race discovered by Ulrich Schmid
20 * in down_interruptible(). Since I started to play here I
21 * also implemented the `trylock' semaphore operation.
22 * 1999-07-02 Artur Skawina <skawina@geocities.com>
23 * Optimized "0(ecx)" -> "(ecx)" (the assembler does not
24 * do this). Changed calling sequences from push/jmp to
25 * traditional call/ret.
26 * Modified 2001-01-01 Andreas Franck <afranck@gmx.de>
27 * Some hacks to ensure compatibility with recent
28 * GCC snapshots, to avoid stack corruption when compiling
29 * with -fomit-frame-pointer. It's not sure if this will
30 * be fixed in GCC, as our previous implementation was a
31 * bit dubious.
32 *
33 * If you would like to see an analysis of this implementation, please
34 * ftp to gcom.com and download the file
35 * /pub/linux/src/semaphore/semaphore-2.0.24.tar.gz.
36 *
37 */
38
39#include <asm/system.h>
40#include <asm/atomic.h>
41#include <linux/wait.h>
42#include <linux/rwsem.h>
43
44struct semaphore {
45 atomic_t count;
46 int sleepers;
47 wait_queue_head_t wait;
48};
49
50
51#define __SEMAPHORE_INITIALIZER(name, n) \
52{ \
53 .count = ATOMIC_INIT(n), \
54 .sleepers = 0, \
55 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
56}
57
58#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
59 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
60
61#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
62
63static inline void sema_init (struct semaphore *sem, int val)
64{
65/*
66 * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
67 *
68 * i'd rather use the more flexible initialization above, but sadly
69 * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
70 */
71 atomic_set(&sem->count, val);
72 sem->sleepers = 0;
73 init_waitqueue_head(&sem->wait);
74}
75
76static inline void init_MUTEX (struct semaphore *sem)
77{
78 sema_init(sem, 1);
79}
80
81static inline void init_MUTEX_LOCKED (struct semaphore *sem)
82{
83 sema_init(sem, 0);
84}
85
86extern asmregparm void __down_failed(atomic_t *count_ptr);
87extern asmregparm int __down_failed_interruptible(atomic_t *count_ptr);
88extern asmregparm int __down_failed_trylock(atomic_t *count_ptr);
89extern asmregparm void __up_wakeup(atomic_t *count_ptr);
90
91/*
92 * This is ugly, but we want the default case to fall through.
93 * "__down_failed" is a special asm handler that calls the C
94 * routine that actually waits. See arch/i386/kernel/semaphore.c
95 */
96static inline void down(struct semaphore * sem)
97{
98 might_sleep();
99 __asm__ __volatile__(
100 "# atomic down operation\n\t"
101 LOCK_PREFIX "decl %0\n\t" /* --sem->count */
102 "jns 2f\n"
103 "\tlea %0,%%eax\n\t"
104 "call __down_failed\n"
105 "2:"
106 :"+m" (sem->count)
107 :
108 :"memory","ax");
109}
110
111/*
112 * Interruptible try to acquire a semaphore. If we obtained
113 * it, return zero. If we were interrupted, returns -EINTR
114 */
115static inline int down_interruptible(struct semaphore * sem)
116{
117 int result;
118
119 might_sleep();
120 __asm__ __volatile__(
121 "# atomic interruptible down operation\n\t"
122 "xorl %0,%0\n\t"
123 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
124 "jns 2f\n\t"
125 "lea %1,%%eax\n\t"
126 "call __down_failed_interruptible\n"
127 "2:"
128 :"=&a" (result), "+m" (sem->count)
129 :
130 :"memory");
131 return result;
132}
133
134/*
135 * Non-blockingly attempt to down() a semaphore.
136 * Returns zero if we acquired it
137 */
138static inline int down_trylock(struct semaphore * sem)
139{
140 int result;
141
142 __asm__ __volatile__(
143 "# atomic interruptible down operation\n\t"
144 "xorl %0,%0\n\t"
145 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
146 "jns 2f\n\t"
147 "lea %1,%%eax\n\t"
148 "call __down_failed_trylock\n\t"
149 "2:\n"
150 :"=&a" (result), "+m" (sem->count)
151 :
152 :"memory");
153 return result;
154}
155
156/*
157 * Note! This is subtle. We jump to wake people up only if
158 * the semaphore was negative (== somebody was waiting on it).
159 */
160static inline void up(struct semaphore * sem)
161{
162 __asm__ __volatile__(
163 "# atomic up operation\n\t"
164 LOCK_PREFIX "incl %0\n\t" /* ++sem->count */
165 "jg 1f\n\t"
166 "lea %0,%%eax\n\t"
167 "call __up_wakeup\n"
168 "1:"
169 :"+m" (sem->count)
170 :
171 :"memory","ax");
172}
173
174#endif
175#endif
diff --git a/include/asm-x86/semaphore_64.h b/include/asm-x86/semaphore_64.h
deleted file mode 100644
index 79694306bf7d..000000000000
--- a/include/asm-x86/semaphore_64.h
+++ /dev/null
@@ -1,180 +0,0 @@
1#ifndef _X86_64_SEMAPHORE_H
2#define _X86_64_SEMAPHORE_H
3
4#include <linux/linkage.h>
5
6#ifdef __KERNEL__
7
8/*
9 * SMP- and interrupt-safe semaphores..
10 *
11 * (C) Copyright 1996 Linus Torvalds
12 *
13 * Modified 1996-12-23 by Dave Grothe <dave@gcom.com> to fix bugs in
14 * the original code and to make semaphore waits
15 * interruptible so that processes waiting on
16 * semaphores can be killed.
17 * Modified 1999-02-14 by Andrea Arcangeli, split the sched.c helper
18 * functions in asm/sempahore-helper.h while fixing a
19 * potential and subtle race discovered by Ulrich Schmid
20 * in down_interruptible(). Since I started to play here I
21 * also implemented the `trylock' semaphore operation.
22 * 1999-07-02 Artur Skawina <skawina@geocities.com>
23 * Optimized "0(ecx)" -> "(ecx)" (the assembler does not
24 * do this). Changed calling sequences from push/jmp to
25 * traditional call/ret.
26 * Modified 2001-01-01 Andreas Franck <afranck@gmx.de>
27 * Some hacks to ensure compatibility with recent
28 * GCC snapshots, to avoid stack corruption when compiling
29 * with -fomit-frame-pointer. It's not sure if this will
30 * be fixed in GCC, as our previous implementation was a
31 * bit dubious.
32 *
33 * If you would like to see an analysis of this implementation, please
34 * ftp to gcom.com and download the file
35 * /pub/linux/src/semaphore/semaphore-2.0.24.tar.gz.
36 *
37 */
38
39#include <asm/system.h>
40#include <asm/atomic.h>
41#include <asm/rwlock.h>
42#include <linux/wait.h>
43#include <linux/rwsem.h>
44#include <linux/stringify.h>
45
46struct semaphore {
47 atomic_t count;
48 int sleepers;
49 wait_queue_head_t wait;
50};
51
52#define __SEMAPHORE_INITIALIZER(name, n) \
53{ \
54 .count = ATOMIC_INIT(n), \
55 .sleepers = 0, \
56 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
57}
58
59#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
60 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
61
62#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
63
64static inline void sema_init (struct semaphore *sem, int val)
65{
66/*
67 * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
68 *
69 * i'd rather use the more flexible initialization above, but sadly
70 * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well.
71 */
72 atomic_set(&sem->count, val);
73 sem->sleepers = 0;
74 init_waitqueue_head(&sem->wait);
75}
76
77static inline void init_MUTEX (struct semaphore *sem)
78{
79 sema_init(sem, 1);
80}
81
82static inline void init_MUTEX_LOCKED (struct semaphore *sem)
83{
84 sema_init(sem, 0);
85}
86
87asmlinkage void __down_failed(void /* special register calling convention */);
88asmlinkage int __down_failed_interruptible(void /* params in registers */);
89asmlinkage int __down_failed_trylock(void /* params in registers */);
90asmlinkage void __up_wakeup(void /* special register calling convention */);
91
92asmlinkage void __down(struct semaphore * sem);
93asmlinkage int __down_interruptible(struct semaphore * sem);
94asmlinkage int __down_trylock(struct semaphore * sem);
95asmlinkage void __up(struct semaphore * sem);
96
97/*
98 * This is ugly, but we want the default case to fall through.
99 * "__down_failed" is a special asm handler that calls the C
100 * routine that actually waits. See arch/x86_64/kernel/semaphore.c
101 */
102static inline void down(struct semaphore * sem)
103{
104 might_sleep();
105
106 __asm__ __volatile__(
107 "# atomic down operation\n\t"
108 LOCK_PREFIX "decl %0\n\t" /* --sem->count */
109 "jns 1f\n\t"
110 "call __down_failed\n"
111 "1:"
112 :"=m" (sem->count)
113 :"D" (sem)
114 :"memory");
115}
116
117/*
118 * Interruptible try to acquire a semaphore. If we obtained
119 * it, return zero. If we were interrupted, returns -EINTR
120 */
121static inline int down_interruptible(struct semaphore * sem)
122{
123 int result;
124
125 might_sleep();
126
127 __asm__ __volatile__(
128 "# atomic interruptible down operation\n\t"
129 "xorl %0,%0\n\t"
130 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
131 "jns 2f\n\t"
132 "call __down_failed_interruptible\n"
133 "2:\n"
134 :"=&a" (result), "=m" (sem->count)
135 :"D" (sem)
136 :"memory");
137 return result;
138}
139
140/*
141 * Non-blockingly attempt to down() a semaphore.
142 * Returns zero if we acquired it
143 */
144static inline int down_trylock(struct semaphore * sem)
145{
146 int result;
147
148 __asm__ __volatile__(
149 "# atomic interruptible down operation\n\t"
150 "xorl %0,%0\n\t"
151 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
152 "jns 2f\n\t"
153 "call __down_failed_trylock\n\t"
154 "2:\n"
155 :"=&a" (result), "=m" (sem->count)
156 :"D" (sem)
157 :"memory","cc");
158 return result;
159}
160
161/*
162 * Note! This is subtle. We jump to wake people up only if
163 * the semaphore was negative (== somebody was waiting on it).
164 * The default case (no contention) will result in NO
165 * jumps for both down() and up().
166 */
167static inline void up(struct semaphore * sem)
168{
169 __asm__ __volatile__(
170 "# atomic up operation\n\t"
171 LOCK_PREFIX "incl %0\n\t" /* ++sem->count */
172 "jg 1f\n\t"
173 "call __up_wakeup\n"
174 "1:"
175 :"=m" (sem->count)
176 :"D" (sem)
177 :"memory");
178}
179#endif /* __KERNEL__ */
180#endif
diff --git a/include/asm-x86/setup.h b/include/asm-x86/setup.h
index 071e054abd82..fa6763af8d26 100644
--- a/include/asm-x86/setup.h
+++ b/include/asm-x86/setup.h
@@ -4,6 +4,10 @@
4#define COMMAND_LINE_SIZE 2048 4#define COMMAND_LINE_SIZE 2048
5 5
6#ifndef __ASSEMBLY__ 6#ifndef __ASSEMBLY__
7
8/* Interrupt control for vSMPowered x86_64 systems */
9void vsmp_init(void);
10
7char *machine_specific_memory_setup(void); 11char *machine_specific_memory_setup(void);
8#ifndef CONFIG_PARAVIRT 12#ifndef CONFIG_PARAVIRT
9#define paravirt_post_allocator_init() do {} while (0) 13#define paravirt_post_allocator_init() do {} while (0)
@@ -51,8 +55,8 @@ struct e820entry;
51char * __init machine_specific_memory_setup(void); 55char * __init machine_specific_memory_setup(void);
52char *memory_setup(void); 56char *memory_setup(void);
53 57
54int __init copy_e820_map(struct e820entry * biosmap, int nr_map); 58int __init copy_e820_map(struct e820entry *biosmap, int nr_map);
55int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map); 59int __init sanitize_e820_map(struct e820entry *biosmap, char *pnr_map);
56void __init add_memory_region(unsigned long long start, 60void __init add_memory_region(unsigned long long start,
57 unsigned long long size, int type); 61 unsigned long long size, int type);
58 62
diff --git a/include/asm-x86/sigcontext.h b/include/asm-x86/sigcontext.h
index d743947f4c77..2f9c884d2c0f 100644
--- a/include/asm-x86/sigcontext.h
+++ b/include/asm-x86/sigcontext.h
@@ -79,7 +79,7 @@ struct sigcontext {
79 unsigned long flags; 79 unsigned long flags;
80 unsigned long sp_at_signal; 80 unsigned long sp_at_signal;
81 unsigned short ss, __ssh; 81 unsigned short ss, __ssh;
82 struct _fpstate __user * fpstate; 82 struct _fpstate __user *fpstate;
83 unsigned long oldmask; 83 unsigned long oldmask;
84 unsigned long cr2; 84 unsigned long cr2;
85}; 85};
@@ -107,7 +107,7 @@ struct sigcontext {
107 unsigned long eflags; 107 unsigned long eflags;
108 unsigned long esp_at_signal; 108 unsigned long esp_at_signal;
109 unsigned short ss, __ssh; 109 unsigned short ss, __ssh;
110 struct _fpstate __user * fpstate; 110 struct _fpstate __user *fpstate;
111 unsigned long oldmask; 111 unsigned long oldmask;
112 unsigned long cr2; 112 unsigned long cr2;
113}; 113};
@@ -121,7 +121,8 @@ struct sigcontext {
121struct _fpstate { 121struct _fpstate {
122 __u16 cwd; 122 __u16 cwd;
123 __u16 swd; 123 __u16 swd;
124 __u16 twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */ 124 __u16 twd; /* Note this is not the same as the
125 32bit/x87/FSAVE twd */
125 __u16 fop; 126 __u16 fop;
126 __u64 rip; 127 __u64 rip;
127 __u64 rdp; 128 __u64 rdp;
diff --git a/include/asm-x86/sigcontext32.h b/include/asm-x86/sigcontext32.h
index 6ffab4fd593a..57a9686fb491 100644
--- a/include/asm-x86/sigcontext32.h
+++ b/include/asm-x86/sigcontext32.h
@@ -26,7 +26,7 @@ struct _fpstate_ia32 {
26 __u32 cw; 26 __u32 cw;
27 __u32 sw; 27 __u32 sw;
28 __u32 tag; /* not compatible to 64bit twd */ 28 __u32 tag; /* not compatible to 64bit twd */
29 __u32 ipoff; 29 __u32 ipoff;
30 __u32 cssel; 30 __u32 cssel;
31 __u32 dataoff; 31 __u32 dataoff;
32 __u32 datasel; 32 __u32 datasel;
@@ -39,7 +39,7 @@ struct _fpstate_ia32 {
39 __u32 mxcsr; 39 __u32 mxcsr;
40 __u32 reserved; 40 __u32 reserved;
41 struct _fpxreg _fxsr_st[8]; 41 struct _fpxreg _fxsr_st[8];
42 struct _xmmreg _xmm[8]; /* It's actually 16 */ 42 struct _xmmreg _xmm[8]; /* It's actually 16 */
43 __u32 padding[56]; 43 __u32 padding[56];
44}; 44};
45 45
diff --git a/include/asm-x86/signal.h b/include/asm-x86/signal.h
index aee7eca585ab..f15186d39c69 100644
--- a/include/asm-x86/signal.h
+++ b/include/asm-x86/signal.h
@@ -185,61 +185,61 @@ typedef struct sigaltstack {
185 185
186#define __HAVE_ARCH_SIG_BITOPS 186#define __HAVE_ARCH_SIG_BITOPS
187 187
188#define sigaddset(set,sig) \ 188#define sigaddset(set,sig) \
189 (__builtin_constantp(sig) ? \ 189 (__builtin_constantp(sig) \
190 __const_sigaddset((set),(sig)) : \ 190 ? __const_sigaddset((set), (sig)) \
191 __gen_sigaddset((set),(sig))) 191 : __gen_sigaddset((set), (sig)))
192 192
193static __inline__ void __gen_sigaddset(sigset_t *set, int _sig) 193static inline void __gen_sigaddset(sigset_t *set, int _sig)
194{ 194{
195 __asm__("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); 195 asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
196} 196}
197 197
198static __inline__ void __const_sigaddset(sigset_t *set, int _sig) 198static inline void __const_sigaddset(sigset_t *set, int _sig)
199{ 199{
200 unsigned long sig = _sig - 1; 200 unsigned long sig = _sig - 1;
201 set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW); 201 set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
202} 202}
203 203
204#define sigdelset(set,sig) \ 204#define sigdelset(set, sig) \
205 (__builtin_constant_p(sig) ? \ 205 (__builtin_constant_p(sig) \
206 __const_sigdelset((set),(sig)) : \ 206 ? __const_sigdelset((set), (sig)) \
207 __gen_sigdelset((set),(sig))) 207 : __gen_sigdelset((set), (sig)))
208 208
209 209
210static __inline__ void __gen_sigdelset(sigset_t *set, int _sig) 210static inline void __gen_sigdelset(sigset_t *set, int _sig)
211{ 211{
212 __asm__("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc"); 212 asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
213} 213}
214 214
215static __inline__ void __const_sigdelset(sigset_t *set, int _sig) 215static inline void __const_sigdelset(sigset_t *set, int _sig)
216{ 216{
217 unsigned long sig = _sig - 1; 217 unsigned long sig = _sig - 1;
218 set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW)); 218 set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
219} 219}
220 220
221static __inline__ int __const_sigismember(sigset_t *set, int _sig) 221static inline int __const_sigismember(sigset_t *set, int _sig)
222{ 222{
223 unsigned long sig = _sig - 1; 223 unsigned long sig = _sig - 1;
224 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW)); 224 return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
225} 225}
226 226
227static __inline__ int __gen_sigismember(sigset_t *set, int _sig) 227static inline int __gen_sigismember(sigset_t *set, int _sig)
228{ 228{
229 int ret; 229 int ret;
230 __asm__("btl %2,%1\n\tsbbl %0,%0" 230 asm("btl %2,%1\n\tsbbl %0,%0"
231 : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc"); 231 : "=r"(ret) : "m"(*set), "Ir"(_sig-1) : "cc");
232 return ret; 232 return ret;
233} 233}
234 234
235#define sigismember(set,sig) \ 235#define sigismember(set, sig) \
236 (__builtin_constant_p(sig) ? \ 236 (__builtin_constant_p(sig) \
237 __const_sigismember((set),(sig)) : \ 237 ? __const_sigismember((set), (sig)) \
238 __gen_sigismember((set),(sig))) 238 : __gen_sigismember((set), (sig)))
239 239
240static __inline__ int sigfindinword(unsigned long word) 240static inline int sigfindinword(unsigned long word)
241{ 241{
242 __asm__("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc"); 242 asm("bsfl %1,%0" : "=r"(word) : "rm"(word) : "cc");
243 return word; 243 return word;
244} 244}
245 245
diff --git a/include/asm-x86/smp.h b/include/asm-x86/smp.h
index f2e8319a6b0b..1ebaa5cd3112 100644
--- a/include/asm-x86/smp.h
+++ b/include/asm-x86/smp.h
@@ -1,5 +1,208 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_SMP_H_
2# include "smp_32.h" 2#define _ASM_X86_SMP_H_
3#ifndef __ASSEMBLY__
4#include <linux/cpumask.h>
5#include <linux/init.h>
6#include <asm/percpu.h>
7
8/*
9 * We need the APIC definitions automatically as part of 'smp.h'
10 */
11#ifdef CONFIG_X86_LOCAL_APIC
12# include <asm/mpspec.h>
13# include <asm/apic.h>
14# ifdef CONFIG_X86_IO_APIC
15# include <asm/io_apic.h>
16# endif
17#endif
18#include <asm/pda.h>
19#include <asm/thread_info.h>
20
21extern cpumask_t cpu_callout_map;
22extern cpumask_t cpu_initialized;
23extern cpumask_t cpu_callin_map;
24
25extern void (*mtrr_hook)(void);
26extern void zap_low_mappings(void);
27
28extern int smp_num_siblings;
29extern unsigned int num_processors;
30extern cpumask_t cpu_initialized;
31
32#ifdef CONFIG_SMP
33extern u16 x86_cpu_to_apicid_init[];
34extern u16 x86_bios_cpu_apicid_init[];
35extern void *x86_cpu_to_apicid_early_ptr;
36extern void *x86_bios_cpu_apicid_early_ptr;
3#else 37#else
4# include "smp_64.h" 38#define x86_cpu_to_apicid_early_ptr NULL
39#define x86_bios_cpu_apicid_early_ptr NULL
40#endif
41
42DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
43DECLARE_PER_CPU(cpumask_t, cpu_core_map);
44DECLARE_PER_CPU(u16, cpu_llc_id);
45DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
46DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
47
48/* Static state in head.S used to set up a CPU */
49extern struct {
50 void *sp;
51 unsigned short ss;
52} stack_start;
53
54struct smp_ops {
55 void (*smp_prepare_boot_cpu)(void);
56 void (*smp_prepare_cpus)(unsigned max_cpus);
57 int (*cpu_up)(unsigned cpu);
58 void (*smp_cpus_done)(unsigned max_cpus);
59
60 void (*smp_send_stop)(void);
61 void (*smp_send_reschedule)(int cpu);
62 int (*smp_call_function_mask)(cpumask_t mask,
63 void (*func)(void *info), void *info,
64 int wait);
65};
66
67/* Globals due to paravirt */
68extern void set_cpu_sibling_map(int cpu);
69
70#ifdef CONFIG_SMP
71#ifndef CONFIG_PARAVIRT
72#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
73#endif
74extern struct smp_ops smp_ops;
75
76static inline void smp_send_stop(void)
77{
78 smp_ops.smp_send_stop();
79}
80
81static inline void smp_prepare_boot_cpu(void)
82{
83 smp_ops.smp_prepare_boot_cpu();
84}
85
86static inline void smp_prepare_cpus(unsigned int max_cpus)
87{
88 smp_ops.smp_prepare_cpus(max_cpus);
89}
90
91static inline void smp_cpus_done(unsigned int max_cpus)
92{
93 smp_ops.smp_cpus_done(max_cpus);
94}
95
96static inline int __cpu_up(unsigned int cpu)
97{
98 return smp_ops.cpu_up(cpu);
99}
100
101static inline void smp_send_reschedule(int cpu)
102{
103 smp_ops.smp_send_reschedule(cpu);
104}
105
106static inline int smp_call_function_mask(cpumask_t mask,
107 void (*func) (void *info), void *info,
108 int wait)
109{
110 return smp_ops.smp_call_function_mask(mask, func, info, wait);
111}
112
113void native_smp_prepare_boot_cpu(void);
114void native_smp_prepare_cpus(unsigned int max_cpus);
115void native_smp_cpus_done(unsigned int max_cpus);
116int native_cpu_up(unsigned int cpunum);
117
118extern int __cpu_disable(void);
119extern void __cpu_die(unsigned int cpu);
120
121extern void prefill_possible_map(void);
122
123void smp_store_cpu_info(int id);
124#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
125
126/* We don't mark CPUs online until __cpu_up(), so we need another measure */
127static inline int num_booting_cpus(void)
128{
129 return cpus_weight(cpu_callout_map);
130}
131#endif /* CONFIG_SMP */
132
133extern unsigned disabled_cpus __cpuinitdata;
134
135#ifdef CONFIG_X86_32_SMP
136/*
137 * This function is needed by all SMP systems. It must _always_ be valid
138 * from the initial startup. We map APIC_BASE very early in page_setup(),
139 * so this is correct in the x86 case.
140 */
141DECLARE_PER_CPU(int, cpu_number);
142#define raw_smp_processor_id() (x86_read_percpu(cpu_number))
143extern int safe_smp_processor_id(void);
144
145#elif defined(CONFIG_X86_64_SMP)
146#define raw_smp_processor_id() read_pda(cpunumber)
147
148#define stack_smp_processor_id() \
149({ \
150 struct thread_info *ti; \
151 __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
152 ti->cpu; \
153})
154#define safe_smp_processor_id() smp_processor_id()
155
156#else /* !CONFIG_X86_32_SMP && !CONFIG_X86_64_SMP */
157#define cpu_physical_id(cpu) boot_cpu_physical_apicid
158#define safe_smp_processor_id() 0
159#define stack_smp_processor_id() 0
160#endif
161
162#ifdef CONFIG_X86_LOCAL_APIC
163
164static inline int logical_smp_processor_id(void)
165{
166 /* we don't want to mark this access volatile - bad code generation */
167 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
168}
169
170#ifndef CONFIG_X86_64
171static inline unsigned int read_apic_id(void)
172{
173 return *(u32 *)(APIC_BASE + APIC_ID);
174}
175#else
176extern unsigned int read_apic_id(void);
177#endif
178
179
180# ifdef APIC_DEFINITION
181extern int hard_smp_processor_id(void);
182# else
183# include <mach_apicdef.h>
184static inline int hard_smp_processor_id(void)
185{
186 /* we don't want to mark this access volatile - bad code generation */
187 return GET_APIC_ID(read_apic_id());
188}
189# endif /* APIC_DEFINITION */
190
191#else /* CONFIG_X86_LOCAL_APIC */
192
193# ifndef CONFIG_SMP
194# define hard_smp_processor_id() 0
195# endif
196
197#endif /* CONFIG_X86_LOCAL_APIC */
198
199#ifdef CONFIG_HOTPLUG_CPU
200extern void cpu_exit_clear(void);
201extern void cpu_uninit(void);
202#endif
203
204extern void smp_alloc_memory(void);
205extern void lock_ipi_call_lock(void);
206extern void unlock_ipi_call_lock(void);
207#endif /* __ASSEMBLY__ */
5#endif 208#endif
diff --git a/include/asm-x86/smp_32.h b/include/asm-x86/smp_32.h
deleted file mode 100644
index 56152e312287..000000000000
--- a/include/asm-x86/smp_32.h
+++ /dev/null
@@ -1,165 +0,0 @@
1#ifndef __ASM_SMP_H
2#define __ASM_SMP_H
3
4#ifndef __ASSEMBLY__
5#include <linux/cpumask.h>
6#include <linux/init.h>
7
8/*
9 * We need the APIC definitions automatically as part of 'smp.h'
10 */
11#ifdef CONFIG_X86_LOCAL_APIC
12# include <asm/mpspec.h>
13# include <asm/apic.h>
14# ifdef CONFIG_X86_IO_APIC
15# include <asm/io_apic.h>
16# endif
17#endif
18
19extern cpumask_t cpu_callout_map;
20extern cpumask_t cpu_callin_map;
21
22extern int smp_num_siblings;
23extern unsigned int num_processors;
24
25extern void smp_alloc_memory(void);
26extern void lock_ipi_call_lock(void);
27extern void unlock_ipi_call_lock(void);
28
29extern void (*mtrr_hook) (void);
30extern void zap_low_mappings (void);
31
32extern u8 __initdata x86_cpu_to_apicid_init[];
33extern void *x86_cpu_to_apicid_early_ptr;
34
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);
39
40#ifdef CONFIG_HOTPLUG_CPU
41extern void cpu_exit_clear(void);
42extern void cpu_uninit(void);
43extern void remove_siblinginfo(int cpu);
44#endif
45
46/* Globals due to paravirt */
47extern void set_cpu_sibling_map(int cpu);
48
49struct smp_ops
50{
51 void (*smp_prepare_boot_cpu)(void);
52 void (*smp_prepare_cpus)(unsigned max_cpus);
53 int (*cpu_up)(unsigned cpu);
54 void (*smp_cpus_done)(unsigned max_cpus);
55
56 void (*smp_send_stop)(void);
57 void (*smp_send_reschedule)(int cpu);
58 int (*smp_call_function_mask)(cpumask_t mask,
59 void (*func)(void *info), void *info,
60 int wait);
61};
62
63#ifdef CONFIG_SMP
64extern struct smp_ops smp_ops;
65
66static inline void smp_prepare_boot_cpu(void)
67{
68 smp_ops.smp_prepare_boot_cpu();
69}
70static inline void smp_prepare_cpus(unsigned int max_cpus)
71{
72 smp_ops.smp_prepare_cpus(max_cpus);
73}
74static inline int __cpu_up(unsigned int cpu)
75{
76 return smp_ops.cpu_up(cpu);
77}
78static inline void smp_cpus_done(unsigned int max_cpus)
79{
80 smp_ops.smp_cpus_done(max_cpus);
81}
82
83static inline void smp_send_stop(void)
84{
85 smp_ops.smp_send_stop();
86}
87static inline void smp_send_reschedule(int cpu)
88{
89 smp_ops.smp_send_reschedule(cpu);
90}
91static inline int smp_call_function_mask(cpumask_t mask,
92 void (*func) (void *info), void *info,
93 int wait)
94{
95 return smp_ops.smp_call_function_mask(mask, func, info, wait);
96}
97
98void native_smp_prepare_boot_cpu(void);
99void native_smp_prepare_cpus(unsigned int max_cpus);
100int native_cpu_up(unsigned int cpunum);
101void native_smp_cpus_done(unsigned int max_cpus);
102
103#ifndef CONFIG_PARAVIRT
104#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
105#endif
106
107extern int __cpu_disable(void);
108extern void __cpu_die(unsigned int cpu);
109
110/*
111 * This function is needed by all SMP systems. It must _always_ be valid
112 * from the initial startup. We map APIC_BASE very early in page_setup(),
113 * so this is correct in the x86 case.
114 */
115DECLARE_PER_CPU(int, cpu_number);
116#define raw_smp_processor_id() (x86_read_percpu(cpu_number))
117
118#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
119
120extern int safe_smp_processor_id(void);
121
122void __cpuinit smp_store_cpu_info(int id);
123
124/* We don't mark CPUs online until __cpu_up(), so we need another measure */
125static inline int num_booting_cpus(void)
126{
127 return cpus_weight(cpu_callout_map);
128}
129
130#else /* CONFIG_SMP */
131
132#define safe_smp_processor_id() 0
133#define cpu_physical_id(cpu) boot_cpu_physical_apicid
134
135#endif /* !CONFIG_SMP */
136
137#ifdef CONFIG_X86_LOCAL_APIC
138
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
146extern int hard_smp_processor_id(void);
147# else
148# include <mach_apicdef.h>
149static inline int hard_smp_processor_id(void)
150{
151 /* we don't want to mark this access volatile - bad code generation */
152 return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
153}
154# endif /* APIC_DEFINITION */
155
156#else /* CONFIG_X86_LOCAL_APIC */
157
158# ifndef CONFIG_SMP
159# define hard_smp_processor_id() 0
160# endif
161
162#endif /* CONFIG_X86_LOCAL_APIC */
163
164#endif /* !ASSEMBLY */
165#endif
diff --git a/include/asm-x86/smp_64.h b/include/asm-x86/smp_64.h
deleted file mode 100644
index e0a75519ad21..000000000000
--- a/include/asm-x86/smp_64.h
+++ /dev/null
@@ -1,101 +0,0 @@
1#ifndef __ASM_SMP_H
2#define __ASM_SMP_H
3
4#include <linux/cpumask.h>
5#include <linux/init.h>
6
7/*
8 * We need the APIC definitions automatically as part of 'smp.h'
9 */
10#include <asm/apic.h>
11#include <asm/io_apic.h>
12#include <asm/mpspec.h>
13#include <asm/pda.h>
14#include <asm/thread_info.h>
15
16extern cpumask_t cpu_callout_map;
17extern cpumask_t cpu_initialized;
18
19extern int smp_num_siblings;
20extern unsigned int num_processors;
21
22extern void smp_alloc_memory(void);
23extern void lock_ipi_call_lock(void);
24extern void unlock_ipi_call_lock(void);
25
26extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
27 void *info, int wait);
28
29extern u16 __initdata x86_cpu_to_apicid_init[];
30extern u16 __initdata x86_bios_cpu_apicid_init[];
31extern void *x86_cpu_to_apicid_early_ptr;
32extern void *x86_bios_cpu_apicid_early_ptr;
33
34DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
35DECLARE_PER_CPU(cpumask_t, cpu_core_map);
36DECLARE_PER_CPU(u16, cpu_llc_id);
37DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
38DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
39
40static inline int cpu_present_to_apicid(int mps_cpu)
41{
42 if (cpu_present(mps_cpu))
43 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
44 else
45 return BAD_APICID;
46}
47
48#ifdef CONFIG_SMP
49
50#define SMP_TRAMPOLINE_BASE 0x6000
51
52extern int __cpu_disable(void);
53extern void __cpu_die(unsigned int cpu);
54extern void prefill_possible_map(void);
55extern unsigned __cpuinitdata disabled_cpus;
56
57#define raw_smp_processor_id() read_pda(cpunumber)
58#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
59
60#define stack_smp_processor_id() \
61 ({ \
62 struct thread_info *ti; \
63 __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
64 ti->cpu; \
65})
66
67/*
68 * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
69 * scheduling and IPI sending and compresses data structures.
70 */
71static inline int num_booting_cpus(void)
72{
73 return cpus_weight(cpu_callout_map);
74}
75
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
82#define stack_smp_processor_id() 0
83
84#endif /* !CONFIG_SMP */
85
86#define safe_smp_processor_id() smp_processor_id()
87
88static __inline int logical_smp_processor_id(void)
89{
90 /* we don't want to mark this access volatile - bad code generation */
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));
98}
99
100#endif
101
diff --git a/include/asm-x86/sparsemem.h b/include/asm-x86/sparsemem.h
index fa58cd55411a..9bd48b0a534b 100644
--- a/include/asm-x86/sparsemem.h
+++ b/include/asm-x86/sparsemem.h
@@ -16,7 +16,7 @@
16 16
17#ifdef CONFIG_X86_32 17#ifdef CONFIG_X86_32
18# ifdef CONFIG_X86_PAE 18# ifdef CONFIG_X86_PAE
19# define SECTION_SIZE_BITS 30 19# define SECTION_SIZE_BITS 29
20# define MAX_PHYSADDR_BITS 36 20# define MAX_PHYSADDR_BITS 36
21# define MAX_PHYSMEM_BITS 36 21# define MAX_PHYSMEM_BITS 36
22# else 22# else
@@ -26,8 +26,8 @@
26# endif 26# endif
27#else /* CONFIG_X86_32 */ 27#else /* CONFIG_X86_32 */
28# define SECTION_SIZE_BITS 27 /* matt - 128 is convenient right now */ 28# define SECTION_SIZE_BITS 27 /* matt - 128 is convenient right now */
29# define MAX_PHYSADDR_BITS 40 29# define MAX_PHYSADDR_BITS 44
30# define MAX_PHYSMEM_BITS 40 30# define MAX_PHYSMEM_BITS 44
31#endif 31#endif
32 32
33#endif /* CONFIG_SPARSEMEM */ 33#endif /* CONFIG_SPARSEMEM */
diff --git a/include/asm-x86/spinlock.h b/include/asm-x86/spinlock.h
index 23804c1890ff..bc6376f1bc5a 100644
--- a/include/asm-x86/spinlock.h
+++ b/include/asm-x86/spinlock.h
@@ -78,11 +78,11 @@ static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
78 return (((tmp >> 8) & 0xff) - (tmp & 0xff)) > 1; 78 return (((tmp >> 8) & 0xff) - (tmp & 0xff)) > 1;
79} 79}
80 80
81static inline void __raw_spin_lock(raw_spinlock_t *lock) 81static __always_inline void __raw_spin_lock(raw_spinlock_t *lock)
82{ 82{
83 short inc = 0x0100; 83 short inc = 0x0100;
84 84
85 __asm__ __volatile__ ( 85 asm volatile (
86 LOCK_PREFIX "xaddw %w0, %1\n" 86 LOCK_PREFIX "xaddw %w0, %1\n"
87 "1:\t" 87 "1:\t"
88 "cmpb %h0, %b0\n\t" 88 "cmpb %h0, %b0\n\t"
@@ -92,42 +92,40 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
92 /* don't need lfence here, because loads are in-order */ 92 /* don't need lfence here, because loads are in-order */
93 "jmp 1b\n" 93 "jmp 1b\n"
94 "2:" 94 "2:"
95 :"+Q" (inc), "+m" (lock->slock) 95 : "+Q" (inc), "+m" (lock->slock)
96 : 96 :
97 :"memory", "cc"); 97 : "memory", "cc");
98} 98}
99 99
100#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) 100#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
101 101
102static inline int __raw_spin_trylock(raw_spinlock_t *lock) 102static __always_inline int __raw_spin_trylock(raw_spinlock_t *lock)
103{ 103{
104 int tmp; 104 int tmp;
105 short new; 105 short new;
106 106
107 asm volatile( 107 asm volatile("movw %2,%w0\n\t"
108 "movw %2,%w0\n\t" 108 "cmpb %h0,%b0\n\t"
109 "cmpb %h0,%b0\n\t" 109 "jne 1f\n\t"
110 "jne 1f\n\t" 110 "movw %w0,%w1\n\t"
111 "movw %w0,%w1\n\t" 111 "incb %h1\n\t"
112 "incb %h1\n\t" 112 "lock ; cmpxchgw %w1,%2\n\t"
113 "lock ; cmpxchgw %w1,%2\n\t" 113 "1:"
114 "1:" 114 "sete %b1\n\t"
115 "sete %b1\n\t" 115 "movzbl %b1,%0\n\t"
116 "movzbl %b1,%0\n\t" 116 : "=&a" (tmp), "=Q" (new), "+m" (lock->slock)
117 :"=&a" (tmp), "=Q" (new), "+m" (lock->slock) 117 :
118 : 118 : "memory", "cc");
119 : "memory", "cc");
120 119
121 return tmp; 120 return tmp;
122} 121}
123 122
124static inline void __raw_spin_unlock(raw_spinlock_t *lock) 123static __always_inline void __raw_spin_unlock(raw_spinlock_t *lock)
125{ 124{
126 __asm__ __volatile__( 125 asm volatile(UNLOCK_LOCK_PREFIX "incb %0"
127 UNLOCK_LOCK_PREFIX "incb %0" 126 : "+m" (lock->slock)
128 :"+m" (lock->slock) 127 :
129 : 128 : "memory", "cc");
130 :"memory", "cc");
131} 129}
132#else 130#else
133static inline int __raw_spin_is_locked(raw_spinlock_t *lock) 131static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
@@ -144,60 +142,57 @@ static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
144 return (((tmp >> 16) & 0xffff) - (tmp & 0xffff)) > 1; 142 return (((tmp >> 16) & 0xffff) - (tmp & 0xffff)) > 1;
145} 143}
146 144
147static inline void __raw_spin_lock(raw_spinlock_t *lock) 145static __always_inline void __raw_spin_lock(raw_spinlock_t *lock)
148{ 146{
149 int inc = 0x00010000; 147 int inc = 0x00010000;
150 int tmp; 148 int tmp;
151 149
152 __asm__ __volatile__ ( 150 asm volatile("lock ; xaddl %0, %1\n"
153 "lock ; xaddl %0, %1\n" 151 "movzwl %w0, %2\n\t"
154 "movzwl %w0, %2\n\t" 152 "shrl $16, %0\n\t"
155 "shrl $16, %0\n\t" 153 "1:\t"
156 "1:\t" 154 "cmpl %0, %2\n\t"
157 "cmpl %0, %2\n\t" 155 "je 2f\n\t"
158 "je 2f\n\t" 156 "rep ; nop\n\t"
159 "rep ; nop\n\t" 157 "movzwl %1, %2\n\t"
160 "movzwl %1, %2\n\t" 158 /* don't need lfence here, because loads are in-order */
161 /* don't need lfence here, because loads are in-order */ 159 "jmp 1b\n"
162 "jmp 1b\n" 160 "2:"
163 "2:" 161 : "+Q" (inc), "+m" (lock->slock), "=r" (tmp)
164 :"+Q" (inc), "+m" (lock->slock), "=r" (tmp) 162 :
165 : 163 : "memory", "cc");
166 :"memory", "cc");
167} 164}
168 165
169#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) 166#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
170 167
171static inline int __raw_spin_trylock(raw_spinlock_t *lock) 168static __always_inline int __raw_spin_trylock(raw_spinlock_t *lock)
172{ 169{
173 int tmp; 170 int tmp;
174 int new; 171 int new;
175 172
176 asm volatile( 173 asm volatile("movl %2,%0\n\t"
177 "movl %2,%0\n\t" 174 "movl %0,%1\n\t"
178 "movl %0,%1\n\t" 175 "roll $16, %0\n\t"
179 "roll $16, %0\n\t" 176 "cmpl %0,%1\n\t"
180 "cmpl %0,%1\n\t" 177 "jne 1f\n\t"
181 "jne 1f\n\t" 178 "addl $0x00010000, %1\n\t"
182 "addl $0x00010000, %1\n\t" 179 "lock ; cmpxchgl %1,%2\n\t"
183 "lock ; cmpxchgl %1,%2\n\t" 180 "1:"
184 "1:" 181 "sete %b1\n\t"
185 "sete %b1\n\t" 182 "movzbl %b1,%0\n\t"
186 "movzbl %b1,%0\n\t" 183 : "=&a" (tmp), "=r" (new), "+m" (lock->slock)
187 :"=&a" (tmp), "=r" (new), "+m" (lock->slock) 184 :
188 : 185 : "memory", "cc");
189 : "memory", "cc");
190 186
191 return tmp; 187 return tmp;
192} 188}
193 189
194static inline void __raw_spin_unlock(raw_spinlock_t *lock) 190static __always_inline void __raw_spin_unlock(raw_spinlock_t *lock)
195{ 191{
196 __asm__ __volatile__( 192 asm volatile(UNLOCK_LOCK_PREFIX "incw %0"
197 UNLOCK_LOCK_PREFIX "incw %0" 193 : "+m" (lock->slock)
198 :"+m" (lock->slock) 194 :
199 : 195 : "memory", "cc");
200 :"memory", "cc");
201} 196}
202#endif 197#endif
203 198
diff --git a/include/asm-x86/srat.h b/include/asm-x86/srat.h
index 165ab4bdc02b..f4bba131d068 100644
--- a/include/asm-x86/srat.h
+++ b/include/asm-x86/srat.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Some of the code in this file has been gleaned from the 64 bit 2 * Some of the code in this file has been gleaned from the 64 bit
3 * discontigmem support code base. 3 * discontigmem support code base.
4 * 4 *
5 * Copyright (C) 2002, IBM Corp. 5 * Copyright (C) 2002, IBM Corp.
diff --git a/include/asm-x86/string_32.h b/include/asm-x86/string_32.h
index c5d13a86dea7..b49369ad9a61 100644
--- a/include/asm-x86/string_32.h
+++ b/include/asm-x86/string_32.h
@@ -3,7 +3,7 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6/* Let gcc decide wether to inline or use the out of line functions */ 6/* Let gcc decide whether to inline or use the out of line functions */
7 7
8#define __HAVE_ARCH_STRCPY 8#define __HAVE_ARCH_STRCPY
9extern char *strcpy(char *dest, const char *src); 9extern char *strcpy(char *dest, const char *src);
diff --git a/include/asm-x86/string_64.h b/include/asm-x86/string_64.h
index e583da7918fb..52b5ab383395 100644
--- a/include/asm-x86/string_64.h
+++ b/include/asm-x86/string_64.h
@@ -3,26 +3,24 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6/* Written 2002 by Andi Kleen */ 6/* Written 2002 by Andi Kleen */
7 7
8/* Only used for special circumstances. Stolen from i386/string.h */ 8/* Only used for special circumstances. Stolen from i386/string.h */
9static __always_inline void * 9static __always_inline void *__inline_memcpy(void *to, const void *from, size_t n)
10__inline_memcpy(void * to, const void * from, size_t n)
11{ 10{
12unsigned long d0, d1, d2; 11 unsigned long d0, d1, d2;
13__asm__ __volatile__( 12 asm volatile("rep ; movsl\n\t"
14 "rep ; movsl\n\t" 13 "testb $2,%b4\n\t"
15 "testb $2,%b4\n\t" 14 "je 1f\n\t"
16 "je 1f\n\t" 15 "movsw\n"
17 "movsw\n" 16 "1:\ttestb $1,%b4\n\t"
18 "1:\ttestb $1,%b4\n\t" 17 "je 2f\n\t"
19 "je 2f\n\t" 18 "movsb\n"
20 "movsb\n" 19 "2:"
21 "2:" 20 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
22 : "=&c" (d0), "=&D" (d1), "=&S" (d2) 21 : "0" (n / 4), "q" (n), "1" ((long)to), "2" ((long)from)
23 :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) 22 : "memory");
24 : "memory"); 23 return to;
25return (to);
26} 24}
27 25
28/* Even with __builtin_ the compiler may decide to use the out of line 26/* Even with __builtin_ the compiler may decide to use the out of line
@@ -32,28 +30,30 @@ return (to);
32#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 30#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
33extern void *memcpy(void *to, const void *from, size_t len); 31extern void *memcpy(void *to, const void *from, size_t len);
34#else 32#else
35extern void *__memcpy(void *to, const void *from, size_t len); 33extern void *__memcpy(void *to, const void *from, size_t len);
36#define memcpy(dst,src,len) \ 34#define memcpy(dst, src, len) \
37 ({ size_t __len = (len); \ 35({ \
38 void *__ret; \ 36 size_t __len = (len); \
39 if (__builtin_constant_p(len) && __len >= 64) \ 37 void *__ret; \
40 __ret = __memcpy((dst),(src),__len); \ 38 if (__builtin_constant_p(len) && __len >= 64) \
41 else \ 39 __ret = __memcpy((dst), (src), __len); \
42 __ret = __builtin_memcpy((dst),(src),__len); \ 40 else \
43 __ret; }) 41 __ret = __builtin_memcpy((dst), (src), __len); \
42 __ret; \
43})
44#endif 44#endif
45 45
46#define __HAVE_ARCH_MEMSET 46#define __HAVE_ARCH_MEMSET
47void *memset(void *s, int c, size_t n); 47void *memset(void *s, int c, size_t n);
48 48
49#define __HAVE_ARCH_MEMMOVE 49#define __HAVE_ARCH_MEMMOVE
50void * memmove(void * dest,const void *src,size_t count); 50void *memmove(void *dest, const void *src, size_t count);
51 51
52int memcmp(const void * cs,const void * ct,size_t count); 52int memcmp(const void *cs, const void *ct, size_t count);
53size_t strlen(const char * s); 53size_t strlen(const char *s);
54char *strcpy(char * dest,const char *src); 54char *strcpy(char *dest, const char *src);
55char *strcat(char * dest, const char * src); 55char *strcat(char *dest, const char *src);
56int strcmp(const char * cs,const char * ct); 56int strcmp(const char *cs, const char *ct);
57 57
58#endif /* __KERNEL__ */ 58#endif /* __KERNEL__ */
59 59
diff --git a/include/asm-x86/suspend_32.h b/include/asm-x86/suspend_32.h
index 1bbda3ad7796..24e1c080aa8a 100644
--- a/include/asm-x86/suspend_32.h
+++ b/include/asm-x86/suspend_32.h
@@ -10,7 +10,7 @@ static inline int arch_prepare_suspend(void) { return 0; }
10 10
11/* image of the saved processor state */ 11/* image of the saved processor state */
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 desc_ptr gdt; 15 struct desc_ptr gdt;
16 struct desc_ptr idt; 16 struct desc_ptr idt;
@@ -32,11 +32,11 @@ extern unsigned long saved_edi;
32static inline void acpi_save_register_state(unsigned long return_point) 32static inline void acpi_save_register_state(unsigned long return_point)
33{ 33{
34 saved_eip = return_point; 34 saved_eip = return_point;
35 asm volatile ("movl %%esp,%0" : "=m" (saved_esp)); 35 asm volatile("movl %%esp,%0" : "=m" (saved_esp));
36 asm volatile ("movl %%ebp,%0" : "=m" (saved_ebp)); 36 asm volatile("movl %%ebp,%0" : "=m" (saved_ebp));
37 asm volatile ("movl %%ebx,%0" : "=m" (saved_ebx)); 37 asm volatile("movl %%ebx,%0" : "=m" (saved_ebx));
38 asm volatile ("movl %%edi,%0" : "=m" (saved_edi)); 38 asm volatile("movl %%edi,%0" : "=m" (saved_edi));
39 asm volatile ("movl %%esi,%0" : "=m" (saved_esi)); 39 asm volatile("movl %%esi,%0" : "=m" (saved_esi));
40} 40}
41 41
42#define acpi_restore_register_state() do {} while (0) 42#define acpi_restore_register_state() do {} while (0)
diff --git a/include/asm-x86/suspend_64.h b/include/asm-x86/suspend_64.h
index 2eb92cb81a0d..dc3262b43072 100644
--- a/include/asm-x86/suspend_64.h
+++ b/include/asm-x86/suspend_64.h
@@ -9,8 +9,7 @@
9#include <asm/desc.h> 9#include <asm/desc.h>
10#include <asm/i387.h> 10#include <asm/i387.h>
11 11
12static inline int 12static inline int arch_prepare_suspend(void)
13arch_prepare_suspend(void)
14{ 13{
15 return 0; 14 return 0;
16} 15}
@@ -25,7 +24,7 @@ arch_prepare_suspend(void)
25 */ 24 */
26struct saved_context { 25struct saved_context {
27 struct pt_regs regs; 26 struct pt_regs regs;
28 u16 ds, es, fs, gs, ss; 27 u16 ds, es, fs, gs, ss;
29 unsigned long gs_base, gs_kernel_base, fs_base; 28 unsigned long gs_base, gs_kernel_base, fs_base;
30 unsigned long cr0, cr2, cr3, cr4, cr8; 29 unsigned long cr0, cr2, cr3, cr4, cr8;
31 unsigned long efer; 30 unsigned long efer;
diff --git a/include/asm-x86/swiotlb.h b/include/asm-x86/swiotlb.h
index f9c589539a82..f5d9e74b1e4a 100644
--- a/include/asm-x86/swiotlb.h
+++ b/include/asm-x86/swiotlb.h
@@ -8,15 +8,15 @@
8extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, 8extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr,
9 size_t size, int dir); 9 size_t size, int dir);
10extern void *swiotlb_alloc_coherent(struct device *hwdev, size_t size, 10extern void *swiotlb_alloc_coherent(struct device *hwdev, size_t size,
11 dma_addr_t *dma_handle, gfp_t flags); 11 dma_addr_t *dma_handle, gfp_t flags);
12extern void swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, 12extern void swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
13 size_t size, int dir); 13 size_t size, int dir);
14extern void swiotlb_sync_single_for_cpu(struct device *hwdev, 14extern void swiotlb_sync_single_for_cpu(struct device *hwdev,
15 dma_addr_t dev_addr, 15 dma_addr_t dev_addr,
16 size_t size, int dir); 16 size_t size, int dir);
17extern void swiotlb_sync_single_for_device(struct device *hwdev, 17extern void swiotlb_sync_single_for_device(struct device *hwdev,
18 dma_addr_t dev_addr, 18 dma_addr_t dev_addr,
19 size_t size, int dir); 19 size_t size, int dir);
20extern void swiotlb_sync_single_range_for_cpu(struct device *hwdev, 20extern void swiotlb_sync_single_range_for_cpu(struct device *hwdev,
21 dma_addr_t dev_addr, 21 dma_addr_t dev_addr,
22 unsigned long offset, 22 unsigned long offset,
@@ -26,18 +26,18 @@ extern void swiotlb_sync_single_range_for_device(struct device *hwdev,
26 unsigned long offset, 26 unsigned long offset,
27 size_t size, int dir); 27 size_t size, int dir);
28extern void swiotlb_sync_sg_for_cpu(struct device *hwdev, 28extern void swiotlb_sync_sg_for_cpu(struct device *hwdev,
29 struct scatterlist *sg, int nelems, 29 struct scatterlist *sg, int nelems,
30 int dir); 30 int dir);
31extern void swiotlb_sync_sg_for_device(struct device *hwdev, 31extern void swiotlb_sync_sg_for_device(struct device *hwdev,
32 struct scatterlist *sg, int nelems, 32 struct scatterlist *sg, int nelems,
33 int dir); 33 int dir);
34extern int swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, 34extern int swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg,
35 int nents, int direction); 35 int nents, int direction);
36extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, 36extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
37 int nents, int direction); 37 int nents, int direction);
38extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr); 38extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr);
39extern void swiotlb_free_coherent (struct device *hwdev, size_t size, 39extern void swiotlb_free_coherent(struct device *hwdev, size_t size,
40 void *vaddr, dma_addr_t dma_handle); 40 void *vaddr, dma_addr_t dma_handle);
41extern int swiotlb_dma_supported(struct device *hwdev, u64 mask); 41extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
42extern void swiotlb_init(void); 42extern void swiotlb_init(void);
43 43
diff --git a/include/asm-x86/sync_bitops.h b/include/asm-x86/sync_bitops.h
index 6b775c905666..b47a1d0b8a83 100644
--- a/include/asm-x86/sync_bitops.h
+++ b/include/asm-x86/sync_bitops.h
@@ -13,7 +13,7 @@
13 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). 13 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
14 */ 14 */
15 15
16#define ADDR (*(volatile long *) addr) 16#define ADDR (*(volatile long *)addr)
17 17
18/** 18/**
19 * sync_set_bit - Atomically set a bit in memory 19 * sync_set_bit - Atomically set a bit in memory
@@ -26,12 +26,12 @@
26 * Note that @nr may be almost arbitrarily large; this function is not 26 * Note that @nr may be almost arbitrarily large; this function is not
27 * restricted to acting on a single-word quantity. 27 * restricted to acting on a single-word quantity.
28 */ 28 */
29static inline void sync_set_bit(int nr, volatile unsigned long * addr) 29static inline void sync_set_bit(int nr, volatile unsigned long *addr)
30{ 30{
31 __asm__ __volatile__("lock; btsl %1,%0" 31 asm volatile("lock; btsl %1,%0"
32 :"+m" (ADDR) 32 : "+m" (ADDR)
33 :"Ir" (nr) 33 : "Ir" (nr)
34 : "memory"); 34 : "memory");
35} 35}
36 36
37/** 37/**
@@ -44,12 +44,12 @@ static inline void sync_set_bit(int nr, volatile unsigned long * addr)
44 * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() 44 * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
45 * in order to ensure changes are visible on other processors. 45 * in order to ensure changes are visible on other processors.
46 */ 46 */
47static inline void sync_clear_bit(int nr, volatile unsigned long * addr) 47static inline void sync_clear_bit(int nr, volatile unsigned long *addr)
48{ 48{
49 __asm__ __volatile__("lock; btrl %1,%0" 49 asm volatile("lock; btrl %1,%0"
50 :"+m" (ADDR) 50 : "+m" (ADDR)
51 :"Ir" (nr) 51 : "Ir" (nr)
52 : "memory"); 52 : "memory");
53} 53}
54 54
55/** 55/**
@@ -61,12 +61,12 @@ static inline void sync_clear_bit(int nr, volatile unsigned long * addr)
61 * Note that @nr may be almost arbitrarily large; this function is not 61 * Note that @nr may be almost arbitrarily large; this function is not
62 * restricted to acting on a single-word quantity. 62 * restricted to acting on a single-word quantity.
63 */ 63 */
64static inline void sync_change_bit(int nr, volatile unsigned long * addr) 64static inline void sync_change_bit(int nr, volatile unsigned long *addr)
65{ 65{
66 __asm__ __volatile__("lock; btcl %1,%0" 66 asm volatile("lock; btcl %1,%0"
67 :"+m" (ADDR) 67 : "+m" (ADDR)
68 :"Ir" (nr) 68 : "Ir" (nr)
69 : "memory"); 69 : "memory");
70} 70}
71 71
72/** 72/**
@@ -77,13 +77,13 @@ static inline void sync_change_bit(int nr, volatile unsigned long * addr)
77 * This operation is atomic and cannot be reordered. 77 * This operation is atomic and cannot be reordered.
78 * It also implies a memory barrier. 78 * It also implies a memory barrier.
79 */ 79 */
80static inline int sync_test_and_set_bit(int nr, volatile unsigned long * addr) 80static inline int sync_test_and_set_bit(int nr, volatile unsigned long *addr)
81{ 81{
82 int oldbit; 82 int oldbit;
83 83
84 __asm__ __volatile__("lock; btsl %2,%1\n\tsbbl %0,%0" 84 asm volatile("lock; btsl %2,%1\n\tsbbl %0,%0"
85 :"=r" (oldbit),"+m" (ADDR) 85 : "=r" (oldbit), "+m" (ADDR)
86 :"Ir" (nr) : "memory"); 86 : "Ir" (nr) : "memory");
87 return oldbit; 87 return oldbit;
88} 88}
89 89
@@ -95,13 +95,13 @@ static inline int sync_test_and_set_bit(int nr, volatile unsigned long * addr)
95 * This operation is atomic and cannot be reordered. 95 * This operation is atomic and cannot be reordered.
96 * It also implies a memory barrier. 96 * It also implies a memory barrier.
97 */ 97 */
98static inline int sync_test_and_clear_bit(int nr, volatile unsigned long * addr) 98static inline int sync_test_and_clear_bit(int nr, volatile unsigned long *addr)
99{ 99{
100 int oldbit; 100 int oldbit;
101 101
102 __asm__ __volatile__("lock; btrl %2,%1\n\tsbbl %0,%0" 102 asm volatile("lock; btrl %2,%1\n\tsbbl %0,%0"
103 :"=r" (oldbit),"+m" (ADDR) 103 : "=r" (oldbit), "+m" (ADDR)
104 :"Ir" (nr) : "memory"); 104 : "Ir" (nr) : "memory");
105 return oldbit; 105 return oldbit;
106} 106}
107 107
@@ -113,36 +113,17 @@ static inline int sync_test_and_clear_bit(int nr, volatile unsigned long * addr)
113 * This operation is atomic and cannot be reordered. 113 * This operation is atomic and cannot be reordered.
114 * It also implies a memory barrier. 114 * It also implies a memory barrier.
115 */ 115 */
116static inline int sync_test_and_change_bit(int nr, volatile unsigned long* addr) 116static inline int sync_test_and_change_bit(int nr, volatile unsigned long *addr)
117{ 117{
118 int oldbit; 118 int oldbit;
119 119
120 __asm__ __volatile__("lock; btcl %2,%1\n\tsbbl %0,%0" 120 asm volatile("lock; btcl %2,%1\n\tsbbl %0,%0"
121 :"=r" (oldbit),"+m" (ADDR) 121 : "=r" (oldbit), "+m" (ADDR)
122 :"Ir" (nr) : "memory"); 122 : "Ir" (nr) : "memory");
123 return oldbit; 123 return oldbit;
124} 124}
125 125
126static __always_inline int sync_constant_test_bit(int nr, const volatile unsigned long *addr) 126#define sync_test_bit(nr, addr) test_bit(nr, addr)
127{
128 return ((1UL << (nr & 31)) &
129 (((const volatile unsigned int *)addr)[nr >> 5])) != 0;
130}
131
132static inline int sync_var_test_bit(int nr, const volatile unsigned long * addr)
133{
134 int oldbit;
135
136 __asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0"
137 :"=r" (oldbit)
138 :"m" (ADDR),"Ir" (nr));
139 return oldbit;
140}
141
142#define sync_test_bit(nr,addr) \
143 (__builtin_constant_p(nr) ? \
144 sync_constant_test_bit((nr),(addr)) : \
145 sync_var_test_bit((nr),(addr)))
146 127
147#undef ADDR 128#undef ADDR
148 129
diff --git a/include/asm-x86/system.h b/include/asm-x86/system.h
index 9cff02ffe6c2..a2f04cd79b29 100644
--- a/include/asm-x86/system.h
+++ b/include/asm-x86/system.h
@@ -27,22 +27,44 @@ struct task_struct *__switch_to(struct task_struct *prev,
27 * Saving eflags is important. It switches not only IOPL between tasks, 27 * Saving eflags is important. It switches not only IOPL between tasks,
28 * it also protects other tasks from NT leaking through sysenter etc. 28 * it also protects other tasks from NT leaking through sysenter etc.
29 */ 29 */
30#define switch_to(prev, next, last) do { \ 30#define switch_to(prev, next, last) \
31 unsigned long esi, edi; \ 31do { \
32 asm volatile("pushfl\n\t" /* Save flags */ \ 32 /* \
33 "pushl %%ebp\n\t" \ 33 * Context-switching clobbers all registers, so we clobber \
34 "movl %%esp,%0\n\t" /* save ESP */ \ 34 * them explicitly, via unused output variables. \
35 "movl %5,%%esp\n\t" /* restore ESP */ \ 35 * (EAX and EBP is not listed because EBP is saved/restored \
36 "movl $1f,%1\n\t" /* save EIP */ \ 36 * explicitly for wchan access and EAX is the return value of \
37 "pushl %6\n\t" /* restore EIP */ \ 37 * __switch_to()) \
38 "jmp __switch_to\n" \ 38 */ \
39 unsigned long ebx, ecx, edx, esi, edi; \
40 \
41 asm volatile("pushfl\n\t" /* save flags */ \
42 "pushl %%ebp\n\t" /* save EBP */ \
43 "movl %%esp,%[prev_sp]\n\t" /* save ESP */ \
44 "movl %[next_sp],%%esp\n\t" /* restore ESP */ \
45 "movl $1f,%[prev_ip]\n\t" /* save EIP */ \
46 "pushl %[next_ip]\n\t" /* restore EIP */ \
47 "jmp __switch_to\n" /* regparm call */ \
39 "1:\t" \ 48 "1:\t" \
40 "popl %%ebp\n\t" \ 49 "popl %%ebp\n\t" /* restore EBP */ \
41 "popfl" \ 50 "popfl\n" /* restore flags */ \
42 :"=m" (prev->thread.sp), "=m" (prev->thread.ip), \ 51 \
43 "=a" (last), "=S" (esi), "=D" (edi) \ 52 /* output parameters */ \
44 :"m" (next->thread.sp), "m" (next->thread.ip), \ 53 : [prev_sp] "=m" (prev->thread.sp), \
45 "2" (prev), "d" (next)); \ 54 [prev_ip] "=m" (prev->thread.ip), \
55 "=a" (last), \
56 \
57 /* clobbered output registers: */ \
58 "=b" (ebx), "=c" (ecx), "=d" (edx), \
59 "=S" (esi), "=D" (edi) \
60 \
61 /* input parameters: */ \
62 : [next_sp] "m" (next->thread.sp), \
63 [next_ip] "m" (next->thread.ip), \
64 \
65 /* regparm parameters for __switch_to(): */ \
66 [prev] "a" (prev), \
67 [next] "d" (next)); \
46} while (0) 68} while (0)
47 69
48/* 70/*
@@ -122,35 +144,34 @@ extern void load_gs_index(unsigned);
122 */ 144 */
123#define loadsegment(seg, value) \ 145#define loadsegment(seg, value) \
124 asm volatile("\n" \ 146 asm volatile("\n" \
125 "1:\t" \ 147 "1:\t" \
126 "movl %k0,%%" #seg "\n" \ 148 "movl %k0,%%" #seg "\n" \
127 "2:\n" \ 149 "2:\n" \
128 ".section .fixup,\"ax\"\n" \ 150 ".section .fixup,\"ax\"\n" \
129 "3:\t" \ 151 "3:\t" \
130 "movl %k1, %%" #seg "\n\t" \ 152 "movl %k1, %%" #seg "\n\t" \
131 "jmp 2b\n" \ 153 "jmp 2b\n" \
132 ".previous\n" \ 154 ".previous\n" \
133 _ASM_EXTABLE(1b,3b) \ 155 _ASM_EXTABLE(1b,3b) \
134 : :"r" (value), "r" (0)) 156 : :"r" (value), "r" (0))
135 157
136 158
137/* 159/*
138 * Save a segment register away 160 * Save a segment register away
139 */ 161 */
140#define savesegment(seg, value) \ 162#define savesegment(seg, value) \
141 asm volatile("mov %%" #seg ",%0":"=rm" (value)) 163 asm volatile("mov %%" #seg ",%0":"=rm" (value))
142 164
143static inline unsigned long get_limit(unsigned long segment) 165static inline unsigned long get_limit(unsigned long segment)
144{ 166{
145 unsigned long __limit; 167 unsigned long __limit;
146 __asm__("lsll %1,%0" 168 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
147 :"=r" (__limit):"r" (segment)); 169 return __limit + 1;
148 return __limit+1;
149} 170}
150 171
151static inline void native_clts(void) 172static inline void native_clts(void)
152{ 173{
153 asm volatile ("clts"); 174 asm volatile("clts");
154} 175}
155 176
156/* 177/*
@@ -165,43 +186,43 @@ static unsigned long __force_order;
165static inline unsigned long native_read_cr0(void) 186static inline unsigned long native_read_cr0(void)
166{ 187{
167 unsigned long val; 188 unsigned long val;
168 asm volatile("mov %%cr0,%0\n\t" :"=r" (val), "=m" (__force_order)); 189 asm volatile("mov %%cr0,%0\n\t" : "=r" (val), "=m" (__force_order));
169 return val; 190 return val;
170} 191}
171 192
172static inline void native_write_cr0(unsigned long val) 193static inline void native_write_cr0(unsigned long val)
173{ 194{
174 asm volatile("mov %0,%%cr0": :"r" (val), "m" (__force_order)); 195 asm volatile("mov %0,%%cr0": : "r" (val), "m" (__force_order));
175} 196}
176 197
177static inline unsigned long native_read_cr2(void) 198static inline unsigned long native_read_cr2(void)
178{ 199{
179 unsigned long val; 200 unsigned long val;
180 asm volatile("mov %%cr2,%0\n\t" :"=r" (val), "=m" (__force_order)); 201 asm volatile("mov %%cr2,%0\n\t" : "=r" (val), "=m" (__force_order));
181 return val; 202 return val;
182} 203}
183 204
184static inline void native_write_cr2(unsigned long val) 205static inline void native_write_cr2(unsigned long val)
185{ 206{
186 asm volatile("mov %0,%%cr2": :"r" (val), "m" (__force_order)); 207 asm volatile("mov %0,%%cr2": : "r" (val), "m" (__force_order));
187} 208}
188 209
189static inline unsigned long native_read_cr3(void) 210static inline unsigned long native_read_cr3(void)
190{ 211{
191 unsigned long val; 212 unsigned long val;
192 asm volatile("mov %%cr3,%0\n\t" :"=r" (val), "=m" (__force_order)); 213 asm volatile("mov %%cr3,%0\n\t" : "=r" (val), "=m" (__force_order));
193 return val; 214 return val;
194} 215}
195 216
196static inline void native_write_cr3(unsigned long val) 217static inline void native_write_cr3(unsigned long val)
197{ 218{
198 asm volatile("mov %0,%%cr3": :"r" (val), "m" (__force_order)); 219 asm volatile("mov %0,%%cr3": : "r" (val), "m" (__force_order));
199} 220}
200 221
201static inline unsigned long native_read_cr4(void) 222static inline unsigned long native_read_cr4(void)
202{ 223{
203 unsigned long val; 224 unsigned long val;
204 asm volatile("mov %%cr4,%0\n\t" :"=r" (val), "=m" (__force_order)); 225 asm volatile("mov %%cr4,%0\n\t" : "=r" (val), "=m" (__force_order));
205 return val; 226 return val;
206} 227}
207 228
@@ -213,7 +234,7 @@ static inline unsigned long native_read_cr4_safe(void)
213#ifdef CONFIG_X86_32 234#ifdef CONFIG_X86_32
214 asm volatile("1: mov %%cr4, %0\n" 235 asm volatile("1: mov %%cr4, %0\n"
215 "2:\n" 236 "2:\n"
216 _ASM_EXTABLE(1b,2b) 237 _ASM_EXTABLE(1b, 2b)
217 : "=r" (val), "=m" (__force_order) : "0" (0)); 238 : "=r" (val), "=m" (__force_order) : "0" (0));
218#else 239#else
219 val = native_read_cr4(); 240 val = native_read_cr4();
@@ -223,7 +244,7 @@ static inline unsigned long native_read_cr4_safe(void)
223 244
224static inline void native_write_cr4(unsigned long val) 245static inline void native_write_cr4(unsigned long val)
225{ 246{
226 asm volatile("mov %0,%%cr4": :"r" (val), "m" (__force_order)); 247 asm volatile("mov %0,%%cr4": : "r" (val), "m" (__force_order));
227} 248}
228 249
229#ifdef CONFIG_X86_64 250#ifdef CONFIG_X86_64
@@ -244,6 +265,7 @@ static inline void native_wbinvd(void)
244{ 265{
245 asm volatile("wbinvd": : :"memory"); 266 asm volatile("wbinvd": : :"memory");
246} 267}
268
247#ifdef CONFIG_PARAVIRT 269#ifdef CONFIG_PARAVIRT
248#include <asm/paravirt.h> 270#include <asm/paravirt.h>
249#else 271#else
@@ -276,7 +298,7 @@ static inline void clflush(volatile void *__p)
276 asm volatile("clflush %0" : "+m" (*(volatile char __force *)__p)); 298 asm volatile("clflush %0" : "+m" (*(volatile char __force *)__p));
277} 299}
278 300
279#define nop() __asm__ __volatile__ ("nop") 301#define nop() asm volatile ("nop")
280 302
281void disable_hlt(void); 303void disable_hlt(void);
282void enable_hlt(void); 304void enable_hlt(void);
@@ -296,16 +318,7 @@ void default_idle(void);
296 */ 318 */
297#ifdef CONFIG_X86_32 319#ifdef CONFIG_X86_32
298/* 320/*
299 * For now, "wmb()" doesn't actually do anything, as all 321 * Some non-Intel clones support out of order store. wmb() ceases to be a
300 * Intel CPU's follow what Intel calls a *Processor Order*,
301 * in which all writes are seen in the program order even
302 * outside the CPU.
303 *
304 * I expect future Intel CPU's to have a weaker ordering,
305 * but I'd also expect them to finally get their act together
306 * and add some real memory barriers if so.
307 *
308 * Some non intel clones support out of order store. wmb() ceases to be a
309 * nop for these. 322 * nop for these.
310 */ 323 */
311#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) 324#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
@@ -384,7 +397,7 @@ void default_idle(void);
384# define smp_wmb() barrier() 397# define smp_wmb() barrier()
385#endif 398#endif
386#define smp_read_barrier_depends() read_barrier_depends() 399#define smp_read_barrier_depends() read_barrier_depends()
387#define set_mb(var, value) do { (void) xchg(&var, value); } while (0) 400#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
388#else 401#else
389#define smp_mb() barrier() 402#define smp_mb() barrier()
390#define smp_rmb() barrier() 403#define smp_rmb() barrier()
diff --git a/include/asm-x86/tce.h b/include/asm-x86/tce.h
index cd955d3d112f..b1a4ea00df78 100644
--- a/include/asm-x86/tce.h
+++ b/include/asm-x86/tce.h
@@ -39,7 +39,7 @@ struct iommu_table;
39#define TCE_RPN_MASK 0x0000fffffffff000ULL 39#define TCE_RPN_MASK 0x0000fffffffff000ULL
40 40
41extern void tce_build(struct iommu_table *tbl, unsigned long index, 41extern void tce_build(struct iommu_table *tbl, unsigned long index,
42 unsigned int npages, unsigned long uaddr, int direction); 42 unsigned int npages, unsigned long uaddr, int direction);
43extern void tce_free(struct iommu_table *tbl, long index, unsigned int npages); 43extern void tce_free(struct iommu_table *tbl, long index, unsigned int npages);
44extern void * __init alloc_tce_table(void); 44extern void * __init alloc_tce_table(void);
45extern void __init free_tce_table(void *tbl); 45extern void __init free_tce_table(void *tbl);
diff --git a/include/asm-x86/thread_info.h b/include/asm-x86/thread_info.h
index d5fd12f2abdb..77244f17993f 100644
--- a/include/asm-x86/thread_info.h
+++ b/include/asm-x86/thread_info.h
@@ -1,5 +1,14 @@
1#ifndef _ASM_X86_THREAD_INFO_H
1#ifdef CONFIG_X86_32 2#ifdef CONFIG_X86_32
2# include "thread_info_32.h" 3# include "thread_info_32.h"
3#else 4#else
4# include "thread_info_64.h" 5# include "thread_info_64.h"
5#endif 6#endif
7
8#ifndef __ASSEMBLY__
9extern void arch_task_cache_init(void);
10extern void free_thread_info(struct thread_info *ti);
11extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
12#define arch_task_cache_init arch_task_cache_init
13#endif
14#endif /* _ASM_X86_THREAD_INFO_H */
diff --git a/include/asm-x86/thread_info_32.h b/include/asm-x86/thread_info_32.h
index 5bd508260ffb..b6338829d1a8 100644
--- a/include/asm-x86/thread_info_32.h
+++ b/include/asm-x86/thread_info_32.h
@@ -20,7 +20,8 @@
20 * low level task data that entry.S needs immediate access to 20 * low level task data that entry.S needs immediate access to
21 * - this struct should fit entirely inside of one cache line 21 * - this struct should fit entirely inside of one cache line
22 * - this struct shares the supervisor stack pages 22 * - this struct shares the supervisor stack pages
23 * - if the contents of this structure are changed, the assembly constants must also be changed 23 * - if the contents of this structure are changed,
24 * the assembly constants must also be changed
24 */ 25 */
25#ifndef __ASSEMBLY__ 26#ifndef __ASSEMBLY__
26 27
@@ -30,18 +31,16 @@ struct thread_info {
30 unsigned long flags; /* low level flags */ 31 unsigned long flags; /* low level flags */
31 unsigned long status; /* thread-synchronous flags */ 32 unsigned long status; /* thread-synchronous flags */
32 __u32 cpu; /* current CPU */ 33 __u32 cpu; /* current CPU */
33 int preempt_count; /* 0 => preemptable, <0 => BUG */ 34 int preempt_count; /* 0 => preemptable,
34 35 <0 => BUG */
35
36 mm_segment_t addr_limit; /* thread address space: 36 mm_segment_t addr_limit; /* thread address space:
37 0-0xBFFFFFFF for user-thead 37 0-0xBFFFFFFF user-thread
38 0-0xFFFFFFFF for kernel-thread 38 0-0xFFFFFFFF kernel-thread
39 */ 39 */
40 void *sysenter_return; 40 void *sysenter_return;
41 struct restart_block restart_block; 41 struct restart_block restart_block;
42 42 unsigned long previous_esp; /* ESP of the previous stack in
43 unsigned long previous_esp; /* ESP of the previous stack in case 43 case of nested (IRQ) stacks
44 of nested (IRQ) stacks
45 */ 44 */
46 __u8 supervisor_stack[0]; 45 __u8 supervisor_stack[0];
47}; 46};
@@ -90,24 +89,23 @@ register unsigned long current_stack_pointer asm("esp") __used;
90/* how to get the thread information struct from C */ 89/* how to get the thread information struct from C */
91static inline struct thread_info *current_thread_info(void) 90static inline struct thread_info *current_thread_info(void)
92{ 91{
93 return (struct thread_info *)(current_stack_pointer & ~(THREAD_SIZE - 1)); 92 return (struct thread_info *)
93 (current_stack_pointer & ~(THREAD_SIZE - 1));
94} 94}
95 95
96/* thread information allocation */ 96/* thread information allocation */
97#ifdef CONFIG_DEBUG_STACK_USAGE 97#ifdef CONFIG_DEBUG_STACK_USAGE
98#define alloc_thread_info(tsk) ((struct thread_info *) \ 98#define alloc_thread_info(tsk) ((struct thread_info *) \
99 __get_free_pages(GFP_KERNEL| __GFP_ZERO, get_order(THREAD_SIZE))) 99 __get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(THREAD_SIZE)))
100#else 100#else
101#define alloc_thread_info(tsk) ((struct thread_info *) \ 101#define alloc_thread_info(tsk) ((struct thread_info *) \
102 __get_free_pages(GFP_KERNEL, get_order(THREAD_SIZE))) 102 __get_free_pages(GFP_KERNEL, get_order(THREAD_SIZE)))
103#endif 103#endif
104 104
105#define free_thread_info(info) free_pages((unsigned long)(info), get_order(THREAD_SIZE))
106
107#else /* !__ASSEMBLY__ */ 105#else /* !__ASSEMBLY__ */
108 106
109/* how to get the thread information struct from ASM */ 107/* how to get the thread information struct from ASM */
110#define GET_THREAD_INFO(reg) \ 108#define GET_THREAD_INFO(reg) \
111 movl $-THREAD_SIZE, reg; \ 109 movl $-THREAD_SIZE, reg; \
112 andl %esp, reg 110 andl %esp, reg
113 111
@@ -119,19 +117,20 @@ static inline struct thread_info *current_thread_info(void)
119 117
120/* 118/*
121 * thread information flags 119 * thread information flags
122 * - these are process state flags that various assembly files may need to access 120 * - these are process state flags that various
121 * assembly files may need to access
123 * - pending work-to-be-done flags are in LSW 122 * - pending work-to-be-done flags are in LSW
124 * - other flags in MSW 123 * - other flags in MSW
125 */ 124 */
126#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 125#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
127#define TIF_SIGPENDING 1 /* signal pending */ 126#define TIF_SIGPENDING 1 /* signal pending */
128#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 127#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
129#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */ 128#define TIF_SINGLESTEP 3 /* restore singlestep on return to
129 user mode */
130#define TIF_IRET 4 /* return with iret */ 130#define TIF_IRET 4 /* return with iret */
131#define TIF_SYSCALL_EMU 5 /* syscall emulation active */ 131#define TIF_SYSCALL_EMU 5 /* syscall emulation active */
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() */
135#define TIF_HRTICK_RESCHED 9 /* reprogram hrtick timer */ 134#define TIF_HRTICK_RESCHED 9 /* reprogram hrtick timer */
136#define TIF_MEMDIE 16 135#define TIF_MEMDIE 16
137#define TIF_DEBUG 17 /* uses debug registers */ 136#define TIF_DEBUG 17 /* uses debug registers */
@@ -143,36 +142,35 @@ static inline struct thread_info *current_thread_info(void)
143#define TIF_DS_AREA_MSR 23 /* uses thread_struct.ds_area_msr */ 142#define TIF_DS_AREA_MSR 23 /* uses thread_struct.ds_area_msr */
144#define TIF_BTS_TRACE_TS 24 /* record scheduling event timestamps */ 143#define TIF_BTS_TRACE_TS 24 /* record scheduling event timestamps */
145 144
146#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 145#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
147#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 146#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
148#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 147#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
149#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 148#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
150#define _TIF_IRET (1<<TIF_IRET) 149#define _TIF_IRET (1 << TIF_IRET)
151#define _TIF_SYSCALL_EMU (1<<TIF_SYSCALL_EMU) 150#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)
152#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 151#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
153#define _TIF_SECCOMP (1<<TIF_SECCOMP) 152#define _TIF_SECCOMP (1 << TIF_SECCOMP)
154#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 153#define _TIF_HRTICK_RESCHED (1 << TIF_HRTICK_RESCHED)
155#define _TIF_HRTICK_RESCHED (1<<TIF_HRTICK_RESCHED) 154#define _TIF_DEBUG (1 << TIF_DEBUG)
156#define _TIF_DEBUG (1<<TIF_DEBUG) 155#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)
157#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) 156#define _TIF_FREEZE (1 << TIF_FREEZE)
158#define _TIF_FREEZE (1<<TIF_FREEZE) 157#define _TIF_NOTSC (1 << TIF_NOTSC)
159#define _TIF_NOTSC (1<<TIF_NOTSC) 158#define _TIF_FORCED_TF (1 << TIF_FORCED_TF)
160#define _TIF_FORCED_TF (1<<TIF_FORCED_TF) 159#define _TIF_DEBUGCTLMSR (1 << TIF_DEBUGCTLMSR)
161#define _TIF_DEBUGCTLMSR (1<<TIF_DEBUGCTLMSR) 160#define _TIF_DS_AREA_MSR (1 << TIF_DS_AREA_MSR)
162#define _TIF_DS_AREA_MSR (1<<TIF_DS_AREA_MSR) 161#define _TIF_BTS_TRACE_TS (1 << TIF_BTS_TRACE_TS)
163#define _TIF_BTS_TRACE_TS (1<<TIF_BTS_TRACE_TS)
164 162
165/* work to do on interrupt/exception return */ 163/* work to do on interrupt/exception return */
166#define _TIF_WORK_MASK \ 164#define _TIF_WORK_MASK \
167 (0x0000FFFF & ~(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ 165 (0x0000FFFF & ~(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
168 _TIF_SECCOMP | _TIF_SYSCALL_EMU)) 166 _TIF_SECCOMP | _TIF_SYSCALL_EMU))
169/* work to do on any return to u-space */ 167/* work to do on any return to u-space */
170#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP) 168#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP)
171 169
172/* flags to check in __switch_to() */ 170/* flags to check in __switch_to() */
173#define _TIF_WORK_CTXSW \ 171#define _TIF_WORK_CTXSW \
174 (_TIF_IO_BITMAP | _TIF_NOTSC | _TIF_DEBUGCTLMSR | \ 172 (_TIF_IO_BITMAP | _TIF_NOTSC | _TIF_DEBUGCTLMSR | \
175 _TIF_DS_AREA_MSR | _TIF_BTS_TRACE_TS) 173 _TIF_DS_AREA_MSR | _TIF_BTS_TRACE_TS)
176#define _TIF_WORK_CTXSW_PREV _TIF_WORK_CTXSW 174#define _TIF_WORK_CTXSW_PREV _TIF_WORK_CTXSW
177#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW | _TIF_DEBUG) 175#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW | _TIF_DEBUG)
178 176
@@ -184,11 +182,24 @@ static inline struct thread_info *current_thread_info(void)
184 * ever touches our thread-synchronous status, so we don't 182 * ever touches our thread-synchronous status, so we don't
185 * have to worry about atomic accesses. 183 * have to worry about atomic accesses.
186 */ 184 */
187#define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */ 185#define TS_USEDFPU 0x0001 /* FPU was used by this task
188#define TS_POLLING 0x0002 /* True if in idle loop and not sleeping */ 186 this quantum (SMP) */
187#define TS_POLLING 0x0002 /* True if in idle loop
188 and not sleeping */
189#define TS_RESTORE_SIGMASK 0x0004 /* restore signal mask in do_signal() */
189 190
190#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) 191#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
191 192
193#ifndef __ASSEMBLY__
194#define HAVE_SET_RESTORE_SIGMASK 1
195static inline void set_restore_sigmask(void)
196{
197 struct thread_info *ti = current_thread_info();
198 ti->status |= TS_RESTORE_SIGMASK;
199 set_bit(TIF_SIGPENDING, &ti->flags);
200}
201#endif /* !__ASSEMBLY__ */
202
192#endif /* __KERNEL__ */ 203#endif /* __KERNEL__ */
193 204
194#endif /* _ASM_THREAD_INFO_H */ 205#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/asm-x86/thread_info_64.h b/include/asm-x86/thread_info_64.h
index 6c9b214b8fc3..cb69f70abba1 100644
--- a/include/asm-x86/thread_info_64.h
+++ b/include/asm-x86/thread_info_64.h
@@ -29,9 +29,9 @@ struct thread_info {
29 __u32 flags; /* low level flags */ 29 __u32 flags; /* low level flags */
30 __u32 status; /* thread synchronous flags */ 30 __u32 status; /* thread synchronous flags */
31 __u32 cpu; /* current CPU */ 31 __u32 cpu; /* current CPU */
32 int preempt_count; /* 0 => preemptable, <0 => BUG */ 32 int preempt_count; /* 0 => preemptable,
33 33 <0 => BUG */
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 36#ifdef CONFIG_IA32_EMULATION
37 void __user *sysenter_return; 37 void __user *sysenter_return;
@@ -61,17 +61,17 @@ struct thread_info {
61#define init_stack (init_thread_union.stack) 61#define init_stack (init_thread_union.stack)
62 62
63static inline struct thread_info *current_thread_info(void) 63static inline struct thread_info *current_thread_info(void)
64{ 64{
65 struct thread_info *ti; 65 struct thread_info *ti;
66 ti = (void *)(read_pda(kernelstack) + PDA_STACKOFFSET - THREAD_SIZE); 66 ti = (void *)(read_pda(kernelstack) + PDA_STACKOFFSET - THREAD_SIZE);
67 return ti; 67 return ti;
68} 68}
69 69
70/* do not use in interrupt context */ 70/* do not use in interrupt context */
71static inline struct thread_info *stack_thread_info(void) 71static inline struct thread_info *stack_thread_info(void)
72{ 72{
73 struct thread_info *ti; 73 struct thread_info *ti;
74 __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (~(THREAD_SIZE - 1))); 74 asm("andq %%rsp,%0; " : "=r" (ti) : "0" (~(THREAD_SIZE - 1)));
75 return ti; 75 return ti;
76} 76}
77 77
@@ -82,10 +82,8 @@ static inline struct thread_info *stack_thread_info(void)
82#define THREAD_FLAGS GFP_KERNEL 82#define THREAD_FLAGS GFP_KERNEL
83#endif 83#endif
84 84
85#define alloc_thread_info(tsk) \ 85#define alloc_thread_info(tsk) \
86 ((struct thread_info *) __get_free_pages(THREAD_FLAGS, THREAD_ORDER)) 86 ((struct thread_info *)__get_free_pages(THREAD_FLAGS, THREAD_ORDER))
87
88#define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_ORDER)
89 87
90#else /* !__ASSEMBLY__ */ 88#else /* !__ASSEMBLY__ */
91 89
@@ -98,7 +96,8 @@ static inline struct thread_info *stack_thread_info(void)
98 96
99/* 97/*
100 * thread information flags 98 * thread information flags
101 * - these are process state flags that various assembly files may need to access 99 * - these are process state flags that various assembly files
100 * may need to access
102 * - pending work-to-be-done flags are in LSW 101 * - pending work-to-be-done flags are in LSW
103 * - other flags in MSW 102 * - other flags in MSW
104 * Warning: layout of LSW is hardcoded in entry.S 103 * Warning: layout of LSW is hardcoded in entry.S
@@ -110,11 +109,10 @@ static inline struct thread_info *stack_thread_info(void)
110#define TIF_IRET 5 /* force IRET */ 109#define TIF_IRET 5 /* force IRET */
111#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 110#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
112#define TIF_SECCOMP 8 /* secure computing */ 111#define TIF_SECCOMP 8 /* secure computing */
113#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */
114#define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */ 112#define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */
115#define TIF_HRTICK_RESCHED 11 /* reprogram hrtick timer */ 113#define TIF_HRTICK_RESCHED 11 /* reprogram hrtick timer */
116/* 16 free */ 114/* 16 free */
117#define TIF_IA32 17 /* 32bit process */ 115#define TIF_IA32 17 /* 32bit process */
118#define TIF_FORK 18 /* ret_from_fork */ 116#define TIF_FORK 18 /* ret_from_fork */
119#define TIF_ABI_PENDING 19 117#define TIF_ABI_PENDING 19
120#define TIF_MEMDIE 20 118#define TIF_MEMDIE 20
@@ -125,40 +123,42 @@ static inline struct thread_info *stack_thread_info(void)
125#define TIF_DEBUGCTLMSR 25 /* uses thread_struct.debugctlmsr */ 123#define TIF_DEBUGCTLMSR 25 /* uses thread_struct.debugctlmsr */
126#define TIF_DS_AREA_MSR 26 /* uses thread_struct.ds_area_msr */ 124#define TIF_DS_AREA_MSR 26 /* uses thread_struct.ds_area_msr */
127#define TIF_BTS_TRACE_TS 27 /* record scheduling event timestamps */ 125#define TIF_BTS_TRACE_TS 27 /* record scheduling event timestamps */
128 126#define TIF_NOTSC 28 /* TSC is not accessible in userland */
129#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 127
130#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 128#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
131#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 129#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
132#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 130#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
133#define _TIF_IRET (1<<TIF_IRET) 131#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
134#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 132#define _TIF_IRET (1 << TIF_IRET)
135#define _TIF_SECCOMP (1<<TIF_SECCOMP) 133#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
136#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 134#define _TIF_SECCOMP (1 << TIF_SECCOMP)
137#define _TIF_MCE_NOTIFY (1<<TIF_MCE_NOTIFY) 135#define _TIF_MCE_NOTIFY (1 << TIF_MCE_NOTIFY)
138#define _TIF_HRTICK_RESCHED (1<<TIF_HRTICK_RESCHED) 136#define _TIF_HRTICK_RESCHED (1 << TIF_HRTICK_RESCHED)
139#define _TIF_IA32 (1<<TIF_IA32) 137#define _TIF_IA32 (1 << TIF_IA32)
140#define _TIF_FORK (1<<TIF_FORK) 138#define _TIF_FORK (1 << TIF_FORK)
141#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 139#define _TIF_ABI_PENDING (1 << TIF_ABI_PENDING)
142#define _TIF_DEBUG (1<<TIF_DEBUG) 140#define _TIF_DEBUG (1 << TIF_DEBUG)
143#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) 141#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)
144#define _TIF_FREEZE (1<<TIF_FREEZE) 142#define _TIF_FREEZE (1 << TIF_FREEZE)
145#define _TIF_FORCED_TF (1<<TIF_FORCED_TF) 143#define _TIF_FORCED_TF (1 << TIF_FORCED_TF)
146#define _TIF_DEBUGCTLMSR (1<<TIF_DEBUGCTLMSR) 144#define _TIF_DEBUGCTLMSR (1 << TIF_DEBUGCTLMSR)
147#define _TIF_DS_AREA_MSR (1<<TIF_DS_AREA_MSR) 145#define _TIF_DS_AREA_MSR (1 << TIF_DS_AREA_MSR)
148#define _TIF_BTS_TRACE_TS (1<<TIF_BTS_TRACE_TS) 146#define _TIF_BTS_TRACE_TS (1 << TIF_BTS_TRACE_TS)
147#define _TIF_NOTSC (1 << TIF_NOTSC)
149 148
150/* work to do on interrupt/exception return */ 149/* work to do on interrupt/exception return */
151#define _TIF_WORK_MASK \ 150#define _TIF_WORK_MASK \
152 (0x0000FFFF & ~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP|_TIF_SECCOMP)) 151 (0x0000FFFF & \
152 ~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP|_TIF_SECCOMP))
153/* work to do on any return to user space */ 153/* work to do on any return to user space */
154#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP) 154#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP)
155 155
156#define _TIF_DO_NOTIFY_MASK \ 156#define _TIF_DO_NOTIFY_MASK \
157 (_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY|_TIF_HRTICK_RESCHED) 157 (_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY|_TIF_HRTICK_RESCHED)
158 158
159/* flags to check in __switch_to() */ 159/* flags to check in __switch_to() */
160#define _TIF_WORK_CTXSW \ 160#define _TIF_WORK_CTXSW \
161 (_TIF_IO_BITMAP|_TIF_DEBUGCTLMSR|_TIF_DS_AREA_MSR|_TIF_BTS_TRACE_TS) 161 (_TIF_IO_BITMAP|_TIF_DEBUGCTLMSR|_TIF_DS_AREA_MSR|_TIF_BTS_TRACE_TS|_TIF_NOTSC)
162#define _TIF_WORK_CTXSW_PREV _TIF_WORK_CTXSW 162#define _TIF_WORK_CTXSW_PREV _TIF_WORK_CTXSW
163#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW|_TIF_DEBUG) 163#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW|_TIF_DEBUG)
164 164
@@ -171,12 +171,25 @@ static inline struct thread_info *stack_thread_info(void)
171 * ever touches our thread-synchronous status, so we don't 171 * ever touches our thread-synchronous status, so we don't
172 * have to worry about atomic accesses. 172 * have to worry about atomic accesses.
173 */ 173 */
174#define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */ 174#define TS_USEDFPU 0x0001 /* FPU was used by this task
175 this quantum (SMP) */
175#define TS_COMPAT 0x0002 /* 32bit syscall active */ 176#define TS_COMPAT 0x0002 /* 32bit syscall active */
176#define TS_POLLING 0x0004 /* true if in idle loop and not sleeping */ 177#define TS_POLLING 0x0004 /* true if in idle loop
178 and not sleeping */
179#define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */
177 180
178#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) 181#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
179 182
183#ifndef __ASSEMBLY__
184#define HAVE_SET_RESTORE_SIGMASK 1
185static inline void set_restore_sigmask(void)
186{
187 struct thread_info *ti = current_thread_info();
188 ti->status |= TS_RESTORE_SIGMASK;
189 set_bit(TIF_SIGPENDING, &ti->flags);
190}
191#endif /* !__ASSEMBLY__ */
192
180#endif /* __KERNEL__ */ 193#endif /* __KERNEL__ */
181 194
182#endif /* _ASM_THREAD_INFO_H */ 195#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/asm-x86/time.h b/include/asm-x86/time.h
index 68779b048a3e..bce72d7a958c 100644
--- a/include/asm-x86/time.h
+++ b/include/asm-x86/time.h
@@ -1,7 +1,6 @@
1#ifndef _ASMX86_TIME_H 1#ifndef _ASMX86_TIME_H
2#define _ASMX86_TIME_H 2#define _ASMX86_TIME_H
3 3
4extern void (*late_time_init)(void);
5extern void hpet_time_init(void); 4extern void hpet_time_init(void);
6 5
7#include <asm/mc146818rtc.h> 6#include <asm/mc146818rtc.h>
diff --git a/include/asm-x86/tlbflush.h b/include/asm-x86/tlbflush.h
index 3998709ed637..0c0674d94255 100644
--- a/include/asm-x86/tlbflush.h
+++ b/include/asm-x86/tlbflush.h
@@ -32,7 +32,7 @@ static inline void __native_flush_tlb_global(void)
32 32
33static inline void __native_flush_tlb_single(unsigned long addr) 33static inline void __native_flush_tlb_single(unsigned long addr)
34{ 34{
35 __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory"); 35 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
36} 36}
37 37
38static inline void __flush_tlb_all(void) 38static inline void __flush_tlb_all(void)
@@ -134,8 +134,7 @@ void native_flush_tlb_others(const cpumask_t *cpumask, struct mm_struct *mm,
134#define TLBSTATE_LAZY 2 134#define TLBSTATE_LAZY 2
135 135
136#ifdef CONFIG_X86_32 136#ifdef CONFIG_X86_32
137struct tlb_state 137struct tlb_state {
138{
139 struct mm_struct *active_mm; 138 struct mm_struct *active_mm;
140 int state; 139 int state;
141 char __cacheline_padding[L1_CACHE_BYTES-8]; 140 char __cacheline_padding[L1_CACHE_BYTES-8];
diff --git a/include/asm-x86/topology.h b/include/asm-x86/topology.h
index 8af05a93f097..4f35a0fb4f22 100644
--- a/include/asm-x86/topology.h
+++ b/include/asm-x86/topology.h
@@ -32,13 +32,18 @@
32/* Mappings between logical cpu number and node number */ 32/* Mappings between logical cpu number and node number */
33#ifdef CONFIG_X86_32 33#ifdef CONFIG_X86_32
34extern int cpu_to_node_map[]; 34extern int cpu_to_node_map[];
35
36#else 35#else
36/* Returns the number of the current Node. */
37#define numa_node_id() (early_cpu_to_node(raw_smp_processor_id()))
38#endif
39
37DECLARE_PER_CPU(int, x86_cpu_to_node_map); 40DECLARE_PER_CPU(int, x86_cpu_to_node_map);
41
42#ifdef CONFIG_SMP
38extern int x86_cpu_to_node_map_init[]; 43extern int x86_cpu_to_node_map_init[];
39extern void *x86_cpu_to_node_map_early_ptr; 44extern void *x86_cpu_to_node_map_early_ptr;
40/* Returns the number of the current Node. */ 45#else
41#define numa_node_id() (early_cpu_to_node(raw_smp_processor_id())) 46#define x86_cpu_to_node_map_early_ptr NULL
42#endif 47#endif
43 48
44extern cpumask_t node_to_cpumask_map[]; 49extern cpumask_t node_to_cpumask_map[];
@@ -54,6 +59,8 @@ static inline int cpu_to_node(int cpu)
54} 59}
55 60
56#else /* CONFIG_X86_64 */ 61#else /* CONFIG_X86_64 */
62
63#ifdef CONFIG_SMP
57static inline int early_cpu_to_node(int cpu) 64static inline int early_cpu_to_node(int cpu)
58{ 65{
59 int *cpu_to_node_map = x86_cpu_to_node_map_early_ptr; 66 int *cpu_to_node_map = x86_cpu_to_node_map_early_ptr;
@@ -65,22 +72,33 @@ static inline int early_cpu_to_node(int cpu)
65 else 72 else
66 return NUMA_NO_NODE; 73 return NUMA_NO_NODE;
67} 74}
75#else
76#define early_cpu_to_node(cpu) cpu_to_node(cpu)
77#endif
68 78
69static inline int cpu_to_node(int cpu) 79static inline int cpu_to_node(int cpu)
70{ 80{
71#ifdef CONFIG_DEBUG_PER_CPU_MAPS 81#ifdef CONFIG_DEBUG_PER_CPU_MAPS
72 if (x86_cpu_to_node_map_early_ptr) { 82 if (x86_cpu_to_node_map_early_ptr) {
73 printk("KERN_NOTICE cpu_to_node(%d): usage too early!\n", 83 printk("KERN_NOTICE cpu_to_node(%d): usage too early!\n",
74 (int)cpu); 84 (int)cpu);
75 dump_stack(); 85 dump_stack();
76 return ((int *)x86_cpu_to_node_map_early_ptr)[cpu]; 86 return ((int *)x86_cpu_to_node_map_early_ptr)[cpu];
77 } 87 }
78#endif 88#endif
79 if (per_cpu_offset(cpu)) 89 return per_cpu(x86_cpu_to_node_map, cpu);
80 return per_cpu(x86_cpu_to_node_map, cpu);
81 else
82 return NUMA_NO_NODE;
83} 90}
91
92#ifdef CONFIG_NUMA
93
94/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
95#define node_to_cpumask_ptr(v, node) \
96 cpumask_t *v = &(node_to_cpumask_map[node])
97
98#define node_to_cpumask_ptr_next(v, node) \
99 v = &(node_to_cpumask_map[node])
100#endif
101
84#endif /* CONFIG_X86_64 */ 102#endif /* CONFIG_X86_64 */
85 103
86/* 104/*
@@ -129,17 +147,13 @@ extern unsigned long node_remap_size[];
129 147
130# define SD_CACHE_NICE_TRIES 2 148# define SD_CACHE_NICE_TRIES 2
131# define SD_IDLE_IDX 2 149# define SD_IDLE_IDX 2
132# define SD_NEWIDLE_IDX 0 150# define SD_NEWIDLE_IDX 2
133# define SD_FORKEXEC_IDX 1 151# define SD_FORKEXEC_IDX 1
134 152
135#endif 153#endif
136 154
137/* sched_domains SD_NODE_INIT for NUMAQ machines */ 155/* sched_domains SD_NODE_INIT for NUMAQ machines */
138#define SD_NODE_INIT (struct sched_domain) { \ 156#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, \ 157 .min_interval = 8, \
144 .max_interval = 32, \ 158 .max_interval = 32, \
145 .busy_factor = 32, \ 159 .busy_factor = 32, \
@@ -157,7 +171,6 @@ extern unsigned long node_remap_size[];
157 | SD_WAKE_BALANCE, \ 171 | SD_WAKE_BALANCE, \
158 .last_balance = jiffies, \ 172 .last_balance = jiffies, \
159 .balance_interval = 1, \ 173 .balance_interval = 1, \
160 .nr_balance_failed = 0, \
161} 174}
162 175
163#ifdef CONFIG_X86_64_ACPI_NUMA 176#ifdef CONFIG_X86_64_ACPI_NUMA
@@ -167,10 +180,10 @@ extern int __node_distance(int, int);
167 180
168#else /* CONFIG_NUMA */ 181#else /* CONFIG_NUMA */
169 182
170#include <asm-generic/topology.h>
171
172#endif 183#endif
173 184
185#include <asm-generic/topology.h>
186
174extern cpumask_t cpu_coregroup_map(int cpu); 187extern cpumask_t cpu_coregroup_map(int cpu);
175 188
176#ifdef ENABLE_TOPO_DEFINES 189#ifdef ENABLE_TOPO_DEFINES
@@ -180,9 +193,29 @@ extern cpumask_t cpu_coregroup_map(int cpu);
180#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu)) 193#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
181#endif 194#endif
182 195
196static inline void arch_fix_phys_package_id(int num, u32 slot)
197{
198}
199
200struct pci_bus;
201void set_pci_bus_resources_arch_default(struct pci_bus *b);
202
183#ifdef CONFIG_SMP 203#ifdef CONFIG_SMP
184#define mc_capable() (boot_cpu_data.x86_max_cores > 1) 204#define mc_capable() (boot_cpu_data.x86_max_cores > 1)
185#define smt_capable() (smp_num_siblings > 1) 205#define smt_capable() (smp_num_siblings > 1)
186#endif 206#endif
187 207
208#ifdef CONFIG_NUMA
209extern int get_mp_bus_to_node(int busnum);
210extern void set_mp_bus_to_node(int busnum, int node);
211#else
212static inline int get_mp_bus_to_node(int busnum)
213{
214 return 0;
215}
216static inline void set_mp_bus_to_node(int busnum, int node)
217{
218}
219#endif
220
188#endif 221#endif
diff --git a/include/asm-x86/trampoline.h b/include/asm-x86/trampoline.h
new file mode 100644
index 000000000000..b156b08d0131
--- /dev/null
+++ b/include/asm-x86/trampoline.h
@@ -0,0 +1,21 @@
1#ifndef __TRAMPOLINE_HEADER
2#define __TRAMPOLINE_HEADER
3
4#ifndef __ASSEMBLY__
5
6/*
7 * Trampoline 80x86 program as an array.
8 */
9extern const unsigned char trampoline_data [];
10extern const unsigned char trampoline_end [];
11extern unsigned char *trampoline_base;
12
13extern unsigned long init_rsp;
14extern unsigned long initial_code;
15
16#define TRAMPOLINE_BASE 0x6000
17extern unsigned long setup_trampoline(void);
18
19#endif /* __ASSEMBLY__ */
20
21#endif /* __TRAMPOLINE_HEADER */
diff --git a/include/asm-x86/tsc.h b/include/asm-x86/tsc.h
index 7d3e27f7d484..548873ab5fc1 100644
--- a/include/asm-x86/tsc.h
+++ b/include/asm-x86/tsc.h
@@ -32,7 +32,7 @@ static inline cycles_t get_cycles(void)
32 return ret; 32 return ret;
33} 33}
34 34
35static inline cycles_t vget_cycles(void) 35static __always_inline cycles_t vget_cycles(void)
36{ 36{
37 /* 37 /*
38 * We only do VDSOs on TSC capable CPUs, so this shouldnt 38 * We only do VDSOs on TSC capable CPUs, so this shouldnt
@@ -42,7 +42,7 @@ static inline cycles_t vget_cycles(void)
42 if (!cpu_has_tsc) 42 if (!cpu_has_tsc)
43 return 0; 43 return 0;
44#endif 44#endif
45 return (cycles_t) __native_read_tsc(); 45 return (cycles_t)__native_read_tsc();
46} 46}
47 47
48extern void tsc_init(void); 48extern void tsc_init(void);
diff --git a/include/asm-x86/uaccess_32.h b/include/asm-x86/uaccess_32.h
index fcc570ec4fee..8e7595c1f34e 100644
--- a/include/asm-x86/uaccess_32.h
+++ b/include/asm-x86/uaccess_32.h
@@ -32,7 +32,7 @@
32#define get_fs() (current_thread_info()->addr_limit) 32#define get_fs() (current_thread_info()->addr_limit)
33#define set_fs(x) (current_thread_info()->addr_limit = (x)) 33#define set_fs(x) (current_thread_info()->addr_limit = (x))
34 34
35#define segment_eq(a,b) ((a).seg == (b).seg) 35#define segment_eq(a, b) ((a).seg == (b).seg)
36 36
37/* 37/*
38 * movsl can be slow when source and dest are not both 8-byte aligned 38 * movsl can be slow when source and dest are not both 8-byte aligned
@@ -43,7 +43,9 @@ extern struct movsl_mask {
43} ____cacheline_aligned_in_smp movsl_mask; 43} ____cacheline_aligned_in_smp movsl_mask;
44#endif 44#endif
45 45
46#define __addr_ok(addr) ((unsigned long __force)(addr) < (current_thread_info()->addr_limit.seg)) 46#define __addr_ok(addr) \
47 ((unsigned long __force)(addr) < \
48 (current_thread_info()->addr_limit.seg))
47 49
48/* 50/*
49 * Test whether a block of memory is a valid user space address. 51 * Test whether a block of memory is a valid user space address.
@@ -54,13 +56,16 @@ extern struct movsl_mask {
54 * 56 *
55 * This needs 33-bit arithmetic. We have a carry... 57 * This needs 33-bit arithmetic. We have a carry...
56 */ 58 */
57#define __range_ok(addr,size) ({ \ 59#define __range_ok(addr, size) \
58 unsigned long flag,roksum; \ 60({ \
59 __chk_user_ptr(addr); \ 61 unsigned long flag, roksum; \
60 asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" \ 62 __chk_user_ptr(addr); \
61 :"=&r" (flag), "=r" (roksum) \ 63 asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" \
62 :"1" (addr),"g" ((int)(size)),"rm" (current_thread_info()->addr_limit.seg)); \ 64 :"=&r" (flag), "=r" (roksum) \
63 flag; }) 65 :"1" (addr), "g" ((int)(size)), \
66 "rm" (current_thread_info()->addr_limit.seg)); \
67 flag; \
68})
64 69
65/** 70/**
66 * access_ok: - Checks if a user space pointer is valid 71 * access_ok: - Checks if a user space pointer is valid
@@ -81,7 +86,7 @@ extern struct movsl_mask {
81 * checks that the pointer is in the user space range - after calling 86 * checks that the pointer is in the user space range - after calling
82 * this function, memory access functions may still return -EFAULT. 87 * this function, memory access functions may still return -EFAULT.
83 */ 88 */
84#define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0)) 89#define access_ok(type, addr, size) (likely(__range_ok(addr, size) == 0))
85 90
86/* 91/*
87 * The exception table consists of pairs of addresses: the first is the 92 * The exception table consists of pairs of addresses: the first is the
@@ -96,8 +101,7 @@ extern struct movsl_mask {
96 * on our cache or tlb entries. 101 * on our cache or tlb entries.
97 */ 102 */
98 103
99struct exception_table_entry 104struct exception_table_entry {
100{
101 unsigned long insn, fixup; 105 unsigned long insn, fixup;
102}; 106};
103 107
@@ -122,13 +126,15 @@ extern void __get_user_1(void);
122extern void __get_user_2(void); 126extern void __get_user_2(void);
123extern void __get_user_4(void); 127extern void __get_user_4(void);
124 128
125#define __get_user_x(size,ret,x,ptr) \ 129#define __get_user_x(size, ret, x, ptr) \
126 __asm__ __volatile__("call __get_user_" #size \ 130 asm volatile("call __get_user_" #size \
127 :"=a" (ret),"=d" (x) \ 131 :"=a" (ret),"=d" (x) \
128 :"0" (ptr)) 132 :"0" (ptr))
133
129 134
135/* Careful: we have to cast the result to the type of the pointer
136 * for sign reasons */
130 137
131/* Careful: we have to cast the result to the type of the pointer for sign reasons */
132/** 138/**
133 * get_user: - Get a simple variable from user space. 139 * get_user: - Get a simple variable from user space.
134 * @x: Variable to store result. 140 * @x: Variable to store result.
@@ -146,15 +152,24 @@ extern void __get_user_4(void);
146 * Returns zero on success, or -EFAULT on error. 152 * Returns zero on success, or -EFAULT on error.
147 * On error, the variable @x is set to zero. 153 * On error, the variable @x is set to zero.
148 */ 154 */
149#define get_user(x,ptr) \ 155#define get_user(x, ptr) \
150({ int __ret_gu; \ 156({ \
157 int __ret_gu; \
151 unsigned long __val_gu; \ 158 unsigned long __val_gu; \
152 __chk_user_ptr(ptr); \ 159 __chk_user_ptr(ptr); \
153 switch(sizeof (*(ptr))) { \ 160 switch (sizeof(*(ptr))) { \
154 case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \ 161 case 1: \
155 case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \ 162 __get_user_x(1, __ret_gu, __val_gu, ptr); \
156 case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \ 163 break; \
157 default: __get_user_x(X,__ret_gu,__val_gu,ptr); break; \ 164 case 2: \
165 __get_user_x(2, __ret_gu, __val_gu, ptr); \
166 break; \
167 case 4: \
168 __get_user_x(4, __ret_gu, __val_gu, ptr); \
169 break; \
170 default: \
171 __get_user_x(X, __ret_gu, __val_gu, ptr); \
172 break; \
158 } \ 173 } \
159 (x) = (__typeof__(*(ptr)))__val_gu; \ 174 (x) = (__typeof__(*(ptr)))__val_gu; \
160 __ret_gu; \ 175 __ret_gu; \
@@ -171,11 +186,25 @@ extern void __put_user_2(void);
171extern void __put_user_4(void); 186extern void __put_user_4(void);
172extern void __put_user_8(void); 187extern void __put_user_8(void);
173 188
174#define __put_user_1(x, ptr) __asm__ __volatile__("call __put_user_1":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) 189#define __put_user_1(x, ptr) \
175#define __put_user_2(x, ptr) __asm__ __volatile__("call __put_user_2":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) 190 asm volatile("call __put_user_1" : "=a" (__ret_pu) \
176#define __put_user_4(x, ptr) __asm__ __volatile__("call __put_user_4":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) 191 : "0" ((typeof(*(ptr)))(x)), "c" (ptr))
177#define __put_user_8(x, ptr) __asm__ __volatile__("call __put_user_8":"=a" (__ret_pu):"A" ((typeof(*(ptr)))(x)), "c" (ptr)) 192
178#define __put_user_X(x, ptr) __asm__ __volatile__("call __put_user_X":"=a" (__ret_pu):"c" (ptr)) 193#define __put_user_2(x, ptr) \
194 asm volatile("call __put_user_2" : "=a" (__ret_pu) \
195 : "0" ((typeof(*(ptr)))(x)), "c" (ptr))
196
197#define __put_user_4(x, ptr) \
198 asm volatile("call __put_user_4" : "=a" (__ret_pu) \
199 : "0" ((typeof(*(ptr)))(x)), "c" (ptr))
200
201#define __put_user_8(x, ptr) \
202 asm volatile("call __put_user_8" : "=a" (__ret_pu) \
203 : "A" ((typeof(*(ptr)))(x)), "c" (ptr))
204
205#define __put_user_X(x, ptr) \
206 asm volatile("call __put_user_X" : "=a" (__ret_pu) \
207 : "c" (ptr))
179 208
180/** 209/**
181 * put_user: - Write a simple value into user space. 210 * put_user: - Write a simple value into user space.
@@ -195,32 +224,43 @@ extern void __put_user_8(void);
195 */ 224 */
196#ifdef CONFIG_X86_WP_WORKS_OK 225#ifdef CONFIG_X86_WP_WORKS_OK
197 226
198#define put_user(x,ptr) \ 227#define put_user(x, ptr) \
199({ int __ret_pu; \ 228({ \
229 int __ret_pu; \
200 __typeof__(*(ptr)) __pu_val; \ 230 __typeof__(*(ptr)) __pu_val; \
201 __chk_user_ptr(ptr); \ 231 __chk_user_ptr(ptr); \
202 __pu_val = x; \ 232 __pu_val = x; \
203 switch(sizeof(*(ptr))) { \ 233 switch (sizeof(*(ptr))) { \
204 case 1: __put_user_1(__pu_val, ptr); break; \ 234 case 1: \
205 case 2: __put_user_2(__pu_val, ptr); break; \ 235 __put_user_1(__pu_val, ptr); \
206 case 4: __put_user_4(__pu_val, ptr); break; \ 236 break; \
207 case 8: __put_user_8(__pu_val, ptr); break; \ 237 case 2: \
208 default:__put_user_X(__pu_val, ptr); break; \ 238 __put_user_2(__pu_val, ptr); \
239 break; \
240 case 4: \
241 __put_user_4(__pu_val, ptr); \
242 break; \
243 case 8: \
244 __put_user_8(__pu_val, ptr); \
245 break; \
246 default: \
247 __put_user_X(__pu_val, ptr); \
248 break; \
209 } \ 249 } \
210 __ret_pu; \ 250 __ret_pu; \
211}) 251})
212 252
213#else 253#else
214#define put_user(x,ptr) \ 254#define put_user(x, ptr) \
215({ \ 255({ \
216 int __ret_pu; \ 256 int __ret_pu; \
217 __typeof__(*(ptr)) __pus_tmp = x; \ 257 __typeof__(*(ptr))__pus_tmp = x; \
218 __ret_pu=0; \ 258 __ret_pu = 0; \
219 if(unlikely(__copy_to_user_ll(ptr, &__pus_tmp, \ 259 if (unlikely(__copy_to_user_ll(ptr, &__pus_tmp, \
220 sizeof(*(ptr))) != 0)) \ 260 sizeof(*(ptr))) != 0)) \
221 __ret_pu=-EFAULT; \ 261 __ret_pu = -EFAULT; \
222 __ret_pu; \ 262 __ret_pu; \
223 }) 263})
224 264
225 265
226#endif 266#endif
@@ -245,8 +285,8 @@ extern void __put_user_8(void);
245 * Returns zero on success, or -EFAULT on error. 285 * Returns zero on success, or -EFAULT on error.
246 * On error, the variable @x is set to zero. 286 * On error, the variable @x is set to zero.
247 */ 287 */
248#define __get_user(x,ptr) \ 288#define __get_user(x, ptr) \
249 __get_user_nocheck((x),(ptr),sizeof(*(ptr))) 289 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
250 290
251 291
252/** 292/**
@@ -268,54 +308,62 @@ extern void __put_user_8(void);
268 * 308 *
269 * Returns zero on success, or -EFAULT on error. 309 * Returns zero on success, or -EFAULT on error.
270 */ 310 */
271#define __put_user(x,ptr) \ 311#define __put_user(x, ptr) \
272 __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) 312 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
273 313
274#define __put_user_nocheck(x,ptr,size) \ 314#define __put_user_nocheck(x, ptr, size) \
275({ \ 315({ \
276 long __pu_err; \ 316 long __pu_err; \
277 __put_user_size((x),(ptr),(size),__pu_err,-EFAULT); \ 317 __put_user_size((x), (ptr), (size), __pu_err, -EFAULT); \
278 __pu_err; \ 318 __pu_err; \
279}) 319})
280 320
281 321
282#define __put_user_u64(x, addr, err) \ 322#define __put_user_u64(x, addr, err) \
283 __asm__ __volatile__( \ 323 asm volatile("1: movl %%eax,0(%2)\n" \
284 "1: movl %%eax,0(%2)\n" \ 324 "2: movl %%edx,4(%2)\n" \
285 "2: movl %%edx,4(%2)\n" \ 325 "3:\n" \
286 "3:\n" \ 326 ".section .fixup,\"ax\"\n" \
287 ".section .fixup,\"ax\"\n" \ 327 "4: movl %3,%0\n" \
288 "4: movl %3,%0\n" \ 328 " jmp 3b\n" \
289 " jmp 3b\n" \ 329 ".previous\n" \
290 ".previous\n" \ 330 _ASM_EXTABLE(1b, 4b) \
291 _ASM_EXTABLE(1b,4b) \ 331 _ASM_EXTABLE(2b, 4b) \
292 _ASM_EXTABLE(2b,4b) \ 332 : "=r" (err) \
293 : "=r"(err) \ 333 : "A" (x), "r" (addr), "i" (-EFAULT), "0" (err))
294 : "A" (x), "r" (addr), "i"(-EFAULT), "0"(err))
295 334
296#ifdef CONFIG_X86_WP_WORKS_OK 335#ifdef CONFIG_X86_WP_WORKS_OK
297 336
298#define __put_user_size(x,ptr,size,retval,errret) \ 337#define __put_user_size(x, ptr, size, retval, errret) \
299do { \ 338do { \
300 retval = 0; \ 339 retval = 0; \
301 __chk_user_ptr(ptr); \ 340 __chk_user_ptr(ptr); \
302 switch (size) { \ 341 switch (size) { \
303 case 1: __put_user_asm(x,ptr,retval,"b","b","iq",errret);break; \ 342 case 1: \
304 case 2: __put_user_asm(x,ptr,retval,"w","w","ir",errret);break; \ 343 __put_user_asm(x, ptr, retval, "b", "b", "iq", errret); \
305 case 4: __put_user_asm(x,ptr,retval,"l","","ir",errret); break; \ 344 break; \
306 case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval); break;\ 345 case 2: \
307 default: __put_user_bad(); \ 346 __put_user_asm(x, ptr, retval, "w", "w", "ir", errret); \
347 break; \
348 case 4: \
349 __put_user_asm(x, ptr, retval, "l", "", "ir", errret); \
350 break; \
351 case 8: \
352 __put_user_u64((__typeof__(*ptr))(x), ptr, retval); \
353 break; \
354 default: \
355 __put_user_bad(); \
308 } \ 356 } \
309} while (0) 357} while (0)
310 358
311#else 359#else
312 360
313#define __put_user_size(x,ptr,size,retval,errret) \ 361#define __put_user_size(x, ptr, size, retval, errret) \
314do { \ 362do { \
315 __typeof__(*(ptr)) __pus_tmp = x; \ 363 __typeof__(*(ptr))__pus_tmp = x; \
316 retval = 0; \ 364 retval = 0; \
317 \ 365 \
318 if(unlikely(__copy_to_user_ll(ptr, &__pus_tmp, size) != 0)) \ 366 if (unlikely(__copy_to_user_ll(ptr, &__pus_tmp, size) != 0)) \
319 retval = errret; \ 367 retval = errret; \
320} while (0) 368} while (0)
321 369
@@ -329,65 +377,70 @@ struct __large_struct { unsigned long buf[100]; };
329 * aliasing issues. 377 * aliasing issues.
330 */ 378 */
331#define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \ 379#define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
332 __asm__ __volatile__( \ 380 asm volatile("1: mov"itype" %"rtype"1,%2\n" \
333 "1: mov"itype" %"rtype"1,%2\n" \ 381 "2:\n" \
334 "2:\n" \ 382 ".section .fixup,\"ax\"\n" \
335 ".section .fixup,\"ax\"\n" \ 383 "3: movl %3,%0\n" \
336 "3: movl %3,%0\n" \ 384 " jmp 2b\n" \
337 " jmp 2b\n" \ 385 ".previous\n" \
338 ".previous\n" \ 386 _ASM_EXTABLE(1b, 3b) \
339 _ASM_EXTABLE(1b,3b) \ 387 : "=r"(err) \
340 : "=r"(err) \ 388 : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
341 : ltype (x), "m"(__m(addr)), "i"(errret), "0"(err)) 389
342 390
343 391#define __get_user_nocheck(x, ptr, size) \
344#define __get_user_nocheck(x,ptr,size) \ 392({ \
345({ \ 393 long __gu_err; \
346 long __gu_err; \ 394 unsigned long __gu_val; \
347 unsigned long __gu_val; \ 395 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
348 __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\ 396 (x) = (__typeof__(*(ptr)))__gu_val; \
349 (x) = (__typeof__(*(ptr)))__gu_val; \ 397 __gu_err; \
350 __gu_err; \
351}) 398})
352 399
353extern long __get_user_bad(void); 400extern long __get_user_bad(void);
354 401
355#define __get_user_size(x,ptr,size,retval,errret) \ 402#define __get_user_size(x, ptr, size, retval, errret) \
356do { \ 403do { \
357 retval = 0; \ 404 retval = 0; \
358 __chk_user_ptr(ptr); \ 405 __chk_user_ptr(ptr); \
359 switch (size) { \ 406 switch (size) { \
360 case 1: __get_user_asm(x,ptr,retval,"b","b","=q",errret);break; \ 407 case 1: \
361 case 2: __get_user_asm(x,ptr,retval,"w","w","=r",errret);break; \ 408 __get_user_asm(x, ptr, retval, "b", "b", "=q", errret); \
362 case 4: __get_user_asm(x,ptr,retval,"l","","=r",errret);break; \ 409 break; \
363 default: (x) = __get_user_bad(); \ 410 case 2: \
411 __get_user_asm(x, ptr, retval, "w", "w", "=r", errret); \
412 break; \
413 case 4: \
414 __get_user_asm(x, ptr, retval, "l", "", "=r", errret); \
415 break; \
416 default: \
417 (x) = __get_user_bad(); \
364 } \ 418 } \
365} while (0) 419} while (0)
366 420
367#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \ 421#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
368 __asm__ __volatile__( \ 422 asm volatile("1: mov"itype" %2,%"rtype"1\n" \
369 "1: mov"itype" %2,%"rtype"1\n" \ 423 "2:\n" \
370 "2:\n" \ 424 ".section .fixup,\"ax\"\n" \
371 ".section .fixup,\"ax\"\n" \ 425 "3: movl %3,%0\n" \
372 "3: movl %3,%0\n" \ 426 " xor"itype" %"rtype"1,%"rtype"1\n" \
373 " xor"itype" %"rtype"1,%"rtype"1\n" \ 427 " jmp 2b\n" \
374 " jmp 2b\n" \ 428 ".previous\n" \
375 ".previous\n" \ 429 _ASM_EXTABLE(1b, 3b) \
376 _ASM_EXTABLE(1b,3b) \ 430 : "=r" (err), ltype (x) \
377 : "=r"(err), ltype (x) \ 431 : "m" (__m(addr)), "i" (errret), "0" (err))
378 : "m"(__m(addr)), "i"(errret), "0"(err)) 432
379 433
380 434unsigned long __must_check __copy_to_user_ll
381unsigned long __must_check __copy_to_user_ll(void __user *to, 435 (void __user *to, const void *from, unsigned long n);
382 const void *from, unsigned long n); 436unsigned long __must_check __copy_from_user_ll
383unsigned long __must_check __copy_from_user_ll(void *to, 437 (void *to, const void __user *from, unsigned long n);
384 const void __user *from, unsigned long n); 438unsigned long __must_check __copy_from_user_ll_nozero
385unsigned long __must_check __copy_from_user_ll_nozero(void *to, 439 (void *to, const void __user *from, unsigned long n);
386 const void __user *from, unsigned long n); 440unsigned long __must_check __copy_from_user_ll_nocache
387unsigned long __must_check __copy_from_user_ll_nocache(void *to, 441 (void *to, const void __user *from, unsigned long n);
388 const void __user *from, unsigned long n); 442unsigned long __must_check __copy_from_user_ll_nocache_nozero
389unsigned long __must_check __copy_from_user_ll_nocache_nozero(void *to, 443 (void *to, const void __user *from, unsigned long n);
390 const void __user *from, unsigned long n);
391 444
392/** 445/**
393 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking. 446 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
@@ -416,13 +469,16 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
416 469
417 switch (n) { 470 switch (n) {
418 case 1: 471 case 1:
419 __put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret, 1); 472 __put_user_size(*(u8 *)from, (u8 __user *)to,
473 1, ret, 1);
420 return ret; 474 return ret;
421 case 2: 475 case 2:
422 __put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret, 2); 476 __put_user_size(*(u16 *)from, (u16 __user *)to,
477 2, ret, 2);
423 return ret; 478 return ret;
424 case 4: 479 case 4:
425 __put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret, 4); 480 __put_user_size(*(u32 *)from, (u32 __user *)to,
481 4, ret, 4);
426 return ret; 482 return ret;
427 } 483 }
428 } 484 }
@@ -545,19 +601,21 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
545} 601}
546 602
547static __always_inline unsigned long 603static __always_inline unsigned long
548__copy_from_user_inatomic_nocache(void *to, const void __user *from, unsigned long n) 604__copy_from_user_inatomic_nocache(void *to, const void __user *from,
605 unsigned long n)
549{ 606{
550 return __copy_from_user_ll_nocache_nozero(to, from, n); 607 return __copy_from_user_ll_nocache_nozero(to, from, n);
551} 608}
552 609
553unsigned long __must_check copy_to_user(void __user *to, 610unsigned long __must_check copy_to_user(void __user *to,
554 const void *from, unsigned long n); 611 const void *from, unsigned long n);
555unsigned long __must_check copy_from_user(void *to, 612unsigned long __must_check copy_from_user(void *to,
556 const void __user *from, unsigned long n); 613 const void __user *from,
614 unsigned long n);
557long __must_check strncpy_from_user(char *dst, const char __user *src, 615long __must_check strncpy_from_user(char *dst, const char __user *src,
558 long count); 616 long count);
559long __must_check __strncpy_from_user(char *dst, 617long __must_check __strncpy_from_user(char *dst,
560 const char __user *src, long count); 618 const char __user *src, long count);
561 619
562/** 620/**
563 * strlen_user: - Get the size of a string in user space. 621 * strlen_user: - Get the size of a string in user space.
diff --git a/include/asm-x86/uaccess_64.h b/include/asm-x86/uaccess_64.h
index b87eb4ba8f9d..b8a2f4339903 100644
--- a/include/asm-x86/uaccess_64.h
+++ b/include/asm-x86/uaccess_64.h
@@ -29,23 +29,27 @@
29#define get_fs() (current_thread_info()->addr_limit) 29#define get_fs() (current_thread_info()->addr_limit)
30#define set_fs(x) (current_thread_info()->addr_limit = (x)) 30#define set_fs(x) (current_thread_info()->addr_limit = (x))
31 31
32#define segment_eq(a,b) ((a).seg == (b).seg) 32#define segment_eq(a, b) ((a).seg == (b).seg)
33 33
34#define __addr_ok(addr) (!((unsigned long)(addr) & (current_thread_info()->addr_limit.seg))) 34#define __addr_ok(addr) (!((unsigned long)(addr) & \
35 (current_thread_info()->addr_limit.seg)))
35 36
36/* 37/*
37 * Uhhuh, this needs 65-bit arithmetic. We have a carry.. 38 * Uhhuh, this needs 65-bit arithmetic. We have a carry..
38 */ 39 */
39#define __range_not_ok(addr,size) ({ \ 40#define __range_not_ok(addr, size) \
40 unsigned long flag,roksum; \ 41({ \
41 __chk_user_ptr(addr); \ 42 unsigned long flag, roksum; \
42 asm("# range_ok\n\r" \ 43 __chk_user_ptr(addr); \
43 "addq %3,%1 ; sbbq %0,%0 ; cmpq %1,%4 ; sbbq $0,%0" \ 44 asm("# range_ok\n\r" \
44 :"=&r" (flag), "=r" (roksum) \ 45 "addq %3,%1 ; sbbq %0,%0 ; cmpq %1,%4 ; sbbq $0,%0" \
45 :"1" (addr),"g" ((long)(size)),"g" (current_thread_info()->addr_limit.seg)); \ 46 : "=&r" (flag), "=r" (roksum) \
46 flag; }) 47 : "1" (addr), "g" ((long)(size)), \
48 "g" (current_thread_info()->addr_limit.seg)); \
49 flag; \
50})
47 51
48#define access_ok(type, addr, size) (__range_not_ok(addr,size) == 0) 52#define access_ok(type, addr, size) (__range_not_ok(addr, size) == 0)
49 53
50/* 54/*
51 * The exception table consists of pairs of addresses: the first is the 55 * The exception table consists of pairs of addresses: the first is the
@@ -60,8 +64,7 @@
60 * on our cache or tlb entries. 64 * on our cache or tlb entries.
61 */ 65 */
62 66
63struct exception_table_entry 67struct exception_table_entry {
64{
65 unsigned long insn, fixup; 68 unsigned long insn, fixup;
66}; 69};
67 70
@@ -84,23 +87,36 @@ extern int fixup_exception(struct pt_regs *regs);
84 * accesses to the same area of user memory). 87 * accesses to the same area of user memory).
85 */ 88 */
86 89
87#define __get_user_x(size,ret,x,ptr) \ 90#define __get_user_x(size, ret, x, ptr) \
88 asm volatile("call __get_user_" #size \ 91 asm volatile("call __get_user_" #size \
89 :"=a" (ret),"=d" (x) \ 92 : "=a" (ret),"=d" (x) \
90 :"c" (ptr) \ 93 : "c" (ptr) \
91 :"r8") 94 : "r8")
95
96/* Careful: we have to cast the result to the type of the pointer
97 * for sign reasons */
92 98
93/* Careful: we have to cast the result to the type of the pointer for sign reasons */ 99#define get_user(x, ptr) \
94#define get_user(x,ptr) \ 100({ \
95({ unsigned long __val_gu; \ 101 unsigned long __val_gu; \
96 int __ret_gu; \ 102 int __ret_gu; \
97 __chk_user_ptr(ptr); \ 103 __chk_user_ptr(ptr); \
98 switch(sizeof (*(ptr))) { \ 104 switch (sizeof(*(ptr))) { \
99 case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \ 105 case 1: \
100 case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \ 106 __get_user_x(1, __ret_gu, __val_gu, ptr); \
101 case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \ 107 break; \
102 case 8: __get_user_x(8,__ret_gu,__val_gu,ptr); break; \ 108 case 2: \
103 default: __get_user_bad(); break; \ 109 __get_user_x(2, __ret_gu, __val_gu, ptr); \
110 break; \
111 case 4: \
112 __get_user_x(4, __ret_gu, __val_gu, ptr); \
113 break; \
114 case 8: \
115 __get_user_x(8, __ret_gu, __val_gu, ptr); \
116 break; \
117 default: \
118 __get_user_bad(); \
119 break; \
104 } \ 120 } \
105 (x) = (__force typeof(*(ptr)))__val_gu; \ 121 (x) = (__force typeof(*(ptr)))__val_gu; \
106 __ret_gu; \ 122 __ret_gu; \
@@ -112,55 +128,73 @@ extern void __put_user_4(void);
112extern void __put_user_8(void); 128extern void __put_user_8(void);
113extern void __put_user_bad(void); 129extern void __put_user_bad(void);
114 130
115#define __put_user_x(size,ret,x,ptr) \ 131#define __put_user_x(size, ret, x, ptr) \
116 asm volatile("call __put_user_" #size \ 132 asm volatile("call __put_user_" #size \
117 :"=a" (ret) \ 133 :"=a" (ret) \
118 :"c" (ptr),"d" (x) \ 134 :"c" (ptr),"d" (x) \
119 :"r8") 135 :"r8")
120 136
121#define put_user(x,ptr) \ 137#define put_user(x, ptr) \
122 __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) 138 __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
123 139
124#define __get_user(x,ptr) \ 140#define __get_user(x, ptr) \
125 __get_user_nocheck((x),(ptr),sizeof(*(ptr))) 141 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
126#define __put_user(x,ptr) \ 142#define __put_user(x, ptr) \
127 __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) 143 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
128 144
129#define __get_user_unaligned __get_user 145#define __get_user_unaligned __get_user
130#define __put_user_unaligned __put_user 146#define __put_user_unaligned __put_user
131 147
132#define __put_user_nocheck(x,ptr,size) \ 148#define __put_user_nocheck(x, ptr, size) \
133({ \ 149({ \
134 int __pu_err; \ 150 int __pu_err; \
135 __put_user_size((x),(ptr),(size),__pu_err); \ 151 __put_user_size((x), (ptr), (size), __pu_err); \
136 __pu_err; \ 152 __pu_err; \
137}) 153})
138 154
139 155
140#define __put_user_check(x,ptr,size) \ 156#define __put_user_check(x, ptr, size) \
141({ \ 157({ \
142 int __pu_err; \ 158 int __pu_err; \
143 typeof(*(ptr)) __user *__pu_addr = (ptr); \ 159 typeof(*(ptr)) __user *__pu_addr = (ptr); \
144 switch (size) { \ 160 switch (size) { \
145 case 1: __put_user_x(1,__pu_err,x,__pu_addr); break; \ 161 case 1: \
146 case 2: __put_user_x(2,__pu_err,x,__pu_addr); break; \ 162 __put_user_x(1, __pu_err, x, __pu_addr); \
147 case 4: __put_user_x(4,__pu_err,x,__pu_addr); break; \ 163 break; \
148 case 8: __put_user_x(8,__pu_err,x,__pu_addr); break; \ 164 case 2: \
149 default: __put_user_bad(); \ 165 __put_user_x(2, __pu_err, x, __pu_addr); \
150 } \ 166 break; \
151 __pu_err; \ 167 case 4: \
168 __put_user_x(4, __pu_err, x, __pu_addr); \
169 break; \
170 case 8: \
171 __put_user_x(8, __pu_err, x, __pu_addr); \
172 break; \
173 default: \
174 __put_user_bad(); \
175 } \
176 __pu_err; \
152}) 177})
153 178
154#define __put_user_size(x,ptr,size,retval) \ 179#define __put_user_size(x, ptr, size, retval) \
155do { \ 180do { \
156 retval = 0; \ 181 retval = 0; \
157 __chk_user_ptr(ptr); \ 182 __chk_user_ptr(ptr); \
158 switch (size) { \ 183 switch (size) { \
159 case 1: __put_user_asm(x,ptr,retval,"b","b","iq",-EFAULT); break;\ 184 case 1: \
160 case 2: __put_user_asm(x,ptr,retval,"w","w","ir",-EFAULT); break;\ 185 __put_user_asm(x, ptr, retval, "b", "b", "iq", -EFAULT);\
161 case 4: __put_user_asm(x,ptr,retval,"l","k","ir",-EFAULT); break;\ 186 break; \
162 case 8: __put_user_asm(x,ptr,retval,"q","","Zr",-EFAULT); break;\ 187 case 2: \
163 default: __put_user_bad(); \ 188 __put_user_asm(x, ptr, retval, "w", "w", "ir", -EFAULT);\
189 break; \
190 case 4: \
191 __put_user_asm(x, ptr, retval, "l", "k", "ir", -EFAULT);\
192 break; \
193 case 8: \
194 __put_user_asm(x, ptr, retval, "q", "", "Zr", -EFAULT); \
195 break; \
196 default: \
197 __put_user_bad(); \
164 } \ 198 } \
165} while (0) 199} while (0)
166 200
@@ -174,23 +208,22 @@ struct __large_struct { unsigned long buf[100]; };
174 * aliasing issues. 208 * aliasing issues.
175 */ 209 */
176#define __put_user_asm(x, addr, err, itype, rtype, ltype, errno) \ 210#define __put_user_asm(x, addr, err, itype, rtype, ltype, errno) \
177 asm volatile( \ 211 asm volatile("1: mov"itype" %"rtype"1,%2\n" \
178 "1: mov"itype" %"rtype"1,%2\n" \ 212 "2:\n" \
179 "2:\n" \ 213 ".section .fixup, \"ax\"\n" \
180 ".section .fixup,\"ax\"\n" \ 214 "3: mov %3,%0\n" \
181 "3: mov %3,%0\n" \ 215 " jmp 2b\n" \
182 " jmp 2b\n" \ 216 ".previous\n" \
183 ".previous\n" \ 217 _ASM_EXTABLE(1b, 3b) \
184 _ASM_EXTABLE(1b,3b) \ 218 : "=r"(err) \
185 : "=r"(err) \ 219 : ltype (x), "m" (__m(addr)), "i" (errno), "0" (err))
186 : ltype (x), "m"(__m(addr)), "i"(errno), "0"(err)) 220
187 221
188 222#define __get_user_nocheck(x, ptr, size) \
189#define __get_user_nocheck(x,ptr,size) \
190({ \ 223({ \
191 int __gu_err; \ 224 int __gu_err; \
192 unsigned long __gu_val; \ 225 unsigned long __gu_val; \
193 __get_user_size(__gu_val,(ptr),(size),__gu_err); \ 226 __get_user_size(__gu_val, (ptr), (size), __gu_err); \
194 (x) = (__force typeof(*(ptr)))__gu_val; \ 227 (x) = (__force typeof(*(ptr)))__gu_val; \
195 __gu_err; \ 228 __gu_err; \
196}) 229})
@@ -201,31 +234,39 @@ extern int __get_user_4(void);
201extern int __get_user_8(void); 234extern int __get_user_8(void);
202extern int __get_user_bad(void); 235extern int __get_user_bad(void);
203 236
204#define __get_user_size(x,ptr,size,retval) \ 237#define __get_user_size(x, ptr, size, retval) \
205do { \ 238do { \
206 retval = 0; \ 239 retval = 0; \
207 __chk_user_ptr(ptr); \ 240 __chk_user_ptr(ptr); \
208 switch (size) { \ 241 switch (size) { \
209 case 1: __get_user_asm(x,ptr,retval,"b","b","=q",-EFAULT); break;\ 242 case 1: \
210 case 2: __get_user_asm(x,ptr,retval,"w","w","=r",-EFAULT); break;\ 243 __get_user_asm(x, ptr, retval, "b", "b", "=q", -EFAULT);\
211 case 4: __get_user_asm(x,ptr,retval,"l","k","=r",-EFAULT); break;\ 244 break; \
212 case 8: __get_user_asm(x,ptr,retval,"q","","=r",-EFAULT); break;\ 245 case 2: \
213 default: (x) = __get_user_bad(); \ 246 __get_user_asm(x, ptr, retval, "w", "w", "=r", -EFAULT);\
247 break; \
248 case 4: \
249 __get_user_asm(x, ptr, retval, "l", "k", "=r", -EFAULT);\
250 break; \
251 case 8: \
252 __get_user_asm(x, ptr, retval, "q", "", "=r", -EFAULT); \
253 break; \
254 default: \
255 (x) = __get_user_bad(); \
214 } \ 256 } \
215} while (0) 257} while (0)
216 258
217#define __get_user_asm(x, addr, err, itype, rtype, ltype, errno) \ 259#define __get_user_asm(x, addr, err, itype, rtype, ltype, errno) \
218 asm volatile( \ 260 asm volatile("1: mov"itype" %2,%"rtype"1\n" \
219 "1: mov"itype" %2,%"rtype"1\n" \ 261 "2:\n" \
220 "2:\n" \ 262 ".section .fixup, \"ax\"\n" \
221 ".section .fixup,\"ax\"\n" \ 263 "3: mov %3,%0\n" \
222 "3: mov %3,%0\n" \ 264 " xor"itype" %"rtype"1,%"rtype"1\n" \
223 " xor"itype" %"rtype"1,%"rtype"1\n" \ 265 " jmp 2b\n" \
224 " jmp 2b\n" \ 266 ".previous\n" \
225 ".previous\n" \ 267 _ASM_EXTABLE(1b, 3b) \
226 _ASM_EXTABLE(1b,3b) \ 268 : "=r" (err), ltype (x) \
227 : "=r"(err), ltype (x) \ 269 : "m" (__m(addr)), "i"(errno), "0"(err))
228 : "m"(__m(addr)), "i"(errno), "0"(err))
229 270
230/* 271/*
231 * Copy To/From Userspace 272 * Copy To/From Userspace
@@ -244,110 +285,142 @@ copy_in_user(void __user *to, const void __user *from, unsigned len);
244 285
245static __always_inline __must_check 286static __always_inline __must_check
246int __copy_from_user(void *dst, const void __user *src, unsigned size) 287int __copy_from_user(void *dst, const void __user *src, unsigned size)
247{ 288{
248 int ret = 0; 289 int ret = 0;
249 if (!__builtin_constant_p(size)) 290 if (!__builtin_constant_p(size))
250 return copy_user_generic(dst,(__force void *)src,size); 291 return copy_user_generic(dst, (__force void *)src, size);
251 switch (size) { 292 switch (size) {
252 case 1:__get_user_asm(*(u8*)dst,(u8 __user *)src,ret,"b","b","=q",1); 293 case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
294 ret, "b", "b", "=q", 1);
253 return ret; 295 return ret;
254 case 2:__get_user_asm(*(u16*)dst,(u16 __user *)src,ret,"w","w","=r",2); 296 case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
297 ret, "w", "w", "=r", 2);
255 return ret; 298 return ret;
256 case 4:__get_user_asm(*(u32*)dst,(u32 __user *)src,ret,"l","k","=r",4); 299 case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
300 ret, "l", "k", "=r", 4);
301 return ret;
302 case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
303 ret, "q", "", "=r", 8);
257 return ret; 304 return ret;
258 case 8:__get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",8);
259 return ret;
260 case 10: 305 case 10:
261 __get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",16); 306 __get_user_asm(*(u64 *)dst, (u64 __user *)src,
262 if (unlikely(ret)) return ret; 307 ret, "q", "", "=r", 16);
263 __get_user_asm(*(u16*)(8+(char*)dst),(u16 __user *)(8+(char __user *)src),ret,"w","w","=r",2); 308 if (unlikely(ret))
264 return ret; 309 return ret;
310 __get_user_asm(*(u16 *)(8 + (char *)dst),
311 (u16 __user *)(8 + (char __user *)src),
312 ret, "w", "w", "=r", 2);
313 return ret;
265 case 16: 314 case 16:
266 __get_user_asm(*(u64*)dst,(u64 __user *)src,ret,"q","","=r",16); 315 __get_user_asm(*(u64 *)dst, (u64 __user *)src,
267 if (unlikely(ret)) return ret; 316 ret, "q", "", "=r", 16);
268 __get_user_asm(*(u64*)(8+(char*)dst),(u64 __user *)(8+(char __user *)src),ret,"q","","=r",8); 317 if (unlikely(ret))
269 return ret; 318 return ret;
319 __get_user_asm(*(u64 *)(8 + (char *)dst),
320 (u64 __user *)(8 + (char __user *)src),
321 ret, "q", "", "=r", 8);
322 return ret;
270 default: 323 default:
271 return copy_user_generic(dst,(__force void *)src,size); 324 return copy_user_generic(dst, (__force void *)src, size);
272 } 325 }
273} 326}
274 327
275static __always_inline __must_check 328static __always_inline __must_check
276int __copy_to_user(void __user *dst, const void *src, unsigned size) 329int __copy_to_user(void __user *dst, const void *src, unsigned size)
277{ 330{
278 int ret = 0; 331 int ret = 0;
279 if (!__builtin_constant_p(size)) 332 if (!__builtin_constant_p(size))
280 return copy_user_generic((__force void *)dst,src,size); 333 return copy_user_generic((__force void *)dst, src, size);
281 switch (size) { 334 switch (size) {
282 case 1:__put_user_asm(*(u8*)src,(u8 __user *)dst,ret,"b","b","iq",1); 335 case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
336 ret, "b", "b", "iq", 1);
283 return ret; 337 return ret;
284 case 2:__put_user_asm(*(u16*)src,(u16 __user *)dst,ret,"w","w","ir",2); 338 case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
339 ret, "w", "w", "ir", 2);
285 return ret; 340 return ret;
286 case 4:__put_user_asm(*(u32*)src,(u32 __user *)dst,ret,"l","k","ir",4); 341 case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
342 ret, "l", "k", "ir", 4);
343 return ret;
344 case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
345 ret, "q", "", "ir", 8);
287 return ret; 346 return ret;
288 case 8:__put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",8);
289 return ret;
290 case 10: 347 case 10:
291 __put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",10); 348 __put_user_asm(*(u64 *)src, (u64 __user *)dst,
292 if (unlikely(ret)) return ret; 349 ret, "q", "", "ir", 10);
350 if (unlikely(ret))
351 return ret;
293 asm("":::"memory"); 352 asm("":::"memory");
294 __put_user_asm(4[(u16*)src],4+(u16 __user *)dst,ret,"w","w","ir",2); 353 __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
295 return ret; 354 ret, "w", "w", "ir", 2);
355 return ret;
296 case 16: 356 case 16:
297 __put_user_asm(*(u64*)src,(u64 __user *)dst,ret,"q","","ir",16); 357 __put_user_asm(*(u64 *)src, (u64 __user *)dst,
298 if (unlikely(ret)) return ret; 358 ret, "q", "", "ir", 16);
359 if (unlikely(ret))
360 return ret;
299 asm("":::"memory"); 361 asm("":::"memory");
300 __put_user_asm(1[(u64*)src],1+(u64 __user *)dst,ret,"q","","ir",8); 362 __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
301 return ret; 363 ret, "q", "", "ir", 8);
364 return ret;
302 default: 365 default:
303 return copy_user_generic((__force void *)dst,src,size); 366 return copy_user_generic((__force void *)dst, src, size);
304 } 367 }
305} 368}
306 369
307static __always_inline __must_check 370static __always_inline __must_check
308int __copy_in_user(void __user *dst, const void __user *src, unsigned size) 371int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
309{ 372{
310 int ret = 0; 373 int ret = 0;
311 if (!__builtin_constant_p(size)) 374 if (!__builtin_constant_p(size))
312 return copy_user_generic((__force void *)dst,(__force void *)src,size); 375 return copy_user_generic((__force void *)dst,
313 switch (size) { 376 (__force void *)src, size);
314 case 1: { 377 switch (size) {
378 case 1: {
315 u8 tmp; 379 u8 tmp;
316 __get_user_asm(tmp,(u8 __user *)src,ret,"b","b","=q",1); 380 __get_user_asm(tmp, (u8 __user *)src,
381 ret, "b", "b", "=q", 1);
317 if (likely(!ret)) 382 if (likely(!ret))
318 __put_user_asm(tmp,(u8 __user *)dst,ret,"b","b","iq",1); 383 __put_user_asm(tmp, (u8 __user *)dst,
384 ret, "b", "b", "iq", 1);
319 return ret; 385 return ret;
320 } 386 }
321 case 2: { 387 case 2: {
322 u16 tmp; 388 u16 tmp;
323 __get_user_asm(tmp,(u16 __user *)src,ret,"w","w","=r",2); 389 __get_user_asm(tmp, (u16 __user *)src,
390 ret, "w", "w", "=r", 2);
324 if (likely(!ret)) 391 if (likely(!ret))
325 __put_user_asm(tmp,(u16 __user *)dst,ret,"w","w","ir",2); 392 __put_user_asm(tmp, (u16 __user *)dst,
393 ret, "w", "w", "ir", 2);
326 return ret; 394 return ret;
327 } 395 }
328 396
329 case 4: { 397 case 4: {
330 u32 tmp; 398 u32 tmp;
331 __get_user_asm(tmp,(u32 __user *)src,ret,"l","k","=r",4); 399 __get_user_asm(tmp, (u32 __user *)src,
400 ret, "l", "k", "=r", 4);
332 if (likely(!ret)) 401 if (likely(!ret))
333 __put_user_asm(tmp,(u32 __user *)dst,ret,"l","k","ir",4); 402 __put_user_asm(tmp, (u32 __user *)dst,
403 ret, "l", "k", "ir", 4);
334 return ret; 404 return ret;
335 } 405 }
336 case 8: { 406 case 8: {
337 u64 tmp; 407 u64 tmp;
338 __get_user_asm(tmp,(u64 __user *)src,ret,"q","","=r",8); 408 __get_user_asm(tmp, (u64 __user *)src,
409 ret, "q", "", "=r", 8);
339 if (likely(!ret)) 410 if (likely(!ret))
340 __put_user_asm(tmp,(u64 __user *)dst,ret,"q","","ir",8); 411 __put_user_asm(tmp, (u64 __user *)dst,
412 ret, "q", "", "ir", 8);
341 return ret; 413 return ret;
342 } 414 }
343 default: 415 default:
344 return copy_user_generic((__force void *)dst,(__force void *)src,size); 416 return copy_user_generic((__force void *)dst,
417 (__force void *)src, size);
345 } 418 }
346} 419}
347 420
348__must_check long 421__must_check long
349strncpy_from_user(char *dst, const char __user *src, long count); 422strncpy_from_user(char *dst, const char __user *src, long count);
350__must_check long 423__must_check long
351__strncpy_from_user(char *dst, const char __user *src, long count); 424__strncpy_from_user(char *dst, const char __user *src, long count);
352__must_check long strnlen_user(const char __user *str, long n); 425__must_check long strnlen_user(const char __user *str, long n);
353__must_check long __strnlen_user(const char __user *str, long n); 426__must_check long __strnlen_user(const char __user *str, long n);
@@ -355,7 +428,8 @@ __must_check long strlen_user(const char __user *str);
355__must_check unsigned long clear_user(void __user *mem, unsigned long len); 428__must_check unsigned long clear_user(void __user *mem, unsigned long len);
356__must_check unsigned long __clear_user(void __user *mem, unsigned long len); 429__must_check unsigned long __clear_user(void __user *mem, unsigned long len);
357 430
358__must_check long __copy_from_user_inatomic(void *dst, const void __user *src, unsigned size); 431__must_check long __copy_from_user_inatomic(void *dst, const void __user *src,
432 unsigned size);
359 433
360static __must_check __always_inline int 434static __must_check __always_inline int
361__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size) 435__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
@@ -364,15 +438,19 @@ __copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
364} 438}
365 439
366#define ARCH_HAS_NOCACHE_UACCESS 1 440#define ARCH_HAS_NOCACHE_UACCESS 1
367extern long __copy_user_nocache(void *dst, const void __user *src, unsigned size, int zerorest); 441extern long __copy_user_nocache(void *dst, const void __user *src,
442 unsigned size, int zerorest);
368 443
369static inline int __copy_from_user_nocache(void *dst, const void __user *src, unsigned size) 444static inline int __copy_from_user_nocache(void *dst, const void __user *src,
445 unsigned size)
370{ 446{
371 might_sleep(); 447 might_sleep();
372 return __copy_user_nocache(dst, src, size, 1); 448 return __copy_user_nocache(dst, src, size, 1);
373} 449}
374 450
375static inline int __copy_from_user_inatomic_nocache(void *dst, const void __user *src, unsigned size) 451static inline int __copy_from_user_inatomic_nocache(void *dst,
452 const void __user *src,
453 unsigned size)
376{ 454{
377 return __copy_user_nocache(dst, src, size, 0); 455 return __copy_user_nocache(dst, src, size, 0);
378} 456}
diff --git a/include/asm-x86/unaligned.h b/include/asm-x86/unaligned.h
index 913598d4f761..a7bd416b4763 100644
--- a/include/asm-x86/unaligned.h
+++ b/include/asm-x86/unaligned.h
@@ -3,35 +3,12 @@
3 3
4/* 4/*
5 * The x86 can do unaligned accesses itself. 5 * The x86 can do unaligned accesses itself.
6 *
7 * The strange macros are there to make sure these can't
8 * be misused in a way that makes them not work on other
9 * architectures where unaligned accesses aren't as simple.
10 */ 6 */
11 7
12/** 8#include <linux/unaligned/access_ok.h>
13 * get_unaligned - get value from possibly mis-aligned location 9#include <linux/unaligned/generic.h>
14 * @ptr: pointer to value
15 *
16 * This macro should be used for accessing values larger in size than
17 * single bytes at locations that are expected to be improperly aligned,
18 * e.g. retrieving a u16 value from a location not u16-aligned.
19 *
20 * Note that unaligned accesses can be very expensive on some architectures.
21 */
22#define get_unaligned(ptr) (*(ptr))
23 10
24/** 11#define get_unaligned __get_unaligned_le
25 * put_unaligned - put value to a possibly mis-aligned location 12#define put_unaligned __put_unaligned_le
26 * @val: value to place
27 * @ptr: pointer to location
28 *
29 * This macro should be used for placing values larger in size than
30 * single bytes at locations that are expected to be improperly aligned,
31 * e.g. writing a u16 value to a location not u16-aligned.
32 *
33 * Note that unaligned accesses can be very expensive on some architectures.
34 */
35#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
36 13
37#endif /* _ASM_X86_UNALIGNED_H */ 14#endif /* _ASM_X86_UNALIGNED_H */
diff --git a/include/asm-x86/unistd_32.h b/include/asm-x86/unistd_32.h
index 984123a68f7c..8317d94771d3 100644
--- a/include/asm-x86/unistd_32.h
+++ b/include/asm-x86/unistd_32.h
@@ -81,7 +81,7 @@
81#define __NR_sigpending 73 81#define __NR_sigpending 73
82#define __NR_sethostname 74 82#define __NR_sethostname 74
83#define __NR_setrlimit 75 83#define __NR_setrlimit 75
84#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ 84#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
85#define __NR_getrusage 77 85#define __NR_getrusage 77
86#define __NR_gettimeofday 78 86#define __NR_gettimeofday 78
87#define __NR_settimeofday 79 87#define __NR_settimeofday 79
diff --git a/include/asm-x86/unistd_64.h b/include/asm-x86/unistd_64.h
index 3883ceb54ef5..fe26e36d0f51 100644
--- a/include/asm-x86/unistd_64.h
+++ b/include/asm-x86/unistd_64.h
@@ -2,7 +2,7 @@
2#define _ASM_X86_64_UNISTD_H_ 2#define _ASM_X86_64_UNISTD_H_
3 3
4#ifndef __SYSCALL 4#ifndef __SYSCALL
5#define __SYSCALL(a,b) 5#define __SYSCALL(a, b)
6#endif 6#endif
7 7
8/* 8/*
diff --git a/include/asm-x86/user32.h b/include/asm-x86/user32.h
index f769872debea..a3d910047879 100644
--- a/include/asm-x86/user32.h
+++ b/include/asm-x86/user32.h
@@ -1,7 +1,8 @@
1#ifndef USER32_H 1#ifndef USER32_H
2#define USER32_H 1 2#define USER32_H 1
3 3
4/* IA32 compatible user structures for ptrace. These should be used for 32bit coredumps too. */ 4/* IA32 compatible user structures for ptrace.
5 * These should be used for 32bit coredumps too. */
5 6
6struct user_i387_ia32_struct { 7struct user_i387_ia32_struct {
7 u32 cwd; 8 u32 cwd;
@@ -42,9 +43,9 @@ struct user_regs_struct32 {
42}; 43};
43 44
44struct user32 { 45struct user32 {
45 struct user_regs_struct32 regs; /* Where the registers are actually stored */ 46 struct user_regs_struct32 regs; /* Where the registers are actually stored */
46 int u_fpvalid; /* True if math co-processor being used. */ 47 int u_fpvalid; /* True if math co-processor being used. */
47 /* for this mess. Not yet used. */ 48 /* for this mess. Not yet used. */
48 struct user_i387_ia32_struct i387; /* Math Co-processor registers. */ 49 struct user_i387_ia32_struct i387; /* Math Co-processor registers. */
49/* The rest of this junk is to help gdb figure out what goes where */ 50/* The rest of this junk is to help gdb figure out what goes where */
50 __u32 u_tsize; /* Text segment size (pages). */ 51 __u32 u_tsize; /* Text segment size (pages). */
diff --git a/include/asm-x86/user_32.h b/include/asm-x86/user_32.h
index 6157da6f882c..d6e51edc259d 100644
--- a/include/asm-x86/user_32.h
+++ b/include/asm-x86/user_32.h
@@ -100,10 +100,10 @@ struct user_regs_struct {
100struct user{ 100struct user{
101/* We start with the registers, to mimic the way that "memory" is returned 101/* We start with the registers, to mimic the way that "memory" is returned
102 from the ptrace(3,...) function. */ 102 from the ptrace(3,...) function. */
103 struct user_regs_struct regs; /* Where the registers are actually stored */ 103 struct user_regs_struct regs; /* Where the registers are actually stored */
104/* ptrace does not yet supply these. Someday.... */ 104/* ptrace does not yet supply these. Someday.... */
105 int u_fpvalid; /* True if math co-processor being used. */ 105 int u_fpvalid; /* True if math co-processor being used. */
106 /* for this mess. Not yet used. */ 106 /* for this mess. Not yet used. */
107 struct user_i387_struct i387; /* Math Co-processor registers. */ 107 struct user_i387_struct i387; /* Math Co-processor registers. */
108/* The rest of this junk is to help gdb figure out what goes where */ 108/* The rest of this junk is to help gdb figure out what goes where */
109 unsigned long int u_tsize; /* Text segment size (pages). */ 109 unsigned long int u_tsize; /* Text segment size (pages). */
@@ -118,7 +118,7 @@ struct user{
118 int reserved; /* No longer used */ 118 int reserved; /* No longer used */
119 unsigned long u_ar0; /* Used by gdb to help find the values for */ 119 unsigned long u_ar0; /* Used by gdb to help find the values for */
120 /* the registers. */ 120 /* the registers. */
121 struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */ 121 struct user_i387_struct *u_fpstate; /* Math Co-processor pointer. */
122 unsigned long magic; /* To uniquely identify a core file */ 122 unsigned long magic; /* To uniquely identify a core file */
123 char u_comm[32]; /* User command that was responsible */ 123 char u_comm[32]; /* User command that was responsible */
124 int u_debugreg[8]; 124 int u_debugreg[8];
diff --git a/include/asm-x86/user_64.h b/include/asm-x86/user_64.h
index 963616455609..6037b634c77f 100644
--- a/include/asm-x86/user_64.h
+++ b/include/asm-x86/user_64.h
@@ -45,12 +45,13 @@
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
49 data and eip are replaced with flat 64bit pointers. */ 49 for 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;
53 unsigned short twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */ 53 unsigned short twd; /* Note this is not the same as
54 the 32bit/x87/FSAVE twd */
54 unsigned short fop; 55 unsigned short fop;
55 __u64 rip; 56 __u64 rip;
56 __u64 rdp; 57 __u64 rdp;
@@ -97,13 +98,14 @@ struct user_regs_struct {
97/* When the kernel dumps core, it starts by dumping the user struct - 98/* When the kernel dumps core, it starts by dumping the user struct -
98 this will be used by gdb to figure out where the data and stack segments 99 this will be used by gdb to figure out where the data and stack segments
99 are within the file, and what virtual addresses to use. */ 100 are within the file, and what virtual addresses to use. */
100struct user{ 101
102struct user {
101/* We start with the registers, to mimic the way that "memory" is returned 103/* We start with the registers, to mimic the way that "memory" is returned
102 from the ptrace(3,...) function. */ 104 from the ptrace(3,...) function. */
103 struct user_regs_struct regs; /* Where the registers are actually stored */ 105 struct user_regs_struct regs; /* Where the registers are actually stored */
104/* ptrace does not yet supply these. Someday.... */ 106/* ptrace does not yet supply these. Someday.... */
105 int u_fpvalid; /* True if math co-processor being used. */ 107 int u_fpvalid; /* True if math co-processor being used. */
106 /* for this mess. Not yet used. */ 108 /* for this mess. Not yet used. */
107 int pad0; 109 int pad0;
108 struct user_i387_struct i387; /* Math Co-processor registers. */ 110 struct user_i387_struct i387; /* Math Co-processor registers. */
109/* The rest of this junk is to help gdb figure out what goes where */ 111/* The rest of this junk is to help gdb figure out what goes where */
@@ -120,7 +122,7 @@ struct user{
120 int pad1; 122 int pad1;
121 unsigned long u_ar0; /* Used by gdb to help find the values for */ 123 unsigned long u_ar0; /* Used by gdb to help find the values for */
122 /* the registers. */ 124 /* the registers. */
123 struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */ 125 struct user_i387_struct *u_fpstate; /* Math Co-processor pointer. */
124 unsigned long magic; /* To uniquely identify a core file */ 126 unsigned long magic; /* To uniquely identify a core file */
125 char u_comm[32]; /* User command that was responsible */ 127 char u_comm[32]; /* User command that was responsible */
126 unsigned long u_debugreg[8]; 128 unsigned long u_debugreg[8];
diff --git a/include/asm-x86/uv/uv_hub.h b/include/asm-x86/uv/uv_hub.h
new file mode 100644
index 000000000000..26b9240d1e23
--- /dev/null
+++ b/include/asm-x86/uv/uv_hub.h
@@ -0,0 +1,284 @@
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 * SGI UV architectural definitions
7 *
8 * Copyright (C) 2007 Silicon Graphics, Inc. All rights reserved.
9 */
10
11#ifndef __ASM_X86_UV_HUB_H__
12#define __ASM_X86_UV_HUB_H__
13
14#include <linux/numa.h>
15#include <linux/percpu.h>
16#include <asm/types.h>
17#include <asm/percpu.h>
18
19
20/*
21 * Addressing Terminology
22 *
23 * NASID - network ID of a router, Mbrick or Cbrick. Nasid values of
24 * routers always have low bit of 1, C/MBricks have low bit
25 * equal to 0. Most addressing macros that target UV hub chips
26 * right shift the NASID by 1 to exclude the always-zero bit.
27 *
28 * SNASID - NASID right shifted by 1 bit.
29 *
30 *
31 * Memory/UV-HUB Processor Socket Address Format:
32 * +--------+---------------+---------------------+
33 * |00..0000| SNASID | NodeOffset |
34 * +--------+---------------+---------------------+
35 * <--- N bits --->|<--------M bits ----->
36 *
37 * M number of node offset bits (35 .. 40)
38 * N number of SNASID bits (0 .. 10)
39 *
40 * Note: M + N cannot currently exceed 44 (x86_64) or 46 (IA64).
41 * The actual values are configuration dependent and are set at
42 * boot time
43 *
44 * APICID format
45 * NOTE!!!!!! This is the current format of the APICID. However, code
46 * should assume that this will change in the future. Use functions
47 * in this file for all APICID bit manipulations and conversion.
48 *
49 * 1111110000000000
50 * 5432109876543210
51 * nnnnnnnnnnlc0cch
52 * sssssssssss
53 *
54 * n = snasid bits
55 * l = socket number on board
56 * c = core
57 * h = hyperthread
58 * s = bits that are in the socket CSR
59 *
60 * Note: Processor only supports 12 bits in the APICID register. The ACPI
61 * tables hold all 16 bits. Software needs to be aware of this.
62 *
63 * Unless otherwise specified, all references to APICID refer to
64 * the FULL value contained in ACPI tables, not the subset in the
65 * processor APICID register.
66 */
67
68
69/*
70 * Maximum number of bricks in all partitions and in all coherency domains.
71 * This is the total number of bricks accessible in the numalink fabric. It
72 * includes all C & M bricks. Routers are NOT included.
73 *
74 * This value is also the value of the maximum number of non-router NASIDs
75 * in the numalink fabric.
76 *
77 * NOTE: a brick may be 1 or 2 OS nodes. Don't get these confused.
78 */
79#define UV_MAX_NUMALINK_BLADES 16384
80
81/*
82 * Maximum number of C/Mbricks within a software SSI (hardware may support
83 * more).
84 */
85#define UV_MAX_SSI_BLADES 256
86
87/*
88 * The largest possible NASID of a C or M brick (+ 2)
89 */
90#define UV_MAX_NASID_VALUE (UV_MAX_NUMALINK_NODES * 2)
91
92/*
93 * The following defines attributes of the HUB chip. These attributes are
94 * frequently referenced and are kept in the per-cpu data areas of each cpu.
95 * They are kept together in a struct to minimize cache misses.
96 */
97struct uv_hub_info_s {
98 unsigned long global_mmr_base;
99 unsigned short local_nasid;
100 unsigned short gnode_upper;
101 unsigned short coherency_domain_number;
102 unsigned short numa_blade_id;
103 unsigned char blade_processor_id;
104 unsigned char m_val;
105 unsigned char n_val;
106};
107DECLARE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
108#define uv_hub_info (&__get_cpu_var(__uv_hub_info))
109#define uv_cpu_hub_info(cpu) (&per_cpu(__uv_hub_info, cpu))
110
111/*
112 * Local & Global MMR space macros.
113 * Note: macros are intended to be used ONLY by inline functions
114 * in this file - not by other kernel code.
115 */
116#define UV_SNASID(n) ((n) >> 1)
117#define UV_NASID(n) ((n) << 1)
118
119#define UV_LOCAL_MMR_BASE 0xf4000000UL
120#define UV_GLOBAL_MMR32_BASE 0xf8000000UL
121#define UV_GLOBAL_MMR64_BASE (uv_hub_info->global_mmr_base)
122
123#define UV_GLOBAL_MMR32_SNASID_MASK 0x3ff
124#define UV_GLOBAL_MMR32_SNASID_SHIFT 15
125#define UV_GLOBAL_MMR64_SNASID_SHIFT 26
126
127#define UV_GLOBAL_MMR32_NASID_BITS(n) \
128 (((UV_SNASID(n) & UV_GLOBAL_MMR32_SNASID_MASK)) << \
129 (UV_GLOBAL_MMR32_SNASID_SHIFT))
130
131#define UV_GLOBAL_MMR64_NASID_BITS(n) \
132 ((unsigned long)UV_SNASID(n) << UV_GLOBAL_MMR64_SNASID_SHIFT)
133
134#define UV_APIC_NASID_SHIFT 6
135
136/*
137 * Extract a NASID from an APICID (full apicid, not processor subset)
138 */
139static inline int uv_apicid_to_nasid(int apicid)
140{
141 return (UV_NASID(apicid >> UV_APIC_NASID_SHIFT));
142}
143
144/*
145 * Access global MMRs using the low memory MMR32 space. This region supports
146 * faster MMR access but not all MMRs are accessible in this space.
147 */
148static inline unsigned long *uv_global_mmr32_address(int nasid,
149 unsigned long offset)
150{
151 return __va(UV_GLOBAL_MMR32_BASE |
152 UV_GLOBAL_MMR32_NASID_BITS(nasid) | offset);
153}
154
155static inline void uv_write_global_mmr32(int nasid, unsigned long offset,
156 unsigned long val)
157{
158 *uv_global_mmr32_address(nasid, offset) = val;
159}
160
161static inline unsigned long uv_read_global_mmr32(int nasid,
162 unsigned long offset)
163{
164 return *uv_global_mmr32_address(nasid, offset);
165}
166
167/*
168 * Access Global MMR space using the MMR space located at the top of physical
169 * memory.
170 */
171static inline unsigned long *uv_global_mmr64_address(int nasid,
172 unsigned long offset)
173{
174 return __va(UV_GLOBAL_MMR64_BASE |
175 UV_GLOBAL_MMR64_NASID_BITS(nasid) | offset);
176}
177
178static inline void uv_write_global_mmr64(int nasid, unsigned long offset,
179 unsigned long val)
180{
181 *uv_global_mmr64_address(nasid, offset) = val;
182}
183
184static inline unsigned long uv_read_global_mmr64(int nasid,
185 unsigned long offset)
186{
187 return *uv_global_mmr64_address(nasid, offset);
188}
189
190/*
191 * Access node local MMRs. Faster than using global space but only local MMRs
192 * are accessible.
193 */
194static inline unsigned long *uv_local_mmr_address(unsigned long offset)
195{
196 return __va(UV_LOCAL_MMR_BASE | offset);
197}
198
199static inline unsigned long uv_read_local_mmr(unsigned long offset)
200{
201 return *uv_local_mmr_address(offset);
202}
203
204static inline void uv_write_local_mmr(unsigned long offset, unsigned long val)
205{
206 *uv_local_mmr_address(offset) = val;
207}
208
209/*
210 * Structures and definitions for converting between cpu, node, and blade
211 * numbers.
212 */
213struct uv_blade_info {
214 unsigned short nr_posible_cpus;
215 unsigned short nr_online_cpus;
216 unsigned short nasid;
217};
218struct uv_blade_info *uv_blade_info;
219extern short *uv_node_to_blade;
220extern short *uv_cpu_to_blade;
221extern short uv_possible_blades;
222
223/* Blade-local cpu number of current cpu. Numbered 0 .. <# cpus on the blade> */
224static inline int uv_blade_processor_id(void)
225{
226 return uv_hub_info->blade_processor_id;
227}
228
229/* Blade number of current cpu. Numnbered 0 .. <#blades -1> */
230static inline int uv_numa_blade_id(void)
231{
232 return uv_hub_info->numa_blade_id;
233}
234
235/* Convert a cpu number to the the UV blade number */
236static inline int uv_cpu_to_blade_id(int cpu)
237{
238 return uv_cpu_to_blade[cpu];
239}
240
241/* Convert linux node number to the UV blade number */
242static inline int uv_node_to_blade_id(int nid)
243{
244 return uv_node_to_blade[nid];
245}
246
247/* Convert a blade id to the NASID of the blade */
248static inline int uv_blade_to_nasid(int bid)
249{
250 return uv_blade_info[bid].nasid;
251}
252
253/* Determine the number of possible cpus on a blade */
254static inline int uv_blade_nr_possible_cpus(int bid)
255{
256 return uv_blade_info[bid].nr_posible_cpus;
257}
258
259/* Determine the number of online cpus on a blade */
260static inline int uv_blade_nr_online_cpus(int bid)
261{
262 return uv_blade_info[bid].nr_online_cpus;
263}
264
265/* Convert a cpu id to the NASID of the blade containing the cpu */
266static inline int uv_cpu_to_nasid(int cpu)
267{
268 return uv_blade_info[uv_cpu_to_blade_id(cpu)].nasid;
269}
270
271/* Convert a node number to the NASID of the blade */
272static inline int uv_node_to_nasid(int nid)
273{
274 return uv_blade_info[uv_node_to_blade_id(nid)].nasid;
275}
276
277/* Maximum possible number of blades */
278static inline int uv_num_possible_blades(void)
279{
280 return uv_possible_blades;
281}
282
283#endif /* __ASM_X86_UV_HUB__ */
284
diff --git a/include/asm-x86/uv/uv_mmrs.h b/include/asm-x86/uv/uv_mmrs.h
new file mode 100644
index 000000000000..3b69fe6b6376
--- /dev/null
+++ b/include/asm-x86/uv/uv_mmrs.h
@@ -0,0 +1,373 @@
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 * SGI UV MMR definitions
7 *
8 * Copyright (C) 2007-2008 Silicon Graphics, Inc. All rights reserved.
9 */
10
11#ifndef __ASM_X86_UV_MMRS__
12#define __ASM_X86_UV_MMRS__
13
14/*
15 * AUTO GENERATED - Do not edit
16 */
17
18 #define UV_MMR_ENABLE (1UL << 63)
19
20/* ========================================================================= */
21/* UVH_IPI_INT */
22/* ========================================================================= */
23#define UVH_IPI_INT 0x60500UL
24#define UVH_IPI_INT_32 0x0360
25
26#define UVH_IPI_INT_VECTOR_SHFT 0
27#define UVH_IPI_INT_VECTOR_MASK 0x00000000000000ffUL
28#define UVH_IPI_INT_DELIVERY_MODE_SHFT 8
29#define UVH_IPI_INT_DELIVERY_MODE_MASK 0x0000000000000700UL
30#define UVH_IPI_INT_DESTMODE_SHFT 11
31#define UVH_IPI_INT_DESTMODE_MASK 0x0000000000000800UL
32#define UVH_IPI_INT_APIC_ID_SHFT 16
33#define UVH_IPI_INT_APIC_ID_MASK 0x0000ffffffff0000UL
34#define UVH_IPI_INT_SEND_SHFT 63
35#define UVH_IPI_INT_SEND_MASK 0x8000000000000000UL
36
37union uvh_ipi_int_u {
38 unsigned long v;
39 struct uvh_ipi_int_s {
40 unsigned long vector_ : 8; /* RW */
41 unsigned long delivery_mode : 3; /* RW */
42 unsigned long destmode : 1; /* RW */
43 unsigned long rsvd_12_15 : 4; /* */
44 unsigned long apic_id : 32; /* RW */
45 unsigned long rsvd_48_62 : 15; /* */
46 unsigned long send : 1; /* WP */
47 } s;
48};
49
50/* ========================================================================= */
51/* UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST */
52/* ========================================================================= */
53#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST 0x320050UL
54#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST_32 0x009f0
55
56#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST_ADDRESS_SHFT 4
57#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST_ADDRESS_MASK 0x000007fffffffff0UL
58#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST_NODE_ID_SHFT 49
59#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST_NODE_ID_MASK 0x7ffe000000000000UL
60
61union uvh_lb_bau_intd_payload_queue_first_u {
62 unsigned long v;
63 struct uvh_lb_bau_intd_payload_queue_first_s {
64 unsigned long rsvd_0_3: 4; /* */
65 unsigned long address : 39; /* RW */
66 unsigned long rsvd_43_48: 6; /* */
67 unsigned long node_id : 14; /* RW */
68 unsigned long rsvd_63 : 1; /* */
69 } s;
70};
71
72/* ========================================================================= */
73/* UVH_LB_BAU_INTD_PAYLOAD_QUEUE_LAST */
74/* ========================================================================= */
75#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_LAST 0x320060UL
76#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_LAST_32 0x009f8
77
78#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_LAST_ADDRESS_SHFT 4
79#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_LAST_ADDRESS_MASK 0x000007fffffffff0UL
80
81union uvh_lb_bau_intd_payload_queue_last_u {
82 unsigned long v;
83 struct uvh_lb_bau_intd_payload_queue_last_s {
84 unsigned long rsvd_0_3: 4; /* */
85 unsigned long address : 39; /* RW */
86 unsigned long rsvd_43_63: 21; /* */
87 } s;
88};
89
90/* ========================================================================= */
91/* UVH_LB_BAU_INTD_PAYLOAD_QUEUE_TAIL */
92/* ========================================================================= */
93#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_TAIL 0x320070UL
94#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_TAIL_32 0x00a00
95
96#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_TAIL_ADDRESS_SHFT 4
97#define UVH_LB_BAU_INTD_PAYLOAD_QUEUE_TAIL_ADDRESS_MASK 0x000007fffffffff0UL
98
99union uvh_lb_bau_intd_payload_queue_tail_u {
100 unsigned long v;
101 struct uvh_lb_bau_intd_payload_queue_tail_s {
102 unsigned long rsvd_0_3: 4; /* */
103 unsigned long address : 39; /* RW */
104 unsigned long rsvd_43_63: 21; /* */
105 } s;
106};
107
108/* ========================================================================= */
109/* UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE */
110/* ========================================================================= */
111#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE 0x320080UL
112
113#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_0_SHFT 0
114#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_0_MASK 0x0000000000000001UL
115#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_1_SHFT 1
116#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_1_MASK 0x0000000000000002UL
117#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_2_SHFT 2
118#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_2_MASK 0x0000000000000004UL
119#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_3_SHFT 3
120#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_3_MASK 0x0000000000000008UL
121#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_4_SHFT 4
122#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_4_MASK 0x0000000000000010UL
123#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_5_SHFT 5
124#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_5_MASK 0x0000000000000020UL
125#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_6_SHFT 6
126#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_6_MASK 0x0000000000000040UL
127#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_7_SHFT 7
128#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_PENDING_7_MASK 0x0000000000000080UL
129#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_0_SHFT 8
130#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_0_MASK 0x0000000000000100UL
131#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_1_SHFT 9
132#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_1_MASK 0x0000000000000200UL
133#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_2_SHFT 10
134#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_2_MASK 0x0000000000000400UL
135#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_3_SHFT 11
136#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_3_MASK 0x0000000000000800UL
137#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_4_SHFT 12
138#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_4_MASK 0x0000000000001000UL
139#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_5_SHFT 13
140#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_5_MASK 0x0000000000002000UL
141#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_6_SHFT 14
142#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_6_MASK 0x0000000000004000UL
143#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_7_SHFT 15
144#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_TIMEOUT_7_MASK 0x0000000000008000UL
145union uvh_lb_bau_intd_software_acknowledge_u {
146 unsigned long v;
147 struct uvh_lb_bau_intd_software_acknowledge_s {
148 unsigned long pending_0 : 1; /* RW, W1C */
149 unsigned long pending_1 : 1; /* RW, W1C */
150 unsigned long pending_2 : 1; /* RW, W1C */
151 unsigned long pending_3 : 1; /* RW, W1C */
152 unsigned long pending_4 : 1; /* RW, W1C */
153 unsigned long pending_5 : 1; /* RW, W1C */
154 unsigned long pending_6 : 1; /* RW, W1C */
155 unsigned long pending_7 : 1; /* RW, W1C */
156 unsigned long timeout_0 : 1; /* RW, W1C */
157 unsigned long timeout_1 : 1; /* RW, W1C */
158 unsigned long timeout_2 : 1; /* RW, W1C */
159 unsigned long timeout_3 : 1; /* RW, W1C */
160 unsigned long timeout_4 : 1; /* RW, W1C */
161 unsigned long timeout_5 : 1; /* RW, W1C */
162 unsigned long timeout_6 : 1; /* RW, W1C */
163 unsigned long timeout_7 : 1; /* RW, W1C */
164 unsigned long rsvd_16_63: 48; /* */
165 } s;
166};
167
168/* ========================================================================= */
169/* UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_ALIAS */
170/* ========================================================================= */
171#define UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_ALIAS 0x0000000000320088UL
172
173/* ========================================================================= */
174/* UVH_LB_BAU_SB_ACTIVATION_CONTROL */
175/* ========================================================================= */
176#define UVH_LB_BAU_SB_ACTIVATION_CONTROL 0x320020UL
177#define UVH_LB_BAU_SB_ACTIVATION_CONTROL_32 0x009d8
178
179#define UVH_LB_BAU_SB_ACTIVATION_CONTROL_INDEX_SHFT 0
180#define UVH_LB_BAU_SB_ACTIVATION_CONTROL_INDEX_MASK 0x000000000000003fUL
181#define UVH_LB_BAU_SB_ACTIVATION_CONTROL_PUSH_SHFT 62
182#define UVH_LB_BAU_SB_ACTIVATION_CONTROL_PUSH_MASK 0x4000000000000000UL
183#define UVH_LB_BAU_SB_ACTIVATION_CONTROL_INIT_SHFT 63
184#define UVH_LB_BAU_SB_ACTIVATION_CONTROL_INIT_MASK 0x8000000000000000UL
185
186union uvh_lb_bau_sb_activation_control_u {
187 unsigned long v;
188 struct uvh_lb_bau_sb_activation_control_s {
189 unsigned long index : 6; /* RW */
190 unsigned long rsvd_6_61: 56; /* */
191 unsigned long push : 1; /* WP */
192 unsigned long init : 1; /* WP */
193 } s;
194};
195
196/* ========================================================================= */
197/* UVH_LB_BAU_SB_ACTIVATION_STATUS_0 */
198/* ========================================================================= */
199#define UVH_LB_BAU_SB_ACTIVATION_STATUS_0 0x320030UL
200#define UVH_LB_BAU_SB_ACTIVATION_STATUS_0_32 0x009e0
201
202#define UVH_LB_BAU_SB_ACTIVATION_STATUS_0_STATUS_SHFT 0
203#define UVH_LB_BAU_SB_ACTIVATION_STATUS_0_STATUS_MASK 0xffffffffffffffffUL
204
205union uvh_lb_bau_sb_activation_status_0_u {
206 unsigned long v;
207 struct uvh_lb_bau_sb_activation_status_0_s {
208 unsigned long status : 64; /* RW */
209 } s;
210};
211
212/* ========================================================================= */
213/* UVH_LB_BAU_SB_ACTIVATION_STATUS_1 */
214/* ========================================================================= */
215#define UVH_LB_BAU_SB_ACTIVATION_STATUS_1 0x320040UL
216#define UVH_LB_BAU_SB_ACTIVATION_STATUS_1_32 0x009e8
217
218#define UVH_LB_BAU_SB_ACTIVATION_STATUS_1_STATUS_SHFT 0
219#define UVH_LB_BAU_SB_ACTIVATION_STATUS_1_STATUS_MASK 0xffffffffffffffffUL
220
221union uvh_lb_bau_sb_activation_status_1_u {
222 unsigned long v;
223 struct uvh_lb_bau_sb_activation_status_1_s {
224 unsigned long status : 64; /* RW */
225 } s;
226};
227
228/* ========================================================================= */
229/* UVH_LB_BAU_SB_DESCRIPTOR_BASE */
230/* ========================================================================= */
231#define UVH_LB_BAU_SB_DESCRIPTOR_BASE 0x320010UL
232#define UVH_LB_BAU_SB_DESCRIPTOR_BASE_32 0x009d0
233
234#define UVH_LB_BAU_SB_DESCRIPTOR_BASE_PAGE_ADDRESS_SHFT 12
235#define UVH_LB_BAU_SB_DESCRIPTOR_BASE_PAGE_ADDRESS_MASK 0x000007fffffff000UL
236#define UVH_LB_BAU_SB_DESCRIPTOR_BASE_NODE_ID_SHFT 49
237#define UVH_LB_BAU_SB_DESCRIPTOR_BASE_NODE_ID_MASK 0x7ffe000000000000UL
238
239union uvh_lb_bau_sb_descriptor_base_u {
240 unsigned long v;
241 struct uvh_lb_bau_sb_descriptor_base_s {
242 unsigned long rsvd_0_11 : 12; /* */
243 unsigned long page_address : 31; /* RW */
244 unsigned long rsvd_43_48 : 6; /* */
245 unsigned long node_id : 14; /* RW */
246 unsigned long rsvd_63 : 1; /* */
247 } s;
248};
249
250/* ========================================================================= */
251/* UVH_NODE_ID */
252/* ========================================================================= */
253#define UVH_NODE_ID 0x0UL
254
255#define UVH_NODE_ID_FORCE1_SHFT 0
256#define UVH_NODE_ID_FORCE1_MASK 0x0000000000000001UL
257#define UVH_NODE_ID_MANUFACTURER_SHFT 1
258#define UVH_NODE_ID_MANUFACTURER_MASK 0x0000000000000ffeUL
259#define UVH_NODE_ID_PART_NUMBER_SHFT 12
260#define UVH_NODE_ID_PART_NUMBER_MASK 0x000000000ffff000UL
261#define UVH_NODE_ID_REVISION_SHFT 28
262#define UVH_NODE_ID_REVISION_MASK 0x00000000f0000000UL
263#define UVH_NODE_ID_NODE_ID_SHFT 32
264#define UVH_NODE_ID_NODE_ID_MASK 0x00007fff00000000UL
265#define UVH_NODE_ID_NODES_PER_BIT_SHFT 48
266#define UVH_NODE_ID_NODES_PER_BIT_MASK 0x007f000000000000UL
267#define UVH_NODE_ID_NI_PORT_SHFT 56
268#define UVH_NODE_ID_NI_PORT_MASK 0x0f00000000000000UL
269
270union uvh_node_id_u {
271 unsigned long v;
272 struct uvh_node_id_s {
273 unsigned long force1 : 1; /* RO */
274 unsigned long manufacturer : 11; /* RO */
275 unsigned long part_number : 16; /* RO */
276 unsigned long revision : 4; /* RO */
277 unsigned long node_id : 15; /* RW */
278 unsigned long rsvd_47 : 1; /* */
279 unsigned long nodes_per_bit : 7; /* RW */
280 unsigned long rsvd_55 : 1; /* */
281 unsigned long ni_port : 4; /* RO */
282 unsigned long rsvd_60_63 : 4; /* */
283 } s;
284};
285
286/* ========================================================================= */
287/* UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR */
288/* ========================================================================= */
289#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR 0x1600010UL
290
291#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT 28
292#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_MASK 0x00003ffff0000000UL
293#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_GR4_SHFT 46
294#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_GR4_MASK 0x0000400000000000UL
295#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_N_GRU_SHFT 52
296#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_N_GRU_MASK 0x00f0000000000000UL
297#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_ENABLE_SHFT 63
298#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_ENABLE_MASK 0x8000000000000000UL
299
300union uvh_rh_gam_gru_overlay_config_mmr_u {
301 unsigned long v;
302 struct uvh_rh_gam_gru_overlay_config_mmr_s {
303 unsigned long rsvd_0_27: 28; /* */
304 unsigned long base : 18; /* RW */
305 unsigned long gr4 : 1; /* RW */
306 unsigned long rsvd_47_51: 5; /* */
307 unsigned long n_gru : 4; /* RW */
308 unsigned long rsvd_56_62: 7; /* */
309 unsigned long enable : 1; /* RW */
310 } s;
311};
312
313/* ========================================================================= */
314/* UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR */
315/* ========================================================================= */
316#define UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR 0x1600028UL
317
318#define UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR_BASE_SHFT 26
319#define UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR_BASE_MASK 0x00003ffffc000000UL
320#define UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR_DUAL_HUB_SHFT 46
321#define UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR_DUAL_HUB_MASK 0x0000400000000000UL
322#define UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR_ENABLE_SHFT 63
323#define UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR_ENABLE_MASK 0x8000000000000000UL
324
325union uvh_rh_gam_mmr_overlay_config_mmr_u {
326 unsigned long v;
327 struct uvh_rh_gam_mmr_overlay_config_mmr_s {
328 unsigned long rsvd_0_25: 26; /* */
329 unsigned long base : 20; /* RW */
330 unsigned long dual_hub : 1; /* RW */
331 unsigned long rsvd_47_62: 16; /* */
332 unsigned long enable : 1; /* RW */
333 } s;
334};
335
336/* ========================================================================= */
337/* UVH_RTC */
338/* ========================================================================= */
339#define UVH_RTC 0x28000UL
340
341#define UVH_RTC_REAL_TIME_CLOCK_SHFT 0
342#define UVH_RTC_REAL_TIME_CLOCK_MASK 0x00ffffffffffffffUL
343
344union uvh_rtc_u {
345 unsigned long v;
346 struct uvh_rtc_s {
347 unsigned long real_time_clock : 56; /* RW */
348 unsigned long rsvd_56_63 : 8; /* */
349 } s;
350};
351
352/* ========================================================================= */
353/* UVH_SI_ADDR_MAP_CONFIG */
354/* ========================================================================= */
355#define UVH_SI_ADDR_MAP_CONFIG 0xc80000UL
356
357#define UVH_SI_ADDR_MAP_CONFIG_M_SKT_SHFT 0
358#define UVH_SI_ADDR_MAP_CONFIG_M_SKT_MASK 0x000000000000003fUL
359#define UVH_SI_ADDR_MAP_CONFIG_N_SKT_SHFT 8
360#define UVH_SI_ADDR_MAP_CONFIG_N_SKT_MASK 0x0000000000000f00UL
361
362union uvh_si_addr_map_config_u {
363 unsigned long v;
364 struct uvh_si_addr_map_config_s {
365 unsigned long m_skt : 6; /* RW */
366 unsigned long rsvd_6_7: 2; /* */
367 unsigned long n_skt : 4; /* RW */
368 unsigned long rsvd_12_63: 52; /* */
369 } s;
370};
371
372
373#endif /* __ASM_X86_UV_MMRS__ */
diff --git a/include/asm-x86/vdso.h b/include/asm-x86/vdso.h
index 629bcb6e8e45..86e085e003d2 100644
--- a/include/asm-x86/vdso.h
+++ b/include/asm-x86/vdso.h
@@ -8,9 +8,11 @@ extern const char VDSO64_PRELINK[];
8 * Given a pointer to the vDSO image, find the pointer to VDSO64_name 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. 9 * as that symbol is defined in the vDSO sources or linker script.
10 */ 10 */
11#define VDSO64_SYMBOL(base, name) ({ \ 11#define VDSO64_SYMBOL(base, name) \
12 extern const char VDSO64_##name[]; \ 12({ \
13 (void *) (VDSO64_##name - VDSO64_PRELINK + (unsigned long) (base)); }) 13 extern const char VDSO64_##name[]; \
14 (void *)(VDSO64_##name - VDSO64_PRELINK + (unsigned long)(base)); \
15})
14#endif 16#endif
15 17
16#if defined CONFIG_X86_32 || defined CONFIG_COMPAT 18#if defined CONFIG_X86_32 || defined CONFIG_COMPAT
@@ -20,9 +22,18 @@ extern const char VDSO32_PRELINK[];
20 * Given a pointer to the vDSO image, find the pointer to VDSO32_name 22 * 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. 23 * as that symbol is defined in the vDSO sources or linker script.
22 */ 24 */
23#define VDSO32_SYMBOL(base, name) ({ \ 25#define VDSO32_SYMBOL(base, name) \
24 extern const char VDSO32_##name[]; \ 26({ \
25 (void *) (VDSO32_##name - VDSO32_PRELINK + (unsigned long) (base)); }) 27 extern const char VDSO32_##name[]; \
28 (void *)(VDSO32_##name - VDSO32_PRELINK + (unsigned long)(base)); \
29})
26#endif 30#endif
27 31
32/*
33 * These symbols are defined with the addresses in the vsyscall page.
34 * See vsyscall-sigreturn.S.
35 */
36extern void __user __kernel_sigreturn;
37extern void __user __kernel_rt_sigreturn;
38
28#endif /* asm-x86/vdso.h */ 39#endif /* asm-x86/vdso.h */
diff --git a/include/asm-x86/vga.h b/include/asm-x86/vga.h
index 0ecf68ac03aa..0ccf804377e6 100644
--- a/include/asm-x86/vga.h
+++ b/include/asm-x86/vga.h
@@ -12,9 +12,9 @@
12 * access the videoram directly without any black magic. 12 * access the videoram directly without any black magic.
13 */ 13 */
14 14
15#define VGA_MAP_MEM(x,s) (unsigned long)phys_to_virt(x) 15#define VGA_MAP_MEM(x, s) (unsigned long)phys_to_virt(x)
16 16
17#define vga_readb(x) (*(x)) 17#define vga_readb(x) (*(x))
18#define vga_writeb(x,y) (*(y) = (x)) 18#define vga_writeb(x, y) (*(y) = (x))
19 19
20#endif 20#endif
diff --git a/include/asm-x86/vm86.h b/include/asm-x86/vm86.h
index c92fe4af52e8..074b357146df 100644
--- a/include/asm-x86/vm86.h
+++ b/include/asm-x86/vm86.h
@@ -12,19 +12,13 @@
12 * Linus 12 * Linus
13 */ 13 */
14 14
15#define TF_MASK 0x00000100 15#include <asm/processor-flags.h>
16#define IF_MASK 0x00000200 16
17#define IOPL_MASK 0x00003000
18#define NT_MASK 0x00004000
19#ifdef CONFIG_VM86 17#ifdef CONFIG_VM86
20#define VM_MASK 0x00020000 18#define X86_VM_MASK X86_EFLAGS_VM
21#else 19#else
22#define VM_MASK 0 /* ignored */ 20#define X86_VM_MASK 0 /* No VM86 support */
23#endif 21#endif
24#define AC_MASK 0x00040000
25#define VIF_MASK 0x00080000 /* virtual interrupt flag */
26#define VIP_MASK 0x00100000 /* virtual interrupt pending */
27#define ID_MASK 0x00200000
28 22
29#define BIOSSEG 0x0f000 23#define BIOSSEG 0x0f000
30 24
@@ -42,9 +36,11 @@
42#define VM86_ARG(retval) ((retval) >> 8) 36#define VM86_ARG(retval) ((retval) >> 8)
43 37
44#define VM86_SIGNAL 0 /* return due to signal */ 38#define VM86_SIGNAL 0 /* return due to signal */
45#define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ 39#define VM86_UNKNOWN 1 /* unhandled GP fault
40 - IO-instruction or similar */
46#define VM86_INTx 2 /* int3/int x instruction (ARG = x) */ 41#define VM86_INTx 2 /* int3/int x instruction (ARG = x) */
47#define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ 42#define VM86_STI 3 /* sti/popf/iret instruction enabled
43 virtual interrupts */
48 44
49/* 45/*
50 * Additional return values when invoking new vm86() 46 * Additional return values when invoking new vm86()
@@ -205,7 +201,8 @@ void release_vm86_irqs(struct task_struct *);
205#define handle_vm86_fault(a, b) 201#define handle_vm86_fault(a, b)
206#define release_vm86_irqs(a) 202#define release_vm86_irqs(a)
207 203
208static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c) { 204static inline int handle_vm86_trap(struct kernel_vm86_regs *a, long b, int c)
205{
209 return 0; 206 return 0;
210} 207}
211 208
diff --git a/include/asm-x86/vmi.h b/include/asm-x86/vmi.h
index eb8bd892c01e..b7c0dea119fe 100644
--- a/include/asm-x86/vmi.h
+++ b/include/asm-x86/vmi.h
@@ -155,9 +155,9 @@
155 155
156#ifndef __ASSEMBLY__ 156#ifndef __ASSEMBLY__
157struct vmi_relocation_info { 157struct vmi_relocation_info {
158 unsigned char *eip; 158 unsigned char *eip;
159 unsigned char type; 159 unsigned char type;
160 unsigned char reserved[3]; 160 unsigned char reserved[3];
161}; 161};
162#endif 162#endif
163 163
@@ -173,53 +173,53 @@ struct vmi_relocation_info {
173#ifndef __ASSEMBLY__ 173#ifndef __ASSEMBLY__
174 174
175struct vrom_header { 175struct vrom_header {
176 u16 rom_signature; // option ROM signature 176 u16 rom_signature; /* option ROM signature */
177 u8 rom_length; // ROM length in 512 byte chunks 177 u8 rom_length; /* ROM length in 512 byte chunks */
178 u8 rom_entry[4]; // 16-bit code entry point 178 u8 rom_entry[4]; /* 16-bit code entry point */
179 u8 rom_pad0; // 4-byte align pad 179 u8 rom_pad0; /* 4-byte align pad */
180 u32 vrom_signature; // VROM identification signature 180 u32 vrom_signature; /* VROM identification signature */
181 u8 api_version_min;// Minor version of API 181 u8 api_version_min;/* Minor version of API */
182 u8 api_version_maj;// Major version of API 182 u8 api_version_maj;/* Major version of API */
183 u8 jump_slots; // Number of jump slots 183 u8 jump_slots; /* Number of jump slots */
184 u8 reserved1; // Reserved for expansion 184 u8 reserved1; /* Reserved for expansion */
185 u32 virtual_top; // Hypervisor virtual address start 185 u32 virtual_top; /* Hypervisor virtual address start */
186 u16 reserved2; // Reserved for expansion 186 u16 reserved2; /* Reserved for expansion */
187 u16 license_offs; // Offset to License string 187 u16 license_offs; /* Offset to License string */
188 u16 pci_header_offs;// Offset to PCI OPROM header 188 u16 pci_header_offs;/* Offset to PCI OPROM header */
189 u16 pnp_header_offs;// Offset to PnP OPROM header 189 u16 pnp_header_offs;/* Offset to PnP OPROM header */
190 u32 rom_pad3; // PnP reserverd / VMI reserved 190 u32 rom_pad3; /* PnP reserverd / VMI reserved */
191 u8 reserved[96]; // Reserved for headers 191 u8 reserved[96]; /* Reserved for headers */
192 char vmi_init[8]; // VMI_Init jump point 192 char vmi_init[8]; /* VMI_Init jump point */
193 char get_reloc[8]; // VMI_GetRelocationInfo jump point 193 char get_reloc[8]; /* VMI_GetRelocationInfo jump point */
194} __attribute__((packed)); 194} __attribute__((packed));
195 195
196struct pnp_header { 196struct pnp_header {
197 char sig[4]; 197 char sig[4];
198 char rev; 198 char rev;
199 char size; 199 char size;
200 short next; 200 short next;
201 short res; 201 short res;
202 long devID; 202 long devID;
203 unsigned short manufacturer_offset; 203 unsigned short manufacturer_offset;
204 unsigned short product_offset; 204 unsigned short product_offset;
205} __attribute__((packed)); 205} __attribute__((packed));
206 206
207struct pci_header { 207struct pci_header {
208 char sig[4]; 208 char sig[4];
209 short vendorID; 209 short vendorID;
210 short deviceID; 210 short deviceID;
211 short vpdData; 211 short vpdData;
212 short size; 212 short size;
213 char rev; 213 char rev;
214 char class; 214 char class;
215 char subclass; 215 char subclass;
216 char interface; 216 char interface;
217 short chunks; 217 short chunks;
218 char rom_version_min; 218 char rom_version_min;
219 char rom_version_maj; 219 char rom_version_maj;
220 char codetype; 220 char codetype;
221 char lastRom; 221 char lastRom;
222 short reserved; 222 short reserved;
223} __attribute__((packed)); 223} __attribute__((packed));
224 224
225/* Function prototypes for bootstrapping */ 225/* Function prototypes for bootstrapping */
diff --git a/include/asm-x86/voyager.h b/include/asm-x86/voyager.h
index 91a9932937ab..9c811d2e6f91 100644
--- a/include/asm-x86/voyager.h
+++ b/include/asm-x86/voyager.h
@@ -91,8 +91,7 @@
91#define VOYAGER_WRITE_CONFIG 0x2 91#define VOYAGER_WRITE_CONFIG 0x2
92#define VOYAGER_BYPASS 0xff 92#define VOYAGER_BYPASS 0xff
93 93
94typedef struct voyager_asic 94typedef struct voyager_asic {
95{
96 __u8 asic_addr; /* ASIC address; Level 4 */ 95 __u8 asic_addr; /* ASIC address; Level 4 */
97 __u8 asic_type; /* ASIC type */ 96 __u8 asic_type; /* ASIC type */
98 __u8 asic_id; /* ASIC id */ 97 __u8 asic_id; /* ASIC id */
@@ -113,7 +112,7 @@ typedef struct voyager_module {
113 __u16 largest_reg; /* Largest register in the scan path */ 112 __u16 largest_reg; /* Largest register in the scan path */
114 __u16 smallest_reg; /* Smallest register in the scan path */ 113 __u16 smallest_reg; /* Smallest register in the scan path */
115 voyager_asic_t *asic; /* First ASIC in scan path (CAT_I) */ 114 voyager_asic_t *asic; /* First ASIC in scan path (CAT_I) */
116 struct voyager_module *submodule; /* Submodule pointer */ 115 struct voyager_module *submodule; /* Submodule pointer */
117 struct voyager_module *next; /* Next module in linked list */ 116 struct voyager_module *next; /* Next module in linked list */
118} voyager_module_t; 117} voyager_module_t;
119 118
@@ -135,7 +134,7 @@ typedef struct voyager_eeprom_hdr {
135 __u16 cct_offset; 134 __u16 cct_offset;
136 __u16 log_length; /* length of err log */ 135 __u16 log_length; /* length of err log */
137 __u16 xsum_end; /* offset to end of 136 __u16 xsum_end; /* offset to end of
138 checksum */ 137 checksum */
139 __u8 reserved[4]; 138 __u8 reserved[4];
140 __u8 sflag; /* starting sentinal */ 139 __u8 sflag; /* starting sentinal */
141 __u8 part_number[13]; /* prom part number */ 140 __u8 part_number[13]; /* prom part number */
@@ -148,7 +147,8 @@ typedef struct voyager_eeprom_hdr {
148 147
149 148
150 149
151#define VOYAGER_EPROM_SIZE_OFFSET ((__u16)(&(((voyager_eprom_hdr_t *)0)->ee_size))) 150#define VOYAGER_EPROM_SIZE_OFFSET \
151 ((__u16)(&(((voyager_eprom_hdr_t *)0)->ee_size)))
152#define VOYAGER_XSUM_END_OFFSET 0x2a 152#define VOYAGER_XSUM_END_OFFSET 0x2a
153 153
154/* the following three definitions are for internal table layouts 154/* the following three definitions are for internal table layouts
@@ -199,7 +199,7 @@ typedef struct voyager_asic_data_table {
199#define VOYAGER_WCBIC_TOM_L 0x4 199#define VOYAGER_WCBIC_TOM_L 0x4
200#define VOYAGER_WCBIC_TOM_H 0x5 200#define VOYAGER_WCBIC_TOM_H 0x5
201 201
202/* register defines for Voyager Memory Contol (VMC) 202/* register defines for Voyager Memory Contol (VMC)
203 * these are present on L4 machines only */ 203 * these are present on L4 machines only */
204#define VOYAGER_VMC1 0x81 204#define VOYAGER_VMC1 0x81
205#define VOYAGER_VMC2 0x91 205#define VOYAGER_VMC2 0x91
@@ -334,7 +334,7 @@ typedef struct {
334 334
335struct QuadDescription { 335struct QuadDescription {
336 __u8 Type; /* for type 0 (DYADIC or MONADIC) all fields 336 __u8 Type; /* for type 0 (DYADIC or MONADIC) all fields
337 * will be zero except for slot */ 337 * will be zero except for slot */
338 __u8 StructureVersion; 338 __u8 StructureVersion;
339 __u32 CPI_BaseAddress; 339 __u32 CPI_BaseAddress;
340 __u32 LARC_BankSize; 340 __u32 LARC_BankSize;
@@ -342,7 +342,7 @@ struct QuadDescription {
342 __u8 Slot; /* Processor slots 1 - 4 */ 342 __u8 Slot; /* Processor slots 1 - 4 */
343} __attribute__((packed)); 343} __attribute__((packed));
344 344
345struct ProcBoardInfo { 345struct ProcBoardInfo {
346 __u8 Type; 346 __u8 Type;
347 __u8 StructureVersion; 347 __u8 StructureVersion;
348 __u8 NumberOfBoards; 348 __u8 NumberOfBoards;
@@ -382,19 +382,30 @@ struct CPU_Info {
382 * packed in it by our friend the compiler. 382 * packed in it by our friend the compiler.
383 */ 383 */
384typedef struct { 384typedef struct {
385 __u8 Mailbox_SUS; /* Written to by SUS to give commands/response to the OS */ 385 __u8 Mailbox_SUS; /* Written to by SUS to give
386 __u8 Mailbox_OS; /* Written to by the OS to give commands/response to SUS */ 386 commands/response to the OS */
387 __u8 SUS_MailboxVersion; /* Tells the OS which iteration of the interface SUS supports */ 387 __u8 Mailbox_OS; /* Written to by the OS to give
388 __u8 OS_MailboxVersion; /* Tells SUS which iteration of the interface the OS supports */ 388 commands/response to SUS */
389 __u32 OS_Flags; /* Flags set by the OS as info for SUS */ 389 __u8 SUS_MailboxVersion; /* Tells the OS which iteration of the
390 __u32 SUS_Flags; /* Flags set by SUS as info for the OS */ 390 interface SUS supports */
391 __u32 WatchDogPeriod; /* Watchdog period (in seconds) which the DP uses to see if the OS is dead */ 391 __u8 OS_MailboxVersion; /* Tells SUS which iteration of the
392 interface the OS supports */
393 __u32 OS_Flags; /* Flags set by the OS as info for
394 SUS */
395 __u32 SUS_Flags; /* Flags set by SUS as info
396 for the OS */
397 __u32 WatchDogPeriod; /* Watchdog period (in seconds) which
398 the DP uses to see if the OS
399 is dead */
392 __u32 WatchDogCount; /* Updated by the OS on every tic. */ 400 __u32 WatchDogCount; /* Updated by the OS on every tic. */
393 __u32 MemoryFor_SUS_ErrorLog; /* Flat 32 bit address which tells SUS where to stuff the SUS error log on a dump */ 401 __u32 MemoryFor_SUS_ErrorLog; /* Flat 32 bit address which tells SUS
394 MC_SlotInformation_t MC_SlotInfo[NUMBER_OF_MC_BUSSES*SLOTS_PER_MC_BUS]; /* Storage for MCA POS data */ 402 where to stuff the SUS error log
403 on a dump */
404 MC_SlotInformation_t MC_SlotInfo[NUMBER_OF_MC_BUSSES*SLOTS_PER_MC_BUS];
405 /* Storage for MCA POS data */
395 /* All new SECOND_PASS_INTERFACE fields added from this point */ 406 /* All new SECOND_PASS_INTERFACE fields added from this point */
396 struct ProcBoardInfo *BoardData; 407 struct ProcBoardInfo *BoardData;
397 struct CPU_Info *CPU_Data; 408 struct CPU_Info *CPU_Data;
398 /* All new fields must be added from this point */ 409 /* All new fields must be added from this point */
399} Voyager_KernelSUS_Mbox_t; 410} Voyager_KernelSUS_Mbox_t;
400 411
@@ -478,7 +489,7 @@ struct voyager_SUS {
478 __u32 SUS_errorlog; 489 __u32 SUS_errorlog;
479 /* lots of system configuration stuff under here */ 490 /* lots of system configuration stuff under here */
480}; 491};
481 492
482/* Variables exported by voyager_smp */ 493/* Variables exported by voyager_smp */
483extern __u32 voyager_extended_vic_processors; 494extern __u32 voyager_extended_vic_processors;
484extern __u32 voyager_allowed_boot_processors; 495extern __u32 voyager_allowed_boot_processors;
diff --git a/include/asm-x86/xen/events.h b/include/asm-x86/xen/events.h
new file mode 100644
index 000000000000..596312a7bfc9
--- /dev/null
+++ b/include/asm-x86/xen/events.h
@@ -0,0 +1,22 @@
1#ifndef __XEN_EVENTS_H
2#define __XEN_EVENTS_H
3
4enum ipi_vector {
5 XEN_RESCHEDULE_VECTOR,
6 XEN_CALL_FUNCTION_VECTOR,
7
8 XEN_NR_IPIS,
9};
10
11static inline int xen_irqs_disabled(struct pt_regs *regs)
12{
13 return raw_irqs_disabled_flags(regs->flags);
14}
15
16static inline void xen_do_IRQ(int irq, struct pt_regs *regs)
17{
18 regs->orig_ax = ~irq;
19 do_IRQ(regs);
20}
21
22#endif /* __XEN_EVENTS_H */
diff --git a/include/asm-x86/xen/grant_table.h b/include/asm-x86/xen/grant_table.h
new file mode 100644
index 000000000000..2444d4593a3b
--- /dev/null
+++ b/include/asm-x86/xen/grant_table.h
@@ -0,0 +1,7 @@
1#ifndef __XEN_GRANT_TABLE_H
2#define __XEN_GRANT_TABLE_H
3
4#define xen_alloc_vm_area(size) alloc_vm_area(size)
5#define xen_free_vm_area(area) free_vm_area(area)
6
7#endif /* __XEN_GRANT_TABLE_H */
diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index bc0ee7d961ca..c2ccd997ed35 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -164,6 +164,12 @@ HYPERVISOR_set_callbacks(unsigned long event_selector,
164} 164}
165 165
166static inline int 166static inline int
167HYPERVISOR_callback_op(int cmd, void *arg)
168{
169 return _hypercall2(int, callback_op, cmd, arg);
170}
171
172static inline int
167HYPERVISOR_fpu_taskswitch(int set) 173HYPERVISOR_fpu_taskswitch(int set)
168{ 174{
169 return _hypercall1(int, fpu_taskswitch, set); 175 return _hypercall1(int, fpu_taskswitch, set);
diff --git a/include/asm-x86/xen/interface.h b/include/asm-x86/xen/interface.h
index 165c3968e138..6227000a1e84 100644
--- a/include/asm-x86/xen/interface.h
+++ b/include/asm-x86/xen/interface.h
@@ -22,6 +22,30 @@
22#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name) 22#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
23#define GUEST_HANDLE(name) __guest_handle_ ## name 23#define GUEST_HANDLE(name) __guest_handle_ ## name
24 24
25#ifdef __XEN__
26#if defined(__i386__)
27#define set_xen_guest_handle(hnd, val) \
28 do { \
29 if (sizeof(hnd) == 8) \
30 *(uint64_t *)&(hnd) = 0; \
31 (hnd).p = val; \
32 } while (0)
33#elif defined(__x86_64__)
34#define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
35#endif
36#else
37#if defined(__i386__)
38#define set_xen_guest_handle(hnd, val) \
39 do { \
40 if (sizeof(hnd) == 8) \
41 *(uint64_t *)&(hnd) = 0; \
42 (hnd) = val; \
43 } while (0)
44#elif defined(__x86_64__)
45#define set_xen_guest_handle(hnd, val) do { (hnd) = val; } while (0)
46#endif
47#endif
48
25#ifndef __ASSEMBLY__ 49#ifndef __ASSEMBLY__
26/* Guest handles for primitive C types. */ 50/* Guest handles for primitive C types. */
27__DEFINE_GUEST_HANDLE(uchar, unsigned char); 51__DEFINE_GUEST_HANDLE(uchar, unsigned char);
@@ -171,6 +195,10 @@ struct arch_vcpu_info {
171 unsigned long pad[5]; /* sizeof(struct vcpu_info) == 64 */ 195 unsigned long pad[5]; /* sizeof(struct vcpu_info) == 64 */
172}; 196};
173 197
198struct xen_callback {
199 unsigned long cs;
200 unsigned long eip;
201};
174#endif /* !__ASSEMBLY__ */ 202#endif /* !__ASSEMBLY__ */
175 203
176/* 204/*
diff --git a/include/asm-x86/xen/page.h b/include/asm-x86/xen/page.h
new file mode 100644
index 000000000000..01799305f02a
--- /dev/null
+++ b/include/asm-x86/xen/page.h
@@ -0,0 +1,168 @@
1#ifndef __XEN_PAGE_H
2#define __XEN_PAGE_H
3
4#include <linux/pfn.h>
5
6#include <asm/uaccess.h>
7#include <asm/pgtable.h>
8
9#include <xen/features.h>
10
11/* Xen machine address */
12typedef struct xmaddr {
13 phys_addr_t maddr;
14} xmaddr_t;
15
16/* Xen pseudo-physical address */
17typedef struct xpaddr {
18 phys_addr_t paddr;
19} xpaddr_t;
20
21#define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
22#define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
23
24/**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
25#define INVALID_P2M_ENTRY (~0UL)
26#define FOREIGN_FRAME_BIT (1UL<<31)
27#define FOREIGN_FRAME(m) ((m) | FOREIGN_FRAME_BIT)
28
29extern unsigned long *phys_to_machine_mapping;
30
31static inline unsigned long pfn_to_mfn(unsigned long pfn)
32{
33 if (xen_feature(XENFEAT_auto_translated_physmap))
34 return pfn;
35
36 return phys_to_machine_mapping[(unsigned int)(pfn)] &
37 ~FOREIGN_FRAME_BIT;
38}
39
40static inline int phys_to_machine_mapping_valid(unsigned long pfn)
41{
42 if (xen_feature(XENFEAT_auto_translated_physmap))
43 return 1;
44
45 return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
46}
47
48static inline unsigned long mfn_to_pfn(unsigned long mfn)
49{
50 unsigned long pfn;
51
52 if (xen_feature(XENFEAT_auto_translated_physmap))
53 return mfn;
54
55#if 0
56 if (unlikely((mfn >> machine_to_phys_order) != 0))
57 return max_mapnr;
58#endif
59
60 pfn = 0;
61 /*
62 * The array access can fail (e.g., device space beyond end of RAM).
63 * In such cases it doesn't matter what we return (we return garbage),
64 * but we must handle the fault without crashing!
65 */
66 __get_user(pfn, &machine_to_phys_mapping[mfn]);
67
68 return pfn;
69}
70
71static inline xmaddr_t phys_to_machine(xpaddr_t phys)
72{
73 unsigned offset = phys.paddr & ~PAGE_MASK;
74 return XMADDR(PFN_PHYS((u64)pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
75}
76
77static inline xpaddr_t machine_to_phys(xmaddr_t machine)
78{
79 unsigned offset = machine.maddr & ~PAGE_MASK;
80 return XPADDR(PFN_PHYS((u64)mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
81}
82
83/*
84 * We detect special mappings in one of two ways:
85 * 1. If the MFN is an I/O page then Xen will set the m2p entry
86 * to be outside our maximum possible pseudophys range.
87 * 2. If the MFN belongs to a different domain then we will certainly
88 * not have MFN in our p2m table. Conversely, if the page is ours,
89 * then we'll have p2m(m2p(MFN))==MFN.
90 * If we detect a special mapping then it doesn't have a 'struct page'.
91 * We force !pfn_valid() by returning an out-of-range pointer.
92 *
93 * NB. These checks require that, for any MFN that is not in our reservation,
94 * there is no PFN such that p2m(PFN) == MFN. Otherwise we can get confused if
95 * we are foreign-mapping the MFN, and the other domain as m2p(MFN) == PFN.
96 * Yikes! Various places must poke in INVALID_P2M_ENTRY for safety.
97 *
98 * NB2. When deliberately mapping foreign pages into the p2m table, you *must*
99 * use FOREIGN_FRAME(). This will cause pte_pfn() to choke on it, as we
100 * require. In all the cases we care about, the FOREIGN_FRAME bit is
101 * masked (e.g., pfn_to_mfn()) so behaviour there is correct.
102 */
103static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
104{
105 extern unsigned long max_mapnr;
106 unsigned long pfn = mfn_to_pfn(mfn);
107 if ((pfn < max_mapnr)
108 && !xen_feature(XENFEAT_auto_translated_physmap)
109 && (phys_to_machine_mapping[pfn] != mfn))
110 return max_mapnr; /* force !pfn_valid() */
111 return pfn;
112}
113
114static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
115{
116 if (xen_feature(XENFEAT_auto_translated_physmap)) {
117 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
118 return;
119 }
120 phys_to_machine_mapping[pfn] = mfn;
121}
122
123/* VIRT <-> MACHINE conversion */
124#define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
125#define virt_to_mfn(v) (pfn_to_mfn(PFN_DOWN(__pa(v))))
126#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
127
128static inline unsigned long pte_mfn(pte_t pte)
129{
130 return (pte.pte & ~_PAGE_NX) >> PAGE_SHIFT;
131}
132
133static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot)
134{
135 pte_t pte;
136
137 pte.pte = ((phys_addr_t)page_nr << PAGE_SHIFT) |
138 (pgprot_val(pgprot) & __supported_pte_mask);
139
140 return pte;
141}
142
143static inline pteval_t pte_val_ma(pte_t pte)
144{
145 return pte.pte;
146}
147
148static inline pte_t __pte_ma(pteval_t x)
149{
150 return (pte_t) { .pte = x };
151}
152
153#ifdef CONFIG_X86_PAE
154#define pmd_val_ma(v) ((v).pmd)
155#define pud_val_ma(v) ((v).pgd.pgd)
156#define __pmd_ma(x) ((pmd_t) { (x) } )
157#else /* !X86_PAE */
158#define pmd_val_ma(v) ((v).pud.pgd.pgd)
159#endif /* CONFIG_X86_PAE */
160
161#define pgd_val_ma(x) ((x).pgd)
162
163
164xmaddr_t arbitrary_virt_to_machine(unsigned long address);
165void make_lowmem_page_readonly(void *vaddr);
166void make_lowmem_page_readwrite(void *vaddr);
167
168#endif /* __XEN_PAGE_H */
diff --git a/include/asm-x86/xor_32.h b/include/asm-x86/xor_32.h
index a41ef1bdd424..067b5c1835a3 100644
--- a/include/asm-x86/xor_32.h
+++ b/include/asm-x86/xor_32.h
@@ -16,12 +16,12 @@
16 * Copyright (C) 1998 Ingo Molnar. 16 * Copyright (C) 1998 Ingo Molnar.
17 */ 17 */
18 18
19#define LD(x,y) " movq 8*("#x")(%1), %%mm"#y" ;\n" 19#define LD(x, y) " movq 8*("#x")(%1), %%mm"#y" ;\n"
20#define ST(x,y) " movq %%mm"#y", 8*("#x")(%1) ;\n" 20#define ST(x, y) " movq %%mm"#y", 8*("#x")(%1) ;\n"
21#define XO1(x,y) " pxor 8*("#x")(%2), %%mm"#y" ;\n" 21#define XO1(x, y) " pxor 8*("#x")(%2), %%mm"#y" ;\n"
22#define XO2(x,y) " pxor 8*("#x")(%3), %%mm"#y" ;\n" 22#define XO2(x, y) " pxor 8*("#x")(%3), %%mm"#y" ;\n"
23#define XO3(x,y) " pxor 8*("#x")(%4), %%mm"#y" ;\n" 23#define XO3(x, y) " pxor 8*("#x")(%4), %%mm"#y" ;\n"
24#define XO4(x,y) " pxor 8*("#x")(%5), %%mm"#y" ;\n" 24#define XO4(x, y) " pxor 8*("#x")(%5), %%mm"#y" ;\n"
25 25
26#include <asm/i387.h> 26#include <asm/i387.h>
27 27
@@ -32,24 +32,24 @@ xor_pII_mmx_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
32 32
33 kernel_fpu_begin(); 33 kernel_fpu_begin();
34 34
35 __asm__ __volatile__ ( 35 asm volatile(
36#undef BLOCK 36#undef BLOCK
37#define BLOCK(i) \ 37#define BLOCK(i) \
38 LD(i,0) \ 38 LD(i, 0) \
39 LD(i+1,1) \ 39 LD(i + 1, 1) \
40 LD(i+2,2) \ 40 LD(i + 2, 2) \
41 LD(i+3,3) \ 41 LD(i + 3, 3) \
42 XO1(i,0) \ 42 XO1(i, 0) \
43 ST(i,0) \ 43 ST(i, 0) \
44 XO1(i+1,1) \ 44 XO1(i+1, 1) \
45 ST(i+1,1) \ 45 ST(i+1, 1) \
46 XO1(i+2,2) \ 46 XO1(i + 2, 2) \
47 ST(i+2,2) \ 47 ST(i + 2, 2) \
48 XO1(i+3,3) \ 48 XO1(i + 3, 3) \
49 ST(i+3,3) 49 ST(i + 3, 3)
50 50
51 " .align 32 ;\n" 51 " .align 32 ;\n"
52 " 1: ;\n" 52 " 1: ;\n"
53 53
54 BLOCK(0) 54 BLOCK(0)
55 BLOCK(4) 55 BLOCK(4)
@@ -76,25 +76,25 @@ xor_pII_mmx_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
76 76
77 kernel_fpu_begin(); 77 kernel_fpu_begin();
78 78
79 __asm__ __volatile__ ( 79 asm volatile(
80#undef BLOCK 80#undef BLOCK
81#define BLOCK(i) \ 81#define BLOCK(i) \
82 LD(i,0) \ 82 LD(i, 0) \
83 LD(i+1,1) \ 83 LD(i + 1, 1) \
84 LD(i+2,2) \ 84 LD(i + 2, 2) \
85 LD(i+3,3) \ 85 LD(i + 3, 3) \
86 XO1(i,0) \ 86 XO1(i, 0) \
87 XO1(i+1,1) \ 87 XO1(i + 1, 1) \
88 XO1(i+2,2) \ 88 XO1(i + 2, 2) \
89 XO1(i+3,3) \ 89 XO1(i + 3, 3) \
90 XO2(i,0) \ 90 XO2(i, 0) \
91 ST(i,0) \ 91 ST(i, 0) \
92 XO2(i+1,1) \ 92 XO2(i + 1, 1) \
93 ST(i+1,1) \ 93 ST(i + 1, 1) \
94 XO2(i+2,2) \ 94 XO2(i + 2, 2) \
95 ST(i+2,2) \ 95 ST(i + 2, 2) \
96 XO2(i+3,3) \ 96 XO2(i + 3, 3) \
97 ST(i+3,3) 97 ST(i + 3, 3)
98 98
99 " .align 32 ;\n" 99 " .align 32 ;\n"
100 " 1: ;\n" 100 " 1: ;\n"
@@ -125,29 +125,29 @@ xor_pII_mmx_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
125 125
126 kernel_fpu_begin(); 126 kernel_fpu_begin();
127 127
128 __asm__ __volatile__ ( 128 asm volatile(
129#undef BLOCK 129#undef BLOCK
130#define BLOCK(i) \ 130#define BLOCK(i) \
131 LD(i,0) \ 131 LD(i, 0) \
132 LD(i+1,1) \ 132 LD(i + 1, 1) \
133 LD(i+2,2) \ 133 LD(i + 2, 2) \
134 LD(i+3,3) \ 134 LD(i + 3, 3) \
135 XO1(i,0) \ 135 XO1(i, 0) \
136 XO1(i+1,1) \ 136 XO1(i + 1, 1) \
137 XO1(i+2,2) \ 137 XO1(i + 2, 2) \
138 XO1(i+3,3) \ 138 XO1(i + 3, 3) \
139 XO2(i,0) \ 139 XO2(i, 0) \
140 XO2(i+1,1) \ 140 XO2(i + 1, 1) \
141 XO2(i+2,2) \ 141 XO2(i + 2, 2) \
142 XO2(i+3,3) \ 142 XO2(i + 3, 3) \
143 XO3(i,0) \ 143 XO3(i, 0) \
144 ST(i,0) \ 144 ST(i, 0) \
145 XO3(i+1,1) \ 145 XO3(i + 1, 1) \
146 ST(i+1,1) \ 146 ST(i + 1, 1) \
147 XO3(i+2,2) \ 147 XO3(i + 2, 2) \
148 ST(i+2,2) \ 148 ST(i + 2, 2) \
149 XO3(i+3,3) \ 149 XO3(i + 3, 3) \
150 ST(i+3,3) 150 ST(i + 3, 3)
151 151
152 " .align 32 ;\n" 152 " .align 32 ;\n"
153 " 1: ;\n" 153 " 1: ;\n"
@@ -186,35 +186,35 @@ xor_pII_mmx_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
186 because we modify p4 and p5 there, but we can't mark them 186 because we modify p4 and p5 there, but we can't mark them
187 as read/write, otherwise we'd overflow the 10-asm-operands 187 as read/write, otherwise we'd overflow the 10-asm-operands
188 limit of GCC < 3.1. */ 188 limit of GCC < 3.1. */
189 __asm__ ("" : "+r" (p4), "+r" (p5)); 189 asm("" : "+r" (p4), "+r" (p5));
190 190
191 __asm__ __volatile__ ( 191 asm volatile(
192#undef BLOCK 192#undef BLOCK
193#define BLOCK(i) \ 193#define BLOCK(i) \
194 LD(i,0) \ 194 LD(i, 0) \
195 LD(i+1,1) \ 195 LD(i + 1, 1) \
196 LD(i+2,2) \ 196 LD(i + 2, 2) \
197 LD(i+3,3) \ 197 LD(i + 3, 3) \
198 XO1(i,0) \ 198 XO1(i, 0) \
199 XO1(i+1,1) \ 199 XO1(i + 1, 1) \
200 XO1(i+2,2) \ 200 XO1(i + 2, 2) \
201 XO1(i+3,3) \ 201 XO1(i + 3, 3) \
202 XO2(i,0) \ 202 XO2(i, 0) \
203 XO2(i+1,1) \ 203 XO2(i + 1, 1) \
204 XO2(i+2,2) \ 204 XO2(i + 2, 2) \
205 XO2(i+3,3) \ 205 XO2(i + 3, 3) \
206 XO3(i,0) \ 206 XO3(i, 0) \
207 XO3(i+1,1) \ 207 XO3(i + 1, 1) \
208 XO3(i+2,2) \ 208 XO3(i + 2, 2) \
209 XO3(i+3,3) \ 209 XO3(i + 3, 3) \
210 XO4(i,0) \ 210 XO4(i, 0) \
211 ST(i,0) \ 211 ST(i, 0) \
212 XO4(i+1,1) \ 212 XO4(i + 1, 1) \
213 ST(i+1,1) \ 213 ST(i + 1, 1) \
214 XO4(i+2,2) \ 214 XO4(i + 2, 2) \
215 ST(i+2,2) \ 215 ST(i + 2, 2) \
216 XO4(i+3,3) \ 216 XO4(i + 3, 3) \
217 ST(i+3,3) 217 ST(i + 3, 3)
218 218
219 " .align 32 ;\n" 219 " .align 32 ;\n"
220 " 1: ;\n" 220 " 1: ;\n"
@@ -233,13 +233,13 @@ xor_pII_mmx_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
233 " jnz 1b ;\n" 233 " jnz 1b ;\n"
234 : "+r" (lines), 234 : "+r" (lines),
235 "+r" (p1), "+r" (p2), "+r" (p3) 235 "+r" (p1), "+r" (p2), "+r" (p3)
236 : "r" (p4), "r" (p5) 236 : "r" (p4), "r" (p5)
237 : "memory"); 237 : "memory");
238 238
239 /* p4 and p5 were modified, and now the variables are dead. 239 /* p4 and p5 were modified, and now the variables are dead.
240 Clobber them just to be sure nobody does something stupid 240 Clobber them just to be sure nobody does something stupid
241 like assuming they have some legal value. */ 241 like assuming they have some legal value. */
242 __asm__ ("" : "=r" (p4), "=r" (p5)); 242 asm("" : "=r" (p4), "=r" (p5));
243 243
244 kernel_fpu_end(); 244 kernel_fpu_end();
245} 245}
@@ -259,7 +259,7 @@ xor_p5_mmx_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
259 259
260 kernel_fpu_begin(); 260 kernel_fpu_begin();
261 261
262 __asm__ __volatile__ ( 262 asm volatile(
263 " .align 32 ;\n" 263 " .align 32 ;\n"
264 " 1: ;\n" 264 " 1: ;\n"
265 " movq (%1), %%mm0 ;\n" 265 " movq (%1), %%mm0 ;\n"
@@ -286,7 +286,7 @@ xor_p5_mmx_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
286 " pxor 56(%2), %%mm7 ;\n" 286 " pxor 56(%2), %%mm7 ;\n"
287 " movq %%mm6, 48(%1) ;\n" 287 " movq %%mm6, 48(%1) ;\n"
288 " movq %%mm7, 56(%1) ;\n" 288 " movq %%mm7, 56(%1) ;\n"
289 289
290 " addl $64, %1 ;\n" 290 " addl $64, %1 ;\n"
291 " addl $64, %2 ;\n" 291 " addl $64, %2 ;\n"
292 " decl %0 ;\n" 292 " decl %0 ;\n"
@@ -307,7 +307,7 @@ xor_p5_mmx_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
307 307
308 kernel_fpu_begin(); 308 kernel_fpu_begin();
309 309
310 __asm__ __volatile__ ( 310 asm volatile(
311 " .align 32,0x90 ;\n" 311 " .align 32,0x90 ;\n"
312 " 1: ;\n" 312 " 1: ;\n"
313 " movq (%1), %%mm0 ;\n" 313 " movq (%1), %%mm0 ;\n"
@@ -342,7 +342,7 @@ xor_p5_mmx_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
342 " pxor 56(%3), %%mm7 ;\n" 342 " pxor 56(%3), %%mm7 ;\n"
343 " movq %%mm6, 48(%1) ;\n" 343 " movq %%mm6, 48(%1) ;\n"
344 " movq %%mm7, 56(%1) ;\n" 344 " movq %%mm7, 56(%1) ;\n"
345 345
346 " addl $64, %1 ;\n" 346 " addl $64, %1 ;\n"
347 " addl $64, %2 ;\n" 347 " addl $64, %2 ;\n"
348 " addl $64, %3 ;\n" 348 " addl $64, %3 ;\n"
@@ -364,7 +364,7 @@ xor_p5_mmx_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
364 364
365 kernel_fpu_begin(); 365 kernel_fpu_begin();
366 366
367 __asm__ __volatile__ ( 367 asm volatile(
368 " .align 32,0x90 ;\n" 368 " .align 32,0x90 ;\n"
369 " 1: ;\n" 369 " 1: ;\n"
370 " movq (%1), %%mm0 ;\n" 370 " movq (%1), %%mm0 ;\n"
@@ -407,7 +407,7 @@ xor_p5_mmx_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
407 " pxor 56(%4), %%mm7 ;\n" 407 " pxor 56(%4), %%mm7 ;\n"
408 " movq %%mm6, 48(%1) ;\n" 408 " movq %%mm6, 48(%1) ;\n"
409 " movq %%mm7, 56(%1) ;\n" 409 " movq %%mm7, 56(%1) ;\n"
410 410
411 " addl $64, %1 ;\n" 411 " addl $64, %1 ;\n"
412 " addl $64, %2 ;\n" 412 " addl $64, %2 ;\n"
413 " addl $64, %3 ;\n" 413 " addl $64, %3 ;\n"
@@ -436,9 +436,9 @@ xor_p5_mmx_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
436 because we modify p4 and p5 there, but we can't mark them 436 because we modify p4 and p5 there, but we can't mark them
437 as read/write, otherwise we'd overflow the 10-asm-operands 437 as read/write, otherwise we'd overflow the 10-asm-operands
438 limit of GCC < 3.1. */ 438 limit of GCC < 3.1. */
439 __asm__ ("" : "+r" (p4), "+r" (p5)); 439 asm("" : "+r" (p4), "+r" (p5));
440 440
441 __asm__ __volatile__ ( 441 asm volatile(
442 " .align 32,0x90 ;\n" 442 " .align 32,0x90 ;\n"
443 " 1: ;\n" 443 " 1: ;\n"
444 " movq (%1), %%mm0 ;\n" 444 " movq (%1), %%mm0 ;\n"
@@ -489,7 +489,7 @@ xor_p5_mmx_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
489 " pxor 56(%5), %%mm7 ;\n" 489 " pxor 56(%5), %%mm7 ;\n"
490 " movq %%mm6, 48(%1) ;\n" 490 " movq %%mm6, 48(%1) ;\n"
491 " movq %%mm7, 56(%1) ;\n" 491 " movq %%mm7, 56(%1) ;\n"
492 492
493 " addl $64, %1 ;\n" 493 " addl $64, %1 ;\n"
494 " addl $64, %2 ;\n" 494 " addl $64, %2 ;\n"
495 " addl $64, %3 ;\n" 495 " addl $64, %3 ;\n"
@@ -505,7 +505,7 @@ xor_p5_mmx_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
505 /* p4 and p5 were modified, and now the variables are dead. 505 /* p4 and p5 were modified, and now the variables are dead.
506 Clobber them just to be sure nobody does something stupid 506 Clobber them just to be sure nobody does something stupid
507 like assuming they have some legal value. */ 507 like assuming they have some legal value. */
508 __asm__ ("" : "=r" (p4), "=r" (p5)); 508 asm("" : "=r" (p4), "=r" (p5));
509 509
510 kernel_fpu_end(); 510 kernel_fpu_end();
511} 511}
@@ -531,11 +531,12 @@ static struct xor_block_template xor_block_p5_mmx = {
531 * Copyright (C) 1999 Zach Brown (with obvious credit due Ingo) 531 * Copyright (C) 1999 Zach Brown (with obvious credit due Ingo)
532 */ 532 */
533 533
534#define XMMS_SAVE do { \ 534#define XMMS_SAVE \
535do { \
535 preempt_disable(); \ 536 preempt_disable(); \
536 cr0 = read_cr0(); \ 537 cr0 = read_cr0(); \
537 clts(); \ 538 clts(); \
538 __asm__ __volatile__ ( \ 539 asm volatile( \
539 "movups %%xmm0,(%0) ;\n\t" \ 540 "movups %%xmm0,(%0) ;\n\t" \
540 "movups %%xmm1,0x10(%0) ;\n\t" \ 541 "movups %%xmm1,0x10(%0) ;\n\t" \
541 "movups %%xmm2,0x20(%0) ;\n\t" \ 542 "movups %%xmm2,0x20(%0) ;\n\t" \
@@ -543,10 +544,11 @@ static struct xor_block_template xor_block_p5_mmx = {
543 : \ 544 : \
544 : "r" (xmm_save) \ 545 : "r" (xmm_save) \
545 : "memory"); \ 546 : "memory"); \
546} while(0) 547} while (0)
547 548
548#define XMMS_RESTORE do { \ 549#define XMMS_RESTORE \
549 __asm__ __volatile__ ( \ 550do { \
551 asm volatile( \
550 "sfence ;\n\t" \ 552 "sfence ;\n\t" \
551 "movups (%0),%%xmm0 ;\n\t" \ 553 "movups (%0),%%xmm0 ;\n\t" \
552 "movups 0x10(%0),%%xmm1 ;\n\t" \ 554 "movups 0x10(%0),%%xmm1 ;\n\t" \
@@ -557,76 +559,76 @@ static struct xor_block_template xor_block_p5_mmx = {
557 : "memory"); \ 559 : "memory"); \
558 write_cr0(cr0); \ 560 write_cr0(cr0); \
559 preempt_enable(); \ 561 preempt_enable(); \
560} while(0) 562} while (0)
561 563
562#define ALIGN16 __attribute__((aligned(16))) 564#define ALIGN16 __attribute__((aligned(16)))
563 565
564#define OFFS(x) "16*("#x")" 566#define OFFS(x) "16*("#x")"
565#define PF_OFFS(x) "256+16*("#x")" 567#define PF_OFFS(x) "256+16*("#x")"
566#define PF0(x) " prefetchnta "PF_OFFS(x)"(%1) ;\n" 568#define PF0(x) " prefetchnta "PF_OFFS(x)"(%1) ;\n"
567#define LD(x,y) " movaps "OFFS(x)"(%1), %%xmm"#y" ;\n" 569#define LD(x, y) " movaps "OFFS(x)"(%1), %%xmm"#y" ;\n"
568#define ST(x,y) " movaps %%xmm"#y", "OFFS(x)"(%1) ;\n" 570#define ST(x, y) " movaps %%xmm"#y", "OFFS(x)"(%1) ;\n"
569#define PF1(x) " prefetchnta "PF_OFFS(x)"(%2) ;\n" 571#define PF1(x) " prefetchnta "PF_OFFS(x)"(%2) ;\n"
570#define PF2(x) " prefetchnta "PF_OFFS(x)"(%3) ;\n" 572#define PF2(x) " prefetchnta "PF_OFFS(x)"(%3) ;\n"
571#define PF3(x) " prefetchnta "PF_OFFS(x)"(%4) ;\n" 573#define PF3(x) " prefetchnta "PF_OFFS(x)"(%4) ;\n"
572#define PF4(x) " prefetchnta "PF_OFFS(x)"(%5) ;\n" 574#define PF4(x) " prefetchnta "PF_OFFS(x)"(%5) ;\n"
573#define PF5(x) " prefetchnta "PF_OFFS(x)"(%6) ;\n" 575#define PF5(x) " prefetchnta "PF_OFFS(x)"(%6) ;\n"
574#define XO1(x,y) " xorps "OFFS(x)"(%2), %%xmm"#y" ;\n" 576#define XO1(x, y) " xorps "OFFS(x)"(%2), %%xmm"#y" ;\n"
575#define XO2(x,y) " xorps "OFFS(x)"(%3), %%xmm"#y" ;\n" 577#define XO2(x, y) " xorps "OFFS(x)"(%3), %%xmm"#y" ;\n"
576#define XO3(x,y) " xorps "OFFS(x)"(%4), %%xmm"#y" ;\n" 578#define XO3(x, y) " xorps "OFFS(x)"(%4), %%xmm"#y" ;\n"
577#define XO4(x,y) " xorps "OFFS(x)"(%5), %%xmm"#y" ;\n" 579#define XO4(x, y) " xorps "OFFS(x)"(%5), %%xmm"#y" ;\n"
578#define XO5(x,y) " xorps "OFFS(x)"(%6), %%xmm"#y" ;\n" 580#define XO5(x, y) " xorps "OFFS(x)"(%6), %%xmm"#y" ;\n"
579 581
580 582
581static void 583static void
582xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) 584xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
583{ 585{
584 unsigned long lines = bytes >> 8; 586 unsigned long lines = bytes >> 8;
585 char xmm_save[16*4] ALIGN16; 587 char xmm_save[16*4] ALIGN16;
586 int cr0; 588 int cr0;
587 589
588 XMMS_SAVE; 590 XMMS_SAVE;
589 591
590 __asm__ __volatile__ ( 592 asm volatile(
591#undef BLOCK 593#undef BLOCK
592#define BLOCK(i) \ 594#define BLOCK(i) \
593 LD(i,0) \ 595 LD(i, 0) \
594 LD(i+1,1) \ 596 LD(i + 1, 1) \
595 PF1(i) \ 597 PF1(i) \
596 PF1(i+2) \ 598 PF1(i + 2) \
597 LD(i+2,2) \ 599 LD(i + 2, 2) \
598 LD(i+3,3) \ 600 LD(i + 3, 3) \
599 PF0(i+4) \ 601 PF0(i + 4) \
600 PF0(i+6) \ 602 PF0(i + 6) \
601 XO1(i,0) \ 603 XO1(i, 0) \
602 XO1(i+1,1) \ 604 XO1(i + 1, 1) \
603 XO1(i+2,2) \ 605 XO1(i + 2, 2) \
604 XO1(i+3,3) \ 606 XO1(i + 3, 3) \
605 ST(i,0) \ 607 ST(i, 0) \
606 ST(i+1,1) \ 608 ST(i + 1, 1) \
607 ST(i+2,2) \ 609 ST(i + 2, 2) \
608 ST(i+3,3) \ 610 ST(i + 3, 3) \
609 611
610 612
611 PF0(0) 613 PF0(0)
612 PF0(2) 614 PF0(2)
613 615
614 " .align 32 ;\n" 616 " .align 32 ;\n"
615 " 1: ;\n" 617 " 1: ;\n"
616 618
617 BLOCK(0) 619 BLOCK(0)
618 BLOCK(4) 620 BLOCK(4)
619 BLOCK(8) 621 BLOCK(8)
620 BLOCK(12) 622 BLOCK(12)
621 623
622 " addl $256, %1 ;\n" 624 " addl $256, %1 ;\n"
623 " addl $256, %2 ;\n" 625 " addl $256, %2 ;\n"
624 " decl %0 ;\n" 626 " decl %0 ;\n"
625 " jnz 1b ;\n" 627 " jnz 1b ;\n"
626 : "+r" (lines), 628 : "+r" (lines),
627 "+r" (p1), "+r" (p2) 629 "+r" (p1), "+r" (p2)
628 : 630 :
629 : "memory"); 631 : "memory");
630 632
631 XMMS_RESTORE; 633 XMMS_RESTORE;
632} 634}
@@ -635,59 +637,59 @@ static void
635xor_sse_3(unsigned long bytes, unsigned long *p1, unsigned long *p2, 637xor_sse_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
636 unsigned long *p3) 638 unsigned long *p3)
637{ 639{
638 unsigned long lines = bytes >> 8; 640 unsigned long lines = bytes >> 8;
639 char xmm_save[16*4] ALIGN16; 641 char xmm_save[16*4] ALIGN16;
640 int cr0; 642 int cr0;
641 643
642 XMMS_SAVE; 644 XMMS_SAVE;
643 645
644 __asm__ __volatile__ ( 646 asm volatile(
645#undef BLOCK 647#undef BLOCK
646#define BLOCK(i) \ 648#define BLOCK(i) \
647 PF1(i) \ 649 PF1(i) \
648 PF1(i+2) \ 650 PF1(i + 2) \
649 LD(i,0) \ 651 LD(i,0) \
650 LD(i+1,1) \ 652 LD(i + 1, 1) \
651 LD(i+2,2) \ 653 LD(i + 2, 2) \
652 LD(i+3,3) \ 654 LD(i + 3, 3) \
653 PF2(i) \ 655 PF2(i) \
654 PF2(i+2) \ 656 PF2(i + 2) \
655 PF0(i+4) \ 657 PF0(i + 4) \
656 PF0(i+6) \ 658 PF0(i + 6) \
657 XO1(i,0) \ 659 XO1(i,0) \
658 XO1(i+1,1) \ 660 XO1(i + 1, 1) \
659 XO1(i+2,2) \ 661 XO1(i + 2, 2) \
660 XO1(i+3,3) \ 662 XO1(i + 3, 3) \
661 XO2(i,0) \ 663 XO2(i,0) \
662 XO2(i+1,1) \ 664 XO2(i + 1, 1) \
663 XO2(i+2,2) \ 665 XO2(i + 2, 2) \
664 XO2(i+3,3) \ 666 XO2(i + 3, 3) \
665 ST(i,0) \ 667 ST(i,0) \
666 ST(i+1,1) \ 668 ST(i + 1, 1) \
667 ST(i+2,2) \ 669 ST(i + 2, 2) \
668 ST(i+3,3) \ 670 ST(i + 3, 3) \
669 671
670 672
671 PF0(0) 673 PF0(0)
672 PF0(2) 674 PF0(2)
673 675
674 " .align 32 ;\n" 676 " .align 32 ;\n"
675 " 1: ;\n" 677 " 1: ;\n"
676 678
677 BLOCK(0) 679 BLOCK(0)
678 BLOCK(4) 680 BLOCK(4)
679 BLOCK(8) 681 BLOCK(8)
680 BLOCK(12) 682 BLOCK(12)
681 683
682 " addl $256, %1 ;\n" 684 " addl $256, %1 ;\n"
683 " addl $256, %2 ;\n" 685 " addl $256, %2 ;\n"
684 " addl $256, %3 ;\n" 686 " addl $256, %3 ;\n"
685 " decl %0 ;\n" 687 " decl %0 ;\n"
686 " jnz 1b ;\n" 688 " jnz 1b ;\n"
687 : "+r" (lines), 689 : "+r" (lines),
688 "+r" (p1), "+r"(p2), "+r"(p3) 690 "+r" (p1), "+r"(p2), "+r"(p3)
689 : 691 :
690 : "memory" ); 692 : "memory" );
691 693
692 XMMS_RESTORE; 694 XMMS_RESTORE;
693} 695}
@@ -696,66 +698,66 @@ static void
696xor_sse_4(unsigned long bytes, unsigned long *p1, unsigned long *p2, 698xor_sse_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
697 unsigned long *p3, unsigned long *p4) 699 unsigned long *p3, unsigned long *p4)
698{ 700{
699 unsigned long lines = bytes >> 8; 701 unsigned long lines = bytes >> 8;
700 char xmm_save[16*4] ALIGN16; 702 char xmm_save[16*4] ALIGN16;
701 int cr0; 703 int cr0;
702 704
703 XMMS_SAVE; 705 XMMS_SAVE;
704 706
705 __asm__ __volatile__ ( 707 asm volatile(
706#undef BLOCK 708#undef BLOCK
707#define BLOCK(i) \ 709#define BLOCK(i) \
708 PF1(i) \ 710 PF1(i) \
709 PF1(i+2) \ 711 PF1(i + 2) \
710 LD(i,0) \ 712 LD(i,0) \
711 LD(i+1,1) \ 713 LD(i + 1, 1) \
712 LD(i+2,2) \ 714 LD(i + 2, 2) \
713 LD(i+3,3) \ 715 LD(i + 3, 3) \
714 PF2(i) \ 716 PF2(i) \
715 PF2(i+2) \ 717 PF2(i + 2) \
716 XO1(i,0) \ 718 XO1(i,0) \
717 XO1(i+1,1) \ 719 XO1(i + 1, 1) \
718 XO1(i+2,2) \ 720 XO1(i + 2, 2) \
719 XO1(i+3,3) \ 721 XO1(i + 3, 3) \
720 PF3(i) \ 722 PF3(i) \
721 PF3(i+2) \ 723 PF3(i + 2) \
722 PF0(i+4) \ 724 PF0(i + 4) \
723 PF0(i+6) \ 725 PF0(i + 6) \
724 XO2(i,0) \ 726 XO2(i,0) \
725 XO2(i+1,1) \ 727 XO2(i + 1, 1) \
726 XO2(i+2,2) \ 728 XO2(i + 2, 2) \
727 XO2(i+3,3) \ 729 XO2(i + 3, 3) \
728 XO3(i,0) \ 730 XO3(i,0) \
729 XO3(i+1,1) \ 731 XO3(i + 1, 1) \
730 XO3(i+2,2) \ 732 XO3(i + 2, 2) \
731 XO3(i+3,3) \ 733 XO3(i + 3, 3) \
732 ST(i,0) \ 734 ST(i,0) \
733 ST(i+1,1) \ 735 ST(i + 1, 1) \
734 ST(i+2,2) \ 736 ST(i + 2, 2) \
735 ST(i+3,3) \ 737 ST(i + 3, 3) \
736 738
737 739
738 PF0(0) 740 PF0(0)
739 PF0(2) 741 PF0(2)
740 742
741 " .align 32 ;\n" 743 " .align 32 ;\n"
742 " 1: ;\n" 744 " 1: ;\n"
743 745
744 BLOCK(0) 746 BLOCK(0)
745 BLOCK(4) 747 BLOCK(4)
746 BLOCK(8) 748 BLOCK(8)
747 BLOCK(12) 749 BLOCK(12)
748 750
749 " addl $256, %1 ;\n" 751 " addl $256, %1 ;\n"
750 " addl $256, %2 ;\n" 752 " addl $256, %2 ;\n"
751 " addl $256, %3 ;\n" 753 " addl $256, %3 ;\n"
752 " addl $256, %4 ;\n" 754 " addl $256, %4 ;\n"
753 " decl %0 ;\n" 755 " decl %0 ;\n"
754 " jnz 1b ;\n" 756 " jnz 1b ;\n"
755 : "+r" (lines), 757 : "+r" (lines),
756 "+r" (p1), "+r" (p2), "+r" (p3), "+r" (p4) 758 "+r" (p1), "+r" (p2), "+r" (p3), "+r" (p4)
757 : 759 :
758 : "memory" ); 760 : "memory" );
759 761
760 XMMS_RESTORE; 762 XMMS_RESTORE;
761} 763}
@@ -764,7 +766,7 @@ static void
764xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, 766xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
765 unsigned long *p3, unsigned long *p4, unsigned long *p5) 767 unsigned long *p3, unsigned long *p4, unsigned long *p5)
766{ 768{
767 unsigned long lines = bytes >> 8; 769 unsigned long lines = bytes >> 8;
768 char xmm_save[16*4] ALIGN16; 770 char xmm_save[16*4] ALIGN16;
769 int cr0; 771 int cr0;
770 772
@@ -776,65 +778,65 @@ xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
776 because we modify p4 and p5 there, but we can't mark them 778 because we modify p4 and p5 there, but we can't mark them
777 as read/write, otherwise we'd overflow the 10-asm-operands 779 as read/write, otherwise we'd overflow the 10-asm-operands
778 limit of GCC < 3.1. */ 780 limit of GCC < 3.1. */
779 __asm__ ("" : "+r" (p4), "+r" (p5)); 781 asm("" : "+r" (p4), "+r" (p5));
780 782
781 __asm__ __volatile__ ( 783 asm volatile(
782#undef BLOCK 784#undef BLOCK
783#define BLOCK(i) \ 785#define BLOCK(i) \
784 PF1(i) \ 786 PF1(i) \
785 PF1(i+2) \ 787 PF1(i + 2) \
786 LD(i,0) \ 788 LD(i,0) \
787 LD(i+1,1) \ 789 LD(i + 1, 1) \
788 LD(i+2,2) \ 790 LD(i + 2, 2) \
789 LD(i+3,3) \ 791 LD(i + 3, 3) \
790 PF2(i) \ 792 PF2(i) \
791 PF2(i+2) \ 793 PF2(i + 2) \
792 XO1(i,0) \ 794 XO1(i,0) \
793 XO1(i+1,1) \ 795 XO1(i + 1, 1) \
794 XO1(i+2,2) \ 796 XO1(i + 2, 2) \
795 XO1(i+3,3) \ 797 XO1(i + 3, 3) \
796 PF3(i) \ 798 PF3(i) \
797 PF3(i+2) \ 799 PF3(i + 2) \
798 XO2(i,0) \ 800 XO2(i,0) \
799 XO2(i+1,1) \ 801 XO2(i + 1, 1) \
800 XO2(i+2,2) \ 802 XO2(i + 2, 2) \
801 XO2(i+3,3) \ 803 XO2(i + 3, 3) \
802 PF4(i) \ 804 PF4(i) \
803 PF4(i+2) \ 805 PF4(i + 2) \
804 PF0(i+4) \ 806 PF0(i + 4) \
805 PF0(i+6) \ 807 PF0(i + 6) \
806 XO3(i,0) \ 808 XO3(i,0) \
807 XO3(i+1,1) \ 809 XO3(i + 1, 1) \
808 XO3(i+2,2) \ 810 XO3(i + 2, 2) \
809 XO3(i+3,3) \ 811 XO3(i + 3, 3) \
810 XO4(i,0) \ 812 XO4(i,0) \
811 XO4(i+1,1) \ 813 XO4(i + 1, 1) \
812 XO4(i+2,2) \ 814 XO4(i + 2, 2) \
813 XO4(i+3,3) \ 815 XO4(i + 3, 3) \
814 ST(i,0) \ 816 ST(i,0) \
815 ST(i+1,1) \ 817 ST(i + 1, 1) \
816 ST(i+2,2) \ 818 ST(i + 2, 2) \
817 ST(i+3,3) \ 819 ST(i + 3, 3) \
818 820
819 821
820 PF0(0) 822 PF0(0)
821 PF0(2) 823 PF0(2)
822 824
823 " .align 32 ;\n" 825 " .align 32 ;\n"
824 " 1: ;\n" 826 " 1: ;\n"
825 827
826 BLOCK(0) 828 BLOCK(0)
827 BLOCK(4) 829 BLOCK(4)
828 BLOCK(8) 830 BLOCK(8)
829 BLOCK(12) 831 BLOCK(12)
830 832
831 " addl $256, %1 ;\n" 833 " addl $256, %1 ;\n"
832 " addl $256, %2 ;\n" 834 " addl $256, %2 ;\n"
833 " addl $256, %3 ;\n" 835 " addl $256, %3 ;\n"
834 " addl $256, %4 ;\n" 836 " addl $256, %4 ;\n"
835 " addl $256, %5 ;\n" 837 " addl $256, %5 ;\n"
836 " decl %0 ;\n" 838 " decl %0 ;\n"
837 " jnz 1b ;\n" 839 " jnz 1b ;\n"
838 : "+r" (lines), 840 : "+r" (lines),
839 "+r" (p1), "+r" (p2), "+r" (p3) 841 "+r" (p1), "+r" (p2), "+r" (p3)
840 : "r" (p4), "r" (p5) 842 : "r" (p4), "r" (p5)
@@ -843,17 +845,17 @@ xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
843 /* p4 and p5 were modified, and now the variables are dead. 845 /* p4 and p5 were modified, and now the variables are dead.
844 Clobber them just to be sure nobody does something stupid 846 Clobber them just to be sure nobody does something stupid
845 like assuming they have some legal value. */ 847 like assuming they have some legal value. */
846 __asm__ ("" : "=r" (p4), "=r" (p5)); 848 asm("" : "=r" (p4), "=r" (p5));
847 849
848 XMMS_RESTORE; 850 XMMS_RESTORE;
849} 851}
850 852
851static struct xor_block_template xor_block_pIII_sse = { 853static struct xor_block_template xor_block_pIII_sse = {
852 .name = "pIII_sse", 854 .name = "pIII_sse",
853 .do_2 = xor_sse_2, 855 .do_2 = xor_sse_2,
854 .do_3 = xor_sse_3, 856 .do_3 = xor_sse_3,
855 .do_4 = xor_sse_4, 857 .do_4 = xor_sse_4,
856 .do_5 = xor_sse_5, 858 .do_5 = xor_sse_5,
857}; 859};
858 860
859/* Also try the generic routines. */ 861/* Also try the generic routines. */
@@ -861,21 +863,21 @@ static struct xor_block_template xor_block_pIII_sse = {
861 863
862#undef XOR_TRY_TEMPLATES 864#undef XOR_TRY_TEMPLATES
863#define XOR_TRY_TEMPLATES \ 865#define XOR_TRY_TEMPLATES \
864 do { \ 866do { \
865 xor_speed(&xor_block_8regs); \ 867 xor_speed(&xor_block_8regs); \
866 xor_speed(&xor_block_8regs_p); \ 868 xor_speed(&xor_block_8regs_p); \
867 xor_speed(&xor_block_32regs); \ 869 xor_speed(&xor_block_32regs); \
868 xor_speed(&xor_block_32regs_p); \ 870 xor_speed(&xor_block_32regs_p); \
869 if (cpu_has_xmm) \ 871 if (cpu_has_xmm) \
870 xor_speed(&xor_block_pIII_sse); \ 872 xor_speed(&xor_block_pIII_sse); \
871 if (cpu_has_mmx) { \ 873 if (cpu_has_mmx) { \
872 xor_speed(&xor_block_pII_mmx); \ 874 xor_speed(&xor_block_pII_mmx); \
873 xor_speed(&xor_block_p5_mmx); \ 875 xor_speed(&xor_block_p5_mmx); \
874 } \ 876 } \
875 } while (0) 877} while (0)
876 878
877/* We force the use of the SSE xor block because it can write around L2. 879/* We force the use of the SSE xor block because it can write around L2.
878 We may also be able to load into the L1 only depending on how the cpu 880 We may also be able to load into the L1 only depending on how the cpu
879 deals with a load to a line that is being prefetched. */ 881 deals with a load to a line that is being prefetched. */
880#define XOR_SELECT_TEMPLATE(FASTEST) \ 882#define XOR_SELECT_TEMPLATE(FASTEST) \
881 (cpu_has_xmm ? &xor_block_pIII_sse : FASTEST) 883 (cpu_has_xmm ? &xor_block_pIII_sse : FASTEST)
diff --git a/include/asm-x86/xor_64.h b/include/asm-x86/xor_64.h
index 1eee7fcb2420..24957e39ac8a 100644
--- a/include/asm-x86/xor_64.h
+++ b/include/asm-x86/xor_64.h
@@ -24,20 +24,23 @@
24 */ 24 */
25 25
26/* 26/*
27 * x86-64 changes / gcc fixes from Andi Kleen. 27 * x86-64 changes / gcc fixes from Andi Kleen.
28 * Copyright 2002 Andi Kleen, SuSE Labs. 28 * Copyright 2002 Andi Kleen, SuSE Labs.
29 * 29 *
30 * This hasn't been optimized for the hammer yet, but there are likely 30 * This hasn't been optimized for the hammer yet, but there are likely
31 * no advantages to be gotten from x86-64 here anyways. 31 * no advantages to be gotten from x86-64 here anyways.
32 */ 32 */
33 33
34typedef struct { unsigned long a,b; } __attribute__((aligned(16))) xmm_store_t; 34typedef struct {
35 unsigned long a, b;
36} __attribute__((aligned(16))) xmm_store_t;
35 37
36/* Doesn't use gcc to save the XMM registers, because there is no easy way to 38/* Doesn't use gcc to save the XMM registers, because there is no easy way to
37 tell it to do a clts before the register saving. */ 39 tell it to do a clts before the register saving. */
38#define XMMS_SAVE do { \ 40#define XMMS_SAVE \
41do { \
39 preempt_disable(); \ 42 preempt_disable(); \
40 asm volatile ( \ 43 asm volatile( \
41 "movq %%cr0,%0 ;\n\t" \ 44 "movq %%cr0,%0 ;\n\t" \
42 "clts ;\n\t" \ 45 "clts ;\n\t" \
43 "movups %%xmm0,(%1) ;\n\t" \ 46 "movups %%xmm0,(%1) ;\n\t" \
@@ -47,10 +50,11 @@ typedef struct { unsigned long a,b; } __attribute__((aligned(16))) xmm_store_t;
47 : "=&r" (cr0) \ 50 : "=&r" (cr0) \
48 : "r" (xmm_save) \ 51 : "r" (xmm_save) \
49 : "memory"); \ 52 : "memory"); \
50} while(0) 53} while (0)
51 54
52#define XMMS_RESTORE do { \ 55#define XMMS_RESTORE \
53 asm volatile ( \ 56do { \
57 asm volatile( \
54 "sfence ;\n\t" \ 58 "sfence ;\n\t" \
55 "movups (%1),%%xmm0 ;\n\t" \ 59 "movups (%1),%%xmm0 ;\n\t" \
56 "movups 0x10(%1),%%xmm1 ;\n\t" \ 60 "movups 0x10(%1),%%xmm1 ;\n\t" \
@@ -61,72 +65,72 @@ typedef struct { unsigned long a,b; } __attribute__((aligned(16))) xmm_store_t;
61 : "r" (cr0), "r" (xmm_save) \ 65 : "r" (cr0), "r" (xmm_save) \
62 : "memory"); \ 66 : "memory"); \
63 preempt_enable(); \ 67 preempt_enable(); \
64} while(0) 68} while (0)
65 69
66#define OFFS(x) "16*("#x")" 70#define OFFS(x) "16*("#x")"
67#define PF_OFFS(x) "256+16*("#x")" 71#define PF_OFFS(x) "256+16*("#x")"
68#define PF0(x) " prefetchnta "PF_OFFS(x)"(%[p1]) ;\n" 72#define PF0(x) " prefetchnta "PF_OFFS(x)"(%[p1]) ;\n"
69#define LD(x,y) " movaps "OFFS(x)"(%[p1]), %%xmm"#y" ;\n" 73#define LD(x, y) " movaps "OFFS(x)"(%[p1]), %%xmm"#y" ;\n"
70#define ST(x,y) " movaps %%xmm"#y", "OFFS(x)"(%[p1]) ;\n" 74#define ST(x, y) " movaps %%xmm"#y", "OFFS(x)"(%[p1]) ;\n"
71#define PF1(x) " prefetchnta "PF_OFFS(x)"(%[p2]) ;\n" 75#define PF1(x) " prefetchnta "PF_OFFS(x)"(%[p2]) ;\n"
72#define PF2(x) " prefetchnta "PF_OFFS(x)"(%[p3]) ;\n" 76#define PF2(x) " prefetchnta "PF_OFFS(x)"(%[p3]) ;\n"
73#define PF3(x) " prefetchnta "PF_OFFS(x)"(%[p4]) ;\n" 77#define PF3(x) " prefetchnta "PF_OFFS(x)"(%[p4]) ;\n"
74#define PF4(x) " prefetchnta "PF_OFFS(x)"(%[p5]) ;\n" 78#define PF4(x) " prefetchnta "PF_OFFS(x)"(%[p5]) ;\n"
75#define PF5(x) " prefetchnta "PF_OFFS(x)"(%[p6]) ;\n" 79#define PF5(x) " prefetchnta "PF_OFFS(x)"(%[p6]) ;\n"
76#define XO1(x,y) " xorps "OFFS(x)"(%[p2]), %%xmm"#y" ;\n" 80#define XO1(x, y) " xorps "OFFS(x)"(%[p2]), %%xmm"#y" ;\n"
77#define XO2(x,y) " xorps "OFFS(x)"(%[p3]), %%xmm"#y" ;\n" 81#define XO2(x, y) " xorps "OFFS(x)"(%[p3]), %%xmm"#y" ;\n"
78#define XO3(x,y) " xorps "OFFS(x)"(%[p4]), %%xmm"#y" ;\n" 82#define XO3(x, y) " xorps "OFFS(x)"(%[p4]), %%xmm"#y" ;\n"
79#define XO4(x,y) " xorps "OFFS(x)"(%[p5]), %%xmm"#y" ;\n" 83#define XO4(x, y) " xorps "OFFS(x)"(%[p5]), %%xmm"#y" ;\n"
80#define XO5(x,y) " xorps "OFFS(x)"(%[p6]), %%xmm"#y" ;\n" 84#define XO5(x, y) " xorps "OFFS(x)"(%[p6]), %%xmm"#y" ;\n"
81 85
82 86
83static void 87static void
84xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) 88xor_sse_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
85{ 89{
86 unsigned int lines = bytes >> 8; 90 unsigned int lines = bytes >> 8;
87 unsigned long cr0; 91 unsigned long cr0;
88 xmm_store_t xmm_save[4]; 92 xmm_store_t xmm_save[4];
89 93
90 XMMS_SAVE; 94 XMMS_SAVE;
91 95
92 asm volatile ( 96 asm volatile(
93#undef BLOCK 97#undef BLOCK
94#define BLOCK(i) \ 98#define BLOCK(i) \
95 LD(i,0) \ 99 LD(i, 0) \
96 LD(i+1,1) \ 100 LD(i + 1, 1) \
97 PF1(i) \ 101 PF1(i) \
98 PF1(i+2) \ 102 PF1(i + 2) \
99 LD(i+2,2) \ 103 LD(i + 2, 2) \
100 LD(i+3,3) \ 104 LD(i + 3, 3) \
101 PF0(i+4) \ 105 PF0(i + 4) \
102 PF0(i+6) \ 106 PF0(i + 6) \
103 XO1(i,0) \ 107 XO1(i, 0) \
104 XO1(i+1,1) \ 108 XO1(i + 1, 1) \
105 XO1(i+2,2) \ 109 XO1(i + 2, 2) \
106 XO1(i+3,3) \ 110 XO1(i + 3, 3) \
107 ST(i,0) \ 111 ST(i, 0) \
108 ST(i+1,1) \ 112 ST(i + 1, 1) \
109 ST(i+2,2) \ 113 ST(i + 2, 2) \
110 ST(i+3,3) \ 114 ST(i + 3, 3) \
111 115
112 116
113 PF0(0) 117 PF0(0)
114 PF0(2) 118 PF0(2)
115 119
116 " .align 32 ;\n" 120 " .align 32 ;\n"
117 " 1: ;\n" 121 " 1: ;\n"
118 122
119 BLOCK(0) 123 BLOCK(0)
120 BLOCK(4) 124 BLOCK(4)
121 BLOCK(8) 125 BLOCK(8)
122 BLOCK(12) 126 BLOCK(12)
123 127
124 " addq %[inc], %[p1] ;\n" 128 " addq %[inc], %[p1] ;\n"
125 " addq %[inc], %[p2] ;\n" 129 " addq %[inc], %[p2] ;\n"
126 " decl %[cnt] ; jnz 1b" 130 " decl %[cnt] ; jnz 1b"
127 : [p1] "+r" (p1), [p2] "+r" (p2), [cnt] "+r" (lines) 131 : [p1] "+r" (p1), [p2] "+r" (p2), [cnt] "+r" (lines)
128 : [inc] "r" (256UL) 132 : [inc] "r" (256UL)
129 : "memory"); 133 : "memory");
130 134
131 XMMS_RESTORE; 135 XMMS_RESTORE;
132} 136}
@@ -141,52 +145,52 @@ xor_sse_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
141 145
142 XMMS_SAVE; 146 XMMS_SAVE;
143 147
144 __asm__ __volatile__ ( 148 asm volatile(
145#undef BLOCK 149#undef BLOCK
146#define BLOCK(i) \ 150#define BLOCK(i) \
147 PF1(i) \ 151 PF1(i) \
148 PF1(i+2) \ 152 PF1(i + 2) \
149 LD(i,0) \ 153 LD(i, 0) \
150 LD(i+1,1) \ 154 LD(i + 1, 1) \
151 LD(i+2,2) \ 155 LD(i + 2, 2) \
152 LD(i+3,3) \ 156 LD(i + 3, 3) \
153 PF2(i) \ 157 PF2(i) \
154 PF2(i+2) \ 158 PF2(i + 2) \
155 PF0(i+4) \ 159 PF0(i + 4) \
156 PF0(i+6) \ 160 PF0(i + 6) \
157 XO1(i,0) \ 161 XO1(i, 0) \
158 XO1(i+1,1) \ 162 XO1(i + 1, 1) \
159 XO1(i+2,2) \ 163 XO1(i + 2, 2) \
160 XO1(i+3,3) \ 164 XO1(i + 3, 3) \
161 XO2(i,0) \ 165 XO2(i, 0) \
162 XO2(i+1,1) \ 166 XO2(i + 1, 1) \
163 XO2(i+2,2) \ 167 XO2(i + 2, 2) \
164 XO2(i+3,3) \ 168 XO2(i + 3, 3) \
165 ST(i,0) \ 169 ST(i, 0) \
166 ST(i+1,1) \ 170 ST(i + 1, 1) \
167 ST(i+2,2) \ 171 ST(i + 2, 2) \
168 ST(i+3,3) \ 172 ST(i + 3, 3) \
169 173
170 174
171 PF0(0) 175 PF0(0)
172 PF0(2) 176 PF0(2)
173 177
174 " .align 32 ;\n" 178 " .align 32 ;\n"
175 " 1: ;\n" 179 " 1: ;\n"
176 180
177 BLOCK(0) 181 BLOCK(0)
178 BLOCK(4) 182 BLOCK(4)
179 BLOCK(8) 183 BLOCK(8)
180 BLOCK(12) 184 BLOCK(12)
181 185
182 " addq %[inc], %[p1] ;\n" 186 " addq %[inc], %[p1] ;\n"
183 " addq %[inc], %[p2] ;\n" 187 " addq %[inc], %[p2] ;\n"
184 " addq %[inc], %[p3] ;\n" 188 " addq %[inc], %[p3] ;\n"
185 " decl %[cnt] ; jnz 1b" 189 " decl %[cnt] ; jnz 1b"
186 : [cnt] "+r" (lines), 190 : [cnt] "+r" (lines),
187 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3) 191 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3)
188 : [inc] "r" (256UL) 192 : [inc] "r" (256UL)
189 : "memory"); 193 : "memory");
190 XMMS_RESTORE; 194 XMMS_RESTORE;
191} 195}
192 196
@@ -195,64 +199,64 @@ xor_sse_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
195 unsigned long *p3, unsigned long *p4) 199 unsigned long *p3, unsigned long *p4)
196{ 200{
197 unsigned int lines = bytes >> 8; 201 unsigned int lines = bytes >> 8;
198 xmm_store_t xmm_save[4]; 202 xmm_store_t xmm_save[4];
199 unsigned long cr0; 203 unsigned long cr0;
200 204
201 XMMS_SAVE; 205 XMMS_SAVE;
202 206
203 __asm__ __volatile__ ( 207 asm volatile(
204#undef BLOCK 208#undef BLOCK
205#define BLOCK(i) \ 209#define BLOCK(i) \
206 PF1(i) \ 210 PF1(i) \
207 PF1(i+2) \ 211 PF1(i + 2) \
208 LD(i,0) \ 212 LD(i, 0) \
209 LD(i+1,1) \ 213 LD(i + 1, 1) \
210 LD(i+2,2) \ 214 LD(i + 2, 2) \
211 LD(i+3,3) \ 215 LD(i + 3, 3) \
212 PF2(i) \ 216 PF2(i) \
213 PF2(i+2) \ 217 PF2(i + 2) \
214 XO1(i,0) \ 218 XO1(i, 0) \
215 XO1(i+1,1) \ 219 XO1(i + 1, 1) \
216 XO1(i+2,2) \ 220 XO1(i + 2, 2) \
217 XO1(i+3,3) \ 221 XO1(i + 3, 3) \
218 PF3(i) \ 222 PF3(i) \
219 PF3(i+2) \ 223 PF3(i + 2) \
220 PF0(i+4) \ 224 PF0(i + 4) \
221 PF0(i+6) \ 225 PF0(i + 6) \
222 XO2(i,0) \ 226 XO2(i, 0) \
223 XO2(i+1,1) \ 227 XO2(i + 1, 1) \
224 XO2(i+2,2) \ 228 XO2(i + 2, 2) \
225 XO2(i+3,3) \ 229 XO2(i + 3, 3) \
226 XO3(i,0) \ 230 XO3(i, 0) \
227 XO3(i+1,1) \ 231 XO3(i + 1, 1) \
228 XO3(i+2,2) \ 232 XO3(i + 2, 2) \
229 XO3(i+3,3) \ 233 XO3(i + 3, 3) \
230 ST(i,0) \ 234 ST(i, 0) \
231 ST(i+1,1) \ 235 ST(i + 1, 1) \
232 ST(i+2,2) \ 236 ST(i + 2, 2) \
233 ST(i+3,3) \ 237 ST(i + 3, 3) \
234 238
235 239
236 PF0(0) 240 PF0(0)
237 PF0(2) 241 PF0(2)
238 242
239 " .align 32 ;\n" 243 " .align 32 ;\n"
240 " 1: ;\n" 244 " 1: ;\n"
241 245
242 BLOCK(0) 246 BLOCK(0)
243 BLOCK(4) 247 BLOCK(4)
244 BLOCK(8) 248 BLOCK(8)
245 BLOCK(12) 249 BLOCK(12)
246 250
247 " addq %[inc], %[p1] ;\n" 251 " addq %[inc], %[p1] ;\n"
248 " addq %[inc], %[p2] ;\n" 252 " addq %[inc], %[p2] ;\n"
249 " addq %[inc], %[p3] ;\n" 253 " addq %[inc], %[p3] ;\n"
250 " addq %[inc], %[p4] ;\n" 254 " addq %[inc], %[p4] ;\n"
251 " decl %[cnt] ; jnz 1b" 255 " decl %[cnt] ; jnz 1b"
252 : [cnt] "+c" (lines), 256 : [cnt] "+c" (lines),
253 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4) 257 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4)
254 : [inc] "r" (256UL) 258 : [inc] "r" (256UL)
255 : "memory" ); 259 : "memory" );
256 260
257 XMMS_RESTORE; 261 XMMS_RESTORE;
258} 262}
@@ -261,70 +265,70 @@ static void
261xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, 265xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
262 unsigned long *p3, unsigned long *p4, unsigned long *p5) 266 unsigned long *p3, unsigned long *p4, unsigned long *p5)
263{ 267{
264 unsigned int lines = bytes >> 8; 268 unsigned int lines = bytes >> 8;
265 xmm_store_t xmm_save[4]; 269 xmm_store_t xmm_save[4];
266 unsigned long cr0; 270 unsigned long cr0;
267 271
268 XMMS_SAVE; 272 XMMS_SAVE;
269 273
270 __asm__ __volatile__ ( 274 asm volatile(
271#undef BLOCK 275#undef BLOCK
272#define BLOCK(i) \ 276#define BLOCK(i) \
273 PF1(i) \ 277 PF1(i) \
274 PF1(i+2) \ 278 PF1(i + 2) \
275 LD(i,0) \ 279 LD(i, 0) \
276 LD(i+1,1) \ 280 LD(i + 1, 1) \
277 LD(i+2,2) \ 281 LD(i + 2, 2) \
278 LD(i+3,3) \ 282 LD(i + 3, 3) \
279 PF2(i) \ 283 PF2(i) \
280 PF2(i+2) \ 284 PF2(i + 2) \
281 XO1(i,0) \ 285 XO1(i, 0) \
282 XO1(i+1,1) \ 286 XO1(i + 1, 1) \
283 XO1(i+2,2) \ 287 XO1(i + 2, 2) \
284 XO1(i+3,3) \ 288 XO1(i + 3, 3) \
285 PF3(i) \ 289 PF3(i) \
286 PF3(i+2) \ 290 PF3(i + 2) \
287 XO2(i,0) \ 291 XO2(i, 0) \
288 XO2(i+1,1) \ 292 XO2(i + 1, 1) \
289 XO2(i+2,2) \ 293 XO2(i + 2, 2) \
290 XO2(i+3,3) \ 294 XO2(i + 3, 3) \
291 PF4(i) \ 295 PF4(i) \
292 PF4(i+2) \ 296 PF4(i + 2) \
293 PF0(i+4) \ 297 PF0(i + 4) \
294 PF0(i+6) \ 298 PF0(i + 6) \
295 XO3(i,0) \ 299 XO3(i, 0) \
296 XO3(i+1,1) \ 300 XO3(i + 1, 1) \
297 XO3(i+2,2) \ 301 XO3(i + 2, 2) \
298 XO3(i+3,3) \ 302 XO3(i + 3, 3) \
299 XO4(i,0) \ 303 XO4(i, 0) \
300 XO4(i+1,1) \ 304 XO4(i + 1, 1) \
301 XO4(i+2,2) \ 305 XO4(i + 2, 2) \
302 XO4(i+3,3) \ 306 XO4(i + 3, 3) \
303 ST(i,0) \ 307 ST(i, 0) \
304 ST(i+1,1) \ 308 ST(i + 1, 1) \
305 ST(i+2,2) \ 309 ST(i + 2, 2) \
306 ST(i+3,3) \ 310 ST(i + 3, 3) \
307 311
308 312
309 PF0(0) 313 PF0(0)
310 PF0(2) 314 PF0(2)
311 315
312 " .align 32 ;\n" 316 " .align 32 ;\n"
313 " 1: ;\n" 317 " 1: ;\n"
314 318
315 BLOCK(0) 319 BLOCK(0)
316 BLOCK(4) 320 BLOCK(4)
317 BLOCK(8) 321 BLOCK(8)
318 BLOCK(12) 322 BLOCK(12)
319 323
320 " addq %[inc], %[p1] ;\n" 324 " addq %[inc], %[p1] ;\n"
321 " addq %[inc], %[p2] ;\n" 325 " addq %[inc], %[p2] ;\n"
322 " addq %[inc], %[p3] ;\n" 326 " addq %[inc], %[p3] ;\n"
323 " addq %[inc], %[p4] ;\n" 327 " addq %[inc], %[p4] ;\n"
324 " addq %[inc], %[p5] ;\n" 328 " addq %[inc], %[p5] ;\n"
325 " decl %[cnt] ; jnz 1b" 329 " decl %[cnt] ; jnz 1b"
326 : [cnt] "+c" (lines), 330 : [cnt] "+c" (lines),
327 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4), 331 [p1] "+r" (p1), [p2] "+r" (p2), [p3] "+r" (p3), [p4] "+r" (p4),
328 [p5] "+r" (p5) 332 [p5] "+r" (p5)
329 : [inc] "r" (256UL) 333 : [inc] "r" (256UL)
330 : "memory"); 334 : "memory");
@@ -333,18 +337,18 @@ xor_sse_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
333} 337}
334 338
335static struct xor_block_template xor_block_sse = { 339static struct xor_block_template xor_block_sse = {
336 .name = "generic_sse", 340 .name = "generic_sse",
337 .do_2 = xor_sse_2, 341 .do_2 = xor_sse_2,
338 .do_3 = xor_sse_3, 342 .do_3 = xor_sse_3,
339 .do_4 = xor_sse_4, 343 .do_4 = xor_sse_4,
340 .do_5 = xor_sse_5, 344 .do_5 = xor_sse_5,
341}; 345};
342 346
343#undef XOR_TRY_TEMPLATES 347#undef XOR_TRY_TEMPLATES
344#define XOR_TRY_TEMPLATES \ 348#define XOR_TRY_TEMPLATES \
345 do { \ 349do { \
346 xor_speed(&xor_block_sse); \ 350 xor_speed(&xor_block_sse); \
347 } while (0) 351} while (0)
348 352
349/* We force the use of the SSE xor block because it can write around L2. 353/* We force the use of the SSE xor block because it can write around L2.
350 We may also be able to load into the L1 only depending on how the cpu 354 We may also be able to load into the L1 only depending on how the cpu
diff --git a/include/asm-xtensa/pgtable.h b/include/asm-xtensa/pgtable.h
index c8b024a48b4d..8014d96b21f1 100644
--- a/include/asm-xtensa/pgtable.h
+++ b/include/asm-xtensa/pgtable.h
@@ -210,6 +210,8 @@ static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITABLE; }
210static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 210static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
211static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 211static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
212static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 212static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
213static inline int pte_special(pte_t pte) { return 0; }
214
213static inline pte_t pte_wrprotect(pte_t pte) 215static inline pte_t pte_wrprotect(pte_t pte)
214 { pte_val(pte) &= ~(_PAGE_WRITABLE | _PAGE_HW_WRITE); return pte; } 216 { pte_val(pte) &= ~(_PAGE_WRITABLE | _PAGE_HW_WRITE); return pte; }
215static inline pte_t pte_mkclean(pte_t pte) 217static inline pte_t pte_mkclean(pte_t pte)
@@ -222,6 +224,8 @@ static inline pte_t pte_mkyoung(pte_t pte)
222 { pte_val(pte) |= _PAGE_ACCESSED; return pte; } 224 { pte_val(pte) |= _PAGE_ACCESSED; return pte; }
223static inline pte_t pte_mkwrite(pte_t pte) 225static inline pte_t pte_mkwrite(pte_t pte)
224 { pte_val(pte) |= _PAGE_WRITABLE; return pte; } 226 { pte_val(pte) |= _PAGE_WRITABLE; return pte; }
227static inline pte_t pte_mkspecial(pte_t pte)
228 { return pte; }
225 229
226/* 230/*
227 * Conversion functions: convert a page and protection to a page entry, 231 * Conversion functions: convert a page and protection to a page entry,
diff --git a/include/asm-xtensa/semaphore.h b/include/asm-xtensa/semaphore.h
index 3e04167cd9dc..d9b2034ed1d2 100644
--- a/include/asm-xtensa/semaphore.h
+++ b/include/asm-xtensa/semaphore.h
@@ -1,99 +1 @@
1/* #include <linux/semaphore.h>
2 * linux/include/asm-xtensa/semaphore.h
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) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_SEMAPHORE_H
12#define _XTENSA_SEMAPHORE_H
13
14#include <asm/atomic.h>
15#include <asm/system.h>
16#include <linux/wait.h>
17#include <linux/rwsem.h>
18
19struct semaphore {
20 atomic_t count;
21 int sleepers;
22 wait_queue_head_t wait;
23};
24
25#define __SEMAPHORE_INITIALIZER(name,n) \
26{ \
27 .count = ATOMIC_INIT(n), \
28 .sleepers = 0, \
29 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
30}
31
32#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
33 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
34
35#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
36
37static inline void sema_init (struct semaphore *sem, int val)
38{
39 atomic_set(&sem->count, val);
40 sem->sleepers = 0;
41 init_waitqueue_head(&sem->wait);
42}
43
44static inline void init_MUTEX (struct semaphore *sem)
45{
46 sema_init(sem, 1);
47}
48
49static inline void init_MUTEX_LOCKED (struct semaphore *sem)
50{
51 sema_init(sem, 0);
52}
53
54asmlinkage void __down(struct semaphore * sem);
55asmlinkage int __down_interruptible(struct semaphore * sem);
56asmlinkage int __down_trylock(struct semaphore * sem);
57asmlinkage void __up(struct semaphore * sem);
58
59extern spinlock_t semaphore_wake_lock;
60
61static inline void down(struct semaphore * sem)
62{
63 might_sleep();
64
65 if (atomic_sub_return(1, &sem->count) < 0)
66 __down(sem);
67}
68
69static inline int down_interruptible(struct semaphore * sem)
70{
71 int ret = 0;
72
73 might_sleep();
74
75 if (atomic_sub_return(1, &sem->count) < 0)
76 ret = __down_interruptible(sem);
77 return ret;
78}
79
80static inline int down_trylock(struct semaphore * sem)
81{
82 int ret = 0;
83
84 if (atomic_sub_return(1, &sem->count) < 0)
85 ret = __down_trylock(sem);
86 return ret;
87}
88
89/*
90 * Note! This is subtle. We jump to wake people up only if
91 * the semaphore was negative (== somebody was waiting on it).
92 */
93static inline void up(struct semaphore * sem)
94{
95 if (atomic_add_return(1, &sem->count) <= 0)
96 __up(sem);
97}
98
99#endif /* _XTENSA_SEMAPHORE_H */
diff --git a/include/asm-xtensa/unaligned.h b/include/asm-xtensa/unaligned.h
index 28220890d0a6..8f3424fc5d18 100644
--- a/include/asm-xtensa/unaligned.h
+++ b/include/asm-xtensa/unaligned.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-xtensa/unaligned.h
3 *
4 * Xtensa doesn't handle unaligned accesses efficiently. 2 * Xtensa doesn't handle unaligned accesses efficiently.
5 * 3 *
6 * 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
@@ -9,20 +7,23 @@
9 * 7 *
10 * Copyright (C) 2001 - 2005 Tensilica Inc. 8 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 */ 9 */
10#ifndef _ASM_XTENSA_UNALIGNED_H
11#define _ASM_XTENSA_UNALIGNED_H
12 12
13#ifndef _XTENSA_UNALIGNED_H 13#ifdef __XTENSA_EL__
14#define _XTENSA_UNALIGNED_H 14# include <linux/unaligned/le_memmove.h>
15 15# include <linux/unaligned/be_byteshift.h>
16#include <linux/string.h> 16# include <linux/unaligned/generic.h>
17 17# define get_unaligned __get_unaligned_le
18/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ 18# define put_unaligned __put_unaligned_le
19 19#elif defined(__XTENSA_EB__)
20#define get_unaligned(ptr) \ 20# include <linux/unaligned/be_memmove.h>
21 ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) 21# include <linux/unaligned/le_byteshift.h>
22 22# include <linux/unaligned/generic.h>
23#define put_unaligned(val, ptr) \ 23# define get_unaligned __get_unaligned_be
24 ({ __typeof__(*(ptr)) __tmp = (val); \ 24# define put_unaligned __put_unaligned_be
25 memmove((ptr), &__tmp, sizeof(*(ptr))); \ 25#else
26 (void)0; }) 26# error processor byte order undefined!
27#endif
27 28
28#endif /* _XTENSA_UNALIGNED_H */ 29#endif /* _ASM_XTENSA_UNALIGNED_H */
diff --git a/include/crypto/aes.h b/include/crypto/aes.h
index d480b76715a8..40008d67ee3d 100644
--- a/include/crypto/aes.h
+++ b/include/crypto/aes.h
@@ -14,11 +14,13 @@
14#define AES_KEYSIZE_192 24 14#define AES_KEYSIZE_192 24
15#define AES_KEYSIZE_256 32 15#define AES_KEYSIZE_256 32
16#define AES_BLOCK_SIZE 16 16#define AES_BLOCK_SIZE 16
17#define AES_MAX_KEYLENGTH (15 * 16)
18#define AES_MAX_KEYLENGTH_U32 (AES_MAX_KEYLENGTH / sizeof(u32))
17 19
18struct crypto_aes_ctx { 20struct crypto_aes_ctx {
19 u32 key_length; 21 u32 key_length;
20 u32 key_enc[60]; 22 u32 key_enc[AES_MAX_KEYLENGTH_U32];
21 u32 key_dec[60]; 23 u32 key_dec[AES_MAX_KEYLENGTH_U32];
22}; 24};
23 25
24extern u32 crypto_ft_tab[4][256]; 26extern u32 crypto_ft_tab[4][256];
@@ -28,4 +30,6 @@ extern u32 crypto_il_tab[4][256];
28 30
29int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, 31int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
30 unsigned int key_len); 32 unsigned int key_len);
33int crypto_aes_expand_key(struct crypto_aes_ctx *ctx, const u8 *in_key,
34 unsigned int key_len);
31#endif 35#endif
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 224658b8d806..833d208c25d6 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -57,10 +57,14 @@ static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num,
57 struct scatterlist *sg2) 57 struct scatterlist *sg2)
58{ 58{
59 sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0); 59 sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0);
60 sg1[num - 1].page_link &= ~0x02;
60} 61}
61 62
62static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) 63static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
63{ 64{
65 if (sg_is_last(sg))
66 return NULL;
67
64 return (++sg)->length ? sg : (void *)sg_page(sg); 68 return (++sg)->length ? sg : (void *)sg_page(sg);
65} 69}
66 70
diff --git a/include/keys/rxrpc-type.h b/include/keys/rxrpc-type.h
index 4ea429b18750..7609365577f1 100644
--- a/include/keys/rxrpc-type.h
+++ b/include/keys/rxrpc-type.h
@@ -21,4 +21,4 @@ extern struct key_type key_type_rxrpc;
21 21
22extern struct key *rxrpc_get_null_key(const char *); 22extern struct key *rxrpc_get_null_key(const char *);
23 23
24#endif /* _KEYS_USER_TYPE_H */ 24#endif /* _KEYS_RXRPC_TYPE_H */
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index cedbbd806bf6..78fade0a1e35 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -20,6 +20,7 @@ header-y += affs_hardblocks.h
20header-y += aio_abi.h 20header-y += aio_abi.h
21header-y += arcfb.h 21header-y += arcfb.h
22header-y += atmapi.h 22header-y += atmapi.h
23header-y += atmarp.h
23header-y += atmbr2684.h 24header-y += atmbr2684.h
24header-y += atmclip.h 25header-y += atmclip.h
25header-y += atm_eni.h 26header-y += atm_eni.h
@@ -48,6 +49,7 @@ header-y += coff.h
48header-y += comstats.h 49header-y += comstats.h
49header-y += const.h 50header-y += const.h
50header-y += cgroupstats.h 51header-y += cgroupstats.h
52header-y += cramfs_fs.h
51header-y += cycx_cfm.h 53header-y += cycx_cfm.h
52header-y += dlmconstants.h 54header-y += dlmconstants.h
53header-y += dlm_device.h 55header-y += dlm_device.h
@@ -70,10 +72,12 @@ header-y += firewire-constants.h
70header-y += fuse.h 72header-y += fuse.h
71header-y += genetlink.h 73header-y += genetlink.h
72header-y += gen_stats.h 74header-y += gen_stats.h
75header-y += gfs2_ondisk.h
73header-y += gigaset_dev.h 76header-y += gigaset_dev.h
74header-y += hysdn_if.h 77header-y += hysdn_if.h
75header-y += i2o-dev.h 78header-y += i2o-dev.h
76header-y += i8k.h 79header-y += i8k.h
80header-y += if_addrlabel.h
77header-y += if_arcnet.h 81header-y += if_arcnet.h
78header-y += if_bonding.h 82header-y += if_bonding.h
79header-y += if_cablemodem.h 83header-y += if_cablemodem.h
@@ -91,6 +95,7 @@ header-y += if_tunnel.h
91header-y += in6.h 95header-y += in6.h
92header-y += in_route.h 96header-y += in_route.h
93header-y += ioctl.h 97header-y += ioctl.h
98header-y += ip6_tunnel.h
94header-y += ipmi_msgdefs.h 99header-y += ipmi_msgdefs.h
95header-y += ipsec.h 100header-y += ipsec.h
96header-y += ipx.h 101header-y += ipx.h
@@ -100,7 +105,7 @@ header-y += ixjuser.h
100header-y += jffs2.h 105header-y += jffs2.h
101header-y += keyctl.h 106header-y += keyctl.h
102header-y += limits.h 107header-y += limits.h
103header-y += lock_dlm_plock.h 108header-y += dlm_plock.h
104header-y += magic.h 109header-y += magic.h
105header-y += major.h 110header-y += major.h
106header-y += matroxfb.h 111header-y += matroxfb.h
@@ -117,7 +122,6 @@ header-y += nfs2.h
117header-y += nfs4_mount.h 122header-y += nfs4_mount.h
118header-y += nfs_mount.h 123header-y += nfs_mount.h
119header-y += nl80211.h 124header-y += nl80211.h
120header-y += oom.h
121header-y += param.h 125header-y += param.h
122header-y += pci_regs.h 126header-y += pci_regs.h
123header-y += pfkeyv2.h 127header-y += pfkeyv2.h
@@ -150,6 +154,7 @@ header-y += tiocl.h
150header-y += tipc.h 154header-y += tipc.h
151header-y += tipc_config.h 155header-y += tipc_config.h
152header-y += toshiba.h 156header-y += toshiba.h
157header-y += udf_fs_i.h
153header-y += ultrasound.h 158header-y += ultrasound.h
154header-y += un.h 159header-y += un.h
155header-y += utime.h 160header-y += utime.h
@@ -165,7 +170,6 @@ unifdef-y += adfs_fs.h
165unifdef-y += agpgart.h 170unifdef-y += agpgart.h
166unifdef-y += apm_bios.h 171unifdef-y += apm_bios.h
167unifdef-y += atalk.h 172unifdef-y += atalk.h
168unifdef-y += atmarp.h
169unifdef-y += atmdev.h 173unifdef-y += atmdev.h
170unifdef-y += atm.h 174unifdef-y += atm.h
171unifdef-y += atm_tcp.h 175unifdef-y += atm_tcp.h
@@ -181,7 +185,6 @@ unifdef-y += cm4000_cs.h
181unifdef-y += cn_proc.h 185unifdef-y += cn_proc.h
182unifdef-y += coda.h 186unifdef-y += coda.h
183unifdef-y += connector.h 187unifdef-y += connector.h
184unifdef-y += cramfs_fs.h
185unifdef-y += cuda.h 188unifdef-y += cuda.h
186unifdef-y += cyclades.h 189unifdef-y += cyclades.h
187unifdef-y += dccp.h 190unifdef-y += dccp.h
@@ -204,20 +207,19 @@ unifdef-y += futex.h
204unifdef-y += fs.h 207unifdef-y += fs.h
205unifdef-y += gameport.h 208unifdef-y += gameport.h
206unifdef-y += generic_serial.h 209unifdef-y += generic_serial.h
207unifdef-y += gfs2_ondisk.h
208unifdef-y += hayesesp.h 210unifdef-y += hayesesp.h
209unifdef-y += hdlcdrv.h 211unifdef-y += hdlcdrv.h
210unifdef-y += hdlc.h 212unifdef-y += hdlc.h
211unifdef-y += hdreg.h 213unifdef-y += hdreg.h
212unifdef-y += hdsmart.h 214unifdef-y += hid.h
213unifdef-y += hiddev.h 215unifdef-y += hiddev.h
216unifdef-y += hidraw.h
214unifdef-y += hpet.h 217unifdef-y += hpet.h
215unifdef-y += i2c.h 218unifdef-y += i2c.h
216unifdef-y += i2c-dev.h 219unifdef-y += i2c-dev.h
217unifdef-y += icmp.h 220unifdef-y += icmp.h
218unifdef-y += icmpv6.h 221unifdef-y += icmpv6.h
219unifdef-y += if_addr.h 222unifdef-y += if_addr.h
220unifdef-y += if_addrlabel.h
221unifdef-y += if_arp.h 223unifdef-y += if_arp.h
222unifdef-y += if_bridge.h 224unifdef-y += if_bridge.h
223unifdef-y += if_ec.h 225unifdef-y += if_ec.h
@@ -231,7 +233,6 @@ unifdef-y += if_pppol2tp.h
231unifdef-y += if_pppox.h 233unifdef-y += if_pppox.h
232unifdef-y += if_tr.h 234unifdef-y += if_tr.h
233unifdef-y += if_vlan.h 235unifdef-y += if_vlan.h
234unifdef-y += if_wanpipe.h
235unifdef-y += igmp.h 236unifdef-y += igmp.h
236unifdef-y += inet_diag.h 237unifdef-y += inet_diag.h
237unifdef-y += in.h 238unifdef-y += in.h
@@ -242,7 +243,6 @@ unifdef-y += ipc.h
242unifdef-y += ipmi.h 243unifdef-y += ipmi.h
243unifdef-y += ipv6.h 244unifdef-y += ipv6.h
244unifdef-y += ipv6_route.h 245unifdef-y += ipv6_route.h
245unifdef-y += ip6_tunnel.h
246unifdef-y += isdn.h 246unifdef-y += isdn.h
247unifdef-y += isdnif.h 247unifdef-y += isdnif.h
248unifdef-y += isdn_divertif.h 248unifdef-y += isdn_divertif.h
@@ -261,6 +261,7 @@ unifdef-y += mempolicy.h
261unifdef-y += mii.h 261unifdef-y += mii.h
262unifdef-y += mman.h 262unifdef-y += mman.h
263unifdef-y += mroute.h 263unifdef-y += mroute.h
264unifdef-y += mroute6.h
264unifdef-y += msdos_fs.h 265unifdef-y += msdos_fs.h
265unifdef-y += msg.h 266unifdef-y += msg.h
266unifdef-y += nbd.h 267unifdef-y += nbd.h
@@ -289,6 +290,7 @@ unifdef-y += parport.h
289unifdef-y += patchkey.h 290unifdef-y += patchkey.h
290unifdef-y += pci.h 291unifdef-y += pci.h
291unifdef-y += personality.h 292unifdef-y += personality.h
293unifdef-y += pim.h
292unifdef-y += pktcdvd.h 294unifdef-y += pktcdvd.h
293unifdef-y += pmu.h 295unifdef-y += pmu.h
294unifdef-y += poll.h 296unifdef-y += poll.h
@@ -333,7 +335,6 @@ unifdef-y += time.h
333unifdef-y += timex.h 335unifdef-y += timex.h
334unifdef-y += tty.h 336unifdef-y += tty.h
335unifdef-y += types.h 337unifdef-y += types.h
336unifdef-y += udf_fs_i.h
337unifdef-y += udp.h 338unifdef-y += udp.h
338unifdef-y += uinput.h 339unifdef-y += uinput.h
339unifdef-y += uio.h 340unifdef-y += uio.h
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 2c7e003356ac..41f7ce7edd7a 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -79,6 +79,7 @@ typedef int (*acpi_table_handler) (struct acpi_table_header *table);
79typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end); 79typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
80 80
81char * __acpi_map_table (unsigned long phys_addr, unsigned long size); 81char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
82int early_acpi_boot_init(void);
82int acpi_boot_init (void); 83int acpi_boot_init (void);
83int acpi_boot_table_init (void); 84int acpi_boot_table_init (void);
84int acpi_numa_init (void); 85int acpi_numa_init (void);
@@ -235,6 +236,10 @@ int acpi_check_mem_region(resource_size_t start, resource_size_t n,
235 236
236#else /* CONFIG_ACPI */ 237#else /* CONFIG_ACPI */
237 238
239static inline int early_acpi_boot_init(void)
240{
241 return 0;
242}
238static inline int acpi_boot_init(void) 243static inline int acpi_boot_init(void)
239{ 244{
240 return 0; 245 return 0;
diff --git a/include/linux/aer.h b/include/linux/aer.h
index bcf236d825e8..f2518141de88 100644
--- a/include/linux/aer.h
+++ b/include/linux/aer.h
@@ -13,7 +13,6 @@ extern int pci_enable_pcie_error_reporting(struct pci_dev *dev);
13extern int pci_find_aer_capability(struct pci_dev *dev); 13extern int pci_find_aer_capability(struct pci_dev *dev);
14extern int pci_disable_pcie_error_reporting(struct pci_dev *dev); 14extern int pci_disable_pcie_error_reporting(struct pci_dev *dev);
15extern int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev); 15extern int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev);
16extern int pci_cleanup_aer_correct_error_status(struct pci_dev *dev);
17#else 16#else
18static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev) 17static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev)
19{ 18{
@@ -31,10 +30,6 @@ static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
31{ 30{
32 return -EINVAL; 31 return -EINVAL;
33} 32}
34static inline int pci_cleanup_aer_correct_error_status(struct pci_dev *dev)
35{
36 return -EINVAL;
37}
38#endif 33#endif
39 34
40#endif //_AER_H_ 35#endif //_AER_H_
diff --git a/include/linux/agp_backend.h b/include/linux/agp_backend.h
index 03e34547d489..661d90d6cf7c 100644
--- a/include/linux/agp_backend.h
+++ b/include/linux/agp_backend.h
@@ -30,8 +30,6 @@
30#ifndef _AGP_BACKEND_H 30#ifndef _AGP_BACKEND_H
31#define _AGP_BACKEND_H 1 31#define _AGP_BACKEND_H 1
32 32
33#ifdef __KERNEL__
34
35#ifndef TRUE 33#ifndef TRUE
36#define TRUE 1 34#define TRUE 1
37#endif 35#endif
@@ -111,5 +109,4 @@ extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
111extern void agp_backend_release(struct agp_bridge_data *); 109extern void agp_backend_release(struct agp_bridge_data *);
112extern void agp_flush_chipset(struct agp_bridge_data *); 110extern void agp_flush_chipset(struct agp_bridge_data *);
113 111
114#endif /* __KERNEL__ */
115#endif /* _AGP_BACKEND_H */ 112#endif /* _AGP_BACKEND_H */
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 0d0b7f629bd3..b51ddd28444e 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -209,27 +209,8 @@ extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb);
209extern int aio_put_req(struct kiocb *iocb); 209extern int aio_put_req(struct kiocb *iocb);
210extern void kick_iocb(struct kiocb *iocb); 210extern void kick_iocb(struct kiocb *iocb);
211extern int aio_complete(struct kiocb *iocb, long res, long res2); 211extern int aio_complete(struct kiocb *iocb, long res, long res2);
212extern void __put_ioctx(struct kioctx *ctx);
213struct mm_struct; 212struct mm_struct;
214extern void exit_aio(struct mm_struct *mm); 213extern void exit_aio(struct mm_struct *mm);
215extern struct kioctx *lookup_ioctx(unsigned long ctx_id);
216extern int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
217 struct iocb *iocb);
218
219/* semi private, but used by the 32bit emulations: */
220struct kioctx *lookup_ioctx(unsigned long ctx_id);
221int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
222 struct iocb *iocb);
223
224#define get_ioctx(kioctx) do { \
225 BUG_ON(atomic_read(&(kioctx)->users) <= 0); \
226 atomic_inc(&(kioctx)->users); \
227} while (0)
228#define put_ioctx(kioctx) do { \
229 BUG_ON(atomic_read(&(kioctx)->users) <= 0); \
230 if (unlikely(atomic_dec_and_test(&(kioctx)->users))) \
231 __put_ioctx(kioctx); \
232} while (0)
233 214
234#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait) 215#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
235 216
diff --git a/include/linux/arcdevice.h b/include/linux/arcdevice.h
index fde675872c56..a1916078fd08 100644
--- a/include/linux/arcdevice.h
+++ b/include/linux/arcdevice.h
@@ -283,8 +283,8 @@ struct arcnet_local {
283 int next_buf, first_free_buf; 283 int next_buf, first_free_buf;
284 284
285 /* network "reconfiguration" handling */ 285 /* network "reconfiguration" handling */
286 time_t first_recon, /* time of "first" RECON message to count */ 286 unsigned long first_recon; /* time of "first" RECON message to count */
287 last_recon; /* time of most recent RECON */ 287 unsigned long last_recon; /* time of most recent RECON */
288 int num_recons; /* number of RECONs between first and last. */ 288 int num_recons; /* number of RECONs between first and last. */
289 bool network_down; /* do we think the network is down? */ 289 bool network_down; /* do we think the network is down? */
290 290
diff --git a/include/linux/ata_platform.h b/include/linux/ata_platform.h
index b856a2a590d9..9a26c83a2c9e 100644
--- a/include/linux/ata_platform.h
+++ b/include/linux/ata_platform.h
@@ -27,7 +27,10 @@ extern int __devexit __pata_platform_remove(struct device *dev);
27/* 27/*
28 * Marvell SATA private data 28 * Marvell SATA private data
29 */ 29 */
30struct mbus_dram_target_info;
31
30struct mv_sata_platform_data { 32struct mv_sata_platform_data {
33 struct mbus_dram_target_info *dram;
31 int n_ports; /* number of sata ports */ 34 int n_ports; /* number of sata ports */
32}; 35};
33 36
diff --git a/include/linux/atalk.h b/include/linux/atalk.h
index ced8a1ed080c..e9ebac2e2ecc 100644
--- a/include/linux/atalk.h
+++ b/include/linux/atalk.h
@@ -85,8 +85,6 @@ static inline struct atalk_sock *at_sk(struct sock *sk)
85 return (struct atalk_sock *)sk; 85 return (struct atalk_sock *)sk;
86} 86}
87 87
88#include <asm/byteorder.h>
89
90struct ddpehdr { 88struct ddpehdr {
91 __be16 deh_len_hops; /* lower 10 bits are length, next 4 - hops */ 89 __be16 deh_len_hops; /* lower 10 bits are length, next 4 - hops */
92 __be16 deh_sum; 90 __be16 deh_sum;
diff --git a/include/linux/atmel_tc.h b/include/linux/atmel_tc.h
new file mode 100644
index 000000000000..53ba65e30caa
--- /dev/null
+++ b/include/linux/atmel_tc.h
@@ -0,0 +1,252 @@
1/*
2 * Timer/Counter Unit (TC) registers.
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
10#ifndef ATMEL_TC_H
11#define ATMEL_TC_H
12
13#include <linux/compiler.h>
14#include <linux/list.h>
15
16/*
17 * Many 32-bit Atmel SOCs include one or more TC blocks, each of which holds
18 * three general-purpose 16-bit timers. These timers share one register bank.
19 * Depending on the SOC, each timer may have its own clock and IRQ, or those
20 * may be shared by the whole TC block.
21 *
22 * These TC blocks may have up to nine external pins: TCLK0..2 signals for
23 * clocks or clock gates, and per-timer TIOA and TIOB signals used for PWM
24 * or triggering. Those pins need to be set up for use with the TC block,
25 * else they will be used as GPIOs or for a different controller.
26 *
27 * Although we expect each TC block to have a platform_device node, those
28 * nodes are not what drivers bind to. Instead, they ask for a specific
29 * TC block, by number ... which is a common approach on systems with many
30 * timers. Then they use clk_get() and platform_get_irq() to get clock and
31 * IRQ resources.
32 */
33
34struct clk;
35
36/**
37 * struct atmel_tc - information about a Timer/Counter Block
38 * @pdev: physical device
39 * @iomem: resource associated with the I/O register
40 * @regs: mapping through which the I/O registers can be accessed
41 * @irq: irq for each of the three channels
42 * @clk: internal clock source for each of the three channels
43 * @node: list node, for tclib internal use
44 *
45 * On some platforms, each TC channel has its own clocks and IRQs,
46 * while on others, all TC channels share the same clock and IRQ.
47 * Drivers should clk_enable() all the clocks they need even though
48 * all the entries in @clk may point to the same physical clock.
49 * Likewise, drivers should request irqs independently for each
50 * channel, but they must use IRQF_SHARED in case some of the entries
51 * in @irq are actually the same IRQ.
52 */
53struct atmel_tc {
54 struct platform_device *pdev;
55 struct resource *iomem;
56 void __iomem *regs;
57 int irq[3];
58 struct clk *clk[3];
59 struct list_head node;
60};
61
62extern struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name);
63extern void atmel_tc_free(struct atmel_tc *tc);
64
65/* platform-specific ATMEL_TC_TIMER_CLOCKx divisors (0 means 32KiHz) */
66extern const u8 atmel_tc_divisors[5];
67
68
69/*
70 * Two registers have block-wide controls. These are: configuring the three
71 * "external" clocks (or event sources) used by the timer channels; and
72 * synchronizing the timers by resetting them all at once.
73 *
74 * "External" can mean "external to chip" using the TCLK0, TCLK1, or TCLK2
75 * signals. Or, it can mean "external to timer", using the TIOA output from
76 * one of the other two timers that's being run in waveform mode.
77 */
78
79#define ATMEL_TC_BCR 0xc0 /* TC Block Control Register */
80#define ATMEL_TC_SYNC (1 << 0) /* synchronize timers */
81
82#define ATMEL_TC_BMR 0xc4 /* TC Block Mode Register */
83#define ATMEL_TC_TC0XC0S (3 << 0) /* external clock 0 source */
84#define ATMEL_TC_TC0XC0S_TCLK0 (0 << 0)
85#define ATMEL_TC_TC0XC0S_NONE (1 << 0)
86#define ATMEL_TC_TC0XC0S_TIOA1 (2 << 0)
87#define ATMEL_TC_TC0XC0S_TIOA2 (3 << 0)
88#define ATMEL_TC_TC1XC1S (3 << 2) /* external clock 1 source */
89#define ATMEL_TC_TC1XC1S_TCLK1 (0 << 2)
90#define ATMEL_TC_TC1XC1S_NONE (1 << 2)
91#define ATMEL_TC_TC1XC1S_TIOA0 (2 << 2)
92#define ATMEL_TC_TC1XC1S_TIOA2 (3 << 2)
93#define ATMEL_TC_TC2XC2S (3 << 4) /* external clock 2 source */
94#define ATMEL_TC_TC2XC2S_TCLK2 (0 << 4)
95#define ATMEL_TC_TC2XC2S_NONE (1 << 4)
96#define ATMEL_TC_TC2XC2S_TIOA0 (2 << 4)
97#define ATMEL_TC_TC2XC2S_TIOA1 (3 << 4)
98
99
100/*
101 * Each TC block has three "channels", each with one counter and controls.
102 *
103 * Note that the semantics of ATMEL_TC_TIMER_CLOCKx (input clock selection
104 * when it's not "external") is silicon-specific. AT91 platforms use one
105 * set of definitions; AVR32 platforms use a different set. Don't hard-wire
106 * such knowledge into your code, use the global "atmel_tc_divisors" ...
107 * where index N is the divisor for clock N+1, else zero to indicate it uses
108 * the 32 KiHz clock.
109 *
110 * The timers can be chained in various ways, and operated in "waveform"
111 * generation mode (including PWM) or "capture" mode (to time events). In
112 * both modes, behavior can be configured in many ways.
113 *
114 * Each timer has two I/O pins, TIOA and TIOB. Waveform mode uses TIOA as a
115 * PWM output, and TIOB as either another PWM or as a trigger. Capture mode
116 * uses them only as inputs.
117 */
118#define ATMEL_TC_CHAN(idx) ((idx)*0x40)
119#define ATMEL_TC_REG(idx, reg) (ATMEL_TC_CHAN(idx) + ATMEL_TC_ ## reg)
120
121#define ATMEL_TC_CCR 0x00 /* Channel Control Register */
122#define ATMEL_TC_CLKEN (1 << 0) /* clock enable */
123#define ATMEL_TC_CLKDIS (1 << 1) /* clock disable */
124#define ATMEL_TC_SWTRG (1 << 2) /* software trigger */
125
126#define ATMEL_TC_CMR 0x04 /* Channel Mode Register */
127
128/* Both modes share some CMR bits */
129#define ATMEL_TC_TCCLKS (7 << 0) /* clock source */
130#define ATMEL_TC_TIMER_CLOCK1 (0 << 0)
131#define ATMEL_TC_TIMER_CLOCK2 (1 << 0)
132#define ATMEL_TC_TIMER_CLOCK3 (2 << 0)
133#define ATMEL_TC_TIMER_CLOCK4 (3 << 0)
134#define ATMEL_TC_TIMER_CLOCK5 (4 << 0)
135#define ATMEL_TC_XC0 (5 << 0)
136#define ATMEL_TC_XC1 (6 << 0)
137#define ATMEL_TC_XC2 (7 << 0)
138#define ATMEL_TC_CLKI (1 << 3) /* clock invert */
139#define ATMEL_TC_BURST (3 << 4) /* clock gating */
140#define ATMEL_TC_GATE_NONE (0 << 4)
141#define ATMEL_TC_GATE_XC0 (1 << 4)
142#define ATMEL_TC_GATE_XC1 (2 << 4)
143#define ATMEL_TC_GATE_XC2 (3 << 4)
144#define ATMEL_TC_WAVE (1 << 15) /* true = Waveform mode */
145
146/* CAPTURE mode CMR bits */
147#define ATMEL_TC_LDBSTOP (1 << 6) /* counter stops on RB load */
148#define ATMEL_TC_LDBDIS (1 << 7) /* counter disable on RB load */
149#define ATMEL_TC_ETRGEDG (3 << 8) /* external trigger edge */
150#define ATMEL_TC_ETRGEDG_NONE (0 << 8)
151#define ATMEL_TC_ETRGEDG_RISING (1 << 8)
152#define ATMEL_TC_ETRGEDG_FALLING (2 << 8)
153#define ATMEL_TC_ETRGEDG_BOTH (3 << 8)
154#define ATMEL_TC_ABETRG (1 << 10) /* external trigger is TIOA? */
155#define ATMEL_TC_CPCTRG (1 << 14) /* RC compare trigger enable */
156#define ATMEL_TC_LDRA (3 << 16) /* RA loading edge (of TIOA) */
157#define ATMEL_TC_LDRA_NONE (0 << 16)
158#define ATMEL_TC_LDRA_RISING (1 << 16)
159#define ATMEL_TC_LDRA_FALLING (2 << 16)
160#define ATMEL_TC_LDRA_BOTH (3 << 16)
161#define ATMEL_TC_LDRB (3 << 18) /* RB loading edge (of TIOA) */
162#define ATMEL_TC_LDRB_NONE (0 << 18)
163#define ATMEL_TC_LDRB_RISING (1 << 18)
164#define ATMEL_TC_LDRB_FALLING (2 << 18)
165#define ATMEL_TC_LDRB_BOTH (3 << 18)
166
167/* WAVEFORM mode CMR bits */
168#define ATMEL_TC_CPCSTOP (1 << 6) /* RC compare stops counter */
169#define ATMEL_TC_CPCDIS (1 << 7) /* RC compare disables counter */
170#define ATMEL_TC_EEVTEDG (3 << 8) /* external event edge */
171#define ATMEL_TC_EEVTEDG_NONE (0 << 8)
172#define ATMEL_TC_EEVTEDG_RISING (1 << 8)
173#define ATMEL_TC_EEVTEDG_FALLING (2 << 8)
174#define ATMEL_TC_EEVTEDG_BOTH (3 << 8)
175#define ATMEL_TC_EEVT (3 << 10) /* external event source */
176#define ATMEL_TC_EEVT_TIOB (0 << 10)
177#define ATMEL_TC_EEVT_XC0 (1 << 10)
178#define ATMEL_TC_EEVT_XC1 (2 << 10)
179#define ATMEL_TC_EEVT_XC2 (3 << 10)
180#define ATMEL_TC_ENETRG (1 << 12) /* external event is trigger */
181#define ATMEL_TC_WAVESEL (3 << 13) /* waveform type */
182#define ATMEL_TC_WAVESEL_UP (0 << 13)
183#define ATMEL_TC_WAVESEL_UPDOWN (1 << 13)
184#define ATMEL_TC_WAVESEL_UP_AUTO (2 << 13)
185#define ATMEL_TC_WAVESEL_UPDOWN_AUTO (3 << 13)
186#define ATMEL_TC_ACPA (3 << 16) /* RA compare changes TIOA */
187#define ATMEL_TC_ACPA_NONE (0 << 16)
188#define ATMEL_TC_ACPA_SET (1 << 16)
189#define ATMEL_TC_ACPA_CLEAR (2 << 16)
190#define ATMEL_TC_ACPA_TOGGLE (3 << 16)
191#define ATMEL_TC_ACPC (3 << 18) /* RC compare changes TIOA */
192#define ATMEL_TC_ACPC_NONE (0 << 18)
193#define ATMEL_TC_ACPC_SET (1 << 18)
194#define ATMEL_TC_ACPC_CLEAR (2 << 18)
195#define ATMEL_TC_ACPC_TOGGLE (3 << 18)
196#define ATMEL_TC_AEEVT (3 << 20) /* external event changes TIOA */
197#define ATMEL_TC_AEEVT_NONE (0 << 20)
198#define ATMEL_TC_AEEVT_SET (1 << 20)
199#define ATMEL_TC_AEEVT_CLEAR (2 << 20)
200#define ATMEL_TC_AEEVT_TOGGLE (3 << 20)
201#define ATMEL_TC_ASWTRG (3 << 22) /* software trigger changes TIOA */
202#define ATMEL_TC_ASWTRG_NONE (0 << 22)
203#define ATMEL_TC_ASWTRG_SET (1 << 22)
204#define ATMEL_TC_ASWTRG_CLEAR (2 << 22)
205#define ATMEL_TC_ASWTRG_TOGGLE (3 << 22)
206#define ATMEL_TC_BCPB (3 << 24) /* RB compare changes TIOB */
207#define ATMEL_TC_BCPB_NONE (0 << 24)
208#define ATMEL_TC_BCPB_SET (1 << 24)
209#define ATMEL_TC_BCPB_CLEAR (2 << 24)
210#define ATMEL_TC_BCPB_TOGGLE (3 << 24)
211#define ATMEL_TC_BCPC (3 << 26) /* RC compare changes TIOB */
212#define ATMEL_TC_BCPC_NONE (0 << 26)
213#define ATMEL_TC_BCPC_SET (1 << 26)
214#define ATMEL_TC_BCPC_CLEAR (2 << 26)
215#define ATMEL_TC_BCPC_TOGGLE (3 << 26)
216#define ATMEL_TC_BEEVT (3 << 28) /* external event changes TIOB */
217#define ATMEL_TC_BEEVT_NONE (0 << 28)
218#define ATMEL_TC_BEEVT_SET (1 << 28)
219#define ATMEL_TC_BEEVT_CLEAR (2 << 28)
220#define ATMEL_TC_BEEVT_TOGGLE (3 << 28)
221#define ATMEL_TC_BSWTRG (3 << 30) /* software trigger changes TIOB */
222#define ATMEL_TC_BSWTRG_NONE (0 << 30)
223#define ATMEL_TC_BSWTRG_SET (1 << 30)
224#define ATMEL_TC_BSWTRG_CLEAR (2 << 30)
225#define ATMEL_TC_BSWTRG_TOGGLE (3 << 30)
226
227#define ATMEL_TC_CV 0x10 /* counter Value */
228#define ATMEL_TC_RA 0x14 /* register A */
229#define ATMEL_TC_RB 0x18 /* register B */
230#define ATMEL_TC_RC 0x1c /* register C */
231
232#define ATMEL_TC_SR 0x20 /* status (read-only) */
233/* Status-only flags */
234#define ATMEL_TC_CLKSTA (1 << 16) /* clock enabled */
235#define ATMEL_TC_MTIOA (1 << 17) /* TIOA mirror */
236#define ATMEL_TC_MTIOB (1 << 18) /* TIOB mirror */
237
238#define ATMEL_TC_IER 0x24 /* interrupt enable (write-only) */
239#define ATMEL_TC_IDR 0x28 /* interrupt disable (write-only) */
240#define ATMEL_TC_IMR 0x2c /* interrupt mask (read-only) */
241
242/* Status and IRQ flags */
243#define ATMEL_TC_COVFS (1 << 0) /* counter overflow */
244#define ATMEL_TC_LOVRS (1 << 1) /* load overrun */
245#define ATMEL_TC_CPAS (1 << 2) /* RA compare */
246#define ATMEL_TC_CPBS (1 << 3) /* RB compare */
247#define ATMEL_TC_CPCS (1 << 4) /* RC compare */
248#define ATMEL_TC_LDRAS (1 << 5) /* RA loading */
249#define ATMEL_TC_LDRBS (1 << 6) /* RB loading */
250#define ATMEL_TC_ETRGS (1 << 7) /* external trigger */
251
252#endif
diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h
index f5582332af04..794ad74b1d61 100644
--- a/include/linux/attribute_container.h
+++ b/include/linux/attribute_container.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * class_container.h - a generic container for all classes 2 * attribute_container.h - a generic container for all classes
3 * 3 *
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com> 4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
5 * 5 *
@@ -18,7 +18,7 @@ struct attribute_container {
18 struct klist containers; 18 struct klist containers;
19 struct class *class; 19 struct class *class;
20 struct attribute_group *grp; 20 struct attribute_group *grp;
21 struct class_device_attribute **attrs; 21 struct device_attribute **attrs;
22 int (*match)(struct attribute_container *, struct device *); 22 int (*match)(struct attribute_container *, struct device *);
23#define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 23#define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01
24 unsigned long flags; 24 unsigned long flags;
@@ -37,35 +37,35 @@ attribute_container_set_no_classdevs(struct attribute_container *atc)
37} 37}
38 38
39int attribute_container_register(struct attribute_container *cont); 39int attribute_container_register(struct attribute_container *cont);
40int attribute_container_unregister(struct attribute_container *cont); 40int __must_check attribute_container_unregister(struct attribute_container *cont);
41void attribute_container_create_device(struct device *dev, 41void attribute_container_create_device(struct device *dev,
42 int (*fn)(struct attribute_container *, 42 int (*fn)(struct attribute_container *,
43 struct device *, 43 struct device *,
44 struct class_device *)); 44 struct device *));
45void attribute_container_add_device(struct device *dev, 45void attribute_container_add_device(struct device *dev,
46 int (*fn)(struct attribute_container *, 46 int (*fn)(struct attribute_container *,
47 struct device *, 47 struct device *,
48 struct class_device *)); 48 struct device *));
49void attribute_container_remove_device(struct device *dev, 49void attribute_container_remove_device(struct device *dev,
50 void (*fn)(struct attribute_container *, 50 void (*fn)(struct attribute_container *,
51 struct device *, 51 struct device *,
52 struct class_device *)); 52 struct device *));
53void attribute_container_device_trigger(struct device *dev, 53void attribute_container_device_trigger(struct device *dev,
54 int (*fn)(struct attribute_container *, 54 int (*fn)(struct attribute_container *,
55 struct device *, 55 struct device *,
56 struct class_device *)); 56 struct device *));
57void attribute_container_trigger(struct device *dev, 57void attribute_container_trigger(struct device *dev,
58 int (*fn)(struct attribute_container *, 58 int (*fn)(struct attribute_container *,
59 struct device *)); 59 struct device *));
60int attribute_container_add_attrs(struct class_device *classdev); 60int attribute_container_add_attrs(struct device *classdev);
61int attribute_container_add_class_device(struct class_device *classdev); 61int attribute_container_add_class_device(struct device *classdev);
62int attribute_container_add_class_device_adapter(struct attribute_container *cont, 62int attribute_container_add_class_device_adapter(struct attribute_container *cont,
63 struct device *dev, 63 struct device *dev,
64 struct class_device *classdev); 64 struct device *classdev);
65void attribute_container_remove_attrs(struct class_device *classdev); 65void attribute_container_remove_attrs(struct device *classdev);
66void attribute_container_class_device_del(struct class_device *classdev); 66void attribute_container_class_device_del(struct device *classdev);
67struct attribute_container *attribute_container_classdev_to_container(struct class_device *); 67struct attribute_container *attribute_container_classdev_to_container(struct device *);
68struct class_device *attribute_container_find_class_device(struct attribute_container *, struct device *); 68struct device *attribute_container_find_class_device(struct attribute_container *, struct device *);
69struct class_device_attribute **attribute_container_classdev_to_attrs(const struct class_device *classdev); 69struct device_attribute **attribute_container_classdev_to_attrs(const struct device *classdev);
70 70
71#endif 71#endif
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 2af9ec025015..63c3bb98558f 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -146,7 +146,7 @@
146/* Rule structure sizes -- if these change, different AUDIT_ADD and 146/* Rule structure sizes -- if these change, different AUDIT_ADD and
147 * AUDIT_LIST commands must be implemented. */ 147 * AUDIT_LIST commands must be implemented. */
148#define AUDIT_MAX_FIELDS 64 148#define AUDIT_MAX_FIELDS 64
149#define AUDIT_MAX_KEY_LEN 32 149#define AUDIT_MAX_KEY_LEN 256
150#define AUDIT_BITMASK_SIZE 64 150#define AUDIT_BITMASK_SIZE 64
151#define AUDIT_WORD(nr) ((__u32)((nr)/32)) 151#define AUDIT_WORD(nr) ((__u32)((nr)/32))
152#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32)) 152#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32))
@@ -209,6 +209,7 @@
209#define AUDIT_WATCH 105 209#define AUDIT_WATCH 105
210#define AUDIT_PERM 106 210#define AUDIT_PERM 106
211#define AUDIT_DIR 107 211#define AUDIT_DIR 107
212#define AUDIT_FILETYPE 108
212 213
213#define AUDIT_ARG0 200 214#define AUDIT_ARG0 200
214#define AUDIT_ARG1 (AUDIT_ARG0+1) 215#define AUDIT_ARG1 (AUDIT_ARG0+1)
@@ -353,6 +354,33 @@ struct netlink_skb_parms;
353struct linux_binprm; 354struct linux_binprm;
354struct mq_attr; 355struct mq_attr;
355struct mqstat; 356struct mqstat;
357struct audit_watch;
358struct audit_tree;
359
360struct audit_krule {
361 int vers_ops;
362 u32 flags;
363 u32 listnr;
364 u32 action;
365 u32 mask[AUDIT_BITMASK_SIZE];
366 u32 buflen; /* for data alloc on list rules */
367 u32 field_count;
368 char *filterkey; /* ties events to rules */
369 struct audit_field *fields;
370 struct audit_field *arch_f; /* quick access to arch field */
371 struct audit_field *inode_f; /* quick access to an inode field */
372 struct audit_watch *watch; /* associated watch */
373 struct audit_tree *tree; /* associated watched tree */
374 struct list_head rlist; /* entry in audit_{watch,tree}.rules list */
375};
376
377struct audit_field {
378 u32 type;
379 u32 val;
380 u32 op;
381 char *lsm_str;
382 void *lsm_rule;
383};
356 384
357#define AUDITSC_INVALID 0 385#define AUDITSC_INVALID 0
358#define AUDITSC_SUCCESS 1 386#define AUDITSC_SUCCESS 1
@@ -522,25 +550,32 @@ extern void audit_log_format(struct audit_buffer *ab,
522 const char *fmt, ...) 550 const char *fmt, ...)
523 __attribute__((format(printf,2,3))); 551 __attribute__((format(printf,2,3)));
524extern void audit_log_end(struct audit_buffer *ab); 552extern void audit_log_end(struct audit_buffer *ab);
525extern void audit_log_hex(struct audit_buffer *ab,
526 const unsigned char *buf,
527 size_t len);
528extern int audit_string_contains_control(const char *string, 553extern int audit_string_contains_control(const char *string,
529 size_t len); 554 size_t len);
555extern void audit_log_n_hex(struct audit_buffer *ab,
556 const unsigned char *buf,
557 size_t len);
558extern void audit_log_n_string(struct audit_buffer *ab,
559 const char *buf,
560 size_t n);
561#define audit_log_string(a,b) audit_log_n_string(a, b, strlen(b));
562extern void audit_log_n_untrustedstring(struct audit_buffer *ab,
563 const char *string,
564 size_t n);
530extern void audit_log_untrustedstring(struct audit_buffer *ab, 565extern void audit_log_untrustedstring(struct audit_buffer *ab,
531 const char *string); 566 const char *string);
532extern void audit_log_n_untrustedstring(struct audit_buffer *ab,
533 size_t n,
534 const char *string);
535extern void audit_log_d_path(struct audit_buffer *ab, 567extern void audit_log_d_path(struct audit_buffer *ab,
536 const char *prefix, 568 const char *prefix,
537 struct path *path); 569 struct path *path);
538extern void audit_log_lost(const char *message); 570extern void audit_log_lost(const char *message);
571extern int audit_update_lsm_rules(void);
572
539 /* Private API (for audit.c only) */ 573 /* Private API (for audit.c only) */
540extern int audit_filter_user(struct netlink_skb_parms *cb, int type); 574extern int audit_filter_user(struct netlink_skb_parms *cb, int type);
541extern int audit_filter_type(int type); 575extern int audit_filter_type(int type);
542extern int audit_receive_filter(int type, int pid, int uid, int seq, 576extern int audit_receive_filter(int type, int pid, int uid, int seq,
543 void *data, size_t datasz, uid_t loginuid, u32 sid); 577 void *data, size_t datasz, uid_t loginuid,
578 u32 sessionid, u32 sid);
544extern int audit_enabled; 579extern int audit_enabled;
545#else 580#else
546#define audit_log(c,g,t,f,...) do { ; } while (0) 581#define audit_log(c,g,t,f,...) do { ; } while (0)
@@ -548,9 +583,11 @@ extern int audit_enabled;
548#define audit_log_vformat(b,f,a) do { ; } while (0) 583#define audit_log_vformat(b,f,a) do { ; } while (0)
549#define audit_log_format(b,f,...) do { ; } while (0) 584#define audit_log_format(b,f,...) do { ; } while (0)
550#define audit_log_end(b) do { ; } while (0) 585#define audit_log_end(b) do { ; } while (0)
551#define audit_log_hex(a,b,l) do { ; } while (0) 586#define audit_log_n_hex(a,b,l) do { ; } while (0)
552#define audit_log_untrustedstring(a,s) do { ; } while (0) 587#define audit_log_n_string(a,c,l) do { ; } while (0)
588#define audit_log_string(a,c) do { ; } while (0)
553#define audit_log_n_untrustedstring(a,n,s) do { ; } while (0) 589#define audit_log_n_untrustedstring(a,n,s) do { ; } while (0)
590#define audit_log_untrustedstring(a,s) do { ; } while (0)
554#define audit_log_d_path(b, p, d) do { ; } while (0) 591#define audit_log_d_path(b, p, d) do { ; } while (0)
555#define audit_enabled 0 592#define audit_enabled 0
556#endif 593#endif
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 48a62baace58..0a24d5550eb3 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -11,9 +11,13 @@
11#include <linux/percpu_counter.h> 11#include <linux/percpu_counter.h>
12#include <linux/log2.h> 12#include <linux/log2.h>
13#include <linux/proportions.h> 13#include <linux/proportions.h>
14#include <linux/kernel.h>
15#include <linux/fs.h>
14#include <asm/atomic.h> 16#include <asm/atomic.h>
15 17
16struct page; 18struct page;
19struct device;
20struct dentry;
17 21
18/* 22/*
19 * Bits in backing_dev_info.state 23 * Bits in backing_dev_info.state
@@ -48,11 +52,26 @@ struct backing_dev_info {
48 52
49 struct prop_local_percpu completions; 53 struct prop_local_percpu completions;
50 int dirty_exceeded; 54 int dirty_exceeded;
55
56 unsigned int min_ratio;
57 unsigned int max_ratio, max_prop_frac;
58
59 struct device *dev;
60
61#ifdef CONFIG_DEBUG_FS
62 struct dentry *debug_dir;
63 struct dentry *debug_stats;
64#endif
51}; 65};
52 66
53int bdi_init(struct backing_dev_info *bdi); 67int bdi_init(struct backing_dev_info *bdi);
54void bdi_destroy(struct backing_dev_info *bdi); 68void bdi_destroy(struct backing_dev_info *bdi);
55 69
70int bdi_register(struct backing_dev_info *bdi, struct device *parent,
71 const char *fmt, ...);
72int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
73void bdi_unregister(struct backing_dev_info *bdi);
74
56static inline void __add_bdi_stat(struct backing_dev_info *bdi, 75static inline void __add_bdi_stat(struct backing_dev_info *bdi,
57 enum bdi_stat_item item, s64 amount) 76 enum bdi_stat_item item, s64 amount)
58{ 77{
@@ -116,6 +135,8 @@ static inline s64 bdi_stat_sum(struct backing_dev_info *bdi,
116 return sum; 135 return sum;
117} 136}
118 137
138extern void bdi_writeout_inc(struct backing_dev_info *bdi);
139
119/* 140/*
120 * maximal error of a stat counter. 141 * maximal error of a stat counter.
121 */ 142 */
@@ -128,24 +149,48 @@ static inline unsigned long bdi_stat_error(struct backing_dev_info *bdi)
128#endif 149#endif
129} 150}
130 151
152int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio);
153int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
154
131/* 155/*
132 * Flags in backing_dev_info::capability 156 * Flags in backing_dev_info::capability
133 * - The first two flags control whether dirty pages will contribute to the 157 *
134 * VM's accounting and whether writepages() should be called for dirty pages 158 * The first three flags control whether dirty pages will contribute to the
135 * (something that would not, for example, be appropriate for ramfs) 159 * VM's accounting and whether writepages() should be called for dirty pages
136 * - These flags let !MMU mmap() govern direct device mapping vs immediate 160 * (something that would not, for example, be appropriate for ramfs)
137 * copying more easily for MAP_PRIVATE, especially for ROM filesystems 161 *
162 * WARNING: these flags are closely related and should not normally be
163 * used separately. The BDI_CAP_NO_ACCT_AND_WRITEBACK combines these
164 * three flags into a single convenience macro.
165 *
166 * BDI_CAP_NO_ACCT_DIRTY: Dirty pages shouldn't contribute to accounting
167 * BDI_CAP_NO_WRITEBACK: Don't write pages back
168 * BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages
169 *
170 * These flags let !MMU mmap() govern direct device mapping vs immediate
171 * copying more easily for MAP_PRIVATE, especially for ROM filesystems.
172 *
173 * BDI_CAP_MAP_COPY: Copy can be mapped (MAP_PRIVATE)
174 * BDI_CAP_MAP_DIRECT: Can be mapped directly (MAP_SHARED)
175 * BDI_CAP_READ_MAP: Can be mapped for reading
176 * BDI_CAP_WRITE_MAP: Can be mapped for writing
177 * BDI_CAP_EXEC_MAP: Can be mapped for execution
138 */ 178 */
139#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */ 179#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
140#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ 180#define BDI_CAP_NO_WRITEBACK 0x00000002
141#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ 181#define BDI_CAP_MAP_COPY 0x00000004
142#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ 182#define BDI_CAP_MAP_DIRECT 0x00000008
143#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ 183#define BDI_CAP_READ_MAP 0x00000010
144#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ 184#define BDI_CAP_WRITE_MAP 0x00000020
145#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ 185#define BDI_CAP_EXEC_MAP 0x00000040
186#define BDI_CAP_NO_ACCT_WB 0x00000080
187
146#define BDI_CAP_VMFLAGS \ 188#define BDI_CAP_VMFLAGS \
147 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) 189 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
148 190
191#define BDI_CAP_NO_ACCT_AND_WRITEBACK \
192 (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
193
149#if defined(VM_MAYREAD) && \ 194#if defined(VM_MAYREAD) && \
150 (BDI_CAP_READ_MAP != VM_MAYREAD || \ 195 (BDI_CAP_READ_MAP != VM_MAYREAD || \
151 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \ 196 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \
@@ -156,9 +201,7 @@ static inline unsigned long bdi_stat_error(struct backing_dev_info *bdi)
156extern struct backing_dev_info default_backing_dev_info; 201extern struct backing_dev_info default_backing_dev_info;
157void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page); 202void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page);
158 203
159int writeback_acquire(struct backing_dev_info *bdi);
160int writeback_in_progress(struct backing_dev_info *bdi); 204int writeback_in_progress(struct backing_dev_info *bdi);
161void writeback_release(struct backing_dev_info *bdi);
162 205
163static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits) 206static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits)
164{ 207{
@@ -187,17 +230,32 @@ void clear_bdi_congested(struct backing_dev_info *bdi, int rw);
187void set_bdi_congested(struct backing_dev_info *bdi, int rw); 230void set_bdi_congested(struct backing_dev_info *bdi, int rw);
188long congestion_wait(int rw, long timeout); 231long congestion_wait(int rw, long timeout);
189 232
190#define bdi_cap_writeback_dirty(bdi) \
191 (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK))
192 233
193#define bdi_cap_account_dirty(bdi) \ 234static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi)
194 (!((bdi)->capabilities & BDI_CAP_NO_ACCT_DIRTY)) 235{
236 return !(bdi->capabilities & BDI_CAP_NO_WRITEBACK);
237}
238
239static inline bool bdi_cap_account_dirty(struct backing_dev_info *bdi)
240{
241 return !(bdi->capabilities & BDI_CAP_NO_ACCT_DIRTY);
242}
195 243
196#define mapping_cap_writeback_dirty(mapping) \ 244static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi)
197 bdi_cap_writeback_dirty((mapping)->backing_dev_info) 245{
246 /* Paranoia: BDI_CAP_NO_WRITEBACK implies BDI_CAP_NO_ACCT_WB */
247 return !(bdi->capabilities & (BDI_CAP_NO_ACCT_WB |
248 BDI_CAP_NO_WRITEBACK));
249}
198 250
199#define mapping_cap_account_dirty(mapping) \ 251static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
200 bdi_cap_account_dirty((mapping)->backing_dev_info) 252{
253 return bdi_cap_writeback_dirty(mapping->backing_dev_info);
254}
201 255
256static inline bool mapping_cap_account_dirty(struct address_space *mapping)
257{
258 return bdi_cap_account_dirty(mapping->backing_dev_info);
259}
202 260
203#endif /* _LINUX_BACKING_DEV_H */ 261#endif /* _LINUX_BACKING_DEV_H */
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index b7fc55ec8d48..b512e48f6d8e 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -34,7 +34,8 @@ struct linux_binprm{
34#endif 34#endif
35 struct mm_struct *mm; 35 struct mm_struct *mm;
36 unsigned long p; /* current top of mem */ 36 unsigned long p; /* current top of mem */
37 int sh_bang; 37 unsigned int sh_bang:1,
38 misc_bang:1;
38 struct file * file; 39 struct file * file;
39 int e_uid, e_gid; 40 int e_uid, e_gid;
40 kernel_cap_t cap_inheritable, cap_permitted; 41 kernel_cap_t cap_inheritable, cap_permitted;
@@ -48,7 +49,6 @@ struct linux_binprm{
48 unsigned interp_flags; 49 unsigned interp_flags;
49 unsigned interp_data; 50 unsigned interp_data;
50 unsigned long loader, exec; 51 unsigned long loader, exec;
51 unsigned long argv_len;
52}; 52};
53 53
54#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 54#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 4c59bdccd3ee..61c15eaf3fb3 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -324,9 +324,13 @@ extern struct bio *bio_map_user_iov(struct request_queue *,
324extern void bio_unmap_user(struct bio *); 324extern void bio_unmap_user(struct bio *);
325extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, 325extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int,
326 gfp_t); 326 gfp_t);
327extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int,
328 gfp_t, int);
327extern void bio_set_pages_dirty(struct bio *bio); 329extern void bio_set_pages_dirty(struct bio *bio);
328extern void bio_check_pages_dirty(struct bio *bio); 330extern void bio_check_pages_dirty(struct bio *bio);
329extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int); 331extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int);
332extern struct bio *bio_copy_user_iov(struct request_queue *, struct sg_iovec *,
333 int, int);
330extern int bio_uncopy_user(struct bio *); 334extern int bio_uncopy_user(struct bio *);
331void zero_fill_bio(struct bio *bio); 335void zero_fill_bio(struct bio *bio);
332 336
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index acad1105d942..43b406def35f 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -46,6 +46,8 @@
46 * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n 46 * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n
47 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src) 47 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src)
48 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit) 48 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit)
49 * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap
50 * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz
49 * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf 51 * bitmap_scnprintf(buf, len, src, nbits) Print bitmap src to buf
50 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf 52 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
51 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf 53 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
@@ -108,6 +110,7 @@ extern int __bitmap_weight(const unsigned long *bitmap, int bits);
108 110
109extern int bitmap_scnprintf(char *buf, unsigned int len, 111extern int bitmap_scnprintf(char *buf, unsigned int len,
110 const unsigned long *src, int nbits); 112 const unsigned long *src, int nbits);
113extern int bitmap_scnprintf_len(unsigned int len);
111extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, 114extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user,
112 unsigned long *dst, int nbits); 115 unsigned long *dst, int nbits);
113extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, 116extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
@@ -120,6 +123,10 @@ extern void bitmap_remap(unsigned long *dst, const unsigned long *src,
120 const unsigned long *old, const unsigned long *new, int bits); 123 const unsigned long *old, const unsigned long *new, int bits);
121extern int bitmap_bitremap(int oldbit, 124extern int bitmap_bitremap(int oldbit,
122 const unsigned long *old, const unsigned long *new, int bits); 125 const unsigned long *old, const unsigned long *new, int bits);
126extern void bitmap_onto(unsigned long *dst, const unsigned long *orig,
127 const unsigned long *relmap, int bits);
128extern void bitmap_fold(unsigned long *dst, const unsigned long *orig,
129 int sz, int bits);
123extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order); 130extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order);
124extern void bitmap_release_region(unsigned long *bitmap, int pos, int order); 131extern void bitmap_release_region(unsigned long *bitmap, int pos, int order);
125extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order); 132extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 40d54731de7e..024f2b027244 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -6,8 +6,8 @@
6#define BIT(nr) (1UL << (nr)) 6#define BIT(nr) (1UL << (nr))
7#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) 7#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
8#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 8#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
9#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG)
10#define BITS_PER_BYTE 8 9#define BITS_PER_BYTE 8
10#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
11#endif 11#endif
12 12
13/* 13/*
@@ -112,4 +112,53 @@ static inline unsigned fls_long(unsigned long l)
112 return fls64(l); 112 return fls64(l);
113} 113}
114 114
115#ifdef __KERNEL__
116#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
117
118/**
119 * find_first_bit - find the first set bit in a memory region
120 * @addr: The address to start the search at
121 * @size: The maximum size to search
122 *
123 * Returns the bit number of the first set bit.
124 */
125extern unsigned long find_first_bit(const unsigned long *addr,
126 unsigned long size);
127
128/**
129 * find_first_zero_bit - find the first cleared bit in a memory region
130 * @addr: The address to start the search at
131 * @size: The maximum size to search
132 *
133 * Returns the bit number of the first cleared bit.
134 */
135extern unsigned long find_first_zero_bit(const unsigned long *addr,
136 unsigned long size);
137
138#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
139
140#ifdef CONFIG_GENERIC_FIND_NEXT_BIT
141
142/**
143 * find_next_bit - find the next set bit in a memory region
144 * @addr: The address to base the search on
145 * @offset: The bitnumber to start searching at
146 * @size: The bitmap size in bits
147 */
148extern unsigned long find_next_bit(const unsigned long *addr,
149 unsigned long size, unsigned long offset);
150
151/**
152 * find_next_zero_bit - find the next cleared bit in a memory region
153 * @addr: The address to base the search on
154 * @offset: The bitnumber to start searching at
155 * @size: The bitmap size in bits
156 */
157
158extern unsigned long find_next_zero_bit(const unsigned long *addr,
159 unsigned long size,
160 unsigned long offset);
161
162#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */
163#endif /* __KERNEL__ */
115#endif 164#endif
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 6f79d40dd3c0..d2a1b71e93c3 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -112,6 +112,7 @@ enum rq_flag_bits {
112 __REQ_RW_SYNC, /* request is sync (O_DIRECT) */ 112 __REQ_RW_SYNC, /* request is sync (O_DIRECT) */
113 __REQ_ALLOCED, /* request came from our alloc pool */ 113 __REQ_ALLOCED, /* request came from our alloc pool */
114 __REQ_RW_META, /* metadata io request */ 114 __REQ_RW_META, /* metadata io request */
115 __REQ_COPY_USER, /* contains copies of user pages */
115 __REQ_NR_BITS, /* stops here */ 116 __REQ_NR_BITS, /* stops here */
116}; 117};
117 118
@@ -133,6 +134,7 @@ enum rq_flag_bits {
133#define REQ_RW_SYNC (1 << __REQ_RW_SYNC) 134#define REQ_RW_SYNC (1 << __REQ_RW_SYNC)
134#define REQ_ALLOCED (1 << __REQ_ALLOCED) 135#define REQ_ALLOCED (1 << __REQ_ALLOCED)
135#define REQ_RW_META (1 << __REQ_RW_META) 136#define REQ_RW_META (1 << __REQ_RW_META)
137#define REQ_COPY_USER (1 << __REQ_COPY_USER)
136 138
137#define BLK_MAX_CDB 16 139#define BLK_MAX_CDB 16
138 140
@@ -213,8 +215,9 @@ struct request {
213 /* 215 /*
214 * when request is used as a packet command carrier 216 * when request is used as a packet command carrier
215 */ 217 */
216 unsigned int cmd_len; 218 unsigned short cmd_len;
217 unsigned char cmd[BLK_MAX_CDB]; 219 unsigned char __cmd[BLK_MAX_CDB];
220 unsigned char *cmd;
218 221
219 unsigned int data_len; 222 unsigned int data_len;
220 unsigned int extra_len; /* length of alignment and padding */ 223 unsigned int extra_len; /* length of alignment and padding */
@@ -405,6 +408,41 @@ struct request_queue
405#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ 408#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */
406#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ 409#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */
407#define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */ 410#define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */
411#define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */
412
413static inline int queue_is_locked(struct request_queue *q)
414{
415#ifdef CONFIG_SMP
416 spinlock_t *lock = q->queue_lock;
417 return lock && spin_is_locked(lock);
418#else
419 return 1;
420#endif
421}
422
423static inline void queue_flag_set_unlocked(unsigned int flag,
424 struct request_queue *q)
425{
426 __set_bit(flag, &q->queue_flags);
427}
428
429static inline void queue_flag_set(unsigned int flag, struct request_queue *q)
430{
431 WARN_ON_ONCE(!queue_is_locked(q));
432 __set_bit(flag, &q->queue_flags);
433}
434
435static inline void queue_flag_clear_unlocked(unsigned int flag,
436 struct request_queue *q)
437{
438 __clear_bit(flag, &q->queue_flags);
439}
440
441static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
442{
443 WARN_ON_ONCE(!queue_is_locked(q));
444 __clear_bit(flag, &q->queue_flags);
445}
408 446
409enum { 447enum {
410 /* 448 /*
@@ -449,6 +487,7 @@ enum {
449#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) 487#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags)
450#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) 488#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
451#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) 489#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
490#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags)
452#define blk_queue_flushing(q) ((q)->ordseq) 491#define blk_queue_flushing(q) ((q)->ordseq)
453 492
454#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) 493#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS)
@@ -494,17 +533,17 @@ static inline int blk_queue_full(struct request_queue *q, int rw)
494static inline void blk_set_queue_full(struct request_queue *q, int rw) 533static inline void blk_set_queue_full(struct request_queue *q, int rw)
495{ 534{
496 if (rw == READ) 535 if (rw == READ)
497 set_bit(QUEUE_FLAG_READFULL, &q->queue_flags); 536 queue_flag_set(QUEUE_FLAG_READFULL, q);
498 else 537 else
499 set_bit(QUEUE_FLAG_WRITEFULL, &q->queue_flags); 538 queue_flag_set(QUEUE_FLAG_WRITEFULL, q);
500} 539}
501 540
502static inline void blk_clear_queue_full(struct request_queue *q, int rw) 541static inline void blk_clear_queue_full(struct request_queue *q, int rw)
503{ 542{
504 if (rw == READ) 543 if (rw == READ)
505 clear_bit(QUEUE_FLAG_READFULL, &q->queue_flags); 544 queue_flag_clear(QUEUE_FLAG_READFULL, q);
506 else 545 else
507 clear_bit(QUEUE_FLAG_WRITEFULL, &q->queue_flags); 546 queue_flag_clear(QUEUE_FLAG_WRITEFULL, q);
508} 547}
509 548
510 549
@@ -533,8 +572,13 @@ extern unsigned long blk_max_low_pfn, blk_max_pfn;
533 * BLK_BOUNCE_ANY : don't bounce anything 572 * BLK_BOUNCE_ANY : don't bounce anything
534 * BLK_BOUNCE_ISA : bounce pages above ISA DMA boundary 573 * BLK_BOUNCE_ISA : bounce pages above ISA DMA boundary
535 */ 574 */
575
576#if BITS_PER_LONG == 32
536#define BLK_BOUNCE_HIGH ((u64)blk_max_low_pfn << PAGE_SHIFT) 577#define BLK_BOUNCE_HIGH ((u64)blk_max_low_pfn << PAGE_SHIFT)
537#define BLK_BOUNCE_ANY ((u64)blk_max_pfn << PAGE_SHIFT) 578#else
579#define BLK_BOUNCE_HIGH -1ULL
580#endif
581#define BLK_BOUNCE_ANY (-1ULL)
538#define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD) 582#define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD)
539 583
540/* 584/*
@@ -576,6 +620,7 @@ extern int blk_register_queue(struct gendisk *disk);
576extern void blk_unregister_queue(struct gendisk *disk); 620extern void blk_unregister_queue(struct gendisk *disk);
577extern void register_disk(struct gendisk *dev); 621extern void register_disk(struct gendisk *dev);
578extern void generic_make_request(struct bio *bio); 622extern void generic_make_request(struct bio *bio);
623extern void blk_rq_init(struct request_queue *q, struct request *rq);
579extern void blk_put_request(struct request *); 624extern void blk_put_request(struct request *);
580extern void __blk_put_request(struct request_queue *, struct request *); 625extern void __blk_put_request(struct request_queue *, struct request *);
581extern void blk_end_sync_rq(struct request *rq, int error); 626extern void blk_end_sync_rq(struct request *rq, int error);
@@ -619,6 +664,7 @@ extern void blk_start_queue(struct request_queue *q);
619extern void blk_stop_queue(struct request_queue *q); 664extern void blk_stop_queue(struct request_queue *q);
620extern void blk_sync_queue(struct request_queue *q); 665extern void blk_sync_queue(struct request_queue *q);
621extern void __blk_stop_queue(struct request_queue *q); 666extern void __blk_stop_queue(struct request_queue *q);
667extern void __blk_run_queue(struct request_queue *);
622extern void blk_run_queue(struct request_queue *); 668extern void blk_run_queue(struct request_queue *);
623extern void blk_start_queueing(struct request_queue *); 669extern void blk_start_queueing(struct request_queue *);
624extern int blk_rq_map_user(struct request_queue *, struct request *, void __user *, unsigned long); 670extern int blk_rq_map_user(struct request_queue *, struct request *, void __user *, unsigned long);
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 4e4e340592fb..6a5dbdc8a7dc 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -101,6 +101,8 @@ extern void reserve_bootmem_node(pg_data_t *pgdat,
101extern void free_bootmem_node(pg_data_t *pgdat, 101extern void free_bootmem_node(pg_data_t *pgdat,
102 unsigned long addr, 102 unsigned long addr,
103 unsigned long size); 103 unsigned long size);
104extern void *alloc_bootmem_section(unsigned long size,
105 unsigned long section_nr);
104 106
105#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE 107#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
106#define alloc_bootmem_node(pgdat, x) \ 108#define alloc_bootmem_node(pgdat, x) \
diff --git a/include/linux/bsg.h b/include/linux/bsg.h
index 60e377b520f8..cf0303a60611 100644
--- a/include/linux/bsg.h
+++ b/include/linux/bsg.h
@@ -55,20 +55,26 @@ struct sg_io_v4 {
55 55
56#if defined(CONFIG_BLK_DEV_BSG) 56#if defined(CONFIG_BLK_DEV_BSG)
57struct bsg_class_device { 57struct bsg_class_device {
58 struct class_device *class_dev; 58 struct device *class_dev;
59 struct device *dev; 59 struct device *parent;
60 int minor; 60 int minor;
61 struct request_queue *queue; 61 struct request_queue *queue;
62 struct kref ref;
63 void (*release)(struct device *);
62}; 64};
63 65
64extern int bsg_register_queue(struct request_queue *, struct device *, const char *); 66extern int bsg_register_queue(struct request_queue *q,
67 struct device *parent, const char *name,
68 void (*release)(struct device *));
65extern void bsg_unregister_queue(struct request_queue *); 69extern void bsg_unregister_queue(struct request_queue *);
66#else 70#else
67static inline int bsg_register_queue(struct request_queue * rq, struct device *dev, const char *name) 71static inline int bsg_register_queue(struct request_queue *q,
72 struct device *parent, const char *name,
73 void (*release)(struct device *))
68{ 74{
69 return 0; 75 return 0;
70} 76}
71static inline void bsg_unregister_queue(struct request_queue *rq) 77static inline void bsg_unregister_queue(struct request_queue *q)
72{ 78{
73} 79}
74#endif 80#endif
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 932eb02a2753..82aa36c53ea7 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -225,7 +225,6 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct page *page,
225 get_block_t get_block); 225 get_block_t get_block);
226void block_sync_page(struct page *); 226void block_sync_page(struct page *);
227sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *); 227sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);
228int generic_commit_write(struct file *, struct page *, unsigned, unsigned);
229int block_truncate_page(struct address_space *, loff_t, get_block_t *); 228int block_truncate_page(struct address_space *, loff_t, get_block_t *);
230int file_fsync(struct file *, struct dentry *, int); 229int file_fsync(struct file *, struct dentry *, int);
231int nobh_write_begin(struct file *, struct address_space *, 230int nobh_write_begin(struct file *, struct address_space *,
diff --git a/include/linux/byteorder/Kbuild b/include/linux/byteorder/Kbuild
index 79bedddfd9ca..1133d5f9d818 100644
--- a/include/linux/byteorder/Kbuild
+++ b/include/linux/byteorder/Kbuild
@@ -1,5 +1,3 @@
1header-y += big_endian.h 1unifdef-y += big_endian.h
2header-y += little_endian.h 2unifdef-y += little_endian.h
3
4unifdef-y += generic.h
5unifdef-y += swab.h 3unifdef-y += swab.h
diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
index bef87891cb24..961ed4b48d8e 100644
--- a/include/linux/byteorder/big_endian.h
+++ b/include/linux/byteorder/big_endian.h
@@ -101,6 +101,8 @@ static inline __u16 __be16_to_cpup(const __be16 *p)
101#define __cpu_to_be16s(x) do {} while (0) 101#define __cpu_to_be16s(x) do {} while (0)
102#define __be16_to_cpus(x) do {} while (0) 102#define __be16_to_cpus(x) do {} while (0)
103 103
104#ifdef __KERNEL__
104#include <linux/byteorder/generic.h> 105#include <linux/byteorder/generic.h>
106#endif
105 107
106#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */ 108#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
index d3771551fdd9..0846e6b931ce 100644
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -82,12 +82,6 @@
82 * 82 *
83 */ 83 */
84 84
85
86#if defined(__KERNEL__)
87/*
88 * inside the kernel, we can use nicknames;
89 * outside of it, we must avoid POSIX namespace pollution...
90 */
91#define cpu_to_le64 __cpu_to_le64 85#define cpu_to_le64 __cpu_to_le64
92#define le64_to_cpu __le64_to_cpu 86#define le64_to_cpu __le64_to_cpu
93#define cpu_to_le32 __cpu_to_le32 87#define cpu_to_le32 __cpu_to_le32
@@ -176,6 +170,4 @@ static inline void be64_add_cpu(__be64 *var, u64 val)
176 *var = cpu_to_be64(be64_to_cpu(*var) + val); 170 *var = cpu_to_be64(be64_to_cpu(*var) + val);
177} 171}
178 172
179#endif /* KERNEL */
180
181#endif /* _LINUX_BYTEORDER_GENERIC_H */ 173#endif /* _LINUX_BYTEORDER_GENERIC_H */
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index 86e62b750176..05dc7c35b3b2 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -101,6 +101,8 @@ static inline __u16 __be16_to_cpup(const __be16 *p)
101#define __cpu_to_be16s(x) __swab16s((x)) 101#define __cpu_to_be16s(x) __swab16s((x))
102#define __be16_to_cpus(x) __swab16s((x)) 102#define __be16_to_cpus(x) __swab16s((x))
103 103
104#ifdef __KERNEL__
104#include <linux/byteorder/generic.h> 105#include <linux/byteorder/generic.h>
106#endif
105 107
106#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ 108#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
diff --git a/include/linux/cache.h b/include/linux/cache.h
index 4552504c0228..97e24881c4c6 100644
--- a/include/linux/cache.h
+++ b/include/linux/cache.h
@@ -60,4 +60,8 @@
60#endif 60#endif
61#endif 61#endif
62 62
63#ifndef CONFIG_ARCH_HAS_CACHE_LINE_SIZE
64#define cache_line_size() L1_CACHE_BYTES
65#endif
66
63#endif /* __LINUX_CACHE_H */ 67#endif /* __LINUX_CACHE_H */
diff --git a/include/linux/calc64.h b/include/linux/calc64.h
deleted file mode 100644
index ebf4b8f38d88..000000000000
--- a/include/linux/calc64.h
+++ /dev/null
@@ -1,49 +0,0 @@
1#ifndef _LINUX_CALC64_H
2#define _LINUX_CALC64_H
3
4#include <linux/types.h>
5#include <asm/div64.h>
6
7/*
8 * This is a generic macro which is used when the architecture
9 * specific div64.h does not provide a optimized one.
10 *
11 * The 64bit dividend is divided by the divisor (data type long), the
12 * result is returned and the remainder stored in the variable
13 * referenced by remainder (data type long *). In contrast to the
14 * do_div macro the dividend is kept intact.
15 */
16#ifndef div_long_long_rem
17#define div_long_long_rem(dividend, divisor, remainder) \
18 do_div_llr((dividend), divisor, remainder)
19
20static inline unsigned long do_div_llr(const long long dividend,
21 const long divisor, long *remainder)
22{
23 u64 result = dividend;
24
25 *(remainder) = do_div(result, divisor);
26 return (unsigned long) result;
27}
28#endif
29
30/*
31 * Sign aware variation of the above. On some architectures a
32 * negative dividend leads to an divide overflow exception, which
33 * is avoided by the sign check.
34 */
35static inline long div_long_long_rem_signed(const long long dividend,
36 const long divisor, long *remainder)
37{
38 long res;
39
40 if (unlikely(dividend < 0)) {
41 res = -div_long_long_rem(-dividend, divisor, remainder);
42 *remainder = -(*remainder);
43 } else
44 res = div_long_long_rem(dividend, divisor, remainder);
45
46 return res;
47}
48
49#endif
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 7d50ff6d269f..f4ea0dd9a618 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -155,6 +155,7 @@ typedef struct kernel_cap_struct {
155 * Add any capability from current's capability bounding set 155 * Add any capability from current's capability bounding set
156 * to the current process' inheritable set 156 * to the current process' inheritable set
157 * Allow taking bits out of capability bounding set 157 * Allow taking bits out of capability bounding set
158 * Allow modification of the securebits for a process
158 */ 159 */
159 160
160#define CAP_SETPCAP 8 161#define CAP_SETPCAP 8
@@ -364,12 +365,12 @@ typedef struct kernel_cap_struct {
364# error Fix up hand-coded capability macro initializers 365# error Fix up hand-coded capability macro initializers
365#else /* HAND-CODED capability initializers */ 366#else /* HAND-CODED capability initializers */
366 367
367# define CAP_EMPTY_SET {{ 0, 0 }} 368# define CAP_EMPTY_SET ((kernel_cap_t){{ 0, 0 }})
368# define CAP_FULL_SET {{ ~0, ~0 }} 369# define CAP_FULL_SET ((kernel_cap_t){{ ~0, ~0 }})
369# define CAP_INIT_EFF_SET {{ ~CAP_TO_MASK(CAP_SETPCAP), ~0 }} 370# define CAP_INIT_EFF_SET ((kernel_cap_t){{ ~CAP_TO_MASK(CAP_SETPCAP), ~0 }})
370# define CAP_FS_SET {{ CAP_FS_MASK_B0, CAP_FS_MASK_B1 } } 371# define CAP_FS_SET ((kernel_cap_t){{ CAP_FS_MASK_B0, CAP_FS_MASK_B1 } })
371# define CAP_NFSD_SET {{ CAP_FS_MASK_B0|CAP_TO_MASK(CAP_SYS_RESOURCE), \ 372# define CAP_NFSD_SET ((kernel_cap_t){{ CAP_FS_MASK_B0|CAP_TO_MASK(CAP_SYS_RESOURCE), \
372 CAP_FS_MASK_B1 } } 373 CAP_FS_MASK_B1 } })
373 374
374#endif /* _LINUX_CAPABILITY_U32S != 2 */ 375#endif /* _LINUX_CAPABILITY_U32S != 2 */
375 376
@@ -490,8 +491,6 @@ extern const kernel_cap_t __cap_init_eff_set;
490int capable(int cap); 491int capable(int cap);
491int __capable(struct task_struct *t, int cap); 492int __capable(struct task_struct *t, int cap);
492 493
493extern long cap_prctl_drop(unsigned long cap);
494
495#endif /* __KERNEL__ */ 494#endif /* __KERNEL__ */
496 495
497#endif /* !_LINUX_CAPABILITY_H */ 496#endif /* !_LINUX_CAPABILITY_H */
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index 1e29b13d0062..fb4591977b03 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -1,6 +1,5 @@
1#ifndef _LINUX_CDEV_H 1#ifndef _LINUX_CDEV_H
2#define _LINUX_CDEV_H 2#define _LINUX_CDEV_H
3#ifdef __KERNEL__
4 3
5#include <linux/kobject.h> 4#include <linux/kobject.h>
6#include <linux/kdev_t.h> 5#include <linux/kdev_t.h>
@@ -34,4 +33,3 @@ void cd_forget(struct inode *);
34extern struct backing_dev_info directly_mappable_cdev_bdi; 33extern struct backing_dev_info directly_mappable_cdev_bdi;
35 34
36#endif 35#endif
37#endif
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index a5cd2047624e..5db265ea60f6 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -910,6 +910,7 @@ struct mode_page_header {
910#ifdef __KERNEL__ 910#ifdef __KERNEL__
911#include <linux/fs.h> /* not really needed, later.. */ 911#include <linux/fs.h> /* not really needed, later.. */
912#include <linux/device.h> 912#include <linux/device.h>
913#include <linux/list.h>
913 914
914struct packet_command 915struct packet_command
915{ 916{
@@ -934,7 +935,7 @@ struct packet_command
934/* Uniform cdrom data structures for cdrom.c */ 935/* Uniform cdrom data structures for cdrom.c */
935struct cdrom_device_info { 936struct cdrom_device_info {
936 struct cdrom_device_ops *ops; /* link to device_ops */ 937 struct cdrom_device_ops *ops; /* link to device_ops */
937 struct cdrom_device_info *next; /* next device_info for this major */ 938 struct list_head list; /* linked list of all device_info */
938 struct gendisk *disk; /* matching block layer disk */ 939 struct gendisk *disk; /* matching block layer disk */
939 void *handle; /* driver-dependent data */ 940 void *handle; /* driver-dependent data */
940/* specifications */ 941/* specifications */
@@ -994,7 +995,7 @@ extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi,
994extern int cdrom_media_changed(struct cdrom_device_info *); 995extern int cdrom_media_changed(struct cdrom_device_info *);
995 996
996extern int register_cdrom(struct cdrom_device_info *cdi); 997extern int register_cdrom(struct cdrom_device_info *cdi);
997extern int unregister_cdrom(struct cdrom_device_info *cdi); 998extern void unregister_cdrom(struct cdrom_device_info *cdi);
998 999
999typedef struct { 1000typedef struct {
1000 int data; 1001 int data;
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index a6a6035a4e1e..e155aa78d859 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -88,6 +88,17 @@ static inline void css_put(struct cgroup_subsys_state *css)
88 __css_put(css); 88 __css_put(css);
89} 89}
90 90
91/* bits in struct cgroup flags field */
92enum {
93 /* Control Group is dead */
94 CGRP_REMOVED,
95 /* Control Group has previously had a child cgroup or a task,
96 * but no longer (only if CGRP_NOTIFY_ON_RELEASE is set) */
97 CGRP_RELEASABLE,
98 /* Control Group requires release notifications to userspace */
99 CGRP_NOTIFY_ON_RELEASE,
100};
101
91struct cgroup { 102struct cgroup {
92 unsigned long flags; /* "unsigned long" so bitops work */ 103 unsigned long flags; /* "unsigned long" so bitops work */
93 104
@@ -139,10 +150,10 @@ struct css_set {
139 struct kref ref; 150 struct kref ref;
140 151
141 /* 152 /*
142 * List running through all cgroup groups. Protected by 153 * List running through all cgroup groups in the same hash
143 * css_set_lock 154 * slot. Protected by css_set_lock
144 */ 155 */
145 struct list_head list; 156 struct hlist_node hlist;
146 157
147 /* 158 /*
148 * List running through all tasks using this cgroup 159 * List running through all tasks using this cgroup
@@ -163,7 +174,16 @@ struct css_set {
163 * during subsystem registration (at boot time). 174 * during subsystem registration (at boot time).
164 */ 175 */
165 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT]; 176 struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
177};
178
179/*
180 * cgroup_map_cb is an abstract callback API for reporting map-valued
181 * control files
182 */
166 183
184struct cgroup_map_cb {
185 int (*fill)(struct cgroup_map_cb *cb, const char *key, u64 value);
186 void *state;
167}; 187};
168 188
169/* struct cftype: 189/* struct cftype:
@@ -190,20 +210,51 @@ struct cftype {
190 struct file *file, 210 struct file *file,
191 char __user *buf, size_t nbytes, loff_t *ppos); 211 char __user *buf, size_t nbytes, loff_t *ppos);
192 /* 212 /*
193 * read_uint() is a shortcut for the common case of returning a 213 * read_u64() is a shortcut for the common case of returning a
194 * single integer. Use it in place of read() 214 * single integer. Use it in place of read()
195 */ 215 */
196 u64 (*read_uint) (struct cgroup *cgrp, struct cftype *cft); 216 u64 (*read_u64) (struct cgroup *cgrp, struct cftype *cft);
217 /*
218 * read_s64() is a signed version of read_u64()
219 */
220 s64 (*read_s64) (struct cgroup *cgrp, struct cftype *cft);
221 /*
222 * read_map() is used for defining a map of key/value
223 * pairs. It should call cb->fill(cb, key, value) for each
224 * entry. The key/value pairs (and their ordering) should not
225 * change between reboots.
226 */
227 int (*read_map) (struct cgroup *cont, struct cftype *cft,
228 struct cgroup_map_cb *cb);
229 /*
230 * read_seq_string() is used for outputting a simple sequence
231 * using seqfile.
232 */
233 int (*read_seq_string) (struct cgroup *cont, struct cftype *cft,
234 struct seq_file *m);
235
197 ssize_t (*write) (struct cgroup *cgrp, struct cftype *cft, 236 ssize_t (*write) (struct cgroup *cgrp, struct cftype *cft,
198 struct file *file, 237 struct file *file,
199 const char __user *buf, size_t nbytes, loff_t *ppos); 238 const char __user *buf, size_t nbytes, loff_t *ppos);
200 239
201 /* 240 /*
202 * write_uint() is a shortcut for the common case of accepting 241 * write_u64() is a shortcut for the common case of accepting
203 * a single integer (as parsed by simple_strtoull) from 242 * a single integer (as parsed by simple_strtoull) from
204 * userspace. Use in place of write(); return 0 or error. 243 * userspace. Use in place of write(); return 0 or error.
205 */ 244 */
206 int (*write_uint) (struct cgroup *cgrp, struct cftype *cft, u64 val); 245 int (*write_u64) (struct cgroup *cgrp, struct cftype *cft, u64 val);
246 /*
247 * write_s64() is a signed version of write_u64()
248 */
249 int (*write_s64) (struct cgroup *cgrp, struct cftype *cft, s64 val);
250
251 /*
252 * trigger() callback can be used to get some kick from the
253 * userspace, when the actual string written is not important
254 * at all. The private field can be used to determine the
255 * kick type for multiplexing.
256 */
257 int (*trigger)(struct cgroup *cgrp, unsigned int event);
207 258
208 int (*release) (struct inode *inode, struct file *file); 259 int (*release) (struct inode *inode, struct file *file);
209}; 260};
@@ -254,6 +305,12 @@ struct cgroup_subsys {
254 struct cgroup *cgrp); 305 struct cgroup *cgrp);
255 void (*post_clone)(struct cgroup_subsys *ss, struct cgroup *cgrp); 306 void (*post_clone)(struct cgroup_subsys *ss, struct cgroup *cgrp);
256 void (*bind)(struct cgroup_subsys *ss, struct cgroup *root); 307 void (*bind)(struct cgroup_subsys *ss, struct cgroup *root);
308 /*
309 * This routine is called with the task_lock of mm->owner held
310 */
311 void (*mm_owner_changed)(struct cgroup_subsys *ss,
312 struct cgroup *old,
313 struct cgroup *new);
257 int subsys_id; 314 int subsys_id;
258 int active; 315 int active;
259 int disabled; 316 int disabled;
@@ -339,4 +396,13 @@ static inline int cgroupstats_build(struct cgroupstats *stats,
339 396
340#endif /* !CONFIG_CGROUPS */ 397#endif /* !CONFIG_CGROUPS */
341 398
399#ifdef CONFIG_MM_OWNER
400extern void
401cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new);
402#else /* !CONFIG_MM_OWNER */
403static inline void
404cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new)
405{
406}
407#endif /* CONFIG_MM_OWNER */
342#endif /* _LINUX_CGROUP_H */ 408#endif /* _LINUX_CGROUP_H */
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index 1ddebfc52565..e2877454ec82 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -42,3 +42,9 @@ SUBSYS(mem_cgroup)
42#endif 42#endif
43 43
44/* */ 44/* */
45
46#ifdef CONFIG_CGROUP_DEVICE
47SUBSYS(devices)
48#endif
49
50/* */
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 85778a4b1209..55e434feec99 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -93,6 +93,8 @@ struct clocksource {
93#endif 93#endif
94}; 94};
95 95
96extern struct clocksource *clock; /* current clocksource */
97
96/* 98/*
97 * Clock source flags bits:: 99 * Clock source flags bits::
98 */ 100 */
@@ -216,6 +218,7 @@ static inline void clocksource_calculate_interval(struct clocksource *c,
216/* used to install a new clocksource */ 218/* used to install a new clocksource */
217extern int clocksource_register(struct clocksource*); 219extern int clocksource_register(struct clocksource*);
218extern void clocksource_unregister(struct clocksource*); 220extern void clocksource_unregister(struct clocksource*);
221extern void clocksource_touch_watchdog(void);
219extern struct clocksource* clocksource_get_next(void); 222extern struct clocksource* clocksource_get_next(void);
220extern void clocksource_change_rating(struct clocksource *cs, int rating); 223extern void clocksource_change_rating(struct clocksource *cs, int rating);
221extern void clocksource_resume(void); 224extern void clocksource_resume(void);
diff --git a/include/linux/coda_fs_i.h b/include/linux/coda_fs_i.h
index 424fe9cf02c4..b3ef0c461578 100644
--- a/include/linux/coda_fs_i.h
+++ b/include/linux/coda_fs_i.h
@@ -8,7 +8,6 @@
8#ifndef _LINUX_CODA_FS_I 8#ifndef _LINUX_CODA_FS_I
9#define _LINUX_CODA_FS_I 9#define _LINUX_CODA_FS_I
10 10
11#ifdef __KERNEL__
12#include <linux/types.h> 11#include <linux/types.h>
13#include <linux/list.h> 12#include <linux/list.h>
14#include <linux/coda.h> 13#include <linux/coda.h>
@@ -52,4 +51,3 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb);
52void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *); 51void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *);
53 52
54#endif 53#endif
55#endif
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
index 1c47a34aa794..31b75311e2ca 100644
--- a/include/linux/coda_linux.h
+++ b/include/linux/coda_linux.h
@@ -43,9 +43,6 @@ int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
43int coda_setattr(struct dentry *, struct iattr *); 43int coda_setattr(struct dentry *, struct iattr *);
44 44
45/* this file: heloers */ 45/* this file: heloers */
46static __inline__ struct CodaFid *coda_i2f(struct inode *);
47static __inline__ char *coda_i2s(struct inode *);
48static __inline__ void coda_flag_inode(struct inode *, int flag);
49char *coda_f2s(struct CodaFid *f); 46char *coda_f2s(struct CodaFid *f);
50int coda_isroot(struct inode *i); 47int coda_isroot(struct inode *i);
51int coda_iscontrol(const char *name, size_t length); 48int coda_iscontrol(const char *name, size_t length);
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 8fa7857e153b..cf8d11cad5ae 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -65,10 +65,11 @@ struct compat_timex {
65 compat_long_t calcnt; 65 compat_long_t calcnt;
66 compat_long_t errcnt; 66 compat_long_t errcnt;
67 compat_long_t stbcnt; 67 compat_long_t stbcnt;
68 compat_int_t tai;
68 69
69 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; 70 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
70 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; 71 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
71 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; 72 compat_int_t :32; compat_int_t :32; compat_int_t :32;
72}; 73};
73 74
74#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) 75#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index fe23792f05c1..5c8351b859f0 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -28,9 +28,17 @@
28#define __must_be_array(a) \ 28#define __must_be_array(a) \
29 BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) 29 BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
30 30
31#define inline inline __attribute__((always_inline)) 31/*
32#define __inline__ __inline__ __attribute__((always_inline)) 32 * Force always-inline if the user requests it so via the .config,
33#define __inline __inline __attribute__((always_inline)) 33 * or if gcc is too old:
34 */
35#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
36 !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
37# define inline inline __attribute__((always_inline))
38# define __inline__ __inline__ __attribute__((always_inline))
39# define __inline __inline __attribute__((always_inline))
40#endif
41
34#define __deprecated __attribute__((deprecated)) 42#define __deprecated __attribute__((deprecated))
35#define __packed __attribute__((packed)) 43#define __packed __attribute__((packed))
36#define __weak __attribute__((weak)) 44#define __weak __attribute__((weak))
diff --git a/include/linux/concap.h b/include/linux/concap.h
index 27304651d700..977acb3d1fb2 100644
--- a/include/linux/concap.h
+++ b/include/linux/concap.h
@@ -8,7 +8,7 @@
8 8
9#ifndef _LINUX_CONCAP_H 9#ifndef _LINUX_CONCAP_H
10#define _LINUX_CONCAP_H 10#define _LINUX_CONCAP_H
11#ifdef __KERNEL__ 11
12#include <linux/skbuff.h> 12#include <linux/skbuff.h>
13#include <linux/netdevice.h> 13#include <linux/netdevice.h>
14 14
@@ -110,4 +110,3 @@ extern int concap_nop(struct concap_proto *cprot);
110 */ 110 */
111extern int concap_drop_skb(struct concap_proto *cprot, struct sk_buff *skb); 111extern int concap_drop_skb(struct concap_proto *cprot, struct sk_buff *skb);
112#endif 112#endif
113#endif
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 4b287ad9371a..3ae65b1bf90f 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -35,8 +35,6 @@
35#ifndef _CONFIGFS_H_ 35#ifndef _CONFIGFS_H_
36#define _CONFIGFS_H_ 36#define _CONFIGFS_H_
37 37
38#ifdef __KERNEL__
39
40#include <linux/kernel.h> 38#include <linux/kernel.h>
41#include <linux/types.h> 39#include <linux/types.h>
42#include <linux/list.h> 40#include <linux/list.h>
@@ -194,6 +192,4 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys);
194int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target); 192int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target);
195void configfs_undepend_item(struct configfs_subsystem *subsys, struct config_item *target); 193void configfs_undepend_item(struct configfs_subsystem *subsys, struct config_item *target);
196 194
197#endif /* __KERNEL__ */
198
199#endif /* _CONFIGFS_H_ */ 195#endif /* _CONFIGFS_H_ */
diff --git a/include/linux/console.h b/include/linux/console.h
index a5f88a6a259d..a4f27fbdf549 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -91,6 +91,7 @@ void give_up_console(const struct consw *sw);
91#define CON_ENABLED (4) 91#define CON_ENABLED (4)
92#define CON_BOOT (8) 92#define CON_BOOT (8)
93#define CON_ANYTIME (16) /* Safe to call when cpu is offline */ 93#define CON_ANYTIME (16) /* Safe to call when cpu is offline */
94#define CON_BRL (32) /* Used for a braille device */
94 95
95struct console { 96struct console {
96 char name[16]; 97 char name[16];
@@ -121,6 +122,9 @@ extern struct tty_driver *console_device(int *);
121extern void console_stop(struct console *); 122extern void console_stop(struct console *);
122extern void console_start(struct console *); 123extern void console_start(struct console *);
123extern int is_console_locked(void); 124extern int is_console_locked(void);
125extern int braille_register_console(struct console *, int index,
126 char *console_options, char *braille_options);
127extern int braille_unregister_console(struct console *);
124 128
125extern int console_suspend_enabled; 129extern int console_suspend_enabled;
126 130
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
index d71f7c0f931b..b03f80a078be 100644
--- a/include/linux/console_struct.h
+++ b/include/linux/console_struct.h
@@ -53,6 +53,7 @@ struct vc_data {
53 unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */ 53 unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */
54 struct console_font vc_font; /* Current VC font set */ 54 struct console_font vc_font; /* Current VC font set */
55 unsigned short vc_video_erase_char; /* Background erase character */ 55 unsigned short vc_video_erase_char; /* Background erase character */
56 unsigned short vc_scrl_erase_char; /* Erase character for scroll */
56 /* VT terminal data */ 57 /* VT terminal data */
57 unsigned int vc_state; /* Escape sequence parser state */ 58 unsigned int vc_state; /* Escape sequence parser state */
58 unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */ 59 unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 0be8d65bc3c8..7464ba3b4333 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -23,7 +23,6 @@
23#include <linux/node.h> 23#include <linux/node.h>
24#include <linux/compiler.h> 24#include <linux/compiler.h>
25#include <linux/cpumask.h> 25#include <linux/cpumask.h>
26#include <asm/semaphore.h>
27#include <linux/mutex.h> 26#include <linux/mutex.h>
28 27
29struct cpu { 28struct cpu {
@@ -109,7 +108,7 @@ static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
109extern void get_online_cpus(void); 108extern void get_online_cpus(void);
110extern void put_online_cpus(void); 109extern void put_online_cpus(void);
111#define hotcpu_notifier(fn, pri) { \ 110#define hotcpu_notifier(fn, pri) { \
112 static struct notifier_block fn##_nb = \ 111 static struct notifier_block fn##_nb __cpuinitdata = \
113 { .notifier_call = fn, .priority = pri }; \ 112 { .notifier_call = fn, .priority = pri }; \
114 register_cpu_notifier(&fn##_nb); \ 113 register_cpu_notifier(&fn##_nb); \
115} 114}
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index ddd8652fc3f3..e7e91dbfde0f 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -83,7 +83,8 @@ struct cpufreq_real_policy {
83}; 83};
84 84
85struct cpufreq_policy { 85struct cpufreq_policy {
86 cpumask_t cpus; /* affected CPUs */ 86 cpumask_t cpus; /* CPUs requiring sw coordination */
87 cpumask_t related_cpus; /* CPUs with any coordination */
87 unsigned int shared_type; /* ANY or ALL affected CPUs 88 unsigned int shared_type; /* ANY or ALL affected CPUs
88 should set cpufreq */ 89 should set cpufreq */
89 unsigned int cpu; /* cpu nr of registered CPU */ 90 unsigned int cpu; /* cpu nr of registered CPU */
@@ -307,6 +308,9 @@ extern struct cpufreq_governor cpufreq_gov_performance;
307#endif 308#endif
308#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE 309#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE
309#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_performance) 310#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_performance)
311#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE)
312extern struct cpufreq_governor cpufreq_gov_powersave;
313#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_powersave)
310#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE) 314#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE)
311extern struct cpufreq_governor cpufreq_gov_userspace; 315extern struct cpufreq_governor cpufreq_gov_userspace;
312#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_userspace) 316#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_userspace)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 7047f58306a7..9650806fe2ea 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -14,6 +14,8 @@
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c 15 * For details of cpu_remap(), see bitmap_bitremap in lib/bitmap.c
16 * For details of cpus_remap(), see bitmap_remap in lib/bitmap.c. 16 * For details of cpus_remap(), see bitmap_remap in lib/bitmap.c.
17 * For details of cpus_onto(), see bitmap_onto in lib/bitmap.c.
18 * For details of cpus_fold(), see bitmap_fold in lib/bitmap.c.
17 * 19 *
18 * The available cpumask operations are: 20 * The available cpumask operations are:
19 * 21 *
@@ -53,7 +55,9 @@
53 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing 55 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
54 * int cpulist_parse(buf, map) Parse ascii string as cpulist 56 * int cpulist_parse(buf, map) Parse ascii string as cpulist
55 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 57 * int cpu_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
56 * int cpus_remap(dst, src, old, new) *dst = map(old, new)(src) 58 * void cpus_remap(dst, src, old, new) *dst = map(old, new)(src)
59 * void cpus_onto(dst, orig, relmap) *dst = orig relative to relmap
60 * void cpus_fold(dst, orig, sz) dst bits = orig bits mod sz
57 * 61 *
58 * for_each_cpu_mask(cpu, mask) for-loop cpu over mask 62 * for_each_cpu_mask(cpu, mask) for-loop cpu over mask
59 * 63 *
@@ -222,8 +226,13 @@ int __next_cpu(int n, const cpumask_t *srcp);
222#define next_cpu(n, src) ({ (void)(src); 1; }) 226#define next_cpu(n, src) ({ (void)(src); 1; })
223#endif 227#endif
224 228
229#ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP
230extern cpumask_t *cpumask_of_cpu_map;
231#define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu])
232
233#else
225#define cpumask_of_cpu(cpu) \ 234#define cpumask_of_cpu(cpu) \
226({ \ 235(*({ \
227 typeof(_unused_cpumask_arg_) m; \ 236 typeof(_unused_cpumask_arg_) m; \
228 if (sizeof(m) == sizeof(unsigned long)) { \ 237 if (sizeof(m) == sizeof(unsigned long)) { \
229 m.bits[0] = 1UL<<(cpu); \ 238 m.bits[0] = 1UL<<(cpu); \
@@ -231,8 +240,9 @@ int __next_cpu(int n, const cpumask_t *srcp);
231 cpus_clear(m); \ 240 cpus_clear(m); \
232 cpu_set((cpu), m); \ 241 cpu_set((cpu), m); \
233 } \ 242 } \
234 m; \ 243 &m; \
235}) 244}))
245#endif
236 246
237#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) 247#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
238 248
@@ -243,6 +253,8 @@ int __next_cpu(int n, const cpumask_t *srcp);
243 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \ 253 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
244} } 254} }
245 255
256#define CPU_MASK_ALL_PTR (&CPU_MASK_ALL)
257
246#else 258#else
247 259
248#define CPU_MASK_ALL \ 260#define CPU_MASK_ALL \
@@ -251,6 +263,10 @@ int __next_cpu(int n, const cpumask_t *srcp);
251 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \ 263 [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \
252} } 264} }
253 265
266/* cpu_mask_all is in init/main.c */
267extern cpumask_t cpu_mask_all;
268#define CPU_MASK_ALL_PTR (&cpu_mask_all)
269
254#endif 270#endif
255 271
256#define CPU_MASK_NONE \ 272#define CPU_MASK_NONE \
@@ -273,6 +289,13 @@ static inline int __cpumask_scnprintf(char *buf, int len,
273 return bitmap_scnprintf(buf, len, srcp->bits, nbits); 289 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
274} 290}
275 291
292#define cpumask_scnprintf_len(len) \
293 __cpumask_scnprintf_len((len))
294static inline int __cpumask_scnprintf_len(int len)
295{
296 return bitmap_scnprintf_len(len);
297}
298
276#define cpumask_parse_user(ubuf, ulen, dst) \ 299#define cpumask_parse_user(ubuf, ulen, dst) \
277 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS) 300 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS)
278static inline int __cpumask_parse_user(const char __user *buf, int len, 301static inline int __cpumask_parse_user(const char __user *buf, int len,
@@ -311,6 +334,22 @@ static inline void __cpus_remap(cpumask_t *dstp, const cpumask_t *srcp,
311 bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits); 334 bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits);
312} 335}
313 336
337#define cpus_onto(dst, orig, relmap) \
338 __cpus_onto(&(dst), &(orig), &(relmap), NR_CPUS)
339static inline void __cpus_onto(cpumask_t *dstp, const cpumask_t *origp,
340 const cpumask_t *relmapp, int nbits)
341{
342 bitmap_onto(dstp->bits, origp->bits, relmapp->bits, nbits);
343}
344
345#define cpus_fold(dst, orig, sz) \
346 __cpus_fold(&(dst), &(orig), sz, NR_CPUS)
347static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,
348 int sz, int nbits)
349{
350 bitmap_fold(dstp->bits, origp->bits, sz, nbits);
351}
352
314#if NR_CPUS > 1 353#if NR_CPUS > 1
315#define for_each_cpu_mask(cpu, mask) \ 354#define for_each_cpu_mask(cpu, mask) \
316 for ((cpu) = first_cpu(mask); \ 355 for ((cpu) = first_cpu(mask); \
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 0a26be353cb3..038578362b47 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -20,13 +20,13 @@ extern int number_of_cpusets; /* How many cpusets are defined in system? */
20extern int cpuset_init_early(void); 20extern int cpuset_init_early(void);
21extern int cpuset_init(void); 21extern int cpuset_init(void);
22extern void cpuset_init_smp(void); 22extern void cpuset_init_smp(void);
23extern cpumask_t cpuset_cpus_allowed(struct task_struct *p); 23extern void cpuset_cpus_allowed(struct task_struct *p, cpumask_t *mask);
24extern cpumask_t cpuset_cpus_allowed_locked(struct task_struct *p); 24extern void cpuset_cpus_allowed_locked(struct task_struct *p, cpumask_t *mask);
25extern nodemask_t cpuset_mems_allowed(struct task_struct *p); 25extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
26#define cpuset_current_mems_allowed (current->mems_allowed) 26#define cpuset_current_mems_allowed (current->mems_allowed)
27void cpuset_init_current_mems_allowed(void); 27void cpuset_init_current_mems_allowed(void);
28void cpuset_update_task_memory_state(void); 28void cpuset_update_task_memory_state(void);
29int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl); 29int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
30 30
31extern int __cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask); 31extern int __cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask);
32extern int __cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask); 32extern int __cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask);
@@ -84,13 +84,14 @@ static inline int cpuset_init_early(void) { return 0; }
84static inline int cpuset_init(void) { return 0; } 84static inline int cpuset_init(void) { return 0; }
85static inline void cpuset_init_smp(void) {} 85static inline void cpuset_init_smp(void) {}
86 86
87static inline cpumask_t cpuset_cpus_allowed(struct task_struct *p) 87static inline void cpuset_cpus_allowed(struct task_struct *p, cpumask_t *mask)
88{ 88{
89 return cpu_possible_map; 89 *mask = cpu_possible_map;
90} 90}
91static inline cpumask_t cpuset_cpus_allowed_locked(struct task_struct *p) 91static inline void cpuset_cpus_allowed_locked(struct task_struct *p,
92 cpumask_t *mask)
92{ 93{
93 return cpu_possible_map; 94 *mask = cpu_possible_map;
94} 95}
95 96
96static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) 97static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
@@ -102,7 +103,7 @@ static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
102static inline void cpuset_init_current_mems_allowed(void) {} 103static inline void cpuset_init_current_mems_allowed(void) {}
103static inline void cpuset_update_task_memory_state(void) {} 104static inline void cpuset_update_task_memory_state(void) {}
104 105
105static inline int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl) 106static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
106{ 107{
107 return 1; 108 return 1;
108} 109}
diff --git a/include/linux/crc-ccitt.h b/include/linux/crc-ccitt.h
index 90037617da8f..f52696a1ff0d 100644
--- a/include/linux/crc-ccitt.h
+++ b/include/linux/crc-ccitt.h
@@ -1,6 +1,5 @@
1#ifndef _LINUX_CRC_CCITT_H 1#ifndef _LINUX_CRC_CCITT_H
2#define _LINUX_CRC_CCITT_H 2#define _LINUX_CRC_CCITT_H
3#ifdef __KERNEL__
4 3
5#include <linux/types.h> 4#include <linux/types.h>
6 5
@@ -13,5 +12,4 @@ static inline u16 crc_ccitt_byte(u16 crc, const u8 c)
13 return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff]; 12 return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff];
14} 13}
15 14
16#endif /* __KERNEL__ */
17#endif /* _LINUX_CRC_CCITT_H */ 15#endif /* _LINUX_CRC_CCITT_H */
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 5e02d1b46370..425824bd49f3 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -317,14 +317,7 @@ int crypto_unregister_alg(struct crypto_alg *alg);
317/* 317/*
318 * Algorithm query interface. 318 * Algorithm query interface.
319 */ 319 */
320#ifdef CONFIG_CRYPTO
321int crypto_has_alg(const char *name, u32 type, u32 mask); 320int crypto_has_alg(const char *name, u32 type, u32 mask);
322#else
323static inline int crypto_has_alg(const char *name, u32 type, u32 mask)
324{
325 return 0;
326}
327#endif
328 321
329/* 322/*
330 * Transforms: user-instantiated objects which encapsulate algorithms 323 * Transforms: user-instantiated objects which encapsulate algorithms
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 6bd646096fa6..2a6639407c80 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -1,8 +1,6 @@
1#ifndef __LINUX_DCACHE_H 1#ifndef __LINUX_DCACHE_H
2#define __LINUX_DCACHE_H 2#define __LINUX_DCACHE_H
3 3
4#ifdef __KERNEL__
5
6#include <asm/atomic.h> 4#include <asm/atomic.h>
7#include <linux/list.h> 5#include <linux/list.h>
8#include <linux/spinlock.h> 6#include <linux/spinlock.h>
@@ -301,7 +299,9 @@ extern int d_validate(struct dentry *, struct dentry *);
301 */ 299 */
302extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); 300extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
303 301
302extern char *__d_path(const struct path *path, struct path *root, char *, int);
304extern char *d_path(struct path *, char *, int); 303extern char *d_path(struct path *, char *, int);
304extern char *dentry_path(struct dentry *, char *, int);
305 305
306/* Allocation counts.. */ 306/* Allocation counts.. */
307 307
@@ -359,11 +359,8 @@ static inline int d_mountpoint(struct dentry *dentry)
359} 359}
360 360
361extern struct vfsmount *lookup_mnt(struct vfsmount *, struct dentry *); 361extern struct vfsmount *lookup_mnt(struct vfsmount *, struct dentry *);
362extern struct vfsmount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
363extern struct dentry *lookup_create(struct nameidata *nd, int is_dir); 362extern struct dentry *lookup_create(struct nameidata *nd, int is_dir);
364 363
365extern int sysctl_vfs_cache_pressure; 364extern int sysctl_vfs_cache_pressure;
366 365
367#endif /* __KERNEL__ */
368
369#endif /* __LINUX_DCACHE_H */ 366#endif /* __LINUX_DCACHE_H */
diff --git a/include/linux/debugobjects.h b/include/linux/debugobjects.h
new file mode 100644
index 000000000000..8c243aaa86a7
--- /dev/null
+++ b/include/linux/debugobjects.h
@@ -0,0 +1,90 @@
1#ifndef _LINUX_DEBUGOBJECTS_H
2#define _LINUX_DEBUGOBJECTS_H
3
4#include <linux/list.h>
5#include <linux/spinlock.h>
6
7enum debug_obj_state {
8 ODEBUG_STATE_NONE,
9 ODEBUG_STATE_INIT,
10 ODEBUG_STATE_INACTIVE,
11 ODEBUG_STATE_ACTIVE,
12 ODEBUG_STATE_DESTROYED,
13 ODEBUG_STATE_NOTAVAILABLE,
14 ODEBUG_STATE_MAX,
15};
16
17struct debug_obj_descr;
18
19/**
20 * struct debug_obj - representaion of an tracked object
21 * @node: hlist node to link the object into the tracker list
22 * @state: tracked object state
23 * @object: pointer to the real object
24 * @descr: pointer to an object type specific debug description structure
25 */
26struct debug_obj {
27 struct hlist_node node;
28 enum debug_obj_state state;
29 void *object;
30 struct debug_obj_descr *descr;
31};
32
33/**
34 * struct debug_obj_descr - object type specific debug description structure
35 * @name: name of the object typee
36 * @fixup_init: fixup function, which is called when the init check
37 * fails
38 * @fixup_activate: fixup function, which is called when the activate check
39 * fails
40 * @fixup_destroy: fixup function, which is called when the destroy check
41 * fails
42 * @fixup_free: fixup function, which is called when the free check
43 * fails
44 */
45struct debug_obj_descr {
46 const char *name;
47
48 int (*fixup_init) (void *addr, enum debug_obj_state state);
49 int (*fixup_activate) (void *addr, enum debug_obj_state state);
50 int (*fixup_destroy) (void *addr, enum debug_obj_state state);
51 int (*fixup_free) (void *addr, enum debug_obj_state state);
52};
53
54#ifdef CONFIG_DEBUG_OBJECTS
55extern void debug_object_init (void *addr, struct debug_obj_descr *descr);
56extern void
57debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr);
58extern void debug_object_activate (void *addr, struct debug_obj_descr *descr);
59extern void debug_object_deactivate(void *addr, struct debug_obj_descr *descr);
60extern void debug_object_destroy (void *addr, struct debug_obj_descr *descr);
61extern void debug_object_free (void *addr, struct debug_obj_descr *descr);
62
63extern void debug_objects_early_init(void);
64extern void debug_objects_mem_init(void);
65#else
66static inline void
67debug_object_init (void *addr, struct debug_obj_descr *descr) { }
68static inline void
69debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr) { }
70static inline void
71debug_object_activate (void *addr, struct debug_obj_descr *descr) { }
72static inline void
73debug_object_deactivate(void *addr, struct debug_obj_descr *descr) { }
74static inline void
75debug_object_destroy (void *addr, struct debug_obj_descr *descr) { }
76static inline void
77debug_object_free (void *addr, struct debug_obj_descr *descr) { }
78
79static inline void debug_objects_early_init(void) { }
80static inline void debug_objects_mem_init(void) { }
81#endif
82
83#ifdef CONFIG_DEBUG_OBJECTS_FREE
84extern void debug_check_no_obj_freed(const void *address, unsigned long size);
85#else
86static inline void
87debug_check_no_obj_freed(const void *address, unsigned long size) { }
88#endif
89
90#endif
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index cb784579956b..0d8d419d191a 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001 Sistina Software (UK) Limited. 2 * Copyright (C) 2001 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This file is released under the LGPL. 5 * This file is released under the LGPL.
6 */ 6 */
@@ -8,7 +8,7 @@
8#ifndef _LINUX_DEVICE_MAPPER_H 8#ifndef _LINUX_DEVICE_MAPPER_H
9#define _LINUX_DEVICE_MAPPER_H 9#define _LINUX_DEVICE_MAPPER_H
10 10
11#ifdef __KERNEL__ 11#include <linux/bio.h>
12 12
13struct dm_target; 13struct dm_target;
14struct dm_table; 14struct dm_table;
@@ -250,11 +250,96 @@ void dm_table_event(struct dm_table *t);
250 */ 250 */
251int dm_swap_table(struct mapped_device *md, struct dm_table *t); 251int dm_swap_table(struct mapped_device *md, struct dm_table *t);
252 252
253/*-----------------------------------------------------------------
254 * Macros.
255 *---------------------------------------------------------------*/
256#define DM_NAME "device-mapper"
257
258#define DMERR(f, arg...) \
259 printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
260#define DMERR_LIMIT(f, arg...) \
261 do { \
262 if (printk_ratelimit()) \
263 printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \
264 f "\n", ## arg); \
265 } while (0)
266
267#define DMWARN(f, arg...) \
268 printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
269#define DMWARN_LIMIT(f, arg...) \
270 do { \
271 if (printk_ratelimit()) \
272 printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \
273 f "\n", ## arg); \
274 } while (0)
275
276#define DMINFO(f, arg...) \
277 printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
278#define DMINFO_LIMIT(f, arg...) \
279 do { \
280 if (printk_ratelimit()) \
281 printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \
282 "\n", ## arg); \
283 } while (0)
284
285#ifdef CONFIG_DM_DEBUG
286# define DMDEBUG(f, arg...) \
287 printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg)
288# define DMDEBUG_LIMIT(f, arg...) \
289 do { \
290 if (printk_ratelimit()) \
291 printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \
292 "\n", ## arg); \
293 } while (0)
294#else
295# define DMDEBUG(f, arg...) do {} while (0)
296# define DMDEBUG_LIMIT(f, arg...) do {} while (0)
297#endif
298
299#define DMEMIT(x...) sz += ((sz >= maxlen) ? \
300 0 : scnprintf(result + sz, maxlen - sz, x))
301
302#define SECTOR_SHIFT 9
303
304/*
305 * Definitions of return values from target end_io function.
306 */
307#define DM_ENDIO_INCOMPLETE 1
308#define DM_ENDIO_REQUEUE 2
309
253/* 310/*
254 * Prepare a table for a device that will error all I/O. 311 * Definitions of return values from target map function.
255 * To make it active, call dm_suspend(), dm_swap_table() then dm_resume().
256 */ 312 */
257int dm_create_error_table(struct dm_table **result, struct mapped_device *md); 313#define DM_MAPIO_SUBMITTED 0
314#define DM_MAPIO_REMAPPED 1
315#define DM_MAPIO_REQUEUE DM_ENDIO_REQUEUE
316
317/*
318 * Ceiling(n / sz)
319 */
320#define dm_div_up(n, sz) (((n) + (sz) - 1) / (sz))
321
322#define dm_sector_div_up(n, sz) ( \
323{ \
324 sector_t _r = ((n) + (sz) - 1); \
325 sector_div(_r, (sz)); \
326 _r; \
327} \
328)
329
330/*
331 * ceiling(n / size) * size
332 */
333#define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
334
335static inline sector_t to_sector(unsigned long n)
336{
337 return (n >> SECTOR_SHIFT);
338}
339
340static inline unsigned long to_bytes(sector_t n)
341{
342 return (n << SECTOR_SHIFT);
343}
258 344
259#endif /* __KERNEL__ */
260#endif /* _LINUX_DEVICE_MAPPER_H */ 345#endif /* _LINUX_DEVICE_MAPPER_H */
diff --git a/include/linux/device.h b/include/linux/device.h
index 2258d89bf523..832fb0eb2933 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -20,7 +20,7 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/pm.h> 22#include <linux/pm.h>
23#include <asm/semaphore.h> 23#include <linux/semaphore.h>
24#include <asm/atomic.h> 24#include <asm/atomic.h>
25#include <asm/device.h> 25#include <asm/device.h>
26 26
@@ -35,7 +35,6 @@ struct device;
35struct device_driver; 35struct device_driver;
36struct driver_private; 36struct driver_private;
37struct class; 37struct class;
38struct class_device;
39struct bus_type; 38struct bus_type;
40struct bus_type_private; 39struct bus_type_private;
41 40
@@ -190,13 +189,10 @@ struct class {
190 struct kset class_dirs; 189 struct kset class_dirs;
191 struct semaphore sem; /* locks children, devices, interfaces */ 190 struct semaphore sem; /* locks children, devices, interfaces */
192 struct class_attribute *class_attrs; 191 struct class_attribute *class_attrs;
193 struct class_device_attribute *class_dev_attrs;
194 struct device_attribute *dev_attrs; 192 struct device_attribute *dev_attrs;
195 193
196 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env);
197 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); 194 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
198 195
199 void (*release)(struct class_device *dev);
200 void (*class_release)(struct class *class); 196 void (*class_release)(struct class *class);
201 void (*dev_release)(struct device *dev); 197 void (*dev_release)(struct device *dev);
202 198
@@ -210,9 +206,6 @@ extern int class_for_each_device(struct class *class, void *data,
210 int (*fn)(struct device *dev, void *data)); 206 int (*fn)(struct device *dev, void *data));
211extern struct device *class_find_device(struct class *class, void *data, 207extern struct device *class_find_device(struct class *class, void *data,
212 int (*match)(struct device *, void *)); 208 int (*match)(struct device *, void *));
213extern struct class_device *class_find_child(struct class *class, void *data,
214 int (*match)(struct class_device *, void *));
215
216 209
217struct class_attribute { 210struct class_attribute {
218 struct attribute attr; 211 struct attribute attr;
@@ -228,92 +221,10 @@ extern int __must_check class_create_file(struct class *class,
228extern void class_remove_file(struct class *class, 221extern void class_remove_file(struct class *class,
229 const struct class_attribute *attr); 222 const struct class_attribute *attr);
230 223
231struct class_device_attribute {
232 struct attribute attr;
233 ssize_t (*show)(struct class_device *, char *buf);
234 ssize_t (*store)(struct class_device *, const char *buf, size_t count);
235};
236
237#define CLASS_DEVICE_ATTR(_name, _mode, _show, _store) \
238struct class_device_attribute class_device_attr_##_name = \
239 __ATTR(_name, _mode, _show, _store)
240
241extern int __must_check class_device_create_file(struct class_device *,
242 const struct class_device_attribute *);
243
244/**
245 * struct class_device - class devices
246 * @class: pointer to the parent class for this class device. This is required.
247 * @devt: for internal use by the driver core only.
248 * @node: for internal use by the driver core only.
249 * @kobj: for internal use by the driver core only.
250 * @groups: optional additional groups to be created
251 * @dev: if set, a symlink to the struct device is created in the sysfs
252 * directory for this struct class device.
253 * @class_data: pointer to whatever you want to store here for this struct
254 * class_device. Use class_get_devdata() and class_set_devdata() to get and
255 * set this pointer.
256 * @parent: pointer to a struct class_device that is the parent of this struct
257 * class_device. If NULL, this class_device will show up at the root of the
258 * struct class in sysfs (which is probably what you want to have happen.)
259 * @release: pointer to a release function for this struct class_device. If
260 * set, this will be called instead of the class specific release function.
261 * Only use this if you want to override the default release function, like
262 * when you are nesting class_device structures.
263 * @uevent: pointer to a uevent function for this struct class_device. If
264 * set, this will be called instead of the class specific uevent function.
265 * Only use this if you want to override the default uevent function, like
266 * when you are nesting class_device structures.
267 */
268struct class_device {
269 struct list_head node;
270
271 struct kobject kobj;
272 struct class *class;
273 dev_t devt;
274 struct device *dev;
275 void *class_data;
276 struct class_device *parent;
277 struct attribute_group **groups;
278
279 void (*release)(struct class_device *dev);
280 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env);
281 char class_id[BUS_ID_SIZE];
282};
283
284static inline void *class_get_devdata(struct class_device *dev)
285{
286 return dev->class_data;
287}
288
289static inline void class_set_devdata(struct class_device *dev, void *data)
290{
291 dev->class_data = data;
292}
293
294
295extern int __must_check class_device_register(struct class_device *);
296extern void class_device_unregister(struct class_device *);
297extern void class_device_initialize(struct class_device *);
298extern int __must_check class_device_add(struct class_device *);
299extern void class_device_del(struct class_device *);
300
301extern struct class_device *class_device_get(struct class_device *);
302extern void class_device_put(struct class_device *);
303
304extern void class_device_remove_file(struct class_device *,
305 const struct class_device_attribute *);
306extern int __must_check class_device_create_bin_file(struct class_device *,
307 struct bin_attribute *);
308extern void class_device_remove_bin_file(struct class_device *,
309 struct bin_attribute *);
310
311struct class_interface { 224struct class_interface {
312 struct list_head node; 225 struct list_head node;
313 struct class *class; 226 struct class *class;
314 227
315 int (*add) (struct class_device *, struct class_interface *);
316 void (*remove) (struct class_device *, struct class_interface *);
317 int (*add_dev) (struct device *, struct class_interface *); 228 int (*add_dev) (struct device *, struct class_interface *);
318 void (*remove_dev) (struct device *, struct class_interface *); 229 void (*remove_dev) (struct device *, struct class_interface *);
319}; 230};
@@ -323,13 +234,6 @@ extern void class_interface_unregister(struct class_interface *);
323 234
324extern struct class *class_create(struct module *owner, const char *name); 235extern struct class *class_create(struct module *owner, const char *name);
325extern void class_destroy(struct class *cls); 236extern void class_destroy(struct class *cls);
326extern struct class_device *class_device_create(struct class *cls,
327 struct class_device *parent,
328 dev_t devt,
329 struct device *device,
330 const char *fmt, ...)
331 __attribute__((format(printf, 5, 6)));
332extern void class_device_destroy(struct class *cls, dev_t devt);
333 237
334/* 238/*
335 * The type of device, "struct device" is embedded in. A class 239 * The type of device, "struct device" is embedded in. A class
@@ -429,7 +333,6 @@ struct device {
429 struct kobject kobj; 333 struct kobject kobj;
430 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 334 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
431 struct device_type *type; 335 struct device_type *type;
432 unsigned is_registered:1;
433 unsigned uevent_suppress:1; 336 unsigned uevent_suppress:1;
434 337
435 struct semaphore sem; /* semaphore to synchronize calls to 338 struct semaphore sem; /* semaphore to synchronize calls to
@@ -466,7 +369,6 @@ struct device {
466 spinlock_t devres_lock; 369 spinlock_t devres_lock;
467 struct list_head devres_head; 370 struct list_head devres_head;
468 371
469 /* class_device migration path */
470 struct list_head node; 372 struct list_head node;
471 struct class *class; 373 struct class *class;
472 dev_t devt; /* dev_t, creates the sysfs "dev" */ 374 dev_t devt; /* dev_t, creates the sysfs "dev" */
@@ -475,6 +377,9 @@ struct device {
475 void (*release)(struct device *dev); 377 void (*release)(struct device *dev);
476}; 378};
477 379
380/* Get the wakeup routines, which depend on struct device */
381#include <linux/pm_wakeup.h>
382
478#ifdef CONFIG_NUMA 383#ifdef CONFIG_NUMA
479static inline int dev_to_node(struct device *dev) 384static inline int dev_to_node(struct device *dev)
480{ 385{
@@ -506,7 +411,7 @@ static inline void dev_set_drvdata(struct device *dev, void *data)
506 411
507static inline int device_is_registered(struct device *dev) 412static inline int device_is_registered(struct device *dev)
508{ 413{
509 return dev->is_registered; 414 return dev->kobj.state_in_sysfs;
510} 415}
511 416
512void driver_init(void); 417void driver_init(void);
@@ -543,20 +448,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
543 dev_t devt, const char *fmt, ...) 448 dev_t devt, const char *fmt, ...)
544 __attribute__((format(printf, 4, 5))); 449 __attribute__((format(printf, 4, 5)));
545extern void device_destroy(struct class *cls, dev_t devt); 450extern void device_destroy(struct class *cls, dev_t devt);
546#ifdef CONFIG_PM_SLEEP
547extern void destroy_suspended_device(struct class *cls, dev_t devt);
548extern void device_pm_schedule_removal(struct device *);
549#else /* !CONFIG_PM_SLEEP */
550static inline void destroy_suspended_device(struct class *cls, dev_t devt)
551{
552 device_destroy(cls, devt);
553}
554
555static inline void device_pm_schedule_removal(struct device *dev)
556{
557 device_unregister(dev);
558}
559#endif /* !CONFIG_PM_SLEEP */
560 451
561/* 452/*
562 * Platform "fixup" functions - allow the platform to have their say 453 * Platform "fixup" functions - allow the platform to have their say
@@ -608,21 +499,16 @@ extern const char *dev_driver_string(struct device *dev);
608#define dev_dbg(dev, format, arg...) \ 499#define dev_dbg(dev, format, arg...) \
609 dev_printk(KERN_DEBUG , dev , format , ## arg) 500 dev_printk(KERN_DEBUG , dev , format , ## arg)
610#else 501#else
611static inline int __attribute__ ((format (printf, 2, 3))) 502#define dev_dbg(dev, format, arg...) \
612dev_dbg(struct device *dev, const char *fmt, ...) 503 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
613{
614 return 0;
615}
616#endif 504#endif
617 505
618#ifdef VERBOSE_DEBUG 506#ifdef VERBOSE_DEBUG
619#define dev_vdbg dev_dbg 507#define dev_vdbg dev_dbg
620#else 508#else
621static inline int __attribute__ ((format (printf, 2, 3))) 509
622dev_vdbg(struct device *dev, const char *fmt, ...) 510#define dev_vdbg(dev, format, arg...) \
623{ 511 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
624 return 0;
625}
626#endif 512#endif
627 513
628/* Create alias, so I can be autoloaded. */ 514/* Create alias, so I can be autoloaded. */
diff --git a/include/linux/device_cgroup.h b/include/linux/device_cgroup.h
new file mode 100644
index 000000000000..0b0d9c39ed67
--- /dev/null
+++ b/include/linux/device_cgroup.h
@@ -0,0 +1,12 @@
1#include <linux/module.h>
2#include <linux/fs.h>
3
4#ifdef CONFIG_CGROUP_DEVICE
5extern int devcgroup_inode_permission(struct inode *inode, int mask);
6extern int devcgroup_inode_mknod(int mode, dev_t dev);
7#else
8static inline int devcgroup_inode_permission(struct inode *inode, int mask)
9{ return 0; }
10static inline int devcgroup_inode_mknod(int mode, dev_t dev)
11{ return 0; }
12#endif
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h
index b672ddc00735..154769cad3f3 100644
--- a/include/linux/devpts_fs.h
+++ b/include/linux/devpts_fs.h
@@ -17,6 +17,8 @@
17 17
18#ifdef CONFIG_UNIX98_PTYS 18#ifdef CONFIG_UNIX98_PTYS
19 19
20int devpts_new_index(void);
21void devpts_kill_index(int idx);
20int devpts_pty_new(struct tty_struct *tty); /* mknod in devpts */ 22int devpts_pty_new(struct tty_struct *tty); /* mknod in devpts */
21struct tty_struct *devpts_get_tty(int number); /* get tty structure */ 23struct tty_struct *devpts_get_tty(int number); /* get tty structure */
22void devpts_pty_kill(int number); /* unlink */ 24void devpts_pty_kill(int number); /* unlink */
@@ -24,6 +26,8 @@ void devpts_pty_kill(int number); /* unlink */
24#else 26#else
25 27
26/* Dummy stubs in the no-pty case */ 28/* Dummy stubs in the no-pty case */
29static inline int devpts_new_index(void) { return -EINVAL; }
30static inline void devpts_kill_index(int idx) { }
27static inline int devpts_pty_new(struct tty_struct *tty) { return -EINVAL; } 31static inline int devpts_pty_new(struct tty_struct *tty) { return -EINVAL; }
28static inline struct tty_struct *devpts_get_tty(int number) { return NULL; } 32static inline struct tty_struct *devpts_get_tty(int number) { return NULL; }
29static inline void devpts_pty_kill(int number) { } 33static inline void devpts_pty_kill(int number) { }
diff --git a/include/linux/dlm.h b/include/linux/dlm.h
index c743fbc769db..203a025e30e5 100644
--- a/include/linux/dlm.h
+++ b/include/linux/dlm.h
@@ -21,10 +21,7 @@
21 21
22/* Lock levels and flags are here */ 22/* Lock levels and flags are here */
23#include <linux/dlmconstants.h> 23#include <linux/dlmconstants.h>
24 24#include <linux/types.h>
25
26#define DLM_RESNAME_MAXLEN 64
27
28 25
29typedef void dlm_lockspace_t; 26typedef void dlm_lockspace_t;
30 27
@@ -63,7 +60,7 @@ typedef void dlm_lockspace_t;
63 60
64struct dlm_lksb { 61struct dlm_lksb {
65 int sb_status; 62 int sb_status;
66 uint32_t sb_lkid; 63 __u32 sb_lkid;
67 char sb_flags; 64 char sb_flags;
68 char * sb_lvbptr; 65 char * sb_lvbptr;
69}; 66};
diff --git a/include/linux/dlm_device.h b/include/linux/dlm_device.h
index 9642277a152a..c6034508fed9 100644
--- a/include/linux/dlm_device.h
+++ b/include/linux/dlm_device.h
@@ -11,10 +11,16 @@
11******************************************************************************* 11*******************************************************************************
12******************************************************************************/ 12******************************************************************************/
13 13
14#ifndef _LINUX_DLM_DEVICE_H
15#define _LINUX_DLM_DEVICE_H
16
14/* This is the device interface for dlm, most users will use a library 17/* This is the device interface for dlm, most users will use a library
15 * interface. 18 * interface.
16 */ 19 */
17 20
21#include <linux/dlm.h>
22#include <linux/types.h>
23
18#define DLM_USER_LVB_LEN 32 24#define DLM_USER_LVB_LEN 32
19 25
20/* Version of the device interface */ 26/* Version of the device interface */
@@ -94,10 +100,9 @@ struct dlm_lock_result {
94#define DLM_USER_PURGE 6 100#define DLM_USER_PURGE 6
95#define DLM_USER_DEADLOCK 7 101#define DLM_USER_DEADLOCK 7
96 102
97/* Arbitrary length restriction */
98#define MAX_LS_NAME_LEN 64
99
100/* Lockspace flags */ 103/* Lockspace flags */
101#define DLM_USER_LSFLG_AUTOFREE 1 104#define DLM_USER_LSFLG_AUTOFREE 1
102#define DLM_USER_LSFLG_FORCEFREE 2 105#define DLM_USER_LSFLG_FORCEFREE 2
103 106
107#endif
108
diff --git a/include/linux/dlm_plock.h b/include/linux/dlm_plock.h
new file mode 100644
index 000000000000..18d5fdbceb74
--- /dev/null
+++ b/include/linux/dlm_plock.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
3 *
4 * This copyrighted material is made available to anyone wishing to use,
5 * modify, copy, or redistribute it subject to the terms and conditions
6 * of the GNU General Public License v.2.
7 */
8
9#ifndef __DLM_PLOCK_DOT_H__
10#define __DLM_PLOCK_DOT_H__
11
12#define DLM_PLOCK_MISC_NAME "dlm_plock"
13
14#define DLM_PLOCK_VERSION_MAJOR 1
15#define DLM_PLOCK_VERSION_MINOR 1
16#define DLM_PLOCK_VERSION_PATCH 0
17
18enum {
19 DLM_PLOCK_OP_LOCK = 1,
20 DLM_PLOCK_OP_UNLOCK,
21 DLM_PLOCK_OP_GET,
22};
23
24struct dlm_plock_info {
25 __u32 version[3];
26 __u8 optype;
27 __u8 ex;
28 __u8 wait;
29 __u8 pad;
30 __u32 pid;
31 __s32 nodeid;
32 __s32 rv;
33 __u32 fsid;
34 __u64 number;
35 __u64 start;
36 __u64 end;
37 __u64 owner;
38};
39
40#ifdef __KERNEL__
41int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
42 int cmd, struct file_lock *fl);
43int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
44 struct file_lock *fl);
45int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file,
46 struct file_lock *fl);
47#endif /* __KERNEL__ */
48
49#endif
50
diff --git a/include/linux/dlmconstants.h b/include/linux/dlmconstants.h
index fddb3d3ff321..47bf08dc7566 100644
--- a/include/linux/dlmconstants.h
+++ b/include/linux/dlmconstants.h
@@ -18,6 +18,10 @@
18 * Constants used by DLM interface. 18 * Constants used by DLM interface.
19 */ 19 */
20 20
21#define DLM_LOCKSPACE_LEN 64
22#define DLM_RESNAME_MAXLEN 64
23
24
21/* 25/*
22 * Lock Modes 26 * Lock Modes
23 */ 27 */
diff --git a/include/linux/dm-dirty-log.h b/include/linux/dm-dirty-log.h
new file mode 100644
index 000000000000..600c5fb2daad
--- /dev/null
+++ b/include/linux/dm-dirty-log.h
@@ -0,0 +1,131 @@
1/*
2 * Copyright (C) 2003 Sistina Software
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * Device-Mapper dirty region log.
6 *
7 * This file is released under the LGPL.
8 */
9
10#ifndef _LINUX_DM_DIRTY_LOG
11#define _LINUX_DM_DIRTY_LOG
12
13#ifdef __KERNEL__
14
15#include <linux/types.h>
16#include <linux/device-mapper.h>
17
18typedef sector_t region_t;
19
20struct dm_dirty_log_type;
21
22struct dm_dirty_log {
23 struct dm_dirty_log_type *type;
24 void *context;
25};
26
27struct dm_dirty_log_type {
28 const char *name;
29 struct module *module;
30
31 int (*ctr)(struct dm_dirty_log *log, struct dm_target *ti,
32 unsigned argc, char **argv);
33 void (*dtr)(struct dm_dirty_log *log);
34
35 /*
36 * There are times when we don't want the log to touch
37 * the disk.
38 */
39 int (*presuspend)(struct dm_dirty_log *log);
40 int (*postsuspend)(struct dm_dirty_log *log);
41 int (*resume)(struct dm_dirty_log *log);
42
43 /*
44 * Retrieves the smallest size of region that the log can
45 * deal with.
46 */
47 uint32_t (*get_region_size)(struct dm_dirty_log *log);
48
49 /*
50 * A predicate to say whether a region is clean or not.
51 * May block.
52 */
53 int (*is_clean)(struct dm_dirty_log *log, region_t region);
54
55 /*
56 * Returns: 0, 1, -EWOULDBLOCK, < 0
57 *
58 * A predicate function to check the area given by
59 * [sector, sector + len) is in sync.
60 *
61 * If -EWOULDBLOCK is returned the state of the region is
62 * unknown, typically this will result in a read being
63 * passed to a daemon to deal with, since a daemon is
64 * allowed to block.
65 */
66 int (*in_sync)(struct dm_dirty_log *log, region_t region,
67 int can_block);
68
69 /*
70 * Flush the current log state (eg, to disk). This
71 * function may block.
72 */
73 int (*flush)(struct dm_dirty_log *log);
74
75 /*
76 * Mark an area as clean or dirty. These functions may
77 * block, though for performance reasons blocking should
78 * be extremely rare (eg, allocating another chunk of
79 * memory for some reason).
80 */
81 void (*mark_region)(struct dm_dirty_log *log, region_t region);
82 void (*clear_region)(struct dm_dirty_log *log, region_t region);
83
84 /*
85 * Returns: <0 (error), 0 (no region), 1 (region)
86 *
87 * The mirrord will need perform recovery on regions of
88 * the mirror that are in the NOSYNC state. This
89 * function asks the log to tell the caller about the
90 * next region that this machine should recover.
91 *
92 * Do not confuse this function with 'in_sync()', one
93 * tells you if an area is synchronised, the other
94 * assigns recovery work.
95 */
96 int (*get_resync_work)(struct dm_dirty_log *log, region_t *region);
97
98 /*
99 * This notifies the log that the resync status of a region
100 * has changed. It also clears the region from the recovering
101 * list (if present).
102 */
103 void (*set_region_sync)(struct dm_dirty_log *log,
104 region_t region, int in_sync);
105
106 /*
107 * Returns the number of regions that are in sync.
108 */
109 region_t (*get_sync_count)(struct dm_dirty_log *log);
110
111 /*
112 * Support function for mirror status requests.
113 */
114 int (*status)(struct dm_dirty_log *log, status_type_t status_type,
115 char *result, unsigned maxlen);
116};
117
118int dm_dirty_log_type_register(struct dm_dirty_log_type *type);
119int dm_dirty_log_type_unregister(struct dm_dirty_log_type *type);
120
121/*
122 * Make sure you use these two functions, rather than calling
123 * type->constructor/destructor() directly.
124 */
125struct dm_dirty_log *dm_dirty_log_create(const char *type_name,
126 struct dm_target *ti,
127 unsigned argc, char **argv);
128void dm_dirty_log_destroy(struct dm_dirty_log *log);
129
130#endif /* __KERNEL__ */
131#endif /* _LINUX_DM_DIRTY_LOG_H */
diff --git a/include/linux/dm-io.h b/include/linux/dm-io.h
new file mode 100644
index 000000000000..b6bf17ee2f61
--- /dev/null
+++ b/include/linux/dm-io.h
@@ -0,0 +1,85 @@
1/*
2 * Copyright (C) 2003 Sistina Software
3 * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved.
4 *
5 * Device-Mapper low-level I/O.
6 *
7 * This file is released under the GPL.
8 */
9
10#ifndef _LINUX_DM_IO_H
11#define _LINUX_DM_IO_H
12
13#ifdef __KERNEL__
14
15#include <linux/types.h>
16
17struct dm_io_region {
18 struct block_device *bdev;
19 sector_t sector;
20 sector_t count; /* If this is zero the region is ignored. */
21};
22
23struct page_list {
24 struct page_list *next;
25 struct page *page;
26};
27
28typedef void (*io_notify_fn)(unsigned long error, void *context);
29
30enum dm_io_mem_type {
31 DM_IO_PAGE_LIST,/* Page list */
32 DM_IO_BVEC, /* Bio vector */
33 DM_IO_VMA, /* Virtual memory area */
34 DM_IO_KMEM, /* Kernel memory */
35};
36
37struct dm_io_memory {
38 enum dm_io_mem_type type;
39
40 union {
41 struct page_list *pl;
42 struct bio_vec *bvec;
43 void *vma;
44 void *addr;
45 } ptr;
46
47 unsigned offset;
48};
49
50struct dm_io_notify {
51 io_notify_fn fn; /* Callback for asynchronous requests */
52 void *context; /* Passed to callback */
53};
54
55/*
56 * IO request structure
57 */
58struct dm_io_client;
59struct dm_io_request {
60 int bi_rw; /* READ|WRITE - not READA */
61 struct dm_io_memory mem; /* Memory to use for io */
62 struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */
63 struct dm_io_client *client; /* Client memory handler */
64};
65
66/*
67 * For async io calls, users can alternatively use the dm_io() function below
68 * and dm_io_client_create() to create private mempools for the client.
69 *
70 * Create/destroy may block.
71 */
72struct dm_io_client *dm_io_client_create(unsigned num_pages);
73int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client);
74void dm_io_client_destroy(struct dm_io_client *client);
75
76/*
77 * IO interface using private per-client pools.
78 * Each bit in the optional 'sync_error_bits' bitset indicates whether an
79 * error occurred doing io to the corresponding region.
80 */
81int dm_io(struct dm_io_request *io_req, unsigned num_regions,
82 struct dm_io_region *region, unsigned long *sync_error_bits);
83
84#endif /* __KERNEL__ */
85#endif /* _LINUX_DM_IO_H */
diff --git a/include/linux/dm-kcopyd.h b/include/linux/dm-kcopyd.h
new file mode 100644
index 000000000000..5db216311695
--- /dev/null
+++ b/include/linux/dm-kcopyd.h
@@ -0,0 +1,47 @@
1/*
2 * Copyright (C) 2001 - 2003 Sistina Software
3 * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved.
4 *
5 * kcopyd provides a simple interface for copying an area of one
6 * block-device to one or more other block-devices, either synchronous
7 * or with an asynchronous completion notification.
8 *
9 * This file is released under the GPL.
10 */
11
12#ifndef _LINUX_DM_KCOPYD_H
13#define _LINUX_DM_KCOPYD_H
14
15#ifdef __KERNEL__
16
17#include <linux/dm-io.h>
18
19/* FIXME: make this configurable */
20#define DM_KCOPYD_MAX_REGIONS 8
21
22#define DM_KCOPYD_IGNORE_ERROR 1
23
24/*
25 * To use kcopyd you must first create a dm_kcopyd_client object.
26 */
27struct dm_kcopyd_client;
28int dm_kcopyd_client_create(unsigned num_pages,
29 struct dm_kcopyd_client **result);
30void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc);
31
32/*
33 * Submit a copy job to kcopyd. This is built on top of the
34 * previous three fns.
35 *
36 * read_err is a boolean,
37 * write_err is a bitset, with 1 bit for each destination region
38 */
39typedef void (*dm_kcopyd_notify_fn)(int read_err, unsigned long write_err,
40 void *context);
41
42int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from,
43 unsigned num_dests, struct dm_io_region *dests,
44 unsigned flags, dm_kcopyd_notify_fn fn, void *context);
45
46#endif /* __KERNEL__ */
47#endif /* _LINUX_DM_KCOPYD_H */
diff --git a/include/linux/dma-attrs.h b/include/linux/dma-attrs.h
new file mode 100644
index 000000000000..1677e2bfa00c
--- /dev/null
+++ b/include/linux/dma-attrs.h
@@ -0,0 +1,74 @@
1#ifndef _DMA_ATTR_H
2#define _DMA_ATTR_H
3
4#include <linux/bitmap.h>
5#include <linux/bitops.h>
6#include <linux/bug.h>
7
8/**
9 * an enum dma_attr represents an attribute associated with a DMA
10 * mapping. The semantics of each attribute should be defined in
11 * Documentation/DMA-attributes.txt.
12 */
13enum dma_attr {
14 DMA_ATTR_WRITE_BARRIER,
15 DMA_ATTR_MAX,
16};
17
18#define __DMA_ATTRS_LONGS BITS_TO_LONGS(DMA_ATTR_MAX)
19
20/**
21 * struct dma_attrs - an opaque container for DMA attributes
22 * @flags - bitmask representing a collection of enum dma_attr
23 */
24struct dma_attrs {
25 unsigned long flags[__DMA_ATTRS_LONGS];
26};
27
28#define DEFINE_DMA_ATTRS(x) \
29 struct dma_attrs x = { \
30 .flags = { [0 ... __DMA_ATTRS_LONGS-1] = 0 }, \
31 }
32
33static inline void init_dma_attrs(struct dma_attrs *attrs)
34{
35 bitmap_zero(attrs->flags, __DMA_ATTRS_LONGS);
36}
37
38#ifdef CONFIG_HAVE_DMA_ATTRS
39/**
40 * dma_set_attr - set a specific attribute
41 * @attr: attribute to set
42 * @attrs: struct dma_attrs (may be NULL)
43 */
44static inline void dma_set_attr(enum dma_attr attr, struct dma_attrs *attrs)
45{
46 if (attrs == NULL)
47 return;
48 BUG_ON(attr >= DMA_ATTR_MAX);
49 __set_bit(attr, attrs->flags);
50}
51
52/**
53 * dma_get_attr - check for a specific attribute
54 * @attr: attribute to set
55 * @attrs: struct dma_attrs (may be NULL)
56 */
57static inline int dma_get_attr(enum dma_attr attr, struct dma_attrs *attrs)
58{
59 if (attrs == NULL)
60 return 0;
61 BUG_ON(attr >= DMA_ATTR_MAX);
62 return test_bit(attr, attrs->flags);
63}
64#else /* !CONFIG_HAVE_DMA_ATTRS */
65static inline void dma_set_attr(enum dma_attr attr, struct dma_attrs *attrs)
66{
67}
68
69static inline int dma_get_attr(enum dma_attr attr, struct dma_attrs *attrs)
70{
71 return 0;
72}
73#endif /* CONFIG_HAVE_DMA_ATTRS */
74#endif /* _DMA_ATTR_H */
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 332030709623..952e0f857ac9 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -146,4 +146,21 @@ static inline void dmam_release_declared_memory(struct device *dev)
146} 146}
147#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */ 147#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */
148 148
149#ifndef CONFIG_HAVE_DMA_ATTRS
150struct dma_attrs;
151
152#define dma_map_single_attrs(dev, cpu_addr, size, dir, attrs) \
153 dma_map_single(dev, cpu_addr, size, dir)
154
155#define dma_unmap_single_attrs(dev, dma_addr, size, dir, attrs) \
156 dma_unmap_single(dev, dma_addr, size, dir)
157
158#define dma_map_sg_attrs(dev, sgl, nents, dir, attrs) \
159 dma_map_sg(dev, sgl, nents, dir)
160
161#define dma_unmap_sg_attrs(dev, sgl, nents, dir, attrs) \
162 dma_unmap_sg(dev, sgl, nents, dir)
163
164#endif /* CONFIG_HAVE_DMA_ATTRS */
165
149#endif 166#endif
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 34d440698293..d08a5c5eb928 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -95,12 +95,17 @@ enum dma_transaction_type {
95#define DMA_TX_TYPE_END (DMA_INTERRUPT + 1) 95#define DMA_TX_TYPE_END (DMA_INTERRUPT + 1)
96 96
97/** 97/**
98 * enum dma_prep_flags - DMA flags to augment operation preparation 98 * enum dma_ctrl_flags - DMA flags to augment operation preparation,
99 * control completion, and communicate status.
99 * @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion of 100 * @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion of
100 * this transaction 101 * this transaction
102 * @DMA_CTRL_ACK - the descriptor cannot be reused until the client
103 * acknowledges receipt, i.e. has has a chance to establish any
104 * dependency chains
101 */ 105 */
102enum dma_prep_flags { 106enum dma_ctrl_flags {
103 DMA_PREP_INTERRUPT = (1 << 0), 107 DMA_PREP_INTERRUPT = (1 << 0),
108 DMA_CTRL_ACK = (1 << 1),
104}; 109};
105 110
106/** 111/**
@@ -211,8 +216,8 @@ typedef void (*dma_async_tx_callback)(void *dma_async_param);
211 * ---dma generic offload fields--- 216 * ---dma generic offload fields---
212 * @cookie: tracking cookie for this transaction, set to -EBUSY if 217 * @cookie: tracking cookie for this transaction, set to -EBUSY if
213 * this tx is sitting on a dependency list 218 * this tx is sitting on a dependency list
214 * @ack: the descriptor can not be reused until the client acknowledges 219 * @flags: flags to augment operation preparation, control completion, and
215 * receipt, i.e. has has a chance to establish any dependency chains 220 * communicate status
216 * @phys: physical address of the descriptor 221 * @phys: physical address of the descriptor
217 * @tx_list: driver common field for operations that require multiple 222 * @tx_list: driver common field for operations that require multiple
218 * descriptors 223 * descriptors
@@ -221,23 +226,20 @@ typedef void (*dma_async_tx_callback)(void *dma_async_param);
221 * @callback: routine to call after this operation is complete 226 * @callback: routine to call after this operation is complete
222 * @callback_param: general parameter to pass to the callback routine 227 * @callback_param: general parameter to pass to the callback routine
223 * ---async_tx api specific fields--- 228 * ---async_tx api specific fields---
224 * @depend_list: at completion this list of transactions are submitted 229 * @next: at completion submit this descriptor
225 * @depend_node: allow this transaction to be executed after another
226 * transaction has completed, possibly on another channel
227 * @parent: pointer to the next level up in the dependency chain 230 * @parent: pointer to the next level up in the dependency chain
228 * @lock: protect the dependency list 231 * @lock: protect the parent and next pointers
229 */ 232 */
230struct dma_async_tx_descriptor { 233struct dma_async_tx_descriptor {
231 dma_cookie_t cookie; 234 dma_cookie_t cookie;
232 int ack; 235 enum dma_ctrl_flags flags; /* not a 'long' to pack with cookie */
233 dma_addr_t phys; 236 dma_addr_t phys;
234 struct list_head tx_list; 237 struct list_head tx_list;
235 struct dma_chan *chan; 238 struct dma_chan *chan;
236 dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx); 239 dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx);
237 dma_async_tx_callback callback; 240 dma_async_tx_callback callback;
238 void *callback_param; 241 void *callback_param;
239 struct list_head depend_list; 242 struct dma_async_tx_descriptor *next;
240 struct list_head depend_node;
241 struct dma_async_tx_descriptor *parent; 243 struct dma_async_tx_descriptor *parent;
242 spinlock_t lock; 244 spinlock_t lock;
243}; 245};
@@ -261,7 +263,6 @@ struct dma_async_tx_descriptor {
261 * @device_prep_dma_zero_sum: prepares a zero_sum operation 263 * @device_prep_dma_zero_sum: prepares a zero_sum operation
262 * @device_prep_dma_memset: prepares a memset operation 264 * @device_prep_dma_memset: prepares a memset operation
263 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation 265 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation
264 * @device_dependency_added: async_tx notifies the channel about new deps
265 * @device_issue_pending: push pending transactions to hardware 266 * @device_issue_pending: push pending transactions to hardware
266 */ 267 */
267struct dma_device { 268struct dma_device {
@@ -294,9 +295,8 @@ struct dma_device {
294 struct dma_chan *chan, dma_addr_t dest, int value, size_t len, 295 struct dma_chan *chan, dma_addr_t dest, int value, size_t len,
295 unsigned long flags); 296 unsigned long flags);
296 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)( 297 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)(
297 struct dma_chan *chan); 298 struct dma_chan *chan, unsigned long flags);
298 299
299 void (*device_dependency_added)(struct dma_chan *chan);
300 enum dma_status (*device_is_tx_complete)(struct dma_chan *chan, 300 enum dma_status (*device_is_tx_complete)(struct dma_chan *chan,
301 dma_cookie_t cookie, dma_cookie_t *last, 301 dma_cookie_t cookie, dma_cookie_t *last,
302 dma_cookie_t *used); 302 dma_cookie_t *used);
@@ -321,7 +321,13 @@ void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx,
321static inline void 321static inline void
322async_tx_ack(struct dma_async_tx_descriptor *tx) 322async_tx_ack(struct dma_async_tx_descriptor *tx)
323{ 323{
324 tx->ack = 1; 324 tx->flags |= DMA_CTRL_ACK;
325}
326
327static inline int
328async_tx_test_ack(struct dma_async_tx_descriptor *tx)
329{
330 return tx->flags & DMA_CTRL_ACK;
325} 331}
326 332
327#define first_dma_cap(mask) __first_dma_cap(&(mask)) 333#define first_dma_cap(mask) __first_dma_cap(&(mask))
@@ -398,7 +404,7 @@ static inline enum dma_status dma_async_is_tx_complete(struct dma_chan *chan,
398 * @last_used: last cookie value handed out 404 * @last_used: last cookie value handed out
399 * 405 *
400 * dma_async_is_complete() is used in dma_async_memcpy_complete() 406 * dma_async_is_complete() is used in dma_async_memcpy_complete()
401 * the test logic is seperated for lightweight testing of multiple cookies 407 * the test logic is separated for lightweight testing of multiple cookies
402 */ 408 */
403static inline enum dma_status dma_async_is_complete(dma_cookie_t cookie, 409static inline enum dma_status dma_async_is_complete(dma_cookie_t cookie,
404 dma_cookie_t last_complete, dma_cookie_t last_used) 410 dma_cookie_t last_complete, dma_cookie_t last_used)
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 325acdf5c462..2a063b64133f 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -90,6 +90,7 @@ static inline int dmi_check_system(const struct dmi_system_id *list) { return 0;
90static inline const char * dmi_get_system_info(int field) { return NULL; } 90static inline const char * dmi_get_system_info(int field) { return NULL; }
91static inline const struct dmi_device * dmi_find_device(int type, const char *name, 91static inline const struct dmi_device * dmi_find_device(int type, const char *name,
92 const struct dmi_device *from) { return NULL; } 92 const struct dmi_device *from) { return NULL; }
93static inline void dmi_scan_machine(void) { return; }
93static inline int dmi_get_year(int year) { return 0; } 94static inline int dmi_get_year(int year) { return 0; }
94static inline int dmi_name_in_vendors(const char *s) { return 0; } 95static inline int dmi_name_in_vendors(const char *s) { return 0; }
95#define dmi_available 0 96#define dmi_available 0
diff --git a/include/linux/dvb/dmx.h b/include/linux/dvb/dmx.h
index c6a2353c4e68..402fb7a8d922 100644
--- a/include/linux/dvb/dmx.h
+++ b/include/linux/dvb/dmx.h
@@ -39,9 +39,10 @@ typedef enum
39 DMX_OUT_DECODER, /* Streaming directly to decoder. */ 39 DMX_OUT_DECODER, /* Streaming directly to decoder. */
40 DMX_OUT_TAP, /* Output going to a memory buffer */ 40 DMX_OUT_TAP, /* Output going to a memory buffer */
41 /* (to be retrieved via the read command).*/ 41 /* (to be retrieved via the read command).*/
42 DMX_OUT_TS_TAP /* Output multiplexed into a new TS */ 42 DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */
43 /* (to be retrieved by reading from the */ 43 /* (to be retrieved by reading from the */
44 /* logical DVR device). */ 44 /* logical DVR device). */
45 DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */
45} dmx_output_t; 46} dmx_output_t;
46 47
47 48
diff --git a/include/linux/edac.h b/include/linux/edac.h
index eab451e69a91..7cf92e8a4196 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Author: Dave Jiang <djiang@mvista.com> 4 * Author: Dave Jiang <djiang@mvista.com>
5 * 5 *
6 * 2006-2007 (c) MontaVista Software, Inc. This file is licensed under 6 * 2006-2008 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program 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 8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied. 9 * or implied.
@@ -26,4 +26,16 @@ extern atomic_t edac_handlers;
26extern int edac_handler_set(void); 26extern int edac_handler_set(void);
27extern void edac_atomic_assert_error(void); 27extern void edac_atomic_assert_error(void);
28 28
29static inline void opstate_init(void)
30{
31 switch (edac_op_state) {
32 case EDAC_OPSTATE_POLL:
33 case EDAC_OPSTATE_NMI:
34 break;
35 default:
36 edac_op_state = EDAC_OPSTATE_POLL;
37 }
38 return;
39}
40
29#endif 41#endif
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 14813b595802..a5f359a7ad0e 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -18,6 +18,7 @@
18#include <linux/proc_fs.h> 18#include <linux/proc_fs.h>
19#include <linux/rtc.h> 19#include <linux/rtc.h>
20#include <linux/ioport.h> 20#include <linux/ioport.h>
21#include <linux/pfn.h>
21 22
22#include <asm/page.h> 23#include <asm/page.h>
23#include <asm/system.h> 24#include <asm/system.h>
@@ -394,4 +395,10 @@ struct efi_generic_dev_path {
394 u16 length; 395 u16 length;
395} __attribute ((packed)); 396} __attribute ((packed));
396 397
398static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
399{
400 *npages = PFN_UP(*addr + (*npages<<EFI_PAGE_SHIFT)) - PFN_DOWN(*addr);
401 *addr &= PAGE_MASK;
402}
403
397#endif /* _LINUX_EFI_H */ 404#endif /* _LINUX_EFI_H */
diff --git a/include/linux/elf.h b/include/linux/elf.h
index bad1b16ec49a..ff9fbed90123 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -208,7 +208,7 @@ typedef struct elf32_hdr{
208} Elf32_Ehdr; 208} Elf32_Ehdr;
209 209
210typedef struct elf64_hdr { 210typedef struct elf64_hdr {
211 unsigned char e_ident[16]; /* ELF "magic number" */ 211 unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */
212 Elf64_Half e_type; 212 Elf64_Half e_type;
213 Elf64_Half e_machine; 213 Elf64_Half e_machine;
214 Elf64_Word e_version; 214 Elf64_Word e_version;
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h
index a5978f18ca40..4332442b1b57 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -82,7 +82,8 @@ struct enclosure_component_callbacks {
82 82
83struct enclosure_component { 83struct enclosure_component {
84 void *scratch; 84 void *scratch;
85 struct class_device cdev; 85 struct device cdev;
86 struct device *dev;
86 enum enclosure_component_type type; 87 enum enclosure_component_type type;
87 int number; 88 int number;
88 int fault; 89 int fault;
@@ -94,20 +95,20 @@ struct enclosure_component {
94struct enclosure_device { 95struct enclosure_device {
95 void *scratch; 96 void *scratch;
96 struct list_head node; 97 struct list_head node;
97 struct class_device cdev; 98 struct device edev;
98 struct enclosure_component_callbacks *cb; 99 struct enclosure_component_callbacks *cb;
99 int components; 100 int components;
100 struct enclosure_component component[0]; 101 struct enclosure_component component[0];
101}; 102};
102 103
103static inline struct enclosure_device * 104static inline struct enclosure_device *
104to_enclosure_device(struct class_device *dev) 105to_enclosure_device(struct device *dev)
105{ 106{
106 return container_of(dev, struct enclosure_device, cdev); 107 return container_of(dev, struct enclosure_device, edev);
107} 108}
108 109
109static inline struct enclosure_component * 110static inline struct enclosure_component *
110to_enclosure_component(struct class_device *dev) 111to_enclosure_component(struct device *dev)
111{ 112{
112 return container_of(dev, struct enclosure_component, cdev); 113 return container_of(dev, struct enclosure_component, cdev);
113} 114}
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h
index b489fc6d0b62..a701399b7fed 100644
--- a/include/linux/eventfd.h
+++ b/include/linux/eventfd.h
@@ -8,9 +8,6 @@
8#ifndef _LINUX_EVENTFD_H 8#ifndef _LINUX_EVENTFD_H
9#define _LINUX_EVENTFD_H 9#define _LINUX_EVENTFD_H
10 10
11
12#ifdef __KERNEL__
13
14#ifdef CONFIG_EVENTFD 11#ifdef CONFIG_EVENTFD
15 12
16struct file *eventfd_fget(int fd); 13struct file *eventfd_fget(int fd);
@@ -24,7 +21,5 @@ static inline int eventfd_signal(struct file *file, int n)
24 21
25#endif /* CONFIG_EVENTFD */ 22#endif /* CONFIG_EVENTFD */
26 23
27#endif /* __KERNEL__ */
28
29#endif /* _LINUX_EVENTFD_H */ 24#endif /* _LINUX_EVENTFD_H */
30 25
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index adcbb05b120b..de8387b7ceb6 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -43,7 +43,7 @@ struct fid {
43 u32 parent_ino; 43 u32 parent_ino;
44 u32 parent_gen; 44 u32 parent_gen;
45 } i32; 45 } i32;
46 __u32 raw[6]; 46 __u32 raw[0];
47 }; 47 };
48}; 48};
49 49
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
deleted file mode 100644
index 250032548597..000000000000
--- a/include/linux/ext4_fs.h
+++ /dev/null
@@ -1,1207 +0,0 @@
1/*
2 * linux/include/linux/ext4_fs.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_H
17#define _LINUX_EXT4_FS_H
18
19#include <linux/types.h>
20#include <linux/blkdev.h>
21#include <linux/magic.h>
22
23#include <linux/ext4_fs_i.h>
24
25/*
26 * The second extended filesystem constants/structures
27 */
28
29/*
30 * Define EXT4FS_DEBUG to produce debug messages
31 */
32#undef EXT4FS_DEBUG
33
34/*
35 * Define EXT4_RESERVATION to reserve data blocks for expanding files
36 */
37#define EXT4_DEFAULT_RESERVE_BLOCKS 8
38/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */
39#define EXT4_MAX_RESERVE_BLOCKS 1027
40#define EXT4_RESERVE_WINDOW_NOT_ALLOCATED 0
41
42/*
43 * Debug code
44 */
45#ifdef EXT4FS_DEBUG
46#define ext4_debug(f, a...) \
47 do { \
48 printk (KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \
49 __FILE__, __LINE__, __FUNCTION__); \
50 printk (KERN_DEBUG f, ## a); \
51 } while (0)
52#else
53#define ext4_debug(f, a...) do {} while (0)
54#endif
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
100/*
101 * Special inodes numbers
102 */
103#define EXT4_BAD_INO 1 /* Bad blocks inode */
104#define EXT4_ROOT_INO 2 /* Root inode */
105#define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */
106#define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
107#define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
108#define EXT4_JOURNAL_INO 8 /* Journal inode */
109
110/* First non-reserved inode for old ext4 filesystems */
111#define EXT4_GOOD_OLD_FIRST_INO 11
112
113/*
114 * Maximal count of links to a file
115 */
116#define EXT4_LINK_MAX 65000
117
118/*
119 * Macro-instructions used to manage several block sizes
120 */
121#define EXT4_MIN_BLOCK_SIZE 1024
122#define EXT4_MAX_BLOCK_SIZE 65536
123#define EXT4_MIN_BLOCK_LOG_SIZE 10
124#ifdef __KERNEL__
125# define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
126#else
127# define EXT4_BLOCK_SIZE(s) (EXT4_MIN_BLOCK_SIZE << (s)->s_log_block_size)
128#endif
129#define EXT4_ADDR_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / sizeof (__u32))
130#ifdef __KERNEL__
131# define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
132#else
133# define EXT4_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
134#endif
135#ifdef __KERNEL__
136#define EXT4_ADDR_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_addr_per_block_bits)
137#define EXT4_INODE_SIZE(s) (EXT4_SB(s)->s_inode_size)
138#define EXT4_FIRST_INO(s) (EXT4_SB(s)->s_first_ino)
139#else
140#define EXT4_INODE_SIZE(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
141 EXT4_GOOD_OLD_INODE_SIZE : \
142 (s)->s_inode_size)
143#define EXT4_FIRST_INO(s) (((s)->s_rev_level == EXT4_GOOD_OLD_REV) ? \
144 EXT4_GOOD_OLD_FIRST_INO : \
145 (s)->s_first_ino)
146#endif
147#define EXT4_BLOCK_ALIGN(size, blkbits) ALIGN((size), (1 << (blkbits)))
148
149/*
150 * Structure of a blocks group descriptor
151 */
152struct ext4_group_desc
153{
154 __le32 bg_block_bitmap_lo; /* Blocks bitmap block */
155 __le32 bg_inode_bitmap_lo; /* Inodes bitmap block */
156 __le32 bg_inode_table_lo; /* Inodes table block */
157 __le16 bg_free_blocks_count; /* Free blocks count */
158 __le16 bg_free_inodes_count; /* Free inodes count */
159 __le16 bg_used_dirs_count; /* Directories count */
160 __le16 bg_flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */
161 __u32 bg_reserved[2]; /* Likely block/inode bitmap checksum */
162 __le16 bg_itable_unused; /* Unused inodes count */
163 __le16 bg_checksum; /* crc16(sb_uuid+group+desc) */
164 __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
165 __le32 bg_inode_bitmap_hi; /* Inodes bitmap 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];
172};
173
174#define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */
175#define EXT4_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not in use */
176#define EXT4_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */
177
178#ifdef __KERNEL__
179#include <linux/ext4_fs_i.h>
180#include <linux/ext4_fs_sb.h>
181#endif
182/*
183 * Macro-instructions used to manage group descriptors
184 */
185#define EXT4_MIN_DESC_SIZE 32
186#define EXT4_MIN_DESC_SIZE_64BIT 64
187#define EXT4_MAX_DESC_SIZE EXT4_MIN_BLOCK_SIZE
188#define EXT4_DESC_SIZE(s) (EXT4_SB(s)->s_desc_size)
189#ifdef __KERNEL__
190# define EXT4_BLOCKS_PER_GROUP(s) (EXT4_SB(s)->s_blocks_per_group)
191# define EXT4_DESC_PER_BLOCK(s) (EXT4_SB(s)->s_desc_per_block)
192# define EXT4_INODES_PER_GROUP(s) (EXT4_SB(s)->s_inodes_per_group)
193# define EXT4_DESC_PER_BLOCK_BITS(s) (EXT4_SB(s)->s_desc_per_block_bits)
194#else
195# define EXT4_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
196# define EXT4_DESC_PER_BLOCK(s) (EXT4_BLOCK_SIZE(s) / EXT4_DESC_SIZE(s))
197# define EXT4_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
198#endif
199
200/*
201 * Constants relative to the data blocks
202 */
203#define EXT4_NDIR_BLOCKS 12
204#define EXT4_IND_BLOCK EXT4_NDIR_BLOCKS
205#define EXT4_DIND_BLOCK (EXT4_IND_BLOCK + 1)
206#define EXT4_TIND_BLOCK (EXT4_DIND_BLOCK + 1)
207#define EXT4_N_BLOCKS (EXT4_TIND_BLOCK + 1)
208
209/*
210 * Inode flags
211 */
212#define EXT4_SECRM_FL 0x00000001 /* Secure deletion */
213#define EXT4_UNRM_FL 0x00000002 /* Undelete */
214#define EXT4_COMPR_FL 0x00000004 /* Compress file */
215#define EXT4_SYNC_FL 0x00000008 /* Synchronous updates */
216#define EXT4_IMMUTABLE_FL 0x00000010 /* Immutable file */
217#define EXT4_APPEND_FL 0x00000020 /* writes to file may only append */
218#define EXT4_NODUMP_FL 0x00000040 /* do not dump file */
219#define EXT4_NOATIME_FL 0x00000080 /* do not update atime */
220/* Reserved for compression usage... */
221#define EXT4_DIRTY_FL 0x00000100
222#define EXT4_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
223#define EXT4_NOCOMPR_FL 0x00000400 /* Don't compress */
224#define EXT4_ECOMPR_FL 0x00000800 /* Compression error */
225/* End compression flags --- maybe not all used */
226#define EXT4_INDEX_FL 0x00001000 /* hash-indexed directory */
227#define EXT4_IMAGIC_FL 0x00002000 /* AFS directory */
228#define EXT4_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
229#define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
230#define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
231#define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
232#define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
233#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
234#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
235
236#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
237#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
238
239/*
240 * Inode dynamic state flags
241 */
242#define EXT4_STATE_JDATA 0x00000001 /* journaled data exists */
243#define EXT4_STATE_NEW 0x00000002 /* inode is newly created */
244#define EXT4_STATE_XATTR 0x00000004 /* has in-inode xattrs */
245#define EXT4_STATE_NO_EXPAND 0x00000008 /* No space for expansion */
246
247/* Used to pass group descriptor data when online resize is done */
248struct ext4_new_group_input {
249 __u32 group; /* Group number for this data */
250 __u64 block_bitmap; /* Absolute block number of block bitmap */
251 __u64 inode_bitmap; /* Absolute block number of inode bitmap */
252 __u64 inode_table; /* Absolute block number of inode table start */
253 __u32 blocks_count; /* Total number of blocks in this group */
254 __u16 reserved_blocks; /* Number of reserved blocks in this group */
255 __u16 unused;
256};
257
258/* The struct ext4_new_group_input in kernel space, with free_blocks_count */
259struct ext4_new_group_data {
260 __u32 group;
261 __u64 block_bitmap;
262 __u64 inode_bitmap;
263 __u64 inode_table;
264 __u32 blocks_count;
265 __u16 reserved_blocks;
266 __u16 unused;
267 __u32 free_blocks_count;
268};
269
270/*
271 * Following is used by preallocation code to tell get_blocks() that we
272 * want uninitialzed extents.
273 */
274#define EXT4_CREATE_UNINITIALIZED_EXT 2
275
276/*
277 * ioctl commands
278 */
279#define EXT4_IOC_GETFLAGS FS_IOC_GETFLAGS
280#define EXT4_IOC_SETFLAGS FS_IOC_SETFLAGS
281#define EXT4_IOC_GETVERSION _IOR('f', 3, long)
282#define EXT4_IOC_SETVERSION _IOW('f', 4, long)
283#define EXT4_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
284#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
285#define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION
286#define EXT4_IOC_SETVERSION_OLD FS_IOC_SETVERSION
287#ifdef CONFIG_JBD2_DEBUG
288#define EXT4_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
289#endif
290#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
291#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
292#define EXT4_IOC_MIGRATE _IO('f', 7)
293
294/*
295 * ioctl commands in 32 bit emulation
296 */
297#define EXT4_IOC32_GETFLAGS FS_IOC32_GETFLAGS
298#define EXT4_IOC32_SETFLAGS FS_IOC32_SETFLAGS
299#define EXT4_IOC32_GETVERSION _IOR('f', 3, int)
300#define EXT4_IOC32_SETVERSION _IOW('f', 4, int)
301#define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
302#define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int)
303#define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
304#ifdef CONFIG_JBD2_DEBUG
305#define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
306#endif
307#define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
308#define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
309
310
311/*
312 * Mount options
313 */
314struct ext4_mount_options {
315 unsigned long s_mount_opt;
316 uid_t s_resuid;
317 gid_t s_resgid;
318 unsigned long s_commit_interval;
319#ifdef CONFIG_QUOTA
320 int s_jquota_fmt;
321 char *s_qf_names[MAXQUOTAS];
322#endif
323};
324
325/*
326 * Structure of an inode on the disk
327 */
328struct ext4_inode {
329 __le16 i_mode; /* File mode */
330 __le16 i_uid; /* Low 16 bits of Owner Uid */
331 __le32 i_size_lo; /* Size in bytes */
332 __le32 i_atime; /* Access time */
333 __le32 i_ctime; /* Inode Change time */
334 __le32 i_mtime; /* Modification time */
335 __le32 i_dtime; /* Deletion Time */
336 __le16 i_gid; /* Low 16 bits of Group Id */
337 __le16 i_links_count; /* Links count */
338 __le32 i_blocks_lo; /* Blocks count */
339 __le32 i_flags; /* File flags */
340 union {
341 struct {
342 __le32 l_i_version;
343 } linux1;
344 struct {
345 __u32 h_i_translator;
346 } hurd1;
347 struct {
348 __u32 m_i_reserved1;
349 } masix1;
350 } osd1; /* OS dependent 1 */
351 __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
352 __le32 i_generation; /* File version (for NFS) */
353 __le32 i_file_acl_lo; /* File ACL */
354 __le32 i_size_high;
355 __le32 i_obso_faddr; /* Obsoleted fragment address */
356 union {
357 struct {
358 __le16 l_i_blocks_high; /* were l_i_reserved1 */
359 __le16 l_i_file_acl_high;
360 __le16 l_i_uid_high; /* these 2 fields */
361 __le16 l_i_gid_high; /* were reserved2[0] */
362 __u32 l_i_reserved2;
363 } linux2;
364 struct {
365 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
366 __u16 h_i_mode_high;
367 __u16 h_i_uid_high;
368 __u16 h_i_gid_high;
369 __u32 h_i_author;
370 } hurd2;
371 struct {
372 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
373 __le16 m_i_file_acl_high;
374 __u32 m_i_reserved2[2];
375 } masix2;
376 } osd2; /* OS dependent 2 */
377 __le16 i_extra_isize;
378 __le16 i_pad1;
379 __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
380 __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */
381 __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
382 __le32 i_crtime; /* File Creation time */
383 __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
384 __le32 i_version_hi; /* high 32 bits for 64-bit version */
385};
386
387
388#define EXT4_EPOCH_BITS 2
389#define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
390#define EXT4_NSEC_MASK (~0UL << EXT4_EPOCH_BITS)
391
392/*
393 * Extended fields will fit into an inode if the filesystem was formatted
394 * with large inodes (-I 256 or larger) and there are not currently any EAs
395 * consuming all of the available space. For new inodes we always reserve
396 * enough space for the kernel's known extended fields, but for inodes
397 * created with an old kernel this might not have been the case. None of
398 * the extended inode fields is critical for correct filesystem operation.
399 * This macro checks if a certain field fits in the inode. Note that
400 * inode-size = GOOD_OLD_INODE_SIZE + i_extra_isize
401 */
402#define EXT4_FITS_IN_INODE(ext4_inode, einode, field) \
403 ((offsetof(typeof(*ext4_inode), field) + \
404 sizeof((ext4_inode)->field)) \
405 <= (EXT4_GOOD_OLD_INODE_SIZE + \
406 (einode)->i_extra_isize)) \
407
408static inline __le32 ext4_encode_extra_time(struct timespec *time)
409{
410 return cpu_to_le32((sizeof(time->tv_sec) > 4 ?
411 time->tv_sec >> 32 : 0) |
412 ((time->tv_nsec << 2) & EXT4_NSEC_MASK));
413}
414
415static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra)
416{
417 if (sizeof(time->tv_sec) > 4)
418 time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK)
419 << 32;
420 time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> 2;
421}
422
423#define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \
424do { \
425 (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \
426 if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \
427 (raw_inode)->xtime ## _extra = \
428 ext4_encode_extra_time(&(inode)->xtime); \
429} while (0)
430
431#define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode) \
432do { \
433 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
434 (raw_inode)->xtime = cpu_to_le32((einode)->xtime.tv_sec); \
435 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
436 (raw_inode)->xtime ## _extra = \
437 ext4_encode_extra_time(&(einode)->xtime); \
438} while (0)
439
440#define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode) \
441do { \
442 (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \
443 if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) \
444 ext4_decode_extra_time(&(inode)->xtime, \
445 raw_inode->xtime ## _extra); \
446} while (0)
447
448#define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode) \
449do { \
450 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
451 (einode)->xtime.tv_sec = \
452 (signed)le32_to_cpu((raw_inode)->xtime); \
453 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
454 ext4_decode_extra_time(&(einode)->xtime, \
455 raw_inode->xtime ## _extra); \
456} while (0)
457
458#define i_disk_version osd1.linux1.l_i_version
459
460#if defined(__KERNEL__) || defined(__linux__)
461#define i_reserved1 osd1.linux1.l_i_reserved1
462#define i_file_acl_high osd2.linux2.l_i_file_acl_high
463#define i_blocks_high osd2.linux2.l_i_blocks_high
464#define i_uid_low i_uid
465#define i_gid_low i_gid
466#define i_uid_high osd2.linux2.l_i_uid_high
467#define i_gid_high osd2.linux2.l_i_gid_high
468#define i_reserved2 osd2.linux2.l_i_reserved2
469
470#elif defined(__GNU__)
471
472#define i_translator osd1.hurd1.h_i_translator
473#define i_uid_high osd2.hurd2.h_i_uid_high
474#define i_gid_high osd2.hurd2.h_i_gid_high
475#define i_author osd2.hurd2.h_i_author
476
477#elif defined(__masix__)
478
479#define i_reserved1 osd1.masix1.m_i_reserved1
480#define i_file_acl_high osd2.masix2.m_i_file_acl_high
481#define i_reserved2 osd2.masix2.m_i_reserved2
482
483#endif /* defined(__KERNEL__) || defined(__linux__) */
484
485/*
486 * File system states
487 */
488#define EXT4_VALID_FS 0x0001 /* Unmounted cleanly */
489#define EXT4_ERROR_FS 0x0002 /* Errors detected */
490#define EXT4_ORPHAN_FS 0x0004 /* Orphans being recovered */
491
492/*
493 * Misc. filesystem flags
494 */
495#define EXT2_FLAGS_SIGNED_HASH 0x0001 /* Signed dirhash in use */
496#define EXT2_FLAGS_UNSIGNED_HASH 0x0002 /* Unsigned dirhash in use */
497#define EXT2_FLAGS_TEST_FILESYS 0x0004 /* to test development code */
498
499/*
500 * Mount flags
501 */
502#define EXT4_MOUNT_CHECK 0x00001 /* Do mount-time checks */
503#define EXT4_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */
504#define EXT4_MOUNT_GRPID 0x00004 /* Create files with directory's group */
505#define EXT4_MOUNT_DEBUG 0x00008 /* Some debugging messages */
506#define EXT4_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */
507#define EXT4_MOUNT_ERRORS_RO 0x00020 /* Remount fs ro on errors */
508#define EXT4_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */
509#define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */
510#define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/
511#define EXT4_MOUNT_ABORT 0x00200 /* Fatal error detected */
512#define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */
513#define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */
514#define EXT4_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */
515#define EXT4_MOUNT_WRITEBACK_DATA 0x00C00 /* No data ordering */
516#define EXT4_MOUNT_UPDATE_JOURNAL 0x01000 /* Update the journal format */
517#define EXT4_MOUNT_NO_UID32 0x02000 /* Disable 32-bit UIDs */
518#define EXT4_MOUNT_XATTR_USER 0x04000 /* Extended user attributes */
519#define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
520#define EXT4_MOUNT_RESERVATION 0x10000 /* Preallocation */
521#define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
522#define EXT4_MOUNT_NOBH 0x40000 /* No bufferheads */
523#define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
524#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
525#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
526#define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
527#define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
528#define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
529#define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
530#define EXT4_MOUNT_MBALLOC 0x4000000 /* Buddy allocation support */
531/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
532#ifndef _LINUX_EXT2_FS_H
533#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
534#define set_opt(o, opt) o |= EXT4_MOUNT_##opt
535#define test_opt(sb, opt) (EXT4_SB(sb)->s_mount_opt & \
536 EXT4_MOUNT_##opt)
537#else
538#define EXT2_MOUNT_NOLOAD EXT4_MOUNT_NOLOAD
539#define EXT2_MOUNT_ABORT EXT4_MOUNT_ABORT
540#define EXT2_MOUNT_DATA_FLAGS EXT4_MOUNT_DATA_FLAGS
541#endif
542
543#define ext4_set_bit ext2_set_bit
544#define ext4_set_bit_atomic ext2_set_bit_atomic
545#define ext4_clear_bit ext2_clear_bit
546#define ext4_clear_bit_atomic ext2_clear_bit_atomic
547#define ext4_test_bit ext2_test_bit
548#define ext4_find_first_zero_bit ext2_find_first_zero_bit
549#define ext4_find_next_zero_bit ext2_find_next_zero_bit
550#define ext4_find_next_bit ext2_find_next_bit
551
552/*
553 * Maximal mount counts between two filesystem checks
554 */
555#define EXT4_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
556#define EXT4_DFL_CHECKINTERVAL 0 /* Don't use interval check */
557
558/*
559 * Behaviour when detecting errors
560 */
561#define EXT4_ERRORS_CONTINUE 1 /* Continue execution */
562#define EXT4_ERRORS_RO 2 /* Remount fs read-only */
563#define EXT4_ERRORS_PANIC 3 /* Panic */
564#define EXT4_ERRORS_DEFAULT EXT4_ERRORS_CONTINUE
565
566/*
567 * Structure of the super block
568 */
569struct ext4_super_block {
570/*00*/ __le32 s_inodes_count; /* Inodes count */
571 __le32 s_blocks_count_lo; /* Blocks count */
572 __le32 s_r_blocks_count_lo; /* Reserved blocks count */
573 __le32 s_free_blocks_count_lo; /* Free blocks count */
574/*10*/ __le32 s_free_inodes_count; /* Free inodes count */
575 __le32 s_first_data_block; /* First Data Block */
576 __le32 s_log_block_size; /* Block size */
577 __le32 s_obso_log_frag_size; /* Obsoleted fragment size */
578/*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
579 __le32 s_obso_frags_per_group; /* Obsoleted fragments per group */
580 __le32 s_inodes_per_group; /* # Inodes per group */
581 __le32 s_mtime; /* Mount time */
582/*30*/ __le32 s_wtime; /* Write time */
583 __le16 s_mnt_count; /* Mount count */
584 __le16 s_max_mnt_count; /* Maximal mount count */
585 __le16 s_magic; /* Magic signature */
586 __le16 s_state; /* File system state */
587 __le16 s_errors; /* Behaviour when detecting errors */
588 __le16 s_minor_rev_level; /* minor revision level */
589/*40*/ __le32 s_lastcheck; /* time of last check */
590 __le32 s_checkinterval; /* max. time between checks */
591 __le32 s_creator_os; /* OS */
592 __le32 s_rev_level; /* Revision level */
593/*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
594 __le16 s_def_resgid; /* Default gid for reserved blocks */
595 /*
596 * These fields are for EXT4_DYNAMIC_REV superblocks only.
597 *
598 * Note: the difference between the compatible feature set and
599 * the incompatible feature set is that if there is a bit set
600 * in the incompatible feature set that the kernel doesn't
601 * know about, it should refuse to mount the filesystem.
602 *
603 * e2fsck's requirements are more strict; if it doesn't know
604 * about a feature in either the compatible or incompatible
605 * feature set, it must abort and not try to meddle with
606 * things it doesn't understand...
607 */
608 __le32 s_first_ino; /* First non-reserved inode */
609 __le16 s_inode_size; /* size of inode structure */
610 __le16 s_block_group_nr; /* block group # of this superblock */
611 __le32 s_feature_compat; /* compatible feature set */
612/*60*/ __le32 s_feature_incompat; /* incompatible feature set */
613 __le32 s_feature_ro_compat; /* readonly-compatible feature set */
614/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
615/*78*/ char s_volume_name[16]; /* volume name */
616/*88*/ char s_last_mounted[64]; /* directory where last mounted */
617/*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
618 /*
619 * Performance hints. Directory preallocation should only
620 * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
621 */
622 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
623 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
624 __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
625 /*
626 * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
627 */
628/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
629/*E0*/ __le32 s_journal_inum; /* inode number of journal file */
630 __le32 s_journal_dev; /* device number of journal file */
631 __le32 s_last_orphan; /* start of list of inodes to delete */
632 __le32 s_hash_seed[4]; /* HTREE hash seed */
633 __u8 s_def_hash_version; /* Default hash version to use */
634 __u8 s_reserved_char_pad;
635 __le16 s_desc_size; /* size of group descriptor */
636/*100*/ __le32 s_default_mount_opts;
637 __le32 s_first_meta_bg; /* First metablock block group */
638 __le32 s_mkfs_time; /* When the filesystem was created */
639 __le32 s_jnl_blocks[17]; /* Backup of the journal inode */
640 /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
641/*150*/ __le32 s_blocks_count_hi; /* Blocks count */
642 __le32 s_r_blocks_count_hi; /* Reserved blocks count */
643 __le32 s_free_blocks_count_hi; /* Free blocks count */
644 __le16 s_min_extra_isize; /* All inodes have at least # bytes */
645 __le16 s_want_extra_isize; /* New inodes should reserve # bytes */
646 __le32 s_flags; /* Miscellaneous flags */
647 __le16 s_raid_stride; /* RAID stride */
648 __le16 s_mmp_interval; /* # seconds to wait in MMP checking */
649 __le64 s_mmp_block; /* Block for multi-mount protection */
650 __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
651 __u32 s_reserved[163]; /* Padding to the end of the block */
652};
653
654#ifdef __KERNEL__
655static inline struct ext4_sb_info * EXT4_SB(struct super_block *sb)
656{
657 return sb->s_fs_info;
658}
659static inline struct ext4_inode_info *EXT4_I(struct inode *inode)
660{
661 return container_of(inode, struct ext4_inode_info, vfs_inode);
662}
663
664static inline struct timespec ext4_current_time(struct inode *inode)
665{
666 return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
667 current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
668}
669
670
671static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
672{
673 return ino == EXT4_ROOT_INO ||
674 ino == EXT4_JOURNAL_INO ||
675 ino == EXT4_RESIZE_INO ||
676 (ino >= EXT4_FIRST_INO(sb) &&
677 ino <= le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count));
678}
679#else
680/* Assume that user mode programs are passing in an ext4fs superblock, not
681 * a kernel struct super_block. This will allow us to call the feature-test
682 * macros from user land. */
683#define EXT4_SB(sb) (sb)
684#endif
685
686#define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
687
688/*
689 * Codes for operating systems
690 */
691#define EXT4_OS_LINUX 0
692#define EXT4_OS_HURD 1
693#define EXT4_OS_MASIX 2
694#define EXT4_OS_FREEBSD 3
695#define EXT4_OS_LITES 4
696
697/*
698 * Revision levels
699 */
700#define EXT4_GOOD_OLD_REV 0 /* The good old (original) format */
701#define EXT4_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
702
703#define EXT4_CURRENT_REV EXT4_GOOD_OLD_REV
704#define EXT4_MAX_SUPP_REV EXT4_DYNAMIC_REV
705
706#define EXT4_GOOD_OLD_INODE_SIZE 128
707
708/*
709 * Feature set definitions
710 */
711
712#define EXT4_HAS_COMPAT_FEATURE(sb,mask) \
713 ( EXT4_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
714#define EXT4_HAS_RO_COMPAT_FEATURE(sb,mask) \
715 ( EXT4_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
716#define EXT4_HAS_INCOMPAT_FEATURE(sb,mask) \
717 ( EXT4_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
718#define EXT4_SET_COMPAT_FEATURE(sb,mask) \
719 EXT4_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
720#define EXT4_SET_RO_COMPAT_FEATURE(sb,mask) \
721 EXT4_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
722#define EXT4_SET_INCOMPAT_FEATURE(sb,mask) \
723 EXT4_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
724#define EXT4_CLEAR_COMPAT_FEATURE(sb,mask) \
725 EXT4_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
726#define EXT4_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
727 EXT4_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
728#define EXT4_CLEAR_INCOMPAT_FEATURE(sb,mask) \
729 EXT4_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
730
731#define EXT4_FEATURE_COMPAT_DIR_PREALLOC 0x0001
732#define EXT4_FEATURE_COMPAT_IMAGIC_INODES 0x0002
733#define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004
734#define EXT4_FEATURE_COMPAT_EXT_ATTR 0x0008
735#define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
736#define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
737
738#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
739#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
740#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
741#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
742#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
743#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
744#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
745
746#define EXT4_FEATURE_INCOMPAT_COMPRESSION 0x0001
747#define EXT4_FEATURE_INCOMPAT_FILETYPE 0x0002
748#define EXT4_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
749#define EXT4_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
750#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
751#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
752#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
753#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
754#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
755
756#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
757#define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
758 EXT4_FEATURE_INCOMPAT_RECOVER| \
759 EXT4_FEATURE_INCOMPAT_META_BG| \
760 EXT4_FEATURE_INCOMPAT_EXTENTS| \
761 EXT4_FEATURE_INCOMPAT_64BIT| \
762 EXT4_FEATURE_INCOMPAT_FLEX_BG)
763#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
764 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
765 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
766 EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
767 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
768 EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\
769 EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
770
771/*
772 * Default values for user and/or group using reserved blocks
773 */
774#define EXT4_DEF_RESUID 0
775#define EXT4_DEF_RESGID 0
776
777/*
778 * Default mount options
779 */
780#define EXT4_DEFM_DEBUG 0x0001
781#define EXT4_DEFM_BSDGROUPS 0x0002
782#define EXT4_DEFM_XATTR_USER 0x0004
783#define EXT4_DEFM_ACL 0x0008
784#define EXT4_DEFM_UID16 0x0010
785#define EXT4_DEFM_JMODE 0x0060
786#define EXT4_DEFM_JMODE_DATA 0x0020
787#define EXT4_DEFM_JMODE_ORDERED 0x0040
788#define EXT4_DEFM_JMODE_WBACK 0x0060
789
790/*
791 * Structure of a directory entry
792 */
793#define EXT4_NAME_LEN 255
794
795struct ext4_dir_entry {
796 __le32 inode; /* Inode number */
797 __le16 rec_len; /* Directory entry length */
798 __le16 name_len; /* Name length */
799 char name[EXT4_NAME_LEN]; /* File name */
800};
801
802/*
803 * The new version of the directory entry. Since EXT4 structures are
804 * stored in intel byte order, and the name_len field could never be
805 * bigger than 255 chars, it's safe to reclaim the extra byte for the
806 * file_type field.
807 */
808struct ext4_dir_entry_2 {
809 __le32 inode; /* Inode number */
810 __le16 rec_len; /* Directory entry length */
811 __u8 name_len; /* Name length */
812 __u8 file_type;
813 char name[EXT4_NAME_LEN]; /* File name */
814};
815
816/*
817 * Ext4 directory file types. Only the low 3 bits are used. The
818 * other bits are reserved for now.
819 */
820#define EXT4_FT_UNKNOWN 0
821#define EXT4_FT_REG_FILE 1
822#define EXT4_FT_DIR 2
823#define EXT4_FT_CHRDEV 3
824#define EXT4_FT_BLKDEV 4
825#define EXT4_FT_FIFO 5
826#define EXT4_FT_SOCK 6
827#define EXT4_FT_SYMLINK 7
828
829#define EXT4_FT_MAX 8
830
831/*
832 * EXT4_DIR_PAD defines the directory entries boundaries
833 *
834 * NOTE: It must be a multiple of 4
835 */
836#define EXT4_DIR_PAD 4
837#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
838#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \
839 ~EXT4_DIR_ROUND)
840#define EXT4_MAX_REC_LEN ((1<<16)-1)
841
842static inline unsigned ext4_rec_len_from_disk(__le16 dlen)
843{
844 unsigned len = le16_to_cpu(dlen);
845
846 if (len == EXT4_MAX_REC_LEN)
847 return 1 << 16;
848 return len;
849}
850
851static inline __le16 ext4_rec_len_to_disk(unsigned len)
852{
853 if (len == (1 << 16))
854 return cpu_to_le16(EXT4_MAX_REC_LEN);
855 else if (len > (1 << 16))
856 BUG();
857 return cpu_to_le16(len);
858}
859
860/*
861 * Hash Tree Directory indexing
862 * (c) Daniel Phillips, 2001
863 */
864
865#define is_dx(dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \
866 EXT4_FEATURE_COMPAT_DIR_INDEX) && \
867 (EXT4_I(dir)->i_flags & EXT4_INDEX_FL))
868#define EXT4_DIR_LINK_MAX(dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)
869#define EXT4_DIR_LINK_EMPTY(dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1)
870
871/* Legal values for the dx_root hash_version field: */
872
873#define DX_HASH_LEGACY 0
874#define DX_HASH_HALF_MD4 1
875#define DX_HASH_TEA 2
876
877#ifdef __KERNEL__
878
879/* hash info structure used by the directory hash */
880struct dx_hash_info
881{
882 u32 hash;
883 u32 minor_hash;
884 int hash_version;
885 u32 *seed;
886};
887
888#define EXT4_HTREE_EOF 0x7fffffff
889
890/*
891 * Control parameters used by ext4_htree_next_block
892 */
893#define HASH_NB_ALWAYS 1
894
895
896/*
897 * Describe an inode's exact location on disk and in memory
898 */
899struct ext4_iloc
900{
901 struct buffer_head *bh;
902 unsigned long offset;
903 ext4_group_t block_group;
904};
905
906static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
907{
908 return (struct ext4_inode *) (iloc->bh->b_data + iloc->offset);
909}
910
911/*
912 * This structure is stuffed into the struct file's private_data field
913 * for directories. It is where we put information so that we can do
914 * readdir operations in hash tree order.
915 */
916struct dir_private_info {
917 struct rb_root root;
918 struct rb_node *curr_node;
919 struct fname *extra_fname;
920 loff_t last_pos;
921 __u32 curr_hash;
922 __u32 curr_minor_hash;
923 __u32 next_hash;
924};
925
926/* calculate the first block number of the group */
927static inline ext4_fsblk_t
928ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
929{
930 return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
931 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
932}
933
934/*
935 * Special error return code only used by dx_probe() and its callers.
936 */
937#define ERR_BAD_DX_DIR -75000
938
939void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
940 unsigned long *blockgrpp, ext4_grpblk_t *offsetp);
941
942/*
943 * Function prototypes
944 */
945
946/*
947 * Ok, these declarations are also in <linux/kernel.h> but none of the
948 * ext4 source programs needs to include it so they are duplicated here.
949 */
950# define NORET_TYPE /**/
951# define ATTRIB_NORET __attribute__((noreturn))
952# define NORET_AND noreturn,
953
954/* balloc.c */
955extern unsigned int ext4_block_group(struct super_block *sb,
956 ext4_fsblk_t blocknr);
957extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
958 ext4_fsblk_t blocknr);
959extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group);
960extern unsigned long ext4_bg_num_gdb(struct super_block *sb,
961 ext4_group_t group);
962extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode,
963 ext4_fsblk_t goal, int *errp);
964extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode,
965 ext4_fsblk_t goal, unsigned long *count, int *errp);
966extern ext4_fsblk_t ext4_new_blocks_old(handle_t *handle, struct inode *inode,
967 ext4_fsblk_t goal, unsigned long *count, int *errp);
968extern void ext4_free_blocks (handle_t *handle, struct inode *inode,
969 ext4_fsblk_t block, unsigned long count, int metadata);
970extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
971 ext4_fsblk_t block, unsigned long count,
972 unsigned long *pdquot_freed_blocks);
973extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *);
974extern void ext4_check_blocks_bitmap (struct super_block *);
975extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
976 ext4_group_t block_group,
977 struct buffer_head ** bh);
978extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
979extern void ext4_init_block_alloc_info(struct inode *);
980extern void ext4_rsv_window_add(struct super_block *sb, struct ext4_reserve_window_node *rsv);
981
982/* dir.c */
983extern int ext4_check_dir_entry(const char *, struct inode *,
984 struct ext4_dir_entry_2 *,
985 struct buffer_head *, unsigned long);
986extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
987 __u32 minor_hash,
988 struct ext4_dir_entry_2 *dirent);
989extern void ext4_htree_free_dir_info(struct dir_private_info *p);
990
991/* fsync.c */
992extern int ext4_sync_file (struct file *, struct dentry *, int);
993
994/* hash.c */
995extern int ext4fs_dirhash(const char *name, int len, struct
996 dx_hash_info *hinfo);
997
998/* ialloc.c */
999extern struct inode * ext4_new_inode (handle_t *, struct inode *, int);
1000extern void ext4_free_inode (handle_t *, struct inode *);
1001extern struct inode * ext4_orphan_get (struct super_block *, unsigned long);
1002extern unsigned long ext4_count_free_inodes (struct super_block *);
1003extern unsigned long ext4_count_dirs (struct super_block *);
1004extern void ext4_check_inodes_bitmap (struct super_block *);
1005extern unsigned long ext4_count_free (struct buffer_head *, unsigned);
1006
1007/* mballoc.c */
1008extern long ext4_mb_stats;
1009extern long ext4_mb_max_to_scan;
1010extern int ext4_mb_init(struct super_block *, int);
1011extern int ext4_mb_release(struct super_block *);
1012extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
1013 struct ext4_allocation_request *, int *);
1014extern int ext4_mb_reserve_blocks(struct super_block *, int);
1015extern void ext4_mb_discard_inode_preallocations(struct inode *);
1016extern int __init init_ext4_mballoc(void);
1017extern void exit_ext4_mballoc(void);
1018extern void ext4_mb_free_blocks(handle_t *, struct inode *,
1019 unsigned long, unsigned long, int, unsigned long *);
1020
1021
1022/* inode.c */
1023int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
1024 struct buffer_head *bh, ext4_fsblk_t blocknr);
1025struct buffer_head *ext4_getblk(handle_t *, struct inode *,
1026 ext4_lblk_t, int, int *);
1027struct buffer_head *ext4_bread(handle_t *, struct inode *,
1028 ext4_lblk_t, int, int *);
1029int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
1030 ext4_lblk_t iblock, unsigned long maxblocks,
1031 struct buffer_head *bh_result,
1032 int create, int extend_disksize);
1033
1034extern struct inode *ext4_iget(struct super_block *, unsigned long);
1035extern int ext4_write_inode (struct inode *, int);
1036extern int ext4_setattr (struct dentry *, struct iattr *);
1037extern void ext4_delete_inode (struct inode *);
1038extern int ext4_sync_inode (handle_t *, struct inode *);
1039extern void ext4_discard_reservation (struct inode *);
1040extern void ext4_dirty_inode(struct inode *);
1041extern int ext4_change_inode_journal_flag(struct inode *, int);
1042extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
1043extern void ext4_truncate (struct inode *);
1044extern void ext4_set_inode_flags(struct inode *);
1045extern void ext4_get_inode_flags(struct ext4_inode_info *);
1046extern void ext4_set_aops(struct inode *inode);
1047extern int ext4_writepage_trans_blocks(struct inode *);
1048extern int ext4_block_truncate_page(handle_t *handle, struct page *page,
1049 struct address_space *mapping, loff_t from);
1050
1051/* ioctl.c */
1052extern int ext4_ioctl (struct inode *, struct file *, unsigned int,
1053 unsigned long);
1054extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
1055
1056/* migrate.c */
1057extern int ext4_ext_migrate(struct inode *, struct file *, unsigned int,
1058 unsigned long);
1059/* namei.c */
1060extern int ext4_orphan_add(handle_t *, struct inode *);
1061extern int ext4_orphan_del(handle_t *, struct inode *);
1062extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
1063 __u32 start_minor_hash, __u32 *next_hash);
1064
1065/* resize.c */
1066extern int ext4_group_add(struct super_block *sb,
1067 struct ext4_new_group_data *input);
1068extern int ext4_group_extend(struct super_block *sb,
1069 struct ext4_super_block *es,
1070 ext4_fsblk_t n_blocks_count);
1071
1072/* super.c */
1073extern void ext4_error (struct super_block *, const char *, const char *, ...)
1074 __attribute__ ((format (printf, 3, 4)));
1075extern void __ext4_std_error (struct super_block *, const char *, int);
1076extern void ext4_abort (struct super_block *, const char *, const char *, ...)
1077 __attribute__ ((format (printf, 3, 4)));
1078extern void ext4_warning (struct super_block *, const char *, const char *, ...)
1079 __attribute__ ((format (printf, 3, 4)));
1080extern void ext4_update_dynamic_rev (struct super_block *sb);
1081extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
1082 __u32 compat);
1083extern int ext4_update_rocompat_feature(handle_t *handle,
1084 struct super_block *sb, __u32 rocompat);
1085extern int ext4_update_incompat_feature(handle_t *handle,
1086 struct super_block *sb, __u32 incompat);
1087extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
1088 struct ext4_group_desc *bg);
1089extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
1090 struct ext4_group_desc *bg);
1091extern ext4_fsblk_t ext4_inode_table(struct super_block *sb,
1092 struct ext4_group_desc *bg);
1093extern void ext4_block_bitmap_set(struct super_block *sb,
1094 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1095extern void ext4_inode_bitmap_set(struct super_block *sb,
1096 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1097extern void ext4_inode_table_set(struct super_block *sb,
1098 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1099
1100static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
1101{
1102 return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
1103 le32_to_cpu(es->s_blocks_count_lo);
1104}
1105
1106static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es)
1107{
1108 return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
1109 le32_to_cpu(es->s_r_blocks_count_lo);
1110}
1111
1112static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)
1113{
1114 return ((ext4_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
1115 le32_to_cpu(es->s_free_blocks_count_lo);
1116}
1117
1118static inline void ext4_blocks_count_set(struct ext4_super_block *es,
1119 ext4_fsblk_t blk)
1120{
1121 es->s_blocks_count_lo = cpu_to_le32((u32)blk);
1122 es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
1123}
1124
1125static inline void ext4_free_blocks_count_set(struct ext4_super_block *es,
1126 ext4_fsblk_t blk)
1127{
1128 es->s_free_blocks_count_lo = cpu_to_le32((u32)blk);
1129 es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
1130}
1131
1132static inline void ext4_r_blocks_count_set(struct ext4_super_block *es,
1133 ext4_fsblk_t blk)
1134{
1135 es->s_r_blocks_count_lo = cpu_to_le32((u32)blk);
1136 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
1137}
1138
1139static inline loff_t ext4_isize(struct ext4_inode *raw_inode)
1140{
1141 return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) |
1142 le32_to_cpu(raw_inode->i_size_lo);
1143}
1144
1145static inline void ext4_isize_set(struct ext4_inode *raw_inode, loff_t i_size)
1146{
1147 raw_inode->i_size_lo = cpu_to_le32(i_size);
1148 raw_inode->i_size_high = cpu_to_le32(i_size >> 32);
1149}
1150
1151static inline
1152struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
1153 ext4_group_t group)
1154{
1155 struct ext4_group_info ***grp_info;
1156 long indexv, indexh;
1157 grp_info = EXT4_SB(sb)->s_group_info;
1158 indexv = group >> (EXT4_DESC_PER_BLOCK_BITS(sb));
1159 indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1);
1160 return grp_info[indexv][indexh];
1161}
1162
1163
1164#define ext4_std_error(sb, errno) \
1165do { \
1166 if ((errno)) \
1167 __ext4_std_error((sb), __FUNCTION__, (errno)); \
1168} while (0)
1169
1170/*
1171 * Inodes and files operations
1172 */
1173
1174/* dir.c */
1175extern const struct file_operations ext4_dir_operations;
1176
1177/* file.c */
1178extern const struct inode_operations ext4_file_inode_operations;
1179extern const struct file_operations ext4_file_operations;
1180
1181/* namei.c */
1182extern const struct inode_operations ext4_dir_inode_operations;
1183extern const struct inode_operations ext4_special_inode_operations;
1184
1185/* symlink.c */
1186extern const struct inode_operations ext4_symlink_inode_operations;
1187extern const struct inode_operations ext4_fast_symlink_inode_operations;
1188
1189/* extents.c */
1190extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
1191extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
1192extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1193 ext4_lblk_t iblock,
1194 unsigned long max_blocks, struct buffer_head *bh_result,
1195 int create, int extend_disksize);
1196extern void ext4_ext_truncate(struct inode *, struct page *);
1197extern void ext4_ext_init(struct super_block *);
1198extern void ext4_ext_release(struct super_block *);
1199extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
1200 loff_t len);
1201extern int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode,
1202 sector_t block, unsigned long max_blocks,
1203 struct buffer_head *bh, int create,
1204 int extend_disksize);
1205#endif /* __KERNEL__ */
1206
1207#endif /* _LINUX_EXT4_FS_H */
diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
deleted file mode 100644
index 1285c583b2d8..000000000000
--- a/include/linux/ext4_fs_extents.h
+++ /dev/null
@@ -1,232 +0,0 @@
1/*
2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
3 * Written by Alex Tomas <alex@clusterfs.com>
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 version 2 as
7 * published by the Free Software Foundation.
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 Licens
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
17 */
18
19#ifndef _LINUX_EXT4_EXTENTS
20#define _LINUX_EXT4_EXTENTS
21
22#include <linux/ext4_fs.h>
23
24/*
25 * With AGGRESSIVE_TEST defined, the capacity of index/leaf blocks
26 * becomes very small, so index split, in-depth growing and
27 * other hard changes happen much more often.
28 * This is for debug purposes only.
29 */
30#define AGGRESSIVE_TEST_
31
32/*
33 * With EXTENTS_STATS defined, the number of blocks and extents
34 * are collected in the truncate path. They'll be shown at
35 * umount time.
36 */
37#define EXTENTS_STATS__
38
39/*
40 * If CHECK_BINSEARCH is defined, then the results of the binary search
41 * will also be checked by linear search.
42 */
43#define CHECK_BINSEARCH__
44
45/*
46 * If EXT_DEBUG is defined you can use the 'extdebug' mount option
47 * to get lots of info about what's going on.
48 */
49#define EXT_DEBUG__
50#ifdef EXT_DEBUG
51#define ext_debug(a...) printk(a)
52#else
53#define ext_debug(a...)
54#endif
55
56/*
57 * If EXT_STATS is defined then stats numbers are collected.
58 * These number will be displayed at umount time.
59 */
60#define EXT_STATS_
61
62
63/*
64 * ext4_inode has i_block array (60 bytes total).
65 * The first 12 bytes store ext4_extent_header;
66 * the remainder stores an array of ext4_extent.
67 */
68
69/*
70 * This is the extent on-disk structure.
71 * It's used at the bottom of the tree.
72 */
73struct ext4_extent {
74 __le32 ee_block; /* first logical block extent covers */
75 __le16 ee_len; /* number of blocks covered by extent */
76 __le16 ee_start_hi; /* high 16 bits of physical block */
77 __le32 ee_start_lo; /* low 32 bits of physical block */
78};
79
80/*
81 * This is index on-disk structure.
82 * It's used at all the levels except the bottom.
83 */
84struct ext4_extent_idx {
85 __le32 ei_block; /* index covers logical blocks from 'block' */
86 __le32 ei_leaf_lo; /* pointer to the physical block of the next *
87 * level. leaf or next index could be there */
88 __le16 ei_leaf_hi; /* high 16 bits of physical block */
89 __u16 ei_unused;
90};
91
92/*
93 * Each block (leaves and indexes), even inode-stored has header.
94 */
95struct ext4_extent_header {
96 __le16 eh_magic; /* probably will support different formats */
97 __le16 eh_entries; /* number of valid entries */
98 __le16 eh_max; /* capacity of store in entries */
99 __le16 eh_depth; /* has tree real underlying blocks? */
100 __le32 eh_generation; /* generation of the tree */
101};
102
103#define EXT4_EXT_MAGIC cpu_to_le16(0xf30a)
104
105/*
106 * Array of ext4_ext_path contains path to some extent.
107 * Creation/lookup routines use it for traversal/splitting/etc.
108 * Truncate uses it to simulate recursive walking.
109 */
110struct ext4_ext_path {
111 ext4_fsblk_t p_block;
112 __u16 p_depth;
113 struct ext4_extent *p_ext;
114 struct ext4_extent_idx *p_idx;
115 struct ext4_extent_header *p_hdr;
116 struct buffer_head *p_bh;
117};
118
119/*
120 * structure for external API
121 */
122
123#define EXT4_EXT_CACHE_NO 0
124#define EXT4_EXT_CACHE_GAP 1
125#define EXT4_EXT_CACHE_EXTENT 2
126
127
128#define EXT_MAX_BLOCK 0xffffffff
129
130/*
131 * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
132 * initialized extent. This is 2^15 and not (2^16 - 1), since we use the
133 * MSB of ee_len field in the extent datastructure to signify if this
134 * particular extent is an initialized extent or an uninitialized (i.e.
135 * preallocated).
136 * EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
137 * uninitialized extent.
138 * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
139 * uninitialized one. In other words, if MSB of ee_len is set, it is an
140 * uninitialized extent with only one special scenario when ee_len = 0x8000.
141 * In this case we can not have an uninitialized extent of zero length and
142 * thus we make it as a special case of initialized extent with 0x8000 length.
143 * This way we get better extent-to-group alignment for initialized extents.
144 * Hence, the maximum number of blocks we can have in an *initialized*
145 * extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
146 */
147#define EXT_INIT_MAX_LEN (1UL << 15)
148#define EXT_UNINIT_MAX_LEN (EXT_INIT_MAX_LEN - 1)
149
150
151#define EXT_FIRST_EXTENT(__hdr__) \
152 ((struct ext4_extent *) (((char *) (__hdr__)) + \
153 sizeof(struct ext4_extent_header)))
154#define EXT_FIRST_INDEX(__hdr__) \
155 ((struct ext4_extent_idx *) (((char *) (__hdr__)) + \
156 sizeof(struct ext4_extent_header)))
157#define EXT_HAS_FREE_INDEX(__path__) \
158 (le16_to_cpu((__path__)->p_hdr->eh_entries) \
159 < le16_to_cpu((__path__)->p_hdr->eh_max))
160#define EXT_LAST_EXTENT(__hdr__) \
161 (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
162#define EXT_LAST_INDEX(__hdr__) \
163 (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
164#define EXT_MAX_EXTENT(__hdr__) \
165 (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
166#define EXT_MAX_INDEX(__hdr__) \
167 (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
168
169static inline struct ext4_extent_header *ext_inode_hdr(struct inode *inode)
170{
171 return (struct ext4_extent_header *) EXT4_I(inode)->i_data;
172}
173
174static inline struct ext4_extent_header *ext_block_hdr(struct buffer_head *bh)
175{
176 return (struct ext4_extent_header *) bh->b_data;
177}
178
179static inline unsigned short ext_depth(struct inode *inode)
180{
181 return le16_to_cpu(ext_inode_hdr(inode)->eh_depth);
182}
183
184static inline void ext4_ext_tree_changed(struct inode *inode)
185{
186 EXT4_I(inode)->i_ext_generation++;
187}
188
189static inline void
190ext4_ext_invalidate_cache(struct inode *inode)
191{
192 EXT4_I(inode)->i_cached_extent.ec_type = EXT4_EXT_CACHE_NO;
193}
194
195static inline void ext4_ext_mark_uninitialized(struct ext4_extent *ext)
196{
197 /* We can not have an uninitialized extent of zero length! */
198 BUG_ON((le16_to_cpu(ext->ee_len) & ~EXT_INIT_MAX_LEN) == 0);
199 ext->ee_len |= cpu_to_le16(EXT_INIT_MAX_LEN);
200}
201
202static inline int ext4_ext_is_uninitialized(struct ext4_extent *ext)
203{
204 /* Extent with ee_len of 0x8000 is treated as an initialized extent */
205 return (le16_to_cpu(ext->ee_len) > EXT_INIT_MAX_LEN);
206}
207
208static inline int ext4_ext_get_actual_len(struct ext4_extent *ext)
209{
210 return (le16_to_cpu(ext->ee_len) <= EXT_INIT_MAX_LEN ?
211 le16_to_cpu(ext->ee_len) :
212 (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
213}
214
215extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
216extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
217extern int ext4_extent_tree_init(handle_t *, struct inode *);
218extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *);
219extern int ext4_ext_try_to_merge(struct inode *inode,
220 struct ext4_ext_path *path,
221 struct ext4_extent *);
222extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *);
223extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *);
224extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
225 struct ext4_ext_path *);
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 *);
230extern void ext4_ext_drop_refs(struct ext4_ext_path *);
231#endif /* _LINUX_EXT4_EXTENTS */
232
diff --git a/include/linux/ext4_fs_i.h b/include/linux/ext4_fs_i.h
deleted file mode 100644
index d5508d3cf290..000000000000
--- a/include/linux/ext4_fs_i.h
+++ /dev/null
@@ -1,167 +0,0 @@
1/*
2 * linux/include/linux/ext4_fs_i.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_i.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_I
17#define _LINUX_EXT4_FS_I
18
19#include <linux/rwsem.h>
20#include <linux/rbtree.h>
21#include <linux/seqlock.h>
22#include <linux/mutex.h>
23
24/* data type for block offset of block group */
25typedef int ext4_grpblk_t;
26
27/* data type for filesystem-wide blocks number */
28typedef unsigned long long ext4_fsblk_t;
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
36struct ext4_reserve_window {
37 ext4_fsblk_t _rsv_start; /* First byte reserved */
38 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */
39};
40
41struct ext4_reserve_window_node {
42 struct rb_node rsv_node;
43 __u32 rsv_goal_size;
44 __u32 rsv_alloc_hit;
45 struct ext4_reserve_window rsv_window;
46};
47
48struct ext4_block_alloc_info {
49 /* information about reservation window */
50 struct ext4_reserve_window_node rsv_window_node;
51 /*
52 * was i_next_alloc_block in ext4_inode_info
53 * is the logical (file-relative) number of the
54 * most-recently-allocated block in this file.
55 * We use this for detecting linearly ascending allocation requests.
56 */
57 ext4_lblk_t last_alloc_logical_block;
58 /*
59 * Was i_next_alloc_goal in ext4_inode_info
60 * is the *physical* companion to i_next_alloc_block.
61 * it the physical block number of the block which was most-recentl
62 * allocated to this file. This give us the goal (target) for the next
63 * allocation when we detect linearly ascending requests.
64 */
65 ext4_fsblk_t last_alloc_physical_block;
66};
67
68#define rsv_start rsv_window._rsv_start
69#define rsv_end rsv_window._rsv_end
70
71/*
72 * storage for cached extent
73 */
74struct ext4_ext_cache {
75 ext4_fsblk_t ec_start;
76 ext4_lblk_t ec_block;
77 __u32 ec_len; /* must be 32bit to return holes */
78 __u32 ec_type;
79};
80
81/*
82 * third extended file system inode data in memory
83 */
84struct ext4_inode_info {
85 __le32 i_data[15]; /* unconverted */
86 __u32 i_flags;
87 ext4_fsblk_t i_file_acl;
88 __u32 i_dtime;
89
90 /*
91 * i_block_group is the number of the block group which contains
92 * this file's inode. Constant across the lifetime of the inode,
93 * it is ued for making block allocation decisions - we try to
94 * place a file's data blocks near its inode block, and new inodes
95 * near to their parent directory's inode.
96 */
97 ext4_group_t i_block_group;
98 __u32 i_state; /* Dynamic state flags for ext4 */
99
100 /* block reservation info */
101 struct ext4_block_alloc_info *i_block_alloc_info;
102
103 ext4_lblk_t i_dir_start_lookup;
104#ifdef CONFIG_EXT4DEV_FS_XATTR
105 /*
106 * Extended attributes can be read independently of the main file
107 * data. Taking i_mutex even when reading would cause contention
108 * between readers of EAs and writers of regular file data, so
109 * instead we synchronize on xattr_sem when reading or changing
110 * EAs.
111 */
112 struct rw_semaphore xattr_sem;
113#endif
114#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
115 struct posix_acl *i_acl;
116 struct posix_acl *i_default_acl;
117#endif
118
119 struct list_head i_orphan; /* unlinked but open inodes */
120
121 /*
122 * i_disksize keeps track of what the inode size is ON DISK, not
123 * in memory. During truncate, i_size is set to the new size by
124 * the VFS prior to calling ext4_truncate(), but the filesystem won't
125 * set i_disksize to 0 until the truncate is actually under way.
126 *
127 * The intent is that i_disksize always represents the blocks which
128 * are used by this file. This allows recovery to restart truncate
129 * on orphans if we crash during truncate. We actually write i_disksize
130 * into the on-disk inode when writing inodes out, instead of i_size.
131 *
132 * The only time when i_disksize and i_size may be different is when
133 * a truncate is in progress. The only things which change i_disksize
134 * are ext4_get_block (growth) and ext4_truncate (shrinkth).
135 */
136 loff_t i_disksize;
137
138 /* on-disk additional length */
139 __u16 i_extra_isize;
140
141 /*
142 * i_data_sem is for serialising ext4_truncate() against
143 * ext4_getblock(). In the 2.4 ext2 design, great chunks of inode's
144 * data tree are chopped off during truncate. We can't do that in
145 * ext4 because whenever we perform intermediate commits during
146 * truncate, the inode and all the metadata blocks *must* be in a
147 * consistent state which allows truncation of the orphans to restart
148 * during recovery. Hence we must fix the get_block-vs-truncate race
149 * by other means, so we have i_data_sem.
150 */
151 struct rw_semaphore i_data_sem;
152 struct inode vfs_inode;
153
154 unsigned long i_ext_generation;
155 struct ext4_ext_cache i_cached_extent;
156 /*
157 * File creation time. Its function is same as that of
158 * struct timespec i_{a,c,m}time in the generic inode.
159 */
160 struct timespec i_crtime;
161
162 /* mballoc */
163 struct list_head i_prealloc_list;
164 spinlock_t i_prealloc_lock;
165};
166
167#endif /* _LINUX_EXT4_FS_I */
diff --git a/include/linux/ext4_fs_sb.h b/include/linux/ext4_fs_sb.h
deleted file mode 100644
index abaae2c8cccf..000000000000
--- a/include/linux/ext4_fs_sb.h
+++ /dev/null
@@ -1,148 +0,0 @@
1/*
2 * linux/include/linux/ext4_fs_sb.h
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *
9 * from
10 *
11 * linux/include/linux/minix_fs_sb.h
12 *
13 * Copyright (C) 1991, 1992 Linus Torvalds
14 */
15
16#ifndef _LINUX_EXT4_FS_SB
17#define _LINUX_EXT4_FS_SB
18
19#ifdef __KERNEL__
20#include <linux/timer.h>
21#include <linux/wait.h>
22#include <linux/blockgroup_lock.h>
23#include <linux/percpu_counter.h>
24#endif
25#include <linux/rbtree.h>
26
27/*
28 * third extended-fs super-block data in memory
29 */
30struct ext4_sb_info {
31 unsigned long s_desc_size; /* Size of a group descriptor in bytes */
32 unsigned long s_inodes_per_block;/* Number of inodes per block */
33 unsigned long s_blocks_per_group;/* Number of blocks in a group */
34 unsigned long s_inodes_per_group;/* Number of inodes in a 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 */
37 unsigned long s_desc_per_block; /* Number of group descriptors per block */
38 ext4_group_t s_groups_count; /* Number of groups in the fs */
39 unsigned long s_overhead_last; /* Last calculated overhead */
40 unsigned long s_blocks_last; /* Last seen block count */
41 loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */
42 struct buffer_head * s_sbh; /* Buffer containing the super block */
43 struct ext4_super_block * s_es; /* Pointer to the super block in the buffer */
44 struct buffer_head ** s_group_desc;
45 unsigned long s_mount_opt;
46 ext4_fsblk_t s_sb_block;
47 uid_t s_resuid;
48 gid_t s_resgid;
49 unsigned short s_mount_state;
50 unsigned short s_pad;
51 int s_addr_per_block_bits;
52 int s_desc_per_block_bits;
53 int s_inode_size;
54 int s_first_ino;
55 spinlock_t s_next_gen_lock;
56 u32 s_next_generation;
57 u32 s_hash_seed[4];
58 int s_def_hash_version;
59 struct percpu_counter s_freeblocks_counter;
60 struct percpu_counter s_freeinodes_counter;
61 struct percpu_counter s_dirs_counter;
62 struct blockgroup_lock s_blockgroup_lock;
63
64 /* root of the per fs reservation window tree */
65 spinlock_t s_rsv_window_lock;
66 struct rb_root s_rsv_window_root;
67 struct ext4_reserve_window_node s_rsv_window_head;
68
69 /* Journaling */
70 struct inode * s_journal_inode;
71 struct journal_s * s_journal;
72 struct list_head s_orphan;
73 unsigned long s_commit_interval;
74 struct block_device *journal_bdev;
75#ifdef CONFIG_JBD2_DEBUG
76 struct timer_list turn_ro_timer; /* For turning read-only (crash simulation) */
77 wait_queue_head_t ro_wait_queue; /* For people waiting for the fs to go read-only */
78#endif
79#ifdef CONFIG_QUOTA
80 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
81 int s_jquota_fmt; /* Format of quota to use */
82#endif
83 unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
84
85#ifdef EXTENTS_STATS
86 /* ext4 extents stats */
87 unsigned long s_ext_min;
88 unsigned long s_ext_max;
89 unsigned long s_depth_max;
90 spinlock_t s_ext_stats_lock;
91 unsigned long s_ext_blocks;
92 unsigned long s_ext_extents;
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;
146};
147
148#endif /* _LINUX_EXT4_FS_SB */
diff --git a/include/linux/ext4_jbd2.h b/include/linux/ext4_jbd2.h
deleted file mode 100644
index 38c71d3c8dbf..000000000000
--- a/include/linux/ext4_jbd2.h
+++ /dev/null
@@ -1,231 +0,0 @@
1/*
2 * linux/include/linux/ext4_jbd2.h
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 *
6 * Copyright 1998--1999 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under
9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference.
11 *
12 * Ext4-specific journaling extensions.
13 */
14
15#ifndef _LINUX_EXT4_JBD2_H
16#define _LINUX_EXT4_JBD2_H
17
18#include <linux/fs.h>
19#include <linux/jbd2.h>
20#include <linux/ext4_fs.h>
21
22#define EXT4_JOURNAL(inode) (EXT4_SB((inode)->i_sb)->s_journal)
23
24/* Define the number of blocks we need to account to a transaction to
25 * modify one block of data.
26 *
27 * We may have to touch one inode, one bitmap buffer, up to three
28 * indirection blocks, the group and superblock summaries, and the data
29 * block to complete the transaction.
30 *
31 * For extents-enabled fs we may have to allocate and modify up to
32 * 5 levels of tree + root which are stored in the inode. */
33
34#define EXT4_SINGLEDATA_TRANS_BLOCKS(sb) \
35 (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \
36 || test_opt(sb, EXTENTS) ? 27U : 8U)
37
38/* Extended attribute operations touch at most two data buffers,
39 * two bitmap buffers, and two group summaries, in addition to the inode
40 * and the superblock, which are already accounted for. */
41
42#define EXT4_XATTR_TRANS_BLOCKS 6U
43
44/* Define the minimum size for a transaction which modifies data. This
45 * needs to take into account the fact that we may end up modifying two
46 * quota files too (one for the group, one for the user quota). The
47 * superblock only gets updated once, of course, so don't bother
48 * counting that again for the quota updates. */
49
50#define EXT4_DATA_TRANS_BLOCKS(sb) (EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + \
51 EXT4_XATTR_TRANS_BLOCKS - 2 + \
52 2*EXT4_QUOTA_TRANS_BLOCKS(sb))
53
54/* Delete operations potentially hit one directory's namespace plus an
55 * entire inode, plus arbitrary amounts of bitmap/indirection data. Be
56 * generous. We can grow the delete transaction later if necessary. */
57
58#define EXT4_DELETE_TRANS_BLOCKS(sb) (2 * EXT4_DATA_TRANS_BLOCKS(sb) + 64)
59
60/* Define an arbitrary limit for the amount of data we will anticipate
61 * writing to any given transaction. For unbounded transactions such as
62 * write(2) and truncate(2) we can write more than this, but we always
63 * start off at the maximum transaction size and grow the transaction
64 * optimistically as we go. */
65
66#define EXT4_MAX_TRANS_DATA 64U
67
68/* We break up a large truncate or write transaction once the handle's
69 * buffer credits gets this low, we need either to extend the
70 * transaction or to start a new one. Reserve enough space here for
71 * inode, bitmap, superblock, group and indirection updates for at least
72 * one block, plus two quota updates. Quota allocations are not
73 * needed. */
74
75#define EXT4_RESERVE_TRANS_BLOCKS 12U
76
77#define EXT4_INDEX_EXTRA_TRANS_BLOCKS 8
78
79#ifdef CONFIG_QUOTA
80/* Amount of blocks needed for quota update - we know that the structure was
81 * allocated so we need to update only inode+data */
82#define EXT4_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0)
83/* Amount of blocks needed for quota insert/delete - we do some block writes
84 * but inode, sb and group updates are done only once */
85#define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
86 (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0)
87#define EXT4_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
88 (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0)
89#else
90#define EXT4_QUOTA_TRANS_BLOCKS(sb) 0
91#define EXT4_QUOTA_INIT_BLOCKS(sb) 0
92#define EXT4_QUOTA_DEL_BLOCKS(sb) 0
93#endif
94
95int
96ext4_mark_iloc_dirty(handle_t *handle,
97 struct inode *inode,
98 struct ext4_iloc *iloc);
99
100/*
101 * On success, We end up with an outstanding reference count against
102 * iloc->bh. This _must_ be cleaned up later.
103 */
104
105int ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
106 struct ext4_iloc *iloc);
107
108int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode);
109
110/*
111 * Wrapper functions with which ext4 calls into JBD. The intent here is
112 * to allow these to be turned into appropriate stubs so ext4 can control
113 * ext2 filesystems, so ext2+ext4 systems only nee one fs. This work hasn't
114 * been done yet.
115 */
116
117static inline void ext4_journal_release_buffer(handle_t *handle,
118 struct buffer_head *bh)
119{
120 jbd2_journal_release_buffer(handle, bh);
121}
122
123void ext4_journal_abort_handle(const char *caller, const char *err_fn,
124 struct buffer_head *bh, handle_t *handle, int err);
125
126int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
127 struct buffer_head *bh);
128
129int __ext4_journal_get_write_access(const char *where, handle_t *handle,
130 struct buffer_head *bh);
131
132int __ext4_journal_forget(const char *where, handle_t *handle,
133 struct buffer_head *bh);
134
135int __ext4_journal_revoke(const char *where, handle_t *handle,
136 ext4_fsblk_t blocknr, struct buffer_head *bh);
137
138int __ext4_journal_get_create_access(const char *where,
139 handle_t *handle, struct buffer_head *bh);
140
141int __ext4_journal_dirty_metadata(const char *where,
142 handle_t *handle, struct buffer_head *bh);
143
144#define ext4_journal_get_undo_access(handle, bh) \
145 __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh))
146#define ext4_journal_get_write_access(handle, bh) \
147 __ext4_journal_get_write_access(__FUNCTION__, (handle), (bh))
148#define ext4_journal_revoke(handle, blocknr, bh) \
149 __ext4_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh))
150#define ext4_journal_get_create_access(handle, bh) \
151 __ext4_journal_get_create_access(__FUNCTION__, (handle), (bh))
152#define ext4_journal_dirty_metadata(handle, bh) \
153 __ext4_journal_dirty_metadata(__FUNCTION__, (handle), (bh))
154#define ext4_journal_forget(handle, bh) \
155 __ext4_journal_forget(__FUNCTION__, (handle), (bh))
156
157int ext4_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
158
159handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks);
160int __ext4_journal_stop(const char *where, handle_t *handle);
161
162static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks)
163{
164 return ext4_journal_start_sb(inode->i_sb, nblocks);
165}
166
167#define ext4_journal_stop(handle) \
168 __ext4_journal_stop(__FUNCTION__, (handle))
169
170static inline handle_t *ext4_journal_current_handle(void)
171{
172 return journal_current_handle();
173}
174
175static inline int ext4_journal_extend(handle_t *handle, int nblocks)
176{
177 return jbd2_journal_extend(handle, nblocks);
178}
179
180static inline int ext4_journal_restart(handle_t *handle, int nblocks)
181{
182 return jbd2_journal_restart(handle, nblocks);
183}
184
185static inline int ext4_journal_blocks_per_page(struct inode *inode)
186{
187 return jbd2_journal_blocks_per_page(inode);
188}
189
190static inline int ext4_journal_force_commit(journal_t *journal)
191{
192 return jbd2_journal_force_commit(journal);
193}
194
195/* super.c */
196int ext4_force_commit(struct super_block *sb);
197
198static inline int ext4_should_journal_data(struct inode *inode)
199{
200 if (!S_ISREG(inode->i_mode))
201 return 1;
202 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
203 return 1;
204 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
205 return 1;
206 return 0;
207}
208
209static inline int ext4_should_order_data(struct inode *inode)
210{
211 if (!S_ISREG(inode->i_mode))
212 return 0;
213 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
214 return 0;
215 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
216 return 1;
217 return 0;
218}
219
220static inline int ext4_should_writeback_data(struct inode *inode)
221{
222 if (!S_ISREG(inode->i_mode))
223 return 0;
224 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
225 return 0;
226 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
227 return 1;
228 return 0;
229}
230
231#endif /* _LINUX_EXT4_JBD2_H */
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 58c57a33e5dd..72295b099228 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -791,6 +791,17 @@ struct fb_tile_ops {
791 */ 791 */
792#define FBINFO_MISC_ALWAYS_SETPAR 0x40000 792#define FBINFO_MISC_ALWAYS_SETPAR 0x40000
793 793
794/*
795 * Host and GPU endianness differ.
796 */
797#define FBINFO_FOREIGN_ENDIAN 0x100000
798/*
799 * Big endian math. This is the same flags as above, but with different
800 * meaning, it is set by the fb subsystem depending FOREIGN_ENDIAN flag
801 * and host endianness. Drivers should not use this flag.
802 */
803#define FBINFO_BE_MATH 0x100000
804
794struct fb_info { 805struct fb_info {
795 int node; 806 int node;
796 int flags; 807 int flags;
@@ -899,15 +910,11 @@ struct fb_info {
899 910
900#endif 911#endif
901 912
902#if defined (__BIG_ENDIAN) 913#define FB_LEFT_POS(p, bpp) (fb_be_math(p) ? (32 - (bpp)) : 0)
903#define FB_LEFT_POS(bpp) (32 - bpp) 914#define FB_SHIFT_HIGH(p, val, bits) (fb_be_math(p) ? (val) >> (bits) : \
904#define FB_SHIFT_HIGH(val, bits) ((val) >> (bits)) 915 (val) << (bits))
905#define FB_SHIFT_LOW(val, bits) ((val) << (bits)) 916#define FB_SHIFT_LOW(p, val, bits) (fb_be_math(p) ? (val) << (bits) : \
906#else 917 (val) >> (bits))
907#define FB_LEFT_POS(bpp) (0)
908#define FB_SHIFT_HIGH(val, bits) ((val) << (bits))
909#define FB_SHIFT_LOW(val, bits) ((val) >> (bits))
910#endif
911 918
912 /* 919 /*
913 * `Generic' versions of the frame buffer device operations 920 * `Generic' versions of the frame buffer device operations
@@ -970,6 +977,25 @@ extern void fb_deferred_io_cleanup(struct fb_info *info);
970extern int fb_deferred_io_fsync(struct file *file, struct dentry *dentry, 977extern int fb_deferred_io_fsync(struct file *file, struct dentry *dentry,
971 int datasync); 978 int datasync);
972 979
980static inline bool fb_be_math(struct fb_info *info)
981{
982#ifdef CONFIG_FB_FOREIGN_ENDIAN
983#if defined(CONFIG_FB_BOTH_ENDIAN)
984 return info->flags & FBINFO_BE_MATH;
985#elif defined(CONFIG_FB_BIG_ENDIAN)
986 return true;
987#elif defined(CONFIG_FB_LITTLE_ENDIAN)
988 return false;
989#endif /* CONFIG_FB_BOTH_ENDIAN */
990#else
991#ifdef __BIG_ENDIAN
992 return true;
993#else
994 return false;
995#endif /* __BIG_ENDIAN */
996#endif /* CONFIG_FB_FOREIGN_ENDIAN */
997}
998
973/* drivers/video/fbsysfs.c */ 999/* drivers/video/fbsysfs.c */
974extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev); 1000extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
975extern void framebuffer_release(struct fb_info *info); 1001extern void framebuffer_release(struct fb_info *info);
diff --git a/include/linux/file.h b/include/linux/file.h
index 7239baac81a9..69baf5a4f0a5 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -61,6 +61,7 @@ extern struct kmem_cache *filp_cachep;
61 61
62extern void __fput(struct file *); 62extern void __fput(struct file *);
63extern void fput(struct file *); 63extern void fput(struct file *);
64extern void drop_file_write_access(struct file *file);
64 65
65struct file_operations; 66struct file_operations;
66struct vfsmount; 67struct vfsmount;
@@ -116,7 +117,8 @@ struct task_struct;
116 117
117struct files_struct *get_files_struct(struct task_struct *); 118struct files_struct *get_files_struct(struct task_struct *);
118void put_files_struct(struct files_struct *fs); 119void put_files_struct(struct files_struct *fs);
119void reset_files_struct(struct task_struct *, struct files_struct *); 120void reset_files_struct(struct files_struct *);
121int unshare_files(struct files_struct **);
120 122
121extern struct kmem_cache *files_cachep; 123extern struct kmem_cache *files_cachep;
122 124
diff --git a/include/linux/filter.h b/include/linux/filter.h
index ddfa0372a3b7..b6ea9aa9e853 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -37,21 +37,6 @@ struct sock_fprog /* Required for SO_ATTACH_FILTER. */
37 struct sock_filter __user *filter; 37 struct sock_filter __user *filter;
38}; 38};
39 39
40#ifdef __KERNEL__
41struct sk_filter
42{
43 atomic_t refcnt;
44 unsigned int len; /* Number of filter blocks */
45 struct rcu_head rcu;
46 struct sock_filter insns[0];
47};
48
49static inline unsigned int sk_filter_len(struct sk_filter *fp)
50{
51 return fp->len*sizeof(struct sock_filter) + sizeof(*fp);
52}
53#endif
54
55/* 40/*
56 * Instruction classes 41 * Instruction classes
57 */ 42 */
@@ -136,15 +121,31 @@ static inline unsigned int sk_filter_len(struct sk_filter *fp)
136#define SKF_AD_PROTOCOL 0 121#define SKF_AD_PROTOCOL 0
137#define SKF_AD_PKTTYPE 4 122#define SKF_AD_PKTTYPE 4
138#define SKF_AD_IFINDEX 8 123#define SKF_AD_IFINDEX 8
139#define SKF_AD_MAX 12 124#define SKF_AD_NLATTR 12
125#define SKF_AD_MAX 16
140#define SKF_NET_OFF (-0x100000) 126#define SKF_NET_OFF (-0x100000)
141#define SKF_LL_OFF (-0x200000) 127#define SKF_LL_OFF (-0x200000)
142 128
143#ifdef __KERNEL__ 129#ifdef __KERNEL__
130struct sk_filter
131{
132 atomic_t refcnt;
133 unsigned int len; /* Number of filter blocks */
134 struct rcu_head rcu;
135 struct sock_filter insns[0];
136};
137
138static inline unsigned int sk_filter_len(const struct sk_filter *fp)
139{
140 return fp->len * sizeof(struct sock_filter) + sizeof(*fp);
141}
142
144struct sk_buff; 143struct sk_buff;
145struct sock; 144struct sock;
146 145
147extern unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen); 146extern int sk_filter(struct sock *sk, struct sk_buff *skb);
147extern unsigned int sk_run_filter(struct sk_buff *skb,
148 struct sock_filter *filter, int flen);
148extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); 149extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
149extern int sk_detach_filter(struct sock *sk); 150extern int sk_detach_filter(struct sock *sk);
150extern int sk_chk_filter(struct sock_filter *filter, int flen); 151extern int sk_chk_filter(struct sock_filter *filter, int flen);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b84b848431f2..a1ba005d08e7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -287,9 +287,9 @@ extern int dir_notify_enable;
287#include <linux/pid.h> 287#include <linux/pid.h>
288#include <linux/mutex.h> 288#include <linux/mutex.h>
289#include <linux/capability.h> 289#include <linux/capability.h>
290#include <linux/semaphore.h>
290 291
291#include <asm/atomic.h> 292#include <asm/atomic.h>
292#include <asm/semaphore.h>
293#include <asm/byteorder.h> 293#include <asm/byteorder.h>
294 294
295struct export_operations; 295struct export_operations;
@@ -305,7 +305,6 @@ struct vfsmount;
305 305
306extern void __init inode_init(void); 306extern void __init inode_init(void);
307extern void __init inode_init_early(void); 307extern void __init inode_init_early(void);
308extern void __init mnt_init(void);
309extern void __init files_init(unsigned long); 308extern void __init files_init(unsigned long);
310 309
311struct buffer_head; 310struct buffer_head;
@@ -475,8 +474,8 @@ struct address_space_operations {
475 int (*releasepage) (struct page *, gfp_t); 474 int (*releasepage) (struct page *, gfp_t);
476 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov, 475 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
477 loff_t offset, unsigned long nr_segs); 476 loff_t offset, unsigned long nr_segs);
478 struct page* (*get_xip_page)(struct address_space *, sector_t, 477 int (*get_xip_mem)(struct address_space *, pgoff_t, int,
479 int); 478 void **, unsigned long *);
480 /* migrate the contents of a page to the specified target */ 479 /* migrate the contents of a page to the specified target */
481 int (*migratepage) (struct address_space *, 480 int (*migratepage) (struct address_space *,
482 struct page *, struct page *); 481 struct page *, struct page *);
@@ -776,6 +775,9 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
776 index < ra->start + ra->size); 775 index < ra->start + ra->size);
777} 776}
778 777
778#define FILE_MNT_WRITE_TAKEN 1
779#define FILE_MNT_WRITE_RELEASED 2
780
779struct file { 781struct file {
780 /* 782 /*
781 * fu_list becomes invalid after file_free is called and queued via 783 * fu_list becomes invalid after file_free is called and queued via
@@ -810,6 +812,9 @@ struct file {
810 spinlock_t f_ep_lock; 812 spinlock_t f_ep_lock;
811#endif /* #ifdef CONFIG_EPOLL */ 813#endif /* #ifdef CONFIG_EPOLL */
812 struct address_space *f_mapping; 814 struct address_space *f_mapping;
815#ifdef CONFIG_DEBUG_WRITECOUNT
816 unsigned long f_mnt_write_state;
817#endif
813}; 818};
814extern spinlock_t files_lock; 819extern spinlock_t files_lock;
815#define file_list_lock() spin_lock(&files_lock); 820#define file_list_lock() spin_lock(&files_lock);
@@ -818,6 +823,49 @@ extern spinlock_t files_lock;
818#define get_file(x) atomic_inc(&(x)->f_count) 823#define get_file(x) atomic_inc(&(x)->f_count)
819#define file_count(x) atomic_read(&(x)->f_count) 824#define file_count(x) atomic_read(&(x)->f_count)
820 825
826#ifdef CONFIG_DEBUG_WRITECOUNT
827static inline void file_take_write(struct file *f)
828{
829 WARN_ON(f->f_mnt_write_state != 0);
830 f->f_mnt_write_state = FILE_MNT_WRITE_TAKEN;
831}
832static inline void file_release_write(struct file *f)
833{
834 f->f_mnt_write_state |= FILE_MNT_WRITE_RELEASED;
835}
836static inline void file_reset_write(struct file *f)
837{
838 f->f_mnt_write_state = 0;
839}
840static inline void file_check_state(struct file *f)
841{
842 /*
843 * At this point, either both or neither of these bits
844 * should be set.
845 */
846 WARN_ON(f->f_mnt_write_state == FILE_MNT_WRITE_TAKEN);
847 WARN_ON(f->f_mnt_write_state == FILE_MNT_WRITE_RELEASED);
848}
849static inline int file_check_writeable(struct file *f)
850{
851 if (f->f_mnt_write_state == FILE_MNT_WRITE_TAKEN)
852 return 0;
853 printk(KERN_WARNING "writeable file with no "
854 "mnt_want_write()\n");
855 WARN_ON(1);
856 return -EINVAL;
857}
858#else /* !CONFIG_DEBUG_WRITECOUNT */
859static inline void file_take_write(struct file *filp) {}
860static inline void file_release_write(struct file *filp) {}
861static inline void file_reset_write(struct file *filp) {}
862static inline void file_check_state(struct file *filp) {}
863static inline int file_check_writeable(struct file *filp)
864{
865 return 0;
866}
867#endif /* CONFIG_DEBUG_WRITECOUNT */
868
821#define MAX_NON_LFS ((1UL<<31) - 1) 869#define MAX_NON_LFS ((1UL<<31) - 1)
822 870
823/* Page cache limit. The filesystems should put that into their s_maxbytes 871/* Page cache limit. The filesystems should put that into their s_maxbytes
@@ -925,6 +973,7 @@ extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
925/* fs/locks.c */ 973/* fs/locks.c */
926extern void locks_init_lock(struct file_lock *); 974extern void locks_init_lock(struct file_lock *);
927extern void locks_copy_lock(struct file_lock *, struct file_lock *); 975extern void locks_copy_lock(struct file_lock *, struct file_lock *);
976extern void __locks_copy_lock(struct file_lock *, const struct file_lock *);
928extern void locks_remove_posix(struct file *, fl_owner_t); 977extern void locks_remove_posix(struct file *, fl_owner_t);
929extern void locks_remove_flock(struct file *); 978extern void locks_remove_flock(struct file *);
930extern void posix_test_lock(struct file *, struct file_lock *); 979extern void posix_test_lock(struct file *, struct file_lock *);
@@ -1129,7 +1178,8 @@ struct block_device_operations {
1129 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long); 1178 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
1130 long (*unlocked_ioctl) (struct file *, unsigned, unsigned long); 1179 long (*unlocked_ioctl) (struct file *, unsigned, unsigned long);
1131 long (*compat_ioctl) (struct file *, unsigned, unsigned long); 1180 long (*compat_ioctl) (struct file *, unsigned, unsigned long);
1132 int (*direct_access) (struct block_device *, sector_t, unsigned long *); 1181 int (*direct_access) (struct block_device *, sector_t,
1182 void **, unsigned long *);
1133 int (*media_changed) (struct gendisk *); 1183 int (*media_changed) (struct gendisk *);
1134 int (*revalidate_disk) (struct gendisk *); 1184 int (*revalidate_disk) (struct gendisk *);
1135 int (*getgeo)(struct block_device *, struct hd_geometry *); 1185 int (*getgeo)(struct block_device *, struct hd_geometry *);
@@ -1260,7 +1310,7 @@ struct super_operations {
1260 int (*statfs) (struct dentry *, struct kstatfs *); 1310 int (*statfs) (struct dentry *, struct kstatfs *);
1261 int (*remount_fs) (struct super_block *, int *, char *); 1311 int (*remount_fs) (struct super_block *, int *, char *);
1262 void (*clear_inode) (struct inode *); 1312 void (*clear_inode) (struct inode *);
1263 void (*umount_begin) (struct vfsmount *, int); 1313 void (*umount_begin) (struct super_block *);
1264 1314
1265 int (*show_options)(struct seq_file *, struct vfsmount *); 1315 int (*show_options)(struct seq_file *, struct vfsmount *);
1266 int (*show_stats)(struct seq_file *, struct vfsmount *); 1316 int (*show_stats)(struct seq_file *, struct vfsmount *);
@@ -1471,7 +1521,6 @@ extern int get_sb_pseudo(struct file_system_type *, char *,
1471 const struct super_operations *ops, unsigned long, 1521 const struct super_operations *ops, unsigned long,
1472 struct vfsmount *mnt); 1522 struct vfsmount *mnt);
1473extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1523extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
1474int __put_super(struct super_block *sb);
1475int __put_super_and_need_restart(struct super_block *sb); 1524int __put_super_and_need_restart(struct super_block *sb);
1476void unnamed_dev_init(void); 1525void unnamed_dev_init(void);
1477 1526
@@ -1487,12 +1536,7 @@ extern struct vfsmount *kern_mount_data(struct file_system_type *, void *data);
1487#define kern_mount(type) kern_mount_data(type, NULL) 1536#define kern_mount(type) kern_mount_data(type, NULL)
1488extern int may_umount_tree(struct vfsmount *); 1537extern int may_umount_tree(struct vfsmount *);
1489extern int may_umount(struct vfsmount *); 1538extern int may_umount(struct vfsmount *);
1490extern void umount_tree(struct vfsmount *, int, struct list_head *);
1491extern void release_mounts(struct list_head *);
1492extern long do_mount(char *, char *, char *, unsigned long, void *); 1539extern long do_mount(char *, char *, char *, unsigned long, void *);
1493extern struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int);
1494extern void mnt_set_mountpoint(struct vfsmount *, struct dentry *,
1495 struct vfsmount *);
1496extern struct vfsmount *collect_mounts(struct vfsmount *, struct dentry *); 1540extern struct vfsmount *collect_mounts(struct vfsmount *, struct dentry *);
1497extern void drop_collected_mounts(struct vfsmount *); 1541extern void drop_collected_mounts(struct vfsmount *);
1498 1542
@@ -1735,7 +1779,8 @@ extern struct file *create_read_pipe(struct file *f);
1735extern struct file *create_write_pipe(void); 1779extern struct file *create_write_pipe(void);
1736extern void free_write_pipe(struct file *); 1780extern void free_write_pipe(struct file *);
1737 1781
1738extern int open_namei(int dfd, const char *, int, int, struct nameidata *); 1782extern struct file *do_filp_open(int dfd, const char *pathname,
1783 int open_flag, int mode);
1739extern int may_open(struct nameidata *, int, int); 1784extern int may_open(struct nameidata *, int, int);
1740 1785
1741extern int kernel_read(struct file *, unsigned long, char *, unsigned long); 1786extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
@@ -1919,7 +1964,6 @@ extern int vfs_stat_fd(int dfd, char __user *, struct kstat *);
1919extern int vfs_lstat_fd(int dfd, char __user *, struct kstat *); 1964extern int vfs_lstat_fd(int dfd, char __user *, struct kstat *);
1920extern int vfs_fstat(unsigned int, struct kstat *); 1965extern int vfs_fstat(unsigned int, struct kstat *);
1921 1966
1922extern long vfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
1923extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, 1967extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
1924 unsigned long arg); 1968 unsigned long arg);
1925 1969
@@ -1989,9 +2033,6 @@ static inline ino_t parent_ino(struct dentry *dentry)
1989 return res; 2033 return res;
1990} 2034}
1991 2035
1992/* kernel/fork.c */
1993extern int unshare_files(void);
1994
1995/* Transaction based IO helpers */ 2036/* Transaction based IO helpers */
1996 2037
1997/* 2038/*
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 1831b196c70a..c415a496de3a 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -14,7 +14,6 @@
14 * option) any later version. 14 * option) any later version.
15 */ 15 */
16 16
17#ifdef __KERNEL__
18#ifndef _FSL_DEVICE_H_ 17#ifndef _FSL_DEVICE_H_
19#define _FSL_DEVICE_H_ 18#define _FSL_DEVICE_H_
20 19
@@ -50,7 +49,7 @@ struct gianfar_platform_data {
50 u32 device_flags; 49 u32 device_flags;
51 /* board specific information */ 50 /* board specific information */
52 u32 board_flags; 51 u32 board_flags;
53 u32 bus_id; 52 char bus_id[MII_BUS_ID_SIZE];
54 u32 phy_id; 53 u32 phy_id;
55 u8 mac_addr[6]; 54 u8 mac_addr[6];
56 phy_interface_t interface; 55 phy_interface_t interface;
@@ -127,4 +126,3 @@ struct mpc8xx_pcmcia_ops {
127}; 126};
128 127
129#endif /* _FSL_DEVICE_H_ */ 128#endif /* _FSL_DEVICE_H_ */
130#endif /* __KERNEL__ */
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index d4b7c4ac72e6..a89513188ce7 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -11,8 +11,6 @@
11 * (C) Copyright 2005 Robert Love 11 * (C) Copyright 2005 Robert Love
12 */ 12 */
13 13
14#ifdef __KERNEL__
15
16#include <linux/dnotify.h> 14#include <linux/dnotify.h>
17#include <linux/inotify.h> 15#include <linux/inotify.h>
18#include <linux/audit.h> 16#include <linux/audit.h>
@@ -296,6 +294,4 @@ static inline void fsnotify_oldname_free(const char *old_name)
296 294
297#endif /* ! CONFIG_INOTIFY */ 295#endif /* ! CONFIG_INOTIFY */
298 296
299#endif /* __KERNEL__ */
300
301#endif /* _LINUX_FS_NOTIFY_H */ 297#endif /* _LINUX_FS_NOTIFY_H */
diff --git a/include/linux/generic_serial.h b/include/linux/generic_serial.h
index 5412da28fa47..110833666e37 100644
--- a/include/linux/generic_serial.h
+++ b/include/linux/generic_serial.h
@@ -78,7 +78,7 @@ struct gs_port {
78#define GS_DEBUG_WRITE 0x00000040 78#define GS_DEBUG_WRITE 0x00000040
79 79
80#ifdef __KERNEL__ 80#ifdef __KERNEL__
81void gs_put_char(struct tty_struct *tty, unsigned char ch); 81int gs_put_char(struct tty_struct *tty, unsigned char ch);
82int gs_write(struct tty_struct *tty, 82int gs_write(struct tty_struct *tty,
83 const unsigned char *buf, int count); 83 const unsigned char *buf, int count);
84int gs_write_room(struct tty_struct *tty); 84int gs_write_room(struct tty_struct *tty);
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 164be9da3c1b..b414be387180 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -40,9 +40,9 @@ struct vm_area_struct;
40#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */ 40#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */
41#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */ 41#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */
42#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */ 42#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */
43#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */ 43#define __GFP_REPEAT ((__force gfp_t)0x400u) /* See above */
44#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */ 44#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* See above */
45#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */ 45#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* See above */
46#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ 46#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */
47#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ 47#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */
48#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ 48#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */
@@ -119,35 +119,22 @@ static inline int allocflags_to_migratetype(gfp_t gfp_flags)
119 119
120static inline enum zone_type gfp_zone(gfp_t flags) 120static inline enum zone_type gfp_zone(gfp_t flags)
121{ 121{
122 int base = 0;
123
124#ifdef CONFIG_NUMA
125 if (flags & __GFP_THISNODE)
126 base = MAX_NR_ZONES;
127#endif
128
129#ifdef CONFIG_ZONE_DMA 122#ifdef CONFIG_ZONE_DMA
130 if (flags & __GFP_DMA) 123 if (flags & __GFP_DMA)
131 return base + ZONE_DMA; 124 return ZONE_DMA;
132#endif 125#endif
133#ifdef CONFIG_ZONE_DMA32 126#ifdef CONFIG_ZONE_DMA32
134 if (flags & __GFP_DMA32) 127 if (flags & __GFP_DMA32)
135 return base + ZONE_DMA32; 128 return ZONE_DMA32;
136#endif 129#endif
137 if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) == 130 if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
138 (__GFP_HIGHMEM | __GFP_MOVABLE)) 131 (__GFP_HIGHMEM | __GFP_MOVABLE))
139 return base + ZONE_MOVABLE; 132 return ZONE_MOVABLE;
140#ifdef CONFIG_HIGHMEM 133#ifdef CONFIG_HIGHMEM
141 if (flags & __GFP_HIGHMEM) 134 if (flags & __GFP_HIGHMEM)
142 return base + ZONE_HIGHMEM; 135 return ZONE_HIGHMEM;
143#endif 136#endif
144 return base + ZONE_NORMAL; 137 return ZONE_NORMAL;
145}
146
147static inline gfp_t set_migrateflags(gfp_t gfp, gfp_t migrate_flags)
148{
149 BUG_ON((gfp & GFP_MOVABLE_MASK) == GFP_MOVABLE_MASK);
150 return (gfp & ~(GFP_MOVABLE_MASK)) | migrate_flags;
151} 138}
152 139
153/* 140/*
@@ -157,13 +144,27 @@ static inline gfp_t set_migrateflags(gfp_t gfp, gfp_t migrate_flags)
157 * virtual kernel addresses to the allocated page(s). 144 * virtual kernel addresses to the allocated page(s).
158 */ 145 */
159 146
147static inline int gfp_zonelist(gfp_t flags)
148{
149 if (NUMA_BUILD && unlikely(flags & __GFP_THISNODE))
150 return 1;
151
152 return 0;
153}
154
160/* 155/*
161 * We get the zone list from the current node and the gfp_mask. 156 * We get the zone list from the current node and the gfp_mask.
162 * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones. 157 * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones.
158 * There are two zonelists per node, one for all zones with memory and
159 * one containing just zones from the node the zonelist belongs to.
163 * 160 *
164 * For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets 161 * For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets
165 * optimized to &contig_page_data at compile-time. 162 * optimized to &contig_page_data at compile-time.
166 */ 163 */
164static inline struct zonelist *node_zonelist(int nid, gfp_t flags)
165{
166 return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags);
167}
167 168
168#ifndef HAVE_ARCH_FREE_PAGE 169#ifndef HAVE_ARCH_FREE_PAGE
169static inline void arch_free_page(struct page *page, int order) { } 170static inline void arch_free_page(struct page *page, int order) { }
@@ -174,6 +175,10 @@ static inline void arch_alloc_page(struct page *page, int order) { }
174 175
175extern struct page *__alloc_pages(gfp_t, unsigned int, struct zonelist *); 176extern struct page *__alloc_pages(gfp_t, unsigned int, struct zonelist *);
176 177
178extern struct page *
179__alloc_pages_nodemask(gfp_t, unsigned int,
180 struct zonelist *, nodemask_t *nodemask);
181
177static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, 182static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
178 unsigned int order) 183 unsigned int order)
179{ 184{
@@ -184,8 +189,7 @@ static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
184 if (nid < 0) 189 if (nid < 0)
185 nid = numa_node_id(); 190 nid = numa_node_id();
186 191
187 return __alloc_pages(gfp_mask, order, 192 return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
188 NODE_DATA(nid)->node_zonelists + gfp_zone(gfp_mask));
189} 193}
190 194
191#ifdef CONFIG_NUMA 195#ifdef CONFIG_NUMA
diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h
index e38e75967e74..c37e9241fae7 100644
--- a/include/linux/hdreg.h
+++ b/include/linux/hdreg.h
@@ -422,9 +422,11 @@ struct hd_geometry {
422#define HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */ 422#define HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
423#define HDIO_SET_DMA 0x0326 /* change use-dma flag */ 423#define HDIO_SET_DMA 0x0326 /* change use-dma flag */
424#define HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */ 424#define HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
425#ifndef __KERNEL__
425#define HDIO_SCAN_HWIF 0x0328 /* register and (re)scan interface */ 426#define HDIO_SCAN_HWIF 0x0328 /* register and (re)scan interface */
426#define HDIO_SET_NICE 0x0329 /* set nice flags */
427#define HDIO_UNREGISTER_HWIF 0x032a /* unregister interface */ 427#define HDIO_UNREGISTER_HWIF 0x032a /* unregister interface */
428#endif
429#define HDIO_SET_NICE 0x0329 /* set nice flags */
428#define HDIO_SET_WCACHE 0x032b /* change write cache enable-disable */ 430#define HDIO_SET_WCACHE 0x032b /* change write cache enable-disable */
429#define HDIO_SET_ACOUSTIC 0x032c /* change acoustic behavior */ 431#define HDIO_SET_ACOUSTIC 0x032c /* change acoustic behavior */
430#define HDIO_SET_BUSSTATE 0x032d /* set the bus state of the hwif */ 432#define HDIO_SET_BUSSTATE 0x032d /* set the bus state of the hwif */
diff --git a/include/linux/hdsmart.h b/include/linux/hdsmart.h
deleted file mode 100644
index 4f4faf9d4238..000000000000
--- a/include/linux/hdsmart.h
+++ /dev/null
@@ -1,126 +0,0 @@
1/*
2 * linux/include/linux/hdsmart.h
3 *
4 * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org>
5 * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org>
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, or (at your option)
10 * any later version.
11 *
12 * You should have received a copy of the GNU General Public License
13 * (for example /usr/src/linux/COPYING); if not, write to the Free
14 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17#ifndef _LINUX_HDSMART_H
18#define _LINUX_HDSMART_H
19
20#ifndef __KERNEL__
21#define OFFLINE_FULL_SCAN 0
22#define SHORT_SELF_TEST 1
23#define EXTEND_SELF_TEST 2
24#define SHORT_CAPTIVE_SELF_TEST 129
25#define EXTEND_CAPTIVE_SELF_TEST 130
26
27/* smart_attribute is the vendor specific in SFF-8035 spec */
28typedef struct ata_smart_attribute_s {
29 unsigned char id;
30 unsigned short status_flag;
31 unsigned char normalized;
32 unsigned char worse_normal;
33 unsigned char raw[6];
34 unsigned char reserv;
35} __attribute__ ((packed)) ata_smart_attribute_t;
36
37/* smart_values is format of the read drive Atrribute command */
38typedef struct ata_smart_values_s {
39 unsigned short revnumber;
40 ata_smart_attribute_t vendor_attributes [30];
41 unsigned char offline_data_collection_status;
42 unsigned char self_test_exec_status;
43 unsigned short total_time_to_complete_off_line;
44 unsigned char vendor_specific_366;
45 unsigned char offline_data_collection_capability;
46 unsigned short smart_capability;
47 unsigned char errorlog_capability;
48 unsigned char vendor_specific_371;
49 unsigned char short_test_completion_time;
50 unsigned char extend_test_completion_time;
51 unsigned char reserved_374_385 [12];
52 unsigned char vendor_specific_386_509 [125];
53 unsigned char chksum;
54} __attribute__ ((packed)) ata_smart_values_t;
55
56/* Smart Threshold data structures */
57/* Vendor attribute of SMART Threshold */
58typedef struct ata_smart_threshold_entry_s {
59 unsigned char id;
60 unsigned char normalized_threshold;
61 unsigned char reserved[10];
62} __attribute__ ((packed)) ata_smart_threshold_entry_t;
63
64/* Format of Read SMART THreshold Command */
65typedef struct ata_smart_thresholds_s {
66 unsigned short revnumber;
67 ata_smart_threshold_entry_t thres_entries[30];
68 unsigned char reserved[149];
69 unsigned char chksum;
70} __attribute__ ((packed)) ata_smart_thresholds_t;
71
72typedef struct ata_smart_errorlog_command_struct_s {
73 unsigned char devicecontrolreg;
74 unsigned char featuresreg;
75 unsigned char sector_count;
76 unsigned char sector_number;
77 unsigned char cylinder_low;
78 unsigned char cylinder_high;
79 unsigned char drive_head;
80 unsigned char commandreg;
81 unsigned int timestamp;
82} __attribute__ ((packed)) ata_smart_errorlog_command_struct_t;
83
84typedef struct ata_smart_errorlog_error_struct_s {
85 unsigned char error_condition;
86 unsigned char extended_error[14];
87 unsigned char state;
88 unsigned short timestamp;
89} __attribute__ ((packed)) ata_smart_errorlog_error_struct_t;
90
91typedef struct ata_smart_errorlog_struct_s {
92 ata_smart_errorlog_command_struct_t commands[6];
93 ata_smart_errorlog_error_struct_t error_struct;
94} __attribute__ ((packed)) ata_smart_errorlog_struct_t;
95
96typedef struct ata_smart_errorlog_s {
97 unsigned char revnumber;
98 unsigned char error_log_pointer;
99 ata_smart_errorlog_struct_t errorlog_struct[5];
100 unsigned short ata_error_count;
101 unsigned short non_fatal_count;
102 unsigned short drive_timeout_count;
103 unsigned char reserved[53];
104 unsigned char chksum;
105} __attribute__ ((packed)) ata_smart_errorlog_t;
106
107typedef struct ata_smart_selftestlog_struct_s {
108 unsigned char selftestnumber;
109 unsigned char selfteststatus;
110 unsigned short timestamp;
111 unsigned char selftestfailurecheckpoint;
112 unsigned int lbafirstfailure;
113 unsigned char vendorspecific[15];
114} __attribute__ ((packed)) ata_smart_selftestlog_struct_t;
115
116typedef struct ata_smart_selftestlog_s {
117 unsigned short revnumber;
118 ata_smart_selftestlog_struct_t selftest_struct[21];
119 unsigned char vendorspecific[2];
120 unsigned char mostrecenttest;
121 unsigned char resevered[2];
122 unsigned char chksum;
123} __attribute__ ((packed)) ata_smart_selftestlog_t;
124#endif /* __KERNEL__ */
125
126#endif /* _LINUX_HDSMART_H */
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 74ff57596eb1..4ce3b7a979ba 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -284,6 +284,7 @@ struct hid_item {
284#define HID_QUIRK_2WHEEL_MOUSE_HACK_B8 0x02000000 284#define HID_QUIRK_2WHEEL_MOUSE_HACK_B8 0x02000000
285#define HID_QUIRK_HWHEEL_WHEEL_INVERT 0x04000000 285#define HID_QUIRK_HWHEEL_WHEEL_INVERT 0x04000000
286#define HID_QUIRK_MICROSOFT_KEYS 0x08000000 286#define HID_QUIRK_MICROSOFT_KEYS 0x08000000
287#define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000
287 288
288/* 289/*
289 * Separate quirks for runtime report descriptor fixup 290 * Separate quirks for runtime report descriptor fixup
@@ -296,6 +297,8 @@ struct hid_item {
296#define HID_QUIRK_RDESC_MACBOOK_JIS 0x00000010 297#define HID_QUIRK_RDESC_MACBOOK_JIS 0x00000010
297#define HID_QUIRK_RDESC_BUTTON_CONSUMER 0x00000020 298#define HID_QUIRK_RDESC_BUTTON_CONSUMER 0x00000020
298#define HID_QUIRK_RDESC_SAMSUNG_REMOTE 0x00000040 299#define HID_QUIRK_RDESC_SAMSUNG_REMOTE 0x00000040
300#define HID_QUIRK_RDESC_MICROSOFT_RECV_1028 0x00000080
301#define HID_QUIRK_RDESC_SUNPLUS_WDESKTOP 0x00000100
299 302
300/* 303/*
301 * This is the global environment of the parser. This information is 304 * This is the global environment of the parser. This information is
@@ -320,7 +323,7 @@ struct hid_global {
320 * This is the local environment. It is persistent up the next main-item. 323 * This is the local environment. It is persistent up the next main-item.
321 */ 324 */
322 325
323#define HID_MAX_USAGES 8192 326#define HID_MAX_USAGES 12288
324#define HID_DEFAULT_NUM_COLLECTIONS 16 327#define HID_DEFAULT_NUM_COLLECTIONS 16
325 328
326struct hid_local { 329struct hid_local {
@@ -421,6 +424,7 @@ struct hid_control_fifo {
421#define HID_RESET_PENDING 4 424#define HID_RESET_PENDING 4
422#define HID_SUSPENDED 5 425#define HID_SUSPENDED 5
423#define HID_CLEAR_HALT 6 426#define HID_CLEAR_HALT 6
427#define HID_DISCONNECTED 7
424 428
425struct hid_input { 429struct hid_input {
426 struct list_head list; 430 struct list_head list;
@@ -452,8 +456,6 @@ struct hid_device { /* device report descriptor */
452 void *hidraw; 456 void *hidraw;
453 int minor; /* Hiddev minor number */ 457 int minor; /* Hiddev minor number */
454 458
455 wait_queue_head_t wait; /* For sleeping */
456
457 int open; /* is the device open by anyone? */ 459 int open; /* is the device open by anyone? */
458 char name[128]; /* Device name */ 460 char name[128]; /* Device name */
459 char phys[64]; /* Device physical location */ 461 char phys[64]; /* Device physical location */
@@ -496,13 +498,13 @@ struct hid_parser {
496 498
497struct hid_class_descriptor { 499struct hid_class_descriptor {
498 __u8 bDescriptorType; 500 __u8 bDescriptorType;
499 __u16 wDescriptorLength; 501 __le16 wDescriptorLength;
500} __attribute__ ((packed)); 502} __attribute__ ((packed));
501 503
502struct hid_descriptor { 504struct hid_descriptor {
503 __u8 bLength; 505 __u8 bLength;
504 __u8 bDescriptorType; 506 __u8 bDescriptorType;
505 __u16 bcdHID; 507 __le16 bcdHID;
506 __u8 bCountryCode; 508 __u8 bCountryCode;
507 __u8 bNumDescriptors; 509 __u8 bNumDescriptors;
508 510
@@ -530,14 +532,12 @@ int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int
530int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned long **, int *); 532int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned long **, int *);
531int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); 533int 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); 534int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32);
533void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt);
534void hid_output_report(struct hid_report *report, __u8 *data); 535void hid_output_report(struct hid_report *report, __u8 *data);
535void hid_free_device(struct hid_device *device); 536void hid_free_device(struct hid_device *device);
536struct hid_device *hid_parse_report(__u8 *start, unsigned size); 537struct hid_device *hid_parse_report(__u8 *start, unsigned size);
537 538
538/* HID quirks API */ 539/* HID quirks API */
539u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct); 540u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct);
540int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct, const u32 quirks);
541int usbhid_quirks_init(char **quirks_param); 541int usbhid_quirks_init(char **quirks_param);
542void usbhid_quirks_exit(void); 542void usbhid_quirks_exit(void);
543void usbhid_fixup_report_descriptor(const u16, const u16, char *, unsigned, char **); 543void usbhid_fixup_report_descriptor(const u16, const u16, char *, unsigned, char **);
@@ -546,6 +546,7 @@ void usbhid_fixup_report_descriptor(const u16, const u16, char *, unsigned, char
546int hid_ff_init(struct hid_device *hid); 546int hid_ff_init(struct hid_device *hid);
547 547
548int hid_lgff_init(struct hid_device *hid); 548int hid_lgff_init(struct hid_device *hid);
549int hid_lg2ff_init(struct hid_device *hid);
549int hid_plff_init(struct hid_device *hid); 550int hid_plff_init(struct hid_device *hid);
550int hid_tmff_init(struct hid_device *hid); 551int hid_tmff_init(struct hid_device *hid);
551int hid_zpff_init(struct hid_device *hid); 552int hid_zpff_init(struct hid_device *hid);
@@ -566,7 +567,11 @@ static inline int hid_ff_init(struct hid_device *hid) { return -1; }
566#define dbg_hid_line(format, arg...) if (hid_debug) \ 567#define dbg_hid_line(format, arg...) if (hid_debug) \
567 printk(format, ## arg) 568 printk(format, ## arg)
568#else 569#else
569#define dbg_hid(format, arg...) do {} while (0) 570static inline int __attribute__((format(printf, 1, 2)))
571dbg_hid(const char *fmt, ...)
572{
573 return 0;
574}
570#define dbg_hid_line dbg_hid 575#define dbg_hid_line dbg_hid
571#endif 576#endif
572 577
diff --git a/include/linux/hidraw.h b/include/linux/hidraw.h
index 0536f299f7ff..dbb5c8c374f0 100644
--- a/include/linux/hidraw.h
+++ b/include/linux/hidraw.h
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/hid.h> 18#include <linux/hid.h>
19#include <linux/types.h>
19 20
20struct hidraw_report_descriptor { 21struct hidraw_report_descriptor {
21 __u32 size; 22 __u32 size;
diff --git a/include/linux/hil_mlc.h b/include/linux/hil_mlc.h
index 8df29ca48a13..394a8405dd74 100644
--- a/include/linux/hil_mlc.h
+++ b/include/linux/hil_mlc.h
@@ -34,7 +34,7 @@
34#include <linux/hil.h> 34#include <linux/hil.h>
35#include <linux/time.h> 35#include <linux/time.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <asm/semaphore.h> 37#include <linux/semaphore.h>
38#include <linux/serio.h> 38#include <linux/serio.h>
39#include <linux/list.h> 39#include <linux/list.h>
40 40
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 1ad56a7b2f74..31a4d653389f 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -173,7 +173,6 @@ struct hrtimer_clock_base {
173 * struct hrtimer_cpu_base - the per cpu clock bases 173 * struct hrtimer_cpu_base - the per cpu clock bases
174 * @lock: lock protecting the base and associated clock bases 174 * @lock: lock protecting the base and associated clock bases
175 * and timers 175 * and timers
176 * @lock_key: the lock_class_key for use with lockdep
177 * @clock_base: array of clock bases for this cpu 176 * @clock_base: array of clock bases for this cpu
178 * @curr_timer: the timer which is executing a callback right now 177 * @curr_timer: the timer which is executing a callback right now
179 * @expires_next: absolute time of the next event which was scheduled 178 * @expires_next: absolute time of the next event which was scheduled
@@ -189,7 +188,6 @@ struct hrtimer_clock_base {
189 */ 188 */
190struct hrtimer_cpu_base { 189struct hrtimer_cpu_base {
191 spinlock_t lock; 190 spinlock_t lock;
192 struct lock_class_key lock_key;
193 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; 191 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
194 struct list_head cb_pending; 192 struct list_head cb_pending;
195#ifdef CONFIG_HIGH_RES_TIMERS 193#ifdef CONFIG_HIGH_RES_TIMERS
@@ -268,6 +266,21 @@ extern ktime_t ktime_get_real(void);
268extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock, 266extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
269 enum hrtimer_mode mode); 267 enum hrtimer_mode mode);
270 268
269#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
270extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
271 enum hrtimer_mode mode);
272
273extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
274#else
275static inline void hrtimer_init_on_stack(struct hrtimer *timer,
276 clockid_t which_clock,
277 enum hrtimer_mode mode)
278{
279 hrtimer_init(timer, which_clock, mode);
280}
281static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
282#endif
283
271/* Basic timer operations: */ 284/* Basic timer operations: */
272extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, 285extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
273 const enum hrtimer_mode mode); 286 const enum hrtimer_mode mode);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index addca4cd4f11..a79e80b689d8 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -8,6 +8,7 @@
8#include <linux/mempolicy.h> 8#include <linux/mempolicy.h>
9#include <linux/shm.h> 9#include <linux/shm.h>
10#include <asm/tlbflush.h> 10#include <asm/tlbflush.h>
11#include <asm/hugetlb.h>
11 12
12struct ctl_table; 13struct ctl_table;
13 14
@@ -51,51 +52,6 @@ int pmd_huge(pmd_t pmd);
51void hugetlb_change_protection(struct vm_area_struct *vma, 52void hugetlb_change_protection(struct vm_area_struct *vma,
52 unsigned long address, unsigned long end, pgprot_t newprot); 53 unsigned long address, unsigned long end, pgprot_t newprot);
53 54
54#ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE
55#define is_hugepage_only_range(mm, addr, len) 0
56#endif
57
58#ifndef ARCH_HAS_HUGETLB_FREE_PGD_RANGE
59#define hugetlb_free_pgd_range free_pgd_range
60#else
61void hugetlb_free_pgd_range(struct mmu_gather **tlb, unsigned long addr,
62 unsigned long end, unsigned long floor,
63 unsigned long ceiling);
64#endif
65
66#ifndef ARCH_HAS_PREPARE_HUGEPAGE_RANGE
67/*
68 * If the arch doesn't supply something else, assume that hugepage
69 * size aligned regions are ok without further preparation.
70 */
71static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
72{
73 if (len & ~HPAGE_MASK)
74 return -EINVAL;
75 if (addr & ~HPAGE_MASK)
76 return -EINVAL;
77 return 0;
78}
79#else
80int prepare_hugepage_range(unsigned long addr, unsigned long len);
81#endif
82
83#ifndef ARCH_HAS_SETCLEAR_HUGE_PTE
84#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
85#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
86#else
87void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
88 pte_t *ptep, pte_t pte);
89pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
90 pte_t *ptep);
91#endif
92
93#ifndef ARCH_HAS_HUGETLB_PREFAULT_HOOK
94#define hugetlb_prefault_arch_hook(mm) do { } while (0)
95#else
96void hugetlb_prefault_arch_hook(struct mm_struct *mm);
97#endif
98
99#else /* !CONFIG_HUGETLB_PAGE */ 55#else /* !CONFIG_HUGETLB_PAGE */
100 56
101static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) 57static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h
index 42131820bb89..7244456e7e65 100644
--- a/include/linux/hw_random.h
+++ b/include/linux/hw_random.h
@@ -11,7 +11,6 @@
11 11
12#ifndef LINUX_HWRANDOM_H_ 12#ifndef LINUX_HWRANDOM_H_
13#define LINUX_HWRANDOM_H_ 13#define LINUX_HWRANDOM_H_
14#ifdef __KERNEL__
15 14
16#include <linux/types.h> 15#include <linux/types.h>
17#include <linux/list.h> 16#include <linux/list.h>
@@ -44,15 +43,6 @@ struct hwrng {
44/** Register a new Hardware Random Number Generator driver. */ 43/** Register a new Hardware Random Number Generator driver. */
45extern int hwrng_register(struct hwrng *rng); 44extern int hwrng_register(struct hwrng *rng);
46/** Unregister a Hardware Random Number Generator driver. */ 45/** Unregister a Hardware Random Number Generator driver. */
47extern void __hwrng_unregister(struct hwrng *rng, bool suspended); 46extern void hwrng_unregister(struct hwrng *rng);
48static inline void hwrng_unregister(struct hwrng *rng) 47
49{
50 __hwrng_unregister(rng, false);
51}
52static inline void hwrng_unregister_suspended(struct hwrng *rng)
53{
54 __hwrng_unregister(rng, true);
55}
56
57#endif /* __KERNEL__ */
58#endif /* LINUX_HWRANDOM_H_ */ 48#endif /* LINUX_HWRANDOM_H_ */
diff --git a/include/linux/i2c-algo-pca.h b/include/linux/i2c-algo-pca.h
index fce47c051bb1..adcb3dc7ac26 100644
--- a/include/linux/i2c-algo-pca.h
+++ b/include/linux/i2c-algo-pca.h
@@ -1,14 +1,41 @@
1#ifndef _LINUX_I2C_ALGO_PCA_H 1#ifndef _LINUX_I2C_ALGO_PCA_H
2#define _LINUX_I2C_ALGO_PCA_H 2#define _LINUX_I2C_ALGO_PCA_H
3 3
4/* Clock speeds for the bus */
5#define I2C_PCA_CON_330kHz 0x00
6#define I2C_PCA_CON_288kHz 0x01
7#define I2C_PCA_CON_217kHz 0x02
8#define I2C_PCA_CON_146kHz 0x03
9#define I2C_PCA_CON_88kHz 0x04
10#define I2C_PCA_CON_59kHz 0x05
11#define I2C_PCA_CON_44kHz 0x06
12#define I2C_PCA_CON_36kHz 0x07
13
14/* PCA9564 registers */
15#define I2C_PCA_STA 0x00 /* STATUS Read Only */
16#define I2C_PCA_TO 0x00 /* TIMEOUT Write Only */
17#define I2C_PCA_DAT 0x01 /* DATA Read/Write */
18#define I2C_PCA_ADR 0x02 /* OWN ADR Read/Write */
19#define I2C_PCA_CON 0x03 /* CONTROL Read/Write */
20
21#define I2C_PCA_CON_AA 0x80 /* Assert Acknowledge */
22#define I2C_PCA_CON_ENSIO 0x40 /* Enable */
23#define I2C_PCA_CON_STA 0x20 /* Start */
24#define I2C_PCA_CON_STO 0x10 /* Stop */
25#define I2C_PCA_CON_SI 0x08 /* Serial Interrupt */
26#define I2C_PCA_CON_CR 0x07 /* Clock Rate (MASK) */
27
4struct i2c_algo_pca_data { 28struct i2c_algo_pca_data {
5 int (*get_own) (struct i2c_algo_pca_data *adap); /* Obtain own address */ 29 void *data; /* private low level data */
6 int (*get_clock) (struct i2c_algo_pca_data *adap); 30 void (*write_byte) (void *data, int reg, int val);
7 void (*write_byte) (struct i2c_algo_pca_data *adap, int reg, int val); 31 int (*read_byte) (void *data, int reg);
8 int (*read_byte) (struct i2c_algo_pca_data *adap, int reg); 32 int (*wait_for_completion) (void *data);
9 int (*wait_for_interrupt) (struct i2c_algo_pca_data *adap); 33 void (*reset_chip) (void *data);
34 /* i2c_clock values are defined in linux/i2c-algo-pca.h */
35 unsigned int i2c_clock;
10}; 36};
11 37
12int i2c_pca_add_bus(struct i2c_adapter *); 38int i2c_pca_add_bus(struct i2c_adapter *);
39int i2c_pca_add_numbered_bus(struct i2c_adapter *);
13 40
14#endif /* _LINUX_I2C_ALGO_PCA_H */ 41#endif /* _LINUX_I2C_ALGO_PCA_H */
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index b979112f74e0..580acc93903e 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -79,12 +79,9 @@
79#define I2C_DRIVERID_UPD64031A 79 /* upd64031a video processor */ 79#define I2C_DRIVERID_UPD64031A 79 /* upd64031a video processor */
80#define I2C_DRIVERID_SAA717X 80 /* saa717x video encoder */ 80#define I2C_DRIVERID_SAA717X 80 /* saa717x video encoder */
81#define I2C_DRIVERID_DS1672 81 /* Dallas/Maxim DS1672 RTC */ 81#define I2C_DRIVERID_DS1672 81 /* Dallas/Maxim DS1672 RTC */
82#define I2C_DRIVERID_X1205 82 /* Xicor/Intersil X1205 RTC */
83#define I2C_DRIVERID_PCF8563 83 /* Philips PCF8563 RTC */
84#define I2C_DRIVERID_BT866 85 /* Conexant bt866 video encoder */ 82#define I2C_DRIVERID_BT866 85 /* Conexant bt866 video encoder */
85#define I2C_DRIVERID_KS0127 86 /* Samsung ks0127 video decoder */ 83#define I2C_DRIVERID_KS0127 86 /* Samsung ks0127 video decoder */
86#define I2C_DRIVERID_TLV320AIC23B 87 /* TI TLV320AIC23B audio codec */ 84#define I2C_DRIVERID_TLV320AIC23B 87 /* TI TLV320AIC23B audio codec */
87#define I2C_DRIVERID_ISL1208 88 /* Intersil ISL1208 RTC */
88#define I2C_DRIVERID_WM8731 89 /* Wolfson WM8731 audio codec */ 85#define I2C_DRIVERID_WM8731 89 /* Wolfson WM8731 audio codec */
89#define I2C_DRIVERID_WM8750 90 /* Wolfson WM8750 audio codec */ 86#define I2C_DRIVERID_WM8750 90 /* Wolfson WM8750 audio codec */
90#define I2C_DRIVERID_WM8753 91 /* Wolfson WM8753 audio codec */ 87#define I2C_DRIVERID_WM8753 91 /* Wolfson WM8753 audio codec */
@@ -125,6 +122,7 @@
125#define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */ 122#define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */
126#define I2C_HW_B_INTELFB 0x010021 /* intel framebuffer driver */ 123#define I2C_HW_B_INTELFB 0x010021 /* intel framebuffer driver */
127#define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */ 124#define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */
125#define I2C_HW_B_AU0828 0x010023 /* auvitek au0828 usb bridge */
128 126
129/* --- PCF 8584 based algorithms */ 127/* --- PCF 8584 based algorithms */
130#define I2C_HW_P_ELEK 0x020002 /* Elektor ISA Bus inteface card */ 128#define I2C_HW_P_ELEK 0x020002 /* Elektor ISA Bus inteface card */
diff --git a/include/linux/i2c-pca-platform.h b/include/linux/i2c-pca-platform.h
new file mode 100644
index 000000000000..3d191873f2d1
--- /dev/null
+++ b/include/linux/i2c-pca-platform.h
@@ -0,0 +1,12 @@
1#ifndef I2C_PCA9564_PLATFORM_H
2#define I2C_PCA9564_PLATFORM_H
3
4struct i2c_pca9564_pf_platform_data {
5 int gpio; /* pin to reset chip. driver will work when
6 * not supplied (negative value), but it
7 * cannot exit some error conditions then */
8 int i2c_clock_speed; /* values are defined in linux/i2c-algo-pca.h */
9 int timeout; /* timeout = this value * 10us */
10};
11
12#endif /* I2C_PCA9564_PLATFORM_H */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 365e0df3646b..cb63da5c2139 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -126,7 +126,7 @@ struct i2c_driver {
126 * With the driver model, device enumeration is NEVER done by drivers; 126 * With the driver model, device enumeration is NEVER done by drivers;
127 * it's done by infrastructure. (NEW STYLE DRIVERS ONLY) 127 * it's done by infrastructure. (NEW STYLE DRIVERS ONLY)
128 */ 128 */
129 int (*probe)(struct i2c_client *); 129 int (*probe)(struct i2c_client *, const struct i2c_device_id *);
130 int (*remove)(struct i2c_client *); 130 int (*remove)(struct i2c_client *);
131 131
132 /* driver model interfaces that don't relate to enumeration */ 132 /* driver model interfaces that don't relate to enumeration */
@@ -140,11 +140,10 @@ 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 const struct i2c_device_id *id_table;
143}; 144};
144#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) 145#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
145 146
146#define I2C_NAME_SIZE 20
147
148/** 147/**
149 * struct i2c_client - represent an I2C slave device 148 * struct i2c_client - represent an I2C slave device
150 * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address; 149 * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
@@ -230,17 +229,17 @@ struct i2c_board_info {
230}; 229};
231 230
232/** 231/**
233 * I2C_BOARD_INFO - macro used to list an i2c device and its driver 232 * I2C_BOARD_INFO - macro used to list an i2c device and its address
234 * @driver: identifies the driver to use with the device 233 * @dev_type: identifies the device type
235 * @dev_addr: the device's address on the bus. 234 * @dev_addr: the device's address on the bus.
236 * 235 *
237 * This macro initializes essential fields of a struct i2c_board_info, 236 * This macro initializes essential fields of a struct i2c_board_info,
238 * declaring what has been provided on a particular board. Optional 237 * declaring what has been provided on a particular board. Optional
239 * fields (such as the chip type, its associated irq, or device-specific 238 * fields (such as associated irq, or device-specific platform_data)
240 * platform_data) are provided using conventional syntax. 239 * are provided using conventional syntax.
241 */ 240 */
242#define I2C_BOARD_INFO(driver,dev_addr) \ 241#define I2C_BOARD_INFO(dev_type,dev_addr) \
243 .driver_name = (driver), .addr = (dev_addr) 242 .type = (dev_type), .addr = (dev_addr)
244 243
245 244
246/* Add-on boards should register/unregister their devices; e.g. a board 245/* Add-on boards should register/unregister their devices; e.g. a board
diff --git a/include/linux/i2c/tps65010.h b/include/linux/i2c/tps65010.h
index 7021635ed6a0..918c5354d9b8 100644
--- a/include/linux/i2c/tps65010.h
+++ b/include/linux/i2c/tps65010.h
@@ -152,5 +152,35 @@ 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
156struct i2c_client;
157
158/**
159 * struct tps65010_board - packages GPIO and LED lines
160 * @base: the GPIO number to assign to GPIO-1
161 * @outmask: bit (N-1) is set to allow GPIO-N to be used as an
162 * (open drain) output
163 * @setup: optional callback issued once the GPIOs are valid
164 * @teardown: optional callback issued before the GPIOs are invalidated
165 * @context: optional parameter passed to setup() and teardown()
166 *
167 * Board data may be used to package the GPIO (and LED) lines for use
168 * in by the generic GPIO and LED frameworks. The first four GPIOs
169 * starting at gpio_base are GPIO1..GPIO4. The next two are LED1/nPG
170 * and LED2 (with hardware blinking capability, not currently exposed).
171 *
172 * The @setup callback may be used with the kind of board-specific glue
173 * which hands the (now-valid) GPIOs to other drivers, or which puts
174 * devices in their initial states using these GPIOs.
175 */
176struct tps65010_board {
177 int base;
178 unsigned outmask;
179
180 int (*setup)(struct i2c_client *client, void *context);
181 int (*teardown)(struct i2c_client *client, void *context);
182 void *context;
183};
184
155#endif /* __LINUX_I2C_TPS65010_H */ 185#endif /* __LINUX_I2C_TPS65010_H */
156 186
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index 7da5b98d90e6..7d51cbca49ab 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -18,8 +18,6 @@
18#ifndef _I2O_H 18#ifndef _I2O_H
19#define _I2O_H 19#define _I2O_H
20 20
21#ifdef __KERNEL__ /* This file to be included by kernel only */
22
23#include <linux/i2o-dev.h> 21#include <linux/i2o-dev.h>
24 22
25/* How many different OSM's are we allowing */ 23/* How many different OSM's are we allowing */
@@ -33,9 +31,9 @@
33#include <linux/mempool.h> 31#include <linux/mempool.h>
34#include <linux/mutex.h> 32#include <linux/mutex.h>
35#include <linux/scatterlist.h> 33#include <linux/scatterlist.h>
34#include <linux/semaphore.h> /* Needed for MUTEX init macros */
36 35
37#include <asm/io.h> 36#include <asm/io.h>
38#include <asm/semaphore.h> /* Needed for MUTEX init macros */
39 37
40/* message queue empty */ 38/* message queue empty */
41#define I2O_QUEUE_EMPTY 0xffffffff 39#define I2O_QUEUE_EMPTY 0xffffffff
@@ -613,14 +611,9 @@ struct i2o_sys_tbl {
613extern struct list_head i2o_controllers; 611extern struct list_head i2o_controllers;
614 612
615/* Message functions */ 613/* Message functions */
616static inline struct i2o_message *i2o_msg_get(struct i2o_controller *);
617extern struct i2o_message *i2o_msg_get_wait(struct i2o_controller *, int); 614extern struct i2o_message *i2o_msg_get_wait(struct i2o_controller *, int);
618static inline void i2o_msg_post(struct i2o_controller *, struct i2o_message *);
619static inline int i2o_msg_post_wait(struct i2o_controller *,
620 struct i2o_message *, unsigned long);
621extern int i2o_msg_post_wait_mem(struct i2o_controller *, struct i2o_message *, 615extern int i2o_msg_post_wait_mem(struct i2o_controller *, struct i2o_message *,
622 unsigned long, struct i2o_dma *); 616 unsigned long, struct i2o_dma *);
623static inline void i2o_flush_reply(struct i2o_controller *, u32);
624 617
625/* IOP functions */ 618/* IOP functions */
626extern int i2o_status_get(struct i2o_controller *); 619extern int i2o_status_get(struct i2o_controller *);
@@ -1260,5 +1253,4 @@ extern void i2o_dump_message(struct i2o_message *);
1260extern void i2o_dump_hrt(struct i2o_controller *c); 1253extern void i2o_dump_hrt(struct i2o_controller *c);
1261extern void i2o_debug_state(struct i2o_controller *c); 1254extern void i2o_debug_state(struct i2o_controller *c);
1262 1255
1263#endif /* __KERNEL__ */
1264#endif /* _I2O_H */ 1256#endif /* _I2O_H */
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
index 7c5e9817e998..03067443198a 100644
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -176,12 +176,21 @@ extern void icmpv6_send(struct sk_buff *skb,
176 __u32 info, 176 __u32 info,
177 struct net_device *dev); 177 struct net_device *dev);
178 178
179extern int icmpv6_init(struct net_proto_family *ops); 179extern int icmpv6_init(void);
180extern int icmpv6_err_convert(int type, int code, 180extern int icmpv6_err_convert(int type, int code,
181 int *err); 181 int *err);
182extern void icmpv6_cleanup(void); 182extern void icmpv6_cleanup(void);
183extern void icmpv6_param_prob(struct sk_buff *skb, 183extern void icmpv6_param_prob(struct sk_buff *skb,
184 int code, int pos); 184 int code, int pos);
185
186struct flowi;
187struct in6_addr;
188extern void icmpv6_flow_init(struct sock *sk,
189 struct flowi *fl,
190 u8 type,
191 const struct in6_addr *saddr,
192 const struct in6_addr *daddr,
193 int oif);
185#endif 194#endif
186 195
187#endif 196#endif
diff --git a/include/linux/ide.h b/include/linux/ide.h
index bc26b2f27359..b0135b0c3a04 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -23,7 +23,6 @@
23#include <asm/byteorder.h> 23#include <asm/byteorder.h>
24#include <asm/system.h> 24#include <asm/system.h>
25#include <asm/io.h> 25#include <asm/io.h>
26#include <asm/semaphore.h>
27#include <asm/mutex.h> 26#include <asm/mutex.h>
28 27
29#if defined(CONFIG_CRIS) || defined(CONFIG_FRV) 28#if defined(CONFIG_CRIS) || defined(CONFIG_FRV)
@@ -49,13 +48,6 @@ typedef unsigned char byte; /* used everywhere */
49#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ 48#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
50 49
51/* 50/*
52 * Tune flags
53 */
54#define IDE_TUNE_NOAUTO 2
55#define IDE_TUNE_AUTO 1
56#define IDE_TUNE_DEFAULT 0
57
58/*
59 * state flags 51 * state flags
60 */ 52 */
61 53
@@ -69,37 +61,30 @@ typedef unsigned char byte; /* used everywhere */
69 */ 61 */
70#define IDE_NR_PORTS (10) 62#define IDE_NR_PORTS (10)
71 63
72#define IDE_DATA_OFFSET (0) 64struct ide_io_ports {
73#define IDE_ERROR_OFFSET (1) 65 unsigned long data_addr;
74#define IDE_NSECTOR_OFFSET (2) 66
75#define IDE_SECTOR_OFFSET (3) 67 union {
76#define IDE_LCYL_OFFSET (4) 68 unsigned long error_addr; /* read: error */
77#define IDE_HCYL_OFFSET (5) 69 unsigned long feature_addr; /* write: feature */
78#define IDE_SELECT_OFFSET (6) 70 };
79#define IDE_STATUS_OFFSET (7) 71
80#define IDE_CONTROL_OFFSET (8) 72 unsigned long nsect_addr;
81#define IDE_IRQ_OFFSET (9) 73 unsigned long lbal_addr;
82 74 unsigned long lbam_addr;
83#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET 75 unsigned long lbah_addr;
84#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET 76
85 77 unsigned long device_addr;
86#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET]) 78
87#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET]) 79 union {
88#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET]) 80 unsigned long status_addr; /*  read: status  */
89#define IDE_SECTOR_REG (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET]) 81 unsigned long command_addr; /* write: command */
90#define IDE_LCYL_REG (HWIF(drive)->io_ports[IDE_LCYL_OFFSET]) 82 };
91#define IDE_HCYL_REG (HWIF(drive)->io_ports[IDE_HCYL_OFFSET]) 83
92#define IDE_SELECT_REG (HWIF(drive)->io_ports[IDE_SELECT_OFFSET]) 84 unsigned long ctl_addr;
93#define IDE_STATUS_REG (HWIF(drive)->io_ports[IDE_STATUS_OFFSET]) 85
94#define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET]) 86 unsigned long irq_addr;
95#define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET]) 87};
96
97#define IDE_FEATURE_REG IDE_ERROR_REG
98#define IDE_COMMAND_REG IDE_STATUS_REG
99#define IDE_ALTSTATUS_REG IDE_CONTROL_REG
100#define IDE_IREASON_REG IDE_NSECTOR_REG
101#define IDE_BCOUNTL_REG IDE_LCYL_REG
102#define IDE_BCOUNTH_REG IDE_HCYL_REG
103 88
104#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) 89#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
105#define BAD_R_STAT (BUSY_STAT | ERR_STAT) 90#define BAD_R_STAT (BUSY_STAT | ERR_STAT)
@@ -169,7 +154,7 @@ enum { ide_unknown, ide_generic, ide_pci,
169 ide_rz1000, ide_trm290, 154 ide_rz1000, ide_trm290,
170 ide_cmd646, ide_cy82c693, ide_4drives, 155 ide_cmd646, ide_cy82c693, ide_4drives,
171 ide_pmac, ide_etrax100, ide_acorn, 156 ide_pmac, ide_etrax100, ide_acorn,
172 ide_au1xxx, ide_palm3710, ide_forced 157 ide_au1xxx, ide_palm3710
173}; 158};
174 159
175typedef u8 hwif_chipset_t; 160typedef u8 hwif_chipset_t;
@@ -178,32 +163,30 @@ typedef u8 hwif_chipset_t;
178 * Structure to hold all information about the location of this port 163 * Structure to hold all information about the location of this port
179 */ 164 */
180typedef struct hw_regs_s { 165typedef struct hw_regs_s {
181 unsigned long io_ports[IDE_NR_PORTS]; /* task file registers */ 166 union {
167 struct ide_io_ports io_ports;
168 unsigned long io_ports_array[IDE_NR_PORTS];
169 };
170
182 int irq; /* our irq number */ 171 int irq; /* our irq number */
183 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ 172 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
184 hwif_chipset_t chipset; 173 hwif_chipset_t chipset;
185 struct device *dev; 174 struct device *dev;
186} hw_regs_t; 175} hw_regs_t;
187 176
188struct hwif_s * ide_find_port(unsigned long);
189struct hwif_s *ide_deprecated_find_port(unsigned long);
190void ide_init_port_data(struct hwif_s *, unsigned int); 177void ide_init_port_data(struct hwif_s *, unsigned int);
191void ide_init_port_hw(struct hwif_s *, hw_regs_t *); 178void ide_init_port_hw(struct hwif_s *, hw_regs_t *);
192 179
193struct ide_drive_s;
194int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *),
195 struct hwif_s **);
196
197static inline void ide_std_init_ports(hw_regs_t *hw, 180static inline void ide_std_init_ports(hw_regs_t *hw,
198 unsigned long io_addr, 181 unsigned long io_addr,
199 unsigned long ctl_addr) 182 unsigned long ctl_addr)
200{ 183{
201 unsigned int i; 184 unsigned int i;
202 185
203 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) 186 for (i = 0; i <= 7; i++)
204 hw->io_ports[i] = io_addr++; 187 hw->io_ports_array[i] = io_addr++;
205 188
206 hw->io_ports[IDE_CONTROL_OFFSET] = ctl_addr; 189 hw->io_ports.ctl_addr = ctl_addr;
207} 190}
208 191
209#include <asm/ide.h> 192#include <asm/ide.h>
@@ -213,45 +196,6 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
213#define MAX_HWIFS CONFIG_IDE_MAX_HWIFS 196#define MAX_HWIFS CONFIG_IDE_MAX_HWIFS
214#endif 197#endif
215 198
216/* needed on alpha, x86/x86_64, ia64, mips, ppc32 and sh */
217#ifndef IDE_ARCH_OBSOLETE_DEFAULTS
218# define ide_default_io_base(index) (0)
219# define ide_default_irq(base) (0)
220# define ide_init_default_irq(base) (0)
221#endif
222
223#ifdef CONFIG_IDE_ARCH_OBSOLETE_INIT
224static inline void ide_init_hwif_ports(hw_regs_t *hw,
225 unsigned long io_addr,
226 unsigned long ctl_addr,
227 int *irq)
228{
229 if (!ctl_addr)
230 ide_std_init_ports(hw, io_addr, ide_default_io_ctl(io_addr));
231 else
232 ide_std_init_ports(hw, io_addr, ctl_addr);
233
234 if (irq)
235 *irq = 0;
236
237 hw->io_ports[IDE_IRQ_OFFSET] = 0;
238
239#ifdef CONFIG_PPC32
240 if (ppc_ide_md.ide_init_hwif)
241 ppc_ide_md.ide_init_hwif(hw, io_addr, ctl_addr, irq);
242#endif
243}
244#else
245static inline void ide_init_hwif_ports(hw_regs_t *hw,
246 unsigned long io_addr,
247 unsigned long ctl_addr,
248 int *irq)
249{
250 if (io_addr || ctl_addr)
251 printk(KERN_WARNING "%s: must not be called\n", __FUNCTION__);
252}
253#endif /* CONFIG_IDE_ARCH_OBSOLETE_INIT */
254
255/* Currently only m68k, apus and m8xx need it */ 199/* Currently only m68k, apus and m8xx need it */
256#ifndef IDE_ARCH_ACK_INTR 200#ifndef IDE_ARCH_ACK_INTR
257# define ide_ack_intr(hwif) (1) 201# define ide_ack_intr(hwif) (1)
@@ -388,7 +332,6 @@ typedef struct ide_drive_s {
388 unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ 332 unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */
389 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ 333 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */
390 unsigned nodma : 1; /* disallow DMA */ 334 unsigned nodma : 1; /* disallow DMA */
391 unsigned autotune : 2; /* 0=default, 1=autotune, 2=noautotune */
392 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ 335 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */
393 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ 336 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */
394 unsigned vdma : 1; /* 1=doing PIO over DMA 0=doing normal DMA */ 337 unsigned vdma : 1; /* 1=doing PIO over DMA 0=doing normal DMA */
@@ -406,7 +349,7 @@ typedef struct ide_drive_s {
406 u8 wcache; /* status of write cache */ 349 u8 wcache; /* status of write cache */
407 u8 acoustic; /* acoustic management */ 350 u8 acoustic; /* acoustic management */
408 u8 media; /* disk, cdrom, tape, floppy, ... */ 351 u8 media; /* disk, cdrom, tape, floppy, ... */
409 u8 ctl; /* "normal" value for IDE_CONTROL_REG */ 352 u8 ctl; /* "normal" value for Control register */
410 u8 ready_stat; /* min status value for drive ready */ 353 u8 ready_stat; /* min status value for drive ready */
411 u8 mult_count; /* current multiple sector setting */ 354 u8 mult_count; /* current multiple sector setting */
412 u8 mult_req; /* requested multiple sector setting */ 355 u8 mult_req; /* requested multiple sector setting */
@@ -447,6 +390,45 @@ typedef struct ide_drive_s {
447 390
448struct ide_port_info; 391struct ide_port_info;
449 392
393struct ide_port_ops {
394 /* host specific initialization of devices on a port */
395 void (*port_init_devs)(struct hwif_s *);
396 /* routine to program host for PIO mode */
397 void (*set_pio_mode)(ide_drive_t *, const u8);
398 /* routine to program host for DMA mode */
399 void (*set_dma_mode)(ide_drive_t *, const u8);
400 /* tweaks hardware to select drive */
401 void (*selectproc)(ide_drive_t *);
402 /* chipset polling based on hba specifics */
403 int (*reset_poll)(ide_drive_t *);
404 /* chipset specific changes to default for device-hba resets */
405 void (*pre_reset)(ide_drive_t *);
406 /* routine to reset controller after a disk reset */
407 void (*resetproc)(ide_drive_t *);
408 /* special host masking for drive selection */
409 void (*maskproc)(ide_drive_t *, int);
410 /* check host's drive quirk list */
411 void (*quirkproc)(ide_drive_t *);
412
413 u8 (*mdma_filter)(ide_drive_t *);
414 u8 (*udma_filter)(ide_drive_t *);
415
416 u8 (*cable_detect)(struct hwif_s *);
417};
418
419struct ide_dma_ops {
420 void (*dma_host_set)(struct ide_drive_s *, int);
421 int (*dma_setup)(struct ide_drive_s *);
422 void (*dma_exec_cmd)(struct ide_drive_s *, u8);
423 void (*dma_start)(struct ide_drive_s *);
424 int (*dma_end)(struct ide_drive_s *);
425 int (*dma_test_irq)(struct ide_drive_s *);
426 void (*dma_lost_irq)(struct ide_drive_s *);
427 void (*dma_timeout)(struct ide_drive_s *);
428};
429
430struct ide_task_s;
431
450typedef struct hwif_s { 432typedef struct hwif_s {
451 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 433 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
452 struct hwif_s *mate; /* other hwif from same PCI chip */ 434 struct hwif_s *mate; /* other hwif from same PCI chip */
@@ -455,8 +437,8 @@ typedef struct hwif_s {
455 437
456 char name[6]; /* name of interface, eg. "ide0" */ 438 char name[6]; /* name of interface, eg. "ide0" */
457 439
458 /* task file registers for pata and sata */ 440 struct ide_io_ports io_ports;
459 unsigned long io_ports[IDE_NR_PORTS]; 441
460 unsigned long sata_scr[SATA_NR_PORTS]; 442 unsigned long sata_scr[SATA_NR_PORTS];
461 443
462 ide_drive_t drives[MAX_DRIVES]; /* drive info */ 444 ide_drive_t drives[MAX_DRIVES]; /* drive info */
@@ -480,67 +462,25 @@ typedef struct hwif_s {
480 462
481 struct device *dev; 463 struct device *dev;
482 464
483 const struct ide_port_info *cds; /* chipset device struct */
484
485 ide_ack_intr_t *ack_intr; 465 ide_ack_intr_t *ack_intr;
486 466
487 void (*rw_disk)(ide_drive_t *, struct request *); 467 void (*rw_disk)(ide_drive_t *, struct request *);
488 468
489#if 0 469 const struct ide_port_ops *port_ops;
490 ide_hwif_ops_t *hwifops; 470 const struct ide_dma_ops *dma_ops;
491#else
492 /* host specific initialization of devices on a port */
493 void (*port_init_devs)(struct hwif_s *);
494 /* routine to program host for PIO mode */
495 void (*set_pio_mode)(ide_drive_t *, const u8);
496 /* routine to program host for DMA mode */
497 void (*set_dma_mode)(ide_drive_t *, const u8);
498 /* tweaks hardware to select drive */
499 void (*selectproc)(ide_drive_t *);
500 /* chipset polling based on hba specifics */
501 int (*reset_poll)(ide_drive_t *);
502 /* chipset specific changes to default for device-hba resets */
503 void (*pre_reset)(ide_drive_t *);
504 /* routine to reset controller after a disk reset */
505 void (*resetproc)(ide_drive_t *);
506 /* special host masking for drive selection */
507 void (*maskproc)(ide_drive_t *, int);
508 /* check host's drive quirk list */
509 void (*quirkproc)(ide_drive_t *);
510 /* driver soft-power interface */
511 int (*busproc)(ide_drive_t *, int);
512#endif
513 u8 (*mdma_filter)(ide_drive_t *);
514 u8 (*udma_filter)(ide_drive_t *);
515
516 u8 (*cable_detect)(struct hwif_s *);
517 471
518 void (*ata_input_data)(ide_drive_t *, void *, u32); 472 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
519 void (*ata_output_data)(ide_drive_t *, void *, u32); 473 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
520 474
521 void (*atapi_input_bytes)(ide_drive_t *, void *, u32); 475 void (*input_data)(ide_drive_t *, struct request *, void *, unsigned);
522 void (*atapi_output_bytes)(ide_drive_t *, void *, u32); 476 void (*output_data)(ide_drive_t *, struct request *, void *, unsigned);
523 477
524 void (*dma_host_set)(ide_drive_t *, int);
525 int (*dma_setup)(ide_drive_t *);
526 void (*dma_exec_cmd)(ide_drive_t *, u8);
527 void (*dma_start)(ide_drive_t *);
528 int (*ide_dma_end)(ide_drive_t *drive);
529 int (*ide_dma_test_irq)(ide_drive_t *drive);
530 void (*ide_dma_clear_irq)(ide_drive_t *drive); 478 void (*ide_dma_clear_irq)(ide_drive_t *drive);
531 void (*dma_lost_irq)(ide_drive_t *drive);
532 void (*dma_timeout)(ide_drive_t *drive);
533 479
534 void (*OUTB)(u8 addr, unsigned long port); 480 void (*OUTB)(u8 addr, unsigned long port);
535 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port); 481 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port);
536 void (*OUTW)(u16 addr, unsigned long port);
537 void (*OUTSW)(unsigned long port, void *addr, u32 count);
538 void (*OUTSL)(unsigned long port, void *addr, u32 count);
539 482
540 u8 (*INB)(unsigned long port); 483 u8 (*INB)(unsigned long port);
541 u16 (*INW)(unsigned long port);
542 void (*INSW)(unsigned long port, void *addr, u32 count);
543 void (*INSL)(unsigned long port, void *addr, u32 count);
544 484
545 /* dma physical region descriptor table (cpu view) */ 485 /* dma physical region descriptor table (cpu view) */
546 unsigned int *dmatable_cpu; 486 unsigned int *dmatable_cpu;
@@ -565,10 +505,7 @@ typedef struct hwif_s {
565 505
566 unsigned long dma_base; /* base addr for dma ports */ 506 unsigned long dma_base; /* base addr for dma ports */
567 unsigned long dma_command; /* dma command register */ 507 unsigned long dma_command; /* dma command register */
568 unsigned long dma_vendor1; /* dma vendor 1 register */
569 unsigned long dma_status; /* dma status register */ 508 unsigned long dma_status; /* dma status register */
570 unsigned long dma_vendor3; /* dma vendor 3 register */
571 unsigned long dma_prdtable; /* actual prd table address */
572 509
573 unsigned long config_data; /* for use by chipset-specific code */ 510 unsigned long config_data; /* for use by chipset-specific code */
574 unsigned long select_data; /* for use by chipset-specific code */ 511 unsigned long select_data; /* for use by chipset-specific code */
@@ -576,17 +513,15 @@ typedef struct hwif_s {
576 unsigned long extra_base; /* extra addr for dma ports */ 513 unsigned long extra_base; /* extra addr for dma ports */
577 unsigned extra_ports; /* number of extra dma ports */ 514 unsigned extra_ports; /* number of extra dma ports */
578 515
579 unsigned noprobe : 1; /* don't probe for this interface */
580 unsigned present : 1; /* this interface exists */ 516 unsigned present : 1; /* this interface exists */
581 unsigned hold : 1; /* this interface is always present */
582 unsigned serialized : 1; /* serialized all channel operation */ 517 unsigned serialized : 1; /* serialized all channel operation */
583 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 518 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
584 unsigned reset : 1; /* reset after probe */
585 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 519 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
586 unsigned mmio : 1; /* host uses MMIO */ 520 unsigned mmio : 1; /* host uses MMIO */
587 unsigned straight8 : 1; /* Alan's straight 8 check */
588 521
589 struct device gendev; 522 struct device gendev;
523 struct device *portdev;
524
590 struct completion gendev_rel_comp; /* To deal with device release() */ 525 struct completion gendev_rel_comp; /* To deal with device release() */
591 526
592 void *hwif_data; /* extra hwif data */ 527 void *hwif_data; /* extra hwif data */
@@ -605,7 +540,7 @@ typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
605typedef int (ide_expiry_t)(ide_drive_t *); 540typedef int (ide_expiry_t)(ide_drive_t *);
606 541
607/* used by ide-cd, ide-floppy, etc. */ 542/* used by ide-cd, ide-floppy, etc. */
608typedef void (xfer_func_t)(ide_drive_t *, void *, u32); 543typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned);
609 544
610typedef struct hwgroup_s { 545typedef struct hwgroup_s {
611 /* irq handler, if active */ 546 /* irq handler, if active */
@@ -647,6 +582,68 @@ int set_io_32bit(ide_drive_t *, int);
647int set_pio_mode(ide_drive_t *, int); 582int set_pio_mode(ide_drive_t *, int);
648int set_using_dma(ide_drive_t *, int); 583int set_using_dma(ide_drive_t *, int);
649 584
585/* ATAPI packet command flags */
586enum {
587 /* set when an error is considered normal - no retry (ide-tape) */
588 PC_FLAG_ABORT = (1 << 0),
589 PC_FLAG_SUPPRESS_ERROR = (1 << 1),
590 PC_FLAG_WAIT_FOR_DSC = (1 << 2),
591 PC_FLAG_DMA_OK = (1 << 3),
592 PC_FLAG_DMA_RECOMMENDED = (1 << 4),
593 PC_FLAG_DMA_IN_PROGRESS = (1 << 5),
594 PC_FLAG_DMA_ERROR = (1 << 6),
595 PC_FLAG_WRITING = (1 << 7),
596 /* command timed out */
597 PC_FLAG_TIMEDOUT = (1 << 8),
598};
599
600struct ide_atapi_pc {
601 /* actual packet bytes */
602 u8 c[12];
603 /* incremented on each retry */
604 int retries;
605 int error;
606
607 /* bytes to transfer */
608 int req_xfer;
609 /* bytes actually transferred */
610 int xferred;
611
612 /* data buffer */
613 u8 *buf;
614 /* current buffer position */
615 u8 *cur_pos;
616 int buf_size;
617 /* missing/available data on the current buffer */
618 int b_count;
619
620 /* the corresponding request */
621 struct request *rq;
622
623 unsigned long flags;
624
625 /*
626 * those are more or less driver-specific and some of them are subject
627 * to change/removal later.
628 */
629 u8 pc_buf[256];
630 void (*idefloppy_callback) (ide_drive_t *);
631 ide_startstop_t (*idetape_callback) (ide_drive_t *);
632
633 /* idetape only */
634 struct idetape_bh *bh;
635 char *b_data;
636
637 /* idescsi only for now */
638 struct scatterlist *sg;
639 unsigned int sg_cnt;
640
641 struct scsi_cmnd *scsi_cmd;
642 void (*done) (struct scsi_cmnd *);
643
644 unsigned long timeout;
645};
646
650#ifdef CONFIG_IDE_PROC_FS 647#ifdef CONFIG_IDE_PROC_FS
651/* 648/*
652 * configurable drive settings 649 * configurable drive settings
@@ -691,6 +688,7 @@ void proc_ide_create(void);
691void proc_ide_destroy(void); 688void proc_ide_destroy(void);
692void ide_proc_register_port(ide_hwif_t *); 689void ide_proc_register_port(ide_hwif_t *);
693void ide_proc_port_register_devices(ide_hwif_t *); 690void ide_proc_port_register_devices(ide_hwif_t *);
691void ide_proc_unregister_device(ide_drive_t *);
694void ide_proc_unregister_port(ide_hwif_t *); 692void ide_proc_unregister_port(ide_hwif_t *);
695void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); 693void ide_proc_register_driver(ide_drive_t *, ide_driver_t *);
696void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); 694void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *);
@@ -700,10 +698,6 @@ void ide_add_generic_settings(ide_drive_t *);
700read_proc_t proc_ide_read_capacity; 698read_proc_t proc_ide_read_capacity;
701read_proc_t proc_ide_read_geometry; 699read_proc_t proc_ide_read_geometry;
702 700
703#ifdef CONFIG_BLK_DEV_IDEPCI
704void ide_pci_create_host_proc(const char *, get_info_t *);
705#endif
706
707/* 701/*
708 * Standard exit stuff: 702 * Standard exit stuff:
709 */ 703 */
@@ -724,6 +718,7 @@ static inline void proc_ide_create(void) { ; }
724static inline void proc_ide_destroy(void) { ; } 718static inline void proc_ide_destroy(void) { ; }
725static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } 719static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; }
726static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } 720static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; }
721static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; }
727static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } 722static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; }
728static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 723static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
729static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 724static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
@@ -803,8 +798,21 @@ int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsig
803#ifndef _IDE_C 798#ifndef _IDE_C
804extern ide_hwif_t ide_hwifs[]; /* master data repository */ 799extern ide_hwif_t ide_hwifs[]; /* master data repository */
805#endif 800#endif
801extern int ide_noacpi;
802extern int ide_acpigtf;
803extern int ide_acpionboot;
806extern int noautodma; 804extern int noautodma;
807 805
806extern int ide_vlb_clk;
807extern int ide_pci_clk;
808
809ide_hwif_t *ide_find_port_slot(const struct ide_port_info *);
810
811static inline ide_hwif_t *ide_find_port(void)
812{
813 return ide_find_port_slot(NULL);
814}
815
808extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 816extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
809int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, 817int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
810 int uptodate, int nr_sectors); 818 int uptodate, int nr_sectors);
@@ -814,6 +822,10 @@ extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigne
814void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int, 822void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int,
815 ide_expiry_t *); 823 ide_expiry_t *);
816 824
825void ide_execute_pkt_cmd(ide_drive_t *);
826
827void ide_pad_transfer(ide_drive_t *, int, int);
828
817ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); 829ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
818 830
819ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); 831ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
@@ -950,8 +962,7 @@ typedef struct ide_task_s {
950 void *special; /* valid_t generally */ 962 void *special; /* valid_t generally */
951} ide_task_t; 963} ide_task_t;
952 964
953void ide_tf_load(ide_drive_t *, ide_task_t *); 965void ide_tf_dump(const char *, struct ide_taskfile *);
954void ide_tf_read(ide_drive_t *, ide_task_t *);
955 966
956extern void SELECT_DRIVE(ide_drive_t *); 967extern void SELECT_DRIVE(ide_drive_t *);
957extern void SELECT_MASK(ide_drive_t *, int); 968extern void SELECT_MASK(ide_drive_t *, int);
@@ -990,7 +1001,6 @@ extern void do_ide_request(struct request_queue *);
990void ide_init_disk(struct gendisk *, ide_drive_t *); 1001void ide_init_disk(struct gendisk *, ide_drive_t *);
991 1002
992#ifdef CONFIG_IDEPCI_PCIBUS_ORDER 1003#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
993extern int ide_scan_direction;
994extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name); 1004extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name);
995#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME) 1005#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME)
996#else 1006#else
@@ -1001,10 +1011,15 @@ void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8
1001void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1011void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
1002 1012
1003#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1013#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1004void ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); 1014int ide_pci_set_master(struct pci_dev *, const char *);
1015unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *);
1016int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
1005#else 1017#else
1006static inline void ide_hwif_setup_dma(ide_hwif_t *hwif, 1018static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
1007 const struct ide_port_info *d) { } 1019 const struct ide_port_info *d)
1020{
1021 return -EINVAL;
1022}
1008#endif 1023#endif
1009 1024
1010extern void default_hwif_iops(ide_hwif_t *); 1025extern void default_hwif_iops(ide_hwif_t *);
@@ -1024,8 +1039,8 @@ enum {
1024 IDE_HFLAG_SINGLE = (1 << 1), 1039 IDE_HFLAG_SINGLE = (1 << 1),
1025 /* don't use legacy PIO blacklist */ 1040 /* don't use legacy PIO blacklist */
1026 IDE_HFLAG_PIO_NO_BLACKLIST = (1 << 2), 1041 IDE_HFLAG_PIO_NO_BLACKLIST = (1 << 2),
1027 /* don't use conservative PIO "downgrade" */ 1042 /* set for the second port of QD65xx */
1028 IDE_HFLAG_PIO_NO_DOWNGRADE = (1 << 3), 1043 IDE_HFLAG_QD_2ND_PORT = (1 << 3),
1029 /* use PIO8/9 for prefetch off/on */ 1044 /* use PIO8/9 for prefetch off/on */
1030 IDE_HFLAG_ABUSE_PREFETCH = (1 << 4), 1045 IDE_HFLAG_ABUSE_PREFETCH = (1 << 4),
1031 /* use PIO6/7 for fast-devsel off/on */ 1046 /* use PIO6/7 for fast-devsel off/on */
@@ -1047,14 +1062,14 @@ enum {
1047 IDE_HFLAG_VDMA = (1 << 11), 1062 IDE_HFLAG_VDMA = (1 << 11),
1048 /* ATAPI DMA is unsupported */ 1063 /* ATAPI DMA is unsupported */
1049 IDE_HFLAG_NO_ATAPI_DMA = (1 << 12), 1064 IDE_HFLAG_NO_ATAPI_DMA = (1 << 12),
1050 /* set if host is a "bootable" controller */ 1065 /* set if host is a "non-bootable" controller */
1051 IDE_HFLAG_BOOTABLE = (1 << 13), 1066 IDE_HFLAG_NON_BOOTABLE = (1 << 13),
1052 /* host doesn't support DMA */ 1067 /* host doesn't support DMA */
1053 IDE_HFLAG_NO_DMA = (1 << 14), 1068 IDE_HFLAG_NO_DMA = (1 << 14),
1054 /* check if host is PCI IDE device before allowing DMA */ 1069 /* check if host is PCI IDE device before allowing DMA */
1055 IDE_HFLAG_NO_AUTODMA = (1 << 15), 1070 IDE_HFLAG_NO_AUTODMA = (1 << 15),
1056 /* don't autotune PIO */ 1071 /* host uses MMIO */
1057 IDE_HFLAG_NO_AUTOTUNE = (1 << 16), 1072 IDE_HFLAG_MMIO = (1 << 16),
1058 /* host is CS5510/CS5520 */ 1073 /* host is CS5510/CS5520 */
1059 IDE_HFLAG_CS5520 = IDE_HFLAG_VDMA, 1074 IDE_HFLAG_CS5520 = IDE_HFLAG_VDMA,
1060 /* no LBA48 */ 1075 /* no LBA48 */
@@ -1076,8 +1091,8 @@ enum {
1076 /* unmask IRQs */ 1091 /* unmask IRQs */
1077 IDE_HFLAG_UNMASK_IRQS = (1 << 25), 1092 IDE_HFLAG_UNMASK_IRQS = (1 << 25),
1078 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), 1093 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26),
1079 /* host is CY82C693 */ 1094 /* serialize ports if DMA is possible (for sl82c105) */
1080 IDE_HFLAG_CY82C693 = (1 << 27), 1095 IDE_HFLAG_SERIALIZE_DMA = (1 << 27),
1081 /* force host out of "simplex" mode */ 1096 /* force host out of "simplex" mode */
1082 IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), 1097 IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28),
1083 /* DSC overlap is unsupported */ 1098 /* DSC overlap is unsupported */
@@ -1089,9 +1104,9 @@ enum {
1089}; 1104};
1090 1105
1091#ifdef CONFIG_BLK_DEV_OFFBOARD 1106#ifdef CONFIG_BLK_DEV_OFFBOARD
1092# define IDE_HFLAG_OFF_BOARD IDE_HFLAG_BOOTABLE
1093#else
1094# define IDE_HFLAG_OFF_BOARD 0 1107# define IDE_HFLAG_OFF_BOARD 0
1108#else
1109# define IDE_HFLAG_OFF_BOARD IDE_HFLAG_NON_BOOTABLE
1095#endif 1110#endif
1096 1111
1097struct ide_port_info { 1112struct ide_port_info {
@@ -1099,10 +1114,14 @@ struct ide_port_info {
1099 unsigned int (*init_chipset)(struct pci_dev *, const char *); 1114 unsigned int (*init_chipset)(struct pci_dev *, const char *);
1100 void (*init_iops)(ide_hwif_t *); 1115 void (*init_iops)(ide_hwif_t *);
1101 void (*init_hwif)(ide_hwif_t *); 1116 void (*init_hwif)(ide_hwif_t *);
1102 void (*init_dma)(ide_hwif_t *, unsigned long); 1117 int (*init_dma)(ide_hwif_t *,
1118 const struct ide_port_info *);
1119
1120 const struct ide_port_ops *port_ops;
1121 const struct ide_dma_ops *dma_ops;
1122
1103 ide_pci_enablebit_t enablebits[2]; 1123 ide_pci_enablebit_t enablebits[2];
1104 hwif_chipset_t chipset; 1124 hwif_chipset_t chipset;
1105 u8 extra;
1106 u32 host_flags; 1125 u32 host_flags;
1107 u8 pio_mask; 1126 u8 pio_mask;
1108 u8 swdma_mask; 1127 u8 swdma_mask;
@@ -1149,13 +1168,16 @@ void ide_destroy_dmatable(ide_drive_t *);
1149 1168
1150#ifdef CONFIG_BLK_DEV_IDEDMA_SFF 1169#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
1151extern int ide_build_dmatable(ide_drive_t *, struct request *); 1170extern int ide_build_dmatable(ide_drive_t *, struct request *);
1152extern int ide_release_dma(ide_hwif_t *); 1171int ide_allocate_dma_engine(ide_hwif_t *);
1153extern void ide_setup_dma(ide_hwif_t *, unsigned long); 1172void ide_release_dma_engine(ide_hwif_t *);
1173void ide_setup_dma(ide_hwif_t *, unsigned long);
1154 1174
1155void ide_dma_host_set(ide_drive_t *, int); 1175void ide_dma_host_set(ide_drive_t *, int);
1156extern int ide_dma_setup(ide_drive_t *); 1176extern int ide_dma_setup(ide_drive_t *);
1177void ide_dma_exec_cmd(ide_drive_t *, u8);
1157extern void ide_dma_start(ide_drive_t *); 1178extern void ide_dma_start(ide_drive_t *);
1158extern int __ide_dma_end(ide_drive_t *); 1179extern int __ide_dma_end(ide_drive_t *);
1180int ide_dma_test_irq(ide_drive_t *);
1159extern void ide_dma_lost_irq(ide_drive_t *); 1181extern void ide_dma_lost_irq(ide_drive_t *);
1160extern void ide_dma_timeout(ide_drive_t *); 1182extern void ide_dma_timeout(ide_drive_t *);
1161#endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ 1183#endif /* CONFIG_BLK_DEV_IDEDMA_SFF */
@@ -1173,7 +1195,7 @@ static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
1173#endif /* CONFIG_BLK_DEV_IDEDMA */ 1195#endif /* CONFIG_BLK_DEV_IDEDMA */
1174 1196
1175#ifndef CONFIG_BLK_DEV_IDEDMA_SFF 1197#ifndef CONFIG_BLK_DEV_IDEDMA_SFF
1176static inline void ide_release_dma(ide_hwif_t *drive) {;} 1198static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
1177#endif 1199#endif
1178 1200
1179#ifdef CONFIG_BLK_DEV_IDEACPI 1201#ifdef CONFIG_BLK_DEV_IDEACPI
@@ -1193,17 +1215,20 @@ static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
1193#endif 1215#endif
1194 1216
1195void ide_remove_port_from_hwgroup(ide_hwif_t *); 1217void ide_remove_port_from_hwgroup(ide_hwif_t *);
1196extern int ide_hwif_request_regions(ide_hwif_t *hwif); 1218void ide_unregister(ide_hwif_t *);
1197extern void ide_hwif_release_regions(ide_hwif_t* hwif);
1198void ide_unregister(unsigned int, int, int);
1199 1219
1200void ide_register_region(struct gendisk *); 1220void ide_register_region(struct gendisk *);
1201void ide_unregister_region(struct gendisk *); 1221void ide_unregister_region(struct gendisk *);
1202 1222
1203void ide_undecoded_slave(ide_drive_t *); 1223void ide_undecoded_slave(ide_drive_t *);
1204 1224
1225void ide_port_apply_params(ide_hwif_t *);
1226
1205int ide_device_add_all(u8 *idx, const struct ide_port_info *); 1227int ide_device_add_all(u8 *idx, const struct ide_port_info *);
1206int ide_device_add(u8 idx[4], const struct ide_port_info *); 1228int ide_device_add(u8 idx[4], const struct ide_port_info *);
1229int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
1230void ide_port_unregister_devices(ide_hwif_t *);
1231void ide_port_scan(ide_hwif_t *);
1207 1232
1208static inline void *ide_get_hwifdata (ide_hwif_t * hwif) 1233static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
1209{ 1234{
@@ -1279,6 +1304,7 @@ extern struct mutex ide_cfg_mtx;
1279#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0) 1304#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0)
1280 1305
1281extern struct bus_type ide_bus_type; 1306extern struct bus_type ide_bus_type;
1307extern struct class *ide_port_class;
1282 1308
1283/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */ 1309/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */
1284#define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000) 1310#define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000)
@@ -1307,28 +1333,29 @@ static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
1307 1333
1308static inline void ide_set_irq(ide_drive_t *drive, int on) 1334static inline void ide_set_irq(ide_drive_t *drive, int on)
1309{ 1335{
1310 drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG); 1336 ide_hwif_t *hwif = drive->hwif;
1337
1338 hwif->OUTB(drive->ctl | (on ? 0 : 2), hwif->io_ports.ctl_addr);
1311} 1339}
1312 1340
1313static inline u8 ide_read_status(ide_drive_t *drive) 1341static inline u8 ide_read_status(ide_drive_t *drive)
1314{ 1342{
1315 ide_hwif_t *hwif = drive->hwif; 1343 ide_hwif_t *hwif = drive->hwif;
1316 1344
1317 return hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); 1345 return hwif->INB(hwif->io_ports.status_addr);
1318} 1346}
1319 1347
1320static inline u8 ide_read_altstatus(ide_drive_t *drive) 1348static inline u8 ide_read_altstatus(ide_drive_t *drive)
1321{ 1349{
1322 ide_hwif_t *hwif = drive->hwif; 1350 ide_hwif_t *hwif = drive->hwif;
1323 1351
1324 return hwif->INB(hwif->io_ports[IDE_CONTROL_OFFSET]); 1352 return hwif->INB(hwif->io_ports.ctl_addr);
1325} 1353}
1326 1354
1327static inline u8 ide_read_error(ide_drive_t *drive) 1355static inline u8 ide_read_error(ide_drive_t *drive)
1328{ 1356{
1329 ide_hwif_t *hwif = drive->hwif; 1357 ide_hwif_t *hwif = drive->hwif;
1330 1358
1331 return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]); 1359 return hwif->INB(hwif->io_ports.error_addr);
1332} 1360}
1333
1334#endif /* _IDE_H */ 1361#endif /* _IDE_H */
diff --git a/include/linux/idr.h b/include/linux/idr.h
index 0edda411959c..9a2d762124de 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -14,6 +14,7 @@
14 14
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/bitops.h> 16#include <linux/bitops.h>
17#include <linux/init.h>
17 18
18#if BITS_PER_LONG == 32 19#if BITS_PER_LONG == 32
19# define IDR_BITS 5 20# define IDR_BITS 5
@@ -115,4 +116,6 @@ void ida_remove(struct ida *ida, int id);
115void ida_destroy(struct ida *ida); 116void ida_destroy(struct ida *ida);
116void ida_init(struct ida *ida); 117void ida_init(struct ida *ida);
117 118
119void __init idr_init_cache(void);
120
118#endif /* __IDR_H__ */ 121#endif /* __IDR_H__ */
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index f577c8f1c66d..529f301d9372 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -97,6 +97,7 @@
97#define IEEE80211_MAX_FRAME_LEN 2352 97#define IEEE80211_MAX_FRAME_LEN 2352
98 98
99#define IEEE80211_MAX_SSID_LEN 32 99#define IEEE80211_MAX_SSID_LEN 32
100#define IEEE80211_MAX_MESH_ID_LEN 32
100 101
101struct ieee80211_hdr { 102struct ieee80211_hdr {
102 __le16 frame_control; 103 __le16 frame_control;
@@ -109,6 +110,16 @@ struct ieee80211_hdr {
109} __attribute__ ((packed)); 110} __attribute__ ((packed));
110 111
111 112
113struct ieee80211s_hdr {
114 u8 flags;
115 u8 ttl;
116 u8 seqnum[3];
117 u8 eaddr1[6];
118 u8 eaddr2[6];
119 u8 eaddr3[6];
120} __attribute__ ((packed));
121
122
112struct ieee80211_mgmt { 123struct ieee80211_mgmt {
113 __le16 frame_control; 124 __le16 frame_control;
114 __le16 duration; 125 __le16 duration;
@@ -206,6 +217,23 @@ struct ieee80211_mgmt {
206 __le16 params; 217 __le16 params;
207 __le16 reason_code; 218 __le16 reason_code;
208 } __attribute__((packed)) delba; 219 } __attribute__((packed)) delba;
220 struct{
221 u8 action_code;
222 /* capab_info for open and confirm,
223 * reason for close
224 */
225 __le16 aux;
226 /* Followed in plink_confirm by status
227 * code, AID and supported rates,
228 * and directly by supported rates in
229 * plink_open and plink_close
230 */
231 u8 variable[0];
232 } __attribute__((packed)) plink_action;
233 struct{
234 u8 action_code;
235 u8 variable[0];
236 } __attribute__((packed)) mesh_action;
209 } u; 237 } u;
210 } __attribute__ ((packed)) action; 238 } __attribute__ ((packed)) action;
211 } u; 239 } u;
@@ -437,6 +465,19 @@ enum ieee80211_eid {
437 WLAN_EID_TS_DELAY = 43, 465 WLAN_EID_TS_DELAY = 43,
438 WLAN_EID_TCLAS_PROCESSING = 44, 466 WLAN_EID_TCLAS_PROCESSING = 44,
439 WLAN_EID_QOS_CAPA = 46, 467 WLAN_EID_QOS_CAPA = 46,
468 /* 802.11s
469 *
470 * All mesh EID numbers are pending IEEE 802.11 ANA approval.
471 * The numbers have been incremented from those suggested in
472 * 802.11s/D2.0 so that MESH_CONFIG does not conflict with
473 * EXT_SUPP_RATES.
474 */
475 WLAN_EID_MESH_CONFIG = 51,
476 WLAN_EID_MESH_ID = 52,
477 WLAN_EID_PEER_LINK = 55,
478 WLAN_EID_PREQ = 68,
479 WLAN_EID_PREP = 69,
480 WLAN_EID_PERR = 70,
440 /* 802.11h */ 481 /* 802.11h */
441 WLAN_EID_PWR_CONSTRAINT = 32, 482 WLAN_EID_PWR_CONSTRAINT = 32,
442 WLAN_EID_PWR_CAPABILITY = 33, 483 WLAN_EID_PWR_CAPABILITY = 33,
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index 296e8e86e91d..4d3401812e6c 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -156,6 +156,12 @@ static inline struct arphdr *arp_hdr(const struct sk_buff *skb)
156{ 156{
157 return (struct arphdr *)skb_network_header(skb); 157 return (struct arphdr *)skb_network_header(skb);
158} 158}
159
160static inline int arp_hdr_len(struct net_device *dev)
161{
162 /* ARP header, plus 2 device addresses, plus 2 IP addresses. */
163 return sizeof(struct arphdr) + (dev->addr_len + sizeof(u32)) * 2;
164}
159#endif 165#endif
160 166
161#endif /* _LINUX_IF_ARP_H */ 167#endif /* _LINUX_IF_ARP_H */
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
index 0d9d7ea2c1cc..5f200bac3749 100644
--- a/include/linux/if_macvlan.h
+++ b/include/linux/if_macvlan.h
@@ -1,9 +1,6 @@
1#ifndef _LINUX_IF_MACVLAN_H 1#ifndef _LINUX_IF_MACVLAN_H
2#define _LINUX_IF_MACVLAN_H 2#define _LINUX_IF_MACVLAN_H
3 3
4#ifdef __KERNEL__
5
6extern struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *); 4extern struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *);
7 5
8#endif /* __KERNEL__ */
9#endif /* _LINUX_IF_MACVLAN_H */ 6#endif /* _LINUX_IF_MACVLAN_H */
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index 40743e032845..6fb7f1788570 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -24,7 +24,6 @@
24#include <linux/if_ether.h> 24#include <linux/if_ether.h>
25#include <linux/if.h> 25#include <linux/if.h>
26#include <linux/netdevice.h> 26#include <linux/netdevice.h>
27#include <asm/semaphore.h>
28#include <linux/ppp_channel.h> 27#include <linux/ppp_channel.h>
29#endif /* __KERNEL__ */ 28#endif /* __KERNEL__ */
30#include <linux/if_pppol2tp.h> 29#include <linux/if_pppol2tp.h>
diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h
index 228eb4eb3129..f1fbe9c930d7 100644
--- a/include/linux/if_tunnel.h
+++ b/include/linux/if_tunnel.h
@@ -7,6 +7,10 @@
7#define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1) 7#define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1)
8#define SIOCDELTUNNEL (SIOCDEVPRIVATE + 2) 8#define SIOCDELTUNNEL (SIOCDEVPRIVATE + 2)
9#define SIOCCHGTUNNEL (SIOCDEVPRIVATE + 3) 9#define SIOCCHGTUNNEL (SIOCDEVPRIVATE + 3)
10#define SIOCGETPRL (SIOCDEVPRIVATE + 4)
11#define SIOCADDPRL (SIOCDEVPRIVATE + 5)
12#define SIOCDELPRL (SIOCDEVPRIVATE + 6)
13#define SIOCCHGPRL (SIOCDEVPRIVATE + 7)
10 14
11#define GRE_CSUM __constant_htons(0x8000) 15#define GRE_CSUM __constant_htons(0x8000)
12#define GRE_ROUTING __constant_htons(0x4000) 16#define GRE_ROUTING __constant_htons(0x4000)
@@ -17,9 +21,6 @@
17#define GRE_FLAGS __constant_htons(0x00F8) 21#define GRE_FLAGS __constant_htons(0x00F8)
18#define GRE_VERSION __constant_htons(0x0007) 22#define GRE_VERSION __constant_htons(0x0007)
19 23
20/* i_flags values for SIT mode */
21#define SIT_ISATAP 0x0001
22
23struct ip_tunnel_parm 24struct ip_tunnel_parm
24{ 25{
25 char name[IFNAMSIZ]; 26 char name[IFNAMSIZ];
@@ -31,4 +32,19 @@ struct ip_tunnel_parm
31 struct iphdr iph; 32 struct iphdr iph;
32}; 33};
33 34
35/* SIT-mode i_flags */
36#define SIT_ISATAP 0x0001
37
38struct ip_tunnel_prl {
39 __be32 addr;
40 __u16 flags;
41 __u16 __reserved;
42 __u32 datalen;
43 __u32 __reserved2;
44 void __user *data;
45};
46
47/* PRL flags */
48#define PRL_DEFAULT 0x0001
49
34#endif /* _IF_TUNNEL_H_ */ 50#endif /* _IF_TUNNEL_H_ */
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 79504b22a932..15ace02b7b24 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -81,7 +81,9 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
81#define VLAN_GROUP_ARRAY_PART_LEN (VLAN_GROUP_ARRAY_LEN/VLAN_GROUP_ARRAY_SPLIT_PARTS) 81#define VLAN_GROUP_ARRAY_PART_LEN (VLAN_GROUP_ARRAY_LEN/VLAN_GROUP_ARRAY_SPLIT_PARTS)
82 82
83struct vlan_group { 83struct vlan_group {
84 int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */ 84 struct net_device *real_dev; /* The ethernet(like) device
85 * the vlan is attached to.
86 */
85 unsigned int nr_vlans; 87 unsigned int nr_vlans;
86 struct hlist_node hlist; /* linked list */ 88 struct hlist_node hlist; /* linked list */
87 struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS]; 89 struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS];
@@ -93,7 +95,7 @@ static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
93{ 95{
94 struct net_device **array; 96 struct net_device **array;
95 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN]; 97 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
96 return array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN]; 98 return array ? array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] : NULL;
97} 99}
98 100
99static inline void vlan_group_set_device(struct vlan_group *vg, 101static inline void vlan_group_set_device(struct vlan_group *vg,
diff --git a/include/linux/if_wanpipe.h b/include/linux/if_wanpipe.h
deleted file mode 100644
index e594ca6069e5..000000000000
--- a/include/linux/if_wanpipe.h
+++ /dev/null
@@ -1,124 +0,0 @@
1/*****************************************************************************
2* if_wanpipe.h Header file for the Sangoma AF_WANPIPE Socket
3*
4* Author: Nenad Corbic
5*
6* Copyright: (c) 2000 Sangoma Technologies Inc.
7*
8* This program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public License
10* as published by the Free Software Foundation; either version
11* 2 of the License, or (at your option) any later version.
12* ============================================================================
13*
14* Jan 28, 2000 Nenad Corbic Initial Version
15*
16*****************************************************************************/
17
18#ifndef __LINUX_IF_WAN_PACKET_H
19#define __LINUX_IF_WAN_PACKET_H
20
21struct wan_sockaddr_ll
22{
23 unsigned short sll_family;
24 unsigned short sll_protocol;
25 int sll_ifindex;
26 unsigned short sll_hatype;
27 unsigned char sll_pkttype;
28 unsigned char sll_halen;
29 unsigned char sll_addr[8];
30 unsigned char sll_device[14];
31 unsigned char sll_card[14];
32};
33
34typedef struct
35{
36 unsigned char free;
37 unsigned char state_sk;
38 int rcvbuf;
39 int sndbuf;
40 int rmem;
41 int wmem;
42 int sk_count;
43 unsigned char bound;
44 char name[14];
45 unsigned char d_state;
46 unsigned char svc;
47 unsigned short lcn;
48 unsigned char mbox;
49 unsigned char cmd_busy;
50 unsigned char command;
51 unsigned poll;
52 unsigned poll_cnt;
53 int rblock;
54} wan_debug_hdr_t;
55
56#define MAX_NUM_DEBUG 10
57#define X25_PROT 0x16
58#define PVC_PROT 0x17
59
60typedef struct
61{
62 wan_debug_hdr_t debug[MAX_NUM_DEBUG];
63}wan_debug_t;
64
65#define SIOC_WANPIPE_GET_CALL_DATA (SIOCPROTOPRIVATE + 0)
66#define SIOC_WANPIPE_SET_CALL_DATA (SIOCPROTOPRIVATE + 1)
67#define SIOC_WANPIPE_ACCEPT_CALL (SIOCPROTOPRIVATE + 2)
68#define SIOC_WANPIPE_CLEAR_CALL (SIOCPROTOPRIVATE + 3)
69#define SIOC_WANPIPE_RESET_CALL (SIOCPROTOPRIVATE + 4)
70#define SIOC_WANPIPE_DEBUG (SIOCPROTOPRIVATE + 5)
71#define SIOC_WANPIPE_SET_NONBLOCK (SIOCPROTOPRIVATE + 6)
72#define SIOC_WANPIPE_CHECK_TX (SIOCPROTOPRIVATE + 7)
73#define SIOC_WANPIPE_SOCK_STATE (SIOCPROTOPRIVATE + 8)
74
75/* Packet types */
76
77#define WAN_PACKET_HOST 0 /* To us */
78#define WAN_PACKET_BROADCAST 1 /* To all */
79#define WAN_PACKET_MULTICAST 2 /* To group */
80#define WAN_PACKET_OTHERHOST 3 /* To someone else */
81#define WAN_PACKET_OUTGOING 4 /* Outgoing of any type */
82/* These ones are invisible by user level */
83#define WAN_PACKET_LOOPBACK 5 /* MC/BRD frame looped back */
84#define WAN_PACKET_FASTROUTE 6 /* Fastrouted frame */
85
86
87/* X25 specific */
88#define WAN_PACKET_DATA 7
89#define WAN_PACKET_CMD 8
90#define WAN_PACKET_ASYNC 9
91#define WAN_PACKET_ERR 10
92
93/* Packet socket options */
94
95#define WAN_PACKET_ADD_MEMBERSHIP 1
96#define WAN_PACKET_DROP_MEMBERSHIP 2
97
98#define WAN_PACKET_MR_MULTICAST 0
99#define WAN_PACKET_MR_PROMISC 1
100#define WAN_PACKET_MR_ALLMULTI 2
101
102#ifdef __KERNEL__
103
104/* Private wanpipe socket structures. */
105struct wanpipe_opt
106{
107 void *mbox; /* Mail box */
108 void *card; /* Card bouded to */
109 struct net_device *dev; /* Bounded device */
110 unsigned short lcn; /* Binded LCN */
111 unsigned char svc; /* 0=pvc, 1=svc */
112 unsigned char timer; /* flag for delayed transmit*/
113 struct timer_list tx_timer;
114 unsigned poll_cnt;
115 unsigned char force; /* Used to force sock release */
116 atomic_t packet_sent;
117 unsigned short num;
118};
119
120#define wp_sk(__sk) ((struct wanpipe_opt *)(__sk)->sk_protinfo)
121
122#endif
123
124#endif
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index f510e7e382a8..f5a1a0db2e8e 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -80,27 +80,6 @@ struct igmpv3_query {
80 __be32 srcs[0]; 80 __be32 srcs[0];
81}; 81};
82 82
83#ifdef __KERNEL__
84#include <linux/skbuff.h>
85
86static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
87{
88 return (struct igmphdr *)skb_transport_header(skb);
89}
90
91static inline struct igmpv3_report *
92 igmpv3_report_hdr(const struct sk_buff *skb)
93{
94 return (struct igmpv3_report *)skb_transport_header(skb);
95}
96
97static inline struct igmpv3_query *
98 igmpv3_query_hdr(const struct sk_buff *skb)
99{
100 return (struct igmpv3_query *)skb_transport_header(skb);
101}
102#endif
103
104#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */ 83#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
105#define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */ 84#define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
106#define IGMP_DVMRP 0x13 /* DVMRP routing */ 85#define IGMP_DVMRP 0x13 /* DVMRP routing */
@@ -151,6 +130,23 @@ static inline struct igmpv3_query *
151#include <linux/timer.h> 130#include <linux/timer.h>
152#include <linux/in.h> 131#include <linux/in.h>
153 132
133static inline struct igmphdr *igmp_hdr(const struct sk_buff *skb)
134{
135 return (struct igmphdr *)skb_transport_header(skb);
136}
137
138static inline struct igmpv3_report *
139 igmpv3_report_hdr(const struct sk_buff *skb)
140{
141 return (struct igmpv3_report *)skb_transport_header(skb);
142}
143
144static inline struct igmpv3_query *
145 igmpv3_query_hdr(const struct sk_buff *skb)
146{
147 return (struct igmpv3_query *)skb_transport_header(skb);
148}
149
154extern int sysctl_igmp_max_memberships; 150extern int sysctl_igmp_max_memberships;
155extern int sysctl_igmp_max_msf; 151extern int sysctl_igmp_max_msf;
156 152
diff --git a/include/linux/in6.h b/include/linux/in6.h
index 2a61c82af115..bc492048c349 100644
--- a/include/linux/in6.h
+++ b/include/linux/in6.h
@@ -48,6 +48,14 @@ extern const struct in6_addr in6addr_any;
48#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } 48#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
49extern const struct in6_addr in6addr_loopback; 49extern const struct in6_addr in6addr_loopback;
50#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } 50#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
51#ifdef __KERNEL__
52extern const struct in6_addr in6addr_linklocal_allnodes;
53#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
54 { { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
55extern const struct in6_addr in6addr_linklocal_allrouters;
56#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
57 { { { 0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2 } } }
58#endif
51 59
52struct sockaddr_in6 { 60struct sockaddr_in6 {
53 unsigned short int sin6_family; /* AF_INET6 */ 61 unsigned short int sin6_family; /* AF_INET6 */
@@ -249,4 +257,30 @@ struct in6_flowlabel_req
249 * IP6T_SO_GET_REVISION_TARGET 69 257 * IP6T_SO_GET_REVISION_TARGET 69
250 */ 258 */
251 259
260/* RFC5014: Source address selection */
261#define IPV6_ADDR_PREFERENCES 72
262
263#define IPV6_PREFER_SRC_TMP 0x0001
264#define IPV6_PREFER_SRC_PUBLIC 0x0002
265#define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100
266#define IPV6_PREFER_SRC_COA 0x0004
267#define IPV6_PREFER_SRC_HOME 0x0400
268#define IPV6_PREFER_SRC_CGA 0x0008
269#define IPV6_PREFER_SRC_NONCGA 0x0800
270
271/*
272 * Multicast Routing:
273 * see include/linux/mroute6.h.
274 *
275 * MRT6_INIT 200
276 * MRT6_DONE 201
277 * MRT6_ADD_MIF 202
278 * MRT6_DEL_MIF 203
279 * MRT6_ADD_MFC 204
280 * MRT6_DEL_MFC 205
281 * MRT6_VERSION 206
282 * MRT6_ASSERT 207
283 * MRT6_PIM 208
284 * (reserved) 209
285 */
252#endif 286#endif
diff --git a/include/linux/inet.h b/include/linux/inet.h
index 675a7dbe86f8..1354080cf8cf 100644
--- a/include/linux/inet.h
+++ b/include/linux/inet.h
@@ -42,11 +42,9 @@
42#ifndef _LINUX_INET_H 42#ifndef _LINUX_INET_H
43#define _LINUX_INET_H 43#define _LINUX_INET_H
44 44
45#ifdef __KERNEL__
46#include <linux/types.h> 45#include <linux/types.h>
47 46
48extern __be32 in_aton(const char *str); 47extern __be32 in_aton(const char *str);
49extern int in4_pton(const char *src, int srclen, u8 *dst, int delim, const char **end); 48extern int in4_pton(const char *src, int srclen, u8 *dst, int delim, const char **end);
50extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char **end); 49extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char **end);
51#endif
52#endif /* _LINUX_INET_H */ 50#endif /* _LINUX_INET_H */
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index fc4e3db649e8..7009b0cdd06f 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -70,13 +70,13 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev)
70 ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val)) 70 ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val))
71 71
72#define IN_DEV_ANDCONF(in_dev, attr) \ 72#define IN_DEV_ANDCONF(in_dev, attr) \
73 (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr) && \ 73 (IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr) && \
74 IN_DEV_CONF_GET((in_dev), 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(in_dev->dev->nd_net, attr) || \ 76 (IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr) || \
77 IN_DEV_CONF_GET((in_dev), attr)) 77 IN_DEV_CONF_GET((in_dev), attr))
78#define IN_DEV_MAXCONF(in_dev, attr) \ 78#define IN_DEV_MAXCONF(in_dev, attr) \
79 (max(IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr), \ 79 (max(IPV4_DEVCONF_ALL(dev_net(in_dev->dev), attr), \
80 IN_DEV_CONF_GET((in_dev), attr))) 80 IN_DEV_CONF_GET((in_dev), attr)))
81 81
82#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)
@@ -129,7 +129,7 @@ extern int unregister_inetaddr_notifier(struct notifier_block *nb);
129 129
130extern struct net_device *ip_dev_find(struct net *net, __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(struct net *net, unsigned int cmd, void __user *);
133extern void devinet_init(void); 133extern void devinet_init(void);
134extern struct in_device *inetdev_by_index(struct net *, 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);
diff --git a/include/linux/init.h b/include/linux/init.h
index fb58c0493cf2..21d658cdfa27 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -147,6 +147,8 @@ extern unsigned int reset_devices;
147void setup_arch(char **); 147void setup_arch(char **);
148void prepare_namespace(void); 148void prepare_namespace(void);
149 149
150extern void (*late_time_init)(void);
151
150#endif 152#endif
151 153
152#ifndef MODULE 154#ifndef MODULE
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 1f74e1d7415f..bf6b8a61f8db 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -9,6 +9,7 @@
9#include <linux/ipc.h> 9#include <linux/ipc.h>
10#include <linux/pid_namespace.h> 10#include <linux/pid_namespace.h>
11#include <linux/user_namespace.h> 11#include <linux/user_namespace.h>
12#include <linux/securebits.h>
12#include <net/net_namespace.h> 13#include <net/net_namespace.h>
13 14
14#define INIT_FDTABLE \ 15#define INIT_FDTABLE \
@@ -151,6 +152,9 @@ extern struct group_info init_groups;
151 .cpus_allowed = CPU_MASK_ALL, \ 152 .cpus_allowed = CPU_MASK_ALL, \
152 .mm = NULL, \ 153 .mm = NULL, \
153 .active_mm = &init_mm, \ 154 .active_mm = &init_mm, \
155 .se = { \
156 .group_node = LIST_HEAD_INIT(tsk.se.group_node), \
157 }, \
154 .rt = { \ 158 .rt = { \
155 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \ 159 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
156 .time_slice = HZ, \ 160 .time_slice = HZ, \
@@ -169,7 +173,7 @@ extern struct group_info init_groups;
169 .cap_inheritable = CAP_INIT_INH_SET, \ 173 .cap_inheritable = CAP_INIT_INH_SET, \
170 .cap_permitted = CAP_FULL_SET, \ 174 .cap_permitted = CAP_FULL_SET, \
171 .cap_bset = CAP_INIT_BSET, \ 175 .cap_bset = CAP_INIT_BSET, \
172 .keep_capabilities = 0, \ 176 .securebits = SECUREBITS_DEFAULT, \
173 .user = INIT_USER, \ 177 .user = INIT_USER, \
174 .comm = "swapper", \ 178 .comm = "swapper", \
175 .thread = INIT_THREAD, \ 179 .thread = INIT_THREAD, \
diff --git a/include/linux/input.h b/include/linux/input.h
index cae2c35d1206..28a094fcfe20 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1025,10 +1025,6 @@ struct ff_effect {
1025 * @node: used to place the device onto input_dev_list 1025 * @node: used to place the device onto input_dev_list
1026 */ 1026 */
1027struct input_dev { 1027struct input_dev {
1028 /* private: */
1029 void *private; /* do not use */
1030 /* public: */
1031
1032 const char *name; 1028 const char *name;
1033 const char *phys; 1029 const char *phys;
1034 const char *uniq; 1030 const char *uniq;
@@ -1238,12 +1234,12 @@ static inline void input_put_device(struct input_dev *dev)
1238 1234
1239static inline void *input_get_drvdata(struct input_dev *dev) 1235static inline void *input_get_drvdata(struct input_dev *dev)
1240{ 1236{
1241 return dev->private; 1237 return dev_get_drvdata(&dev->dev);
1242} 1238}
1243 1239
1244static inline void input_set_drvdata(struct input_dev *dev, void *data) 1240static inline void input_set_drvdata(struct input_dev *dev, void *data)
1245{ 1241{
1246 dev->private = data; 1242 dev_set_drvdata(&dev->dev, data);
1247} 1243}
1248 1244
1249int __must_check input_register_device(struct input_dev *); 1245int __must_check input_register_device(struct input_dev *);
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index f8ab4ce70564..f1fc7470d26c 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -102,6 +102,25 @@ extern void disable_irq_nosync(unsigned int irq);
102extern void disable_irq(unsigned int irq); 102extern void disable_irq(unsigned int irq);
103extern void enable_irq(unsigned int irq); 103extern void enable_irq(unsigned int irq);
104 104
105#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS)
106
107extern int irq_set_affinity(unsigned int irq, cpumask_t cpumask);
108extern int irq_can_set_affinity(unsigned int irq);
109
110#else /* CONFIG_SMP */
111
112static inline int irq_set_affinity(unsigned int irq, cpumask_t cpumask)
113{
114 return -EINVAL;
115}
116
117static inline int irq_can_set_affinity(unsigned int irq)
118{
119 return 0;
120}
121
122#endif /* CONFIG_SMP && CONFIG_GENERIC_HARDIRQS */
123
105#ifdef CONFIG_GENERIC_HARDIRQS 124#ifdef CONFIG_GENERIC_HARDIRQS
106/* 125/*
107 * Special lockdep variants of irq disabling/enabling. 126 * Special lockdep variants of irq disabling/enabling.
@@ -270,6 +289,7 @@ struct softirq_action
270}; 289};
271 290
272asmlinkage void do_softirq(void); 291asmlinkage void do_softirq(void);
292asmlinkage void __do_softirq(void);
273extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data); 293extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
274extern void softirq_init(void); 294extern void softirq_init(void);
275#define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0) 295#define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0)
diff --git a/include/linux/io.h b/include/linux/io.h
index e3b2dda6c8eb..3a03a3604cce 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -58,9 +58,9 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
58} 58}
59#endif 59#endif
60 60
61void __iomem * devm_ioremap(struct device *dev, unsigned long offset, 61void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
62 unsigned long size); 62 unsigned long size);
63void __iomem * devm_ioremap_nocache(struct device *dev, unsigned long offset, 63void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
64 unsigned long size); 64 unsigned long size);
65void devm_iounmap(struct device *dev, void __iomem *addr); 65void devm_iounmap(struct device *dev, void __iomem *addr);
66int check_signature(const volatile void __iomem *io_addr, 66int check_signature(const volatile void __iomem *io_addr,
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 605d237364d2..d5d40a9f7929 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -44,7 +44,9 @@ struct resource_list {
44#define IORESOURCE_CACHEABLE 0x00004000 44#define IORESOURCE_CACHEABLE 0x00004000
45#define IORESOURCE_RANGELENGTH 0x00008000 45#define IORESOURCE_RANGELENGTH 0x00008000
46#define IORESOURCE_SHADOWABLE 0x00010000 46#define IORESOURCE_SHADOWABLE 0x00010000
47#define IORESOURCE_BUS_HAS_VGA 0x00080000 47
48#define IORESOURCE_SIZEALIGN 0x00020000 /* size indicates alignment */
49#define IORESOURCE_STARTALIGN 0x00040000 /* start field is alignment */
48 50
49#define IORESOURCE_DISABLED 0x10000000 51#define IORESOURCE_DISABLED 0x10000000
50#define IORESOURCE_UNSET 0x20000000 52#define IORESOURCE_UNSET 0x20000000
@@ -110,6 +112,7 @@ extern int allocate_resource(struct resource *root, struct resource *new,
110 void *alignf_data); 112 void *alignf_data);
111int adjust_resource(struct resource *res, resource_size_t start, 113int adjust_resource(struct resource *res, resource_size_t start,
112 resource_size_t size); 114 resource_size_t size);
115resource_size_t resource_alignment(struct resource *res);
113 116
114/* Convenience shorthand with allocation */ 117/* Convenience shorthand with allocation */
115#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name)) 118#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index e4451d1da753..ea6c18a8b0d4 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -4,6 +4,17 @@
4#include <linux/err.h> 4#include <linux/err.h>
5#include <linux/idr.h> 5#include <linux/idr.h>
6#include <linux/rwsem.h> 6#include <linux/rwsem.h>
7#include <linux/notifier.h>
8
9/*
10 * ipc namespace events
11 */
12#define IPCNS_MEMCHANGED 0x00000001 /* Notify lowmem size changed */
13#define IPCNS_CREATED 0x00000002 /* Notify new ipc namespace created */
14#define IPCNS_REMOVED 0x00000003 /* Notify ipc namespace removed */
15
16#define IPCNS_CALLBACK_PRI 0
17
7 18
8struct ipc_ids { 19struct ipc_ids {
9 int in_use; 20 int in_use;
@@ -30,15 +41,24 @@ struct ipc_namespace {
30 size_t shm_ctlall; 41 size_t shm_ctlall;
31 int shm_ctlmni; 42 int shm_ctlmni;
32 int shm_tot; 43 int shm_tot;
44
45 struct notifier_block ipcns_nb;
33}; 46};
34 47
35extern struct ipc_namespace init_ipc_ns; 48extern struct ipc_namespace init_ipc_ns;
49extern atomic_t nr_ipc_ns;
36 50
37#ifdef CONFIG_SYSVIPC 51#ifdef CONFIG_SYSVIPC
38#define INIT_IPC_NS(ns) .ns = &init_ipc_ns, 52#define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
39#else 53
54extern int register_ipcns_notifier(struct ipc_namespace *);
55extern int cond_register_ipcns_notifier(struct ipc_namespace *);
56extern int unregister_ipcns_notifier(struct ipc_namespace *);
57extern int ipcns_notify(unsigned long);
58
59#else /* CONFIG_SYSVIPC */
40#define INIT_IPC_NS(ns) 60#define INIT_IPC_NS(ns)
41#endif 61#endif /* CONFIG_SYSVIPC */
42 62
43#if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS) 63#if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS)
44extern void free_ipc_ns(struct kref *kref); 64extern void free_ipc_ns(struct kref *kref);
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h
index c5bd28b69aec..7ebdb4fb4e54 100644
--- a/include/linux/ipmi.h
+++ b/include/linux/ipmi.h
@@ -64,7 +64,7 @@
64 * applications and another for userland applications. The 64 * applications and another for userland applications. The
65 * capabilities are basically the same for both interface, although 65 * capabilities are basically the same for both interface, although
66 * the interfaces are somewhat different. The stuff in the 66 * the interfaces are somewhat different. The stuff in the
67 * #ifdef KERNEL below is the in-kernel interface. The userland 67 * #ifdef __KERNEL__ below is the in-kernel interface. The userland
68 * interface is defined later in the file. */ 68 * interface is defined later in the file. */
69 69
70 70
@@ -75,8 +75,7 @@
75 * work for sockets. 75 * work for sockets.
76 */ 76 */
77#define IPMI_MAX_ADDR_SIZE 32 77#define IPMI_MAX_ADDR_SIZE 32
78struct ipmi_addr 78struct ipmi_addr {
79{
80 /* Try to take these from the "Channel Medium Type" table 79 /* Try to take these from the "Channel Medium Type" table
81 in section 6.5 of the IPMI 1.5 manual. */ 80 in section 6.5 of the IPMI 1.5 manual. */
82 int addr_type; 81 int addr_type;
@@ -90,8 +89,7 @@ struct ipmi_addr
90 * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC. 89 * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC.
91 */ 90 */
92#define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c 91#define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c
93struct ipmi_system_interface_addr 92struct ipmi_system_interface_addr {
94{
95 int addr_type; 93 int addr_type;
96 short channel; 94 short channel;
97 unsigned char lun; 95 unsigned char lun;
@@ -100,10 +98,9 @@ struct ipmi_system_interface_addr
100/* An IPMB Address. */ 98/* An IPMB Address. */
101#define IPMI_IPMB_ADDR_TYPE 0x01 99#define IPMI_IPMB_ADDR_TYPE 0x01
102/* Used for broadcast get device id as described in section 17.9 of the 100/* Used for broadcast get device id as described in section 17.9 of the
103 IPMI 1.5 manual. */ 101 IPMI 1.5 manual. */
104#define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41 102#define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41
105struct ipmi_ipmb_addr 103struct ipmi_ipmb_addr {
106{
107 int addr_type; 104 int addr_type;
108 short channel; 105 short channel;
109 unsigned char slave_addr; 106 unsigned char slave_addr;
@@ -128,8 +125,7 @@ struct ipmi_ipmb_addr
128 * message is a little weird, but this is required. 125 * message is a little weird, but this is required.
129 */ 126 */
130#define IPMI_LAN_ADDR_TYPE 0x04 127#define IPMI_LAN_ADDR_TYPE 0x04
131struct ipmi_lan_addr 128struct ipmi_lan_addr {
132{
133 int addr_type; 129 int addr_type;
134 short channel; 130 short channel;
135 unsigned char privilege; 131 unsigned char privilege;
@@ -162,16 +158,14 @@ struct ipmi_lan_addr
162 * byte of data in the response (as the spec shows the messages laid 158 * byte of data in the response (as the spec shows the messages laid
163 * out). 159 * out).
164 */ 160 */
165struct ipmi_msg 161struct ipmi_msg {
166{
167 unsigned char netfn; 162 unsigned char netfn;
168 unsigned char cmd; 163 unsigned char cmd;
169 unsigned short data_len; 164 unsigned short data_len;
170 unsigned char __user *data; 165 unsigned char __user *data;
171}; 166};
172 167
173struct kernel_ipmi_msg 168struct kernel_ipmi_msg {
174{
175 unsigned char netfn; 169 unsigned char netfn;
176 unsigned char cmd; 170 unsigned char cmd;
177 unsigned short data_len; 171 unsigned short data_len;
@@ -239,12 +233,11 @@ typedef struct ipmi_user *ipmi_user_t;
239 * used after the message is delivered, so the upper layer may use the 233 * used after the message is delivered, so the upper layer may use the
240 * link to build a linked list, if it likes. 234 * link to build a linked list, if it likes.
241 */ 235 */
242struct ipmi_recv_msg 236struct ipmi_recv_msg {
243{
244 struct list_head link; 237 struct list_head link;
245 238
246 /* The type of message as defined in the "Receive Types" 239 /* The type of message as defined in the "Receive Types"
247 defines above. */ 240 defines above. */
248 int recv_type; 241 int recv_type;
249 242
250 ipmi_user_t user; 243 ipmi_user_t user;
@@ -271,9 +264,8 @@ struct ipmi_recv_msg
271/* Allocate and free the receive message. */ 264/* Allocate and free the receive message. */
272void ipmi_free_recv_msg(struct ipmi_recv_msg *msg); 265void ipmi_free_recv_msg(struct ipmi_recv_msg *msg);
273 266
274struct ipmi_user_hndl 267struct ipmi_user_hndl {
275{ 268 /* Routine type to call when a message needs to be routed to
276 /* Routine type to call when a message needs to be routed to
277 the upper layer. This will be called with some locks held, 269 the upper layer. This will be called with some locks held,
278 the only IPMI routines that can be called are ipmi_request 270 the only IPMI routines that can be called are ipmi_request
279 and the alloc/free operations. The handler_data is the 271 and the alloc/free operations. The handler_data is the
@@ -368,9 +360,8 @@ int ipmi_request_supply_msgs(ipmi_user_t user,
368 * Poll the IPMI interface for the user. This causes the IPMI code to 360 * Poll the IPMI interface for the user. This causes the IPMI code to
369 * do an immediate check for information from the driver and handle 361 * do an immediate check for information from the driver and handle
370 * anything that is immediately pending. This will not block in any 362 * anything that is immediately pending. This will not block in any
371 * way. This is useful if you need to implement polling from the user 363 * way. This is useful if you need to spin waiting for something to
372 * for things like modifying the watchdog timeout when a panic occurs 364 * happen in the IPMI driver.
373 * or disabling the watchdog timer on a reboot.
374 */ 365 */
375void ipmi_poll_interface(ipmi_user_t user); 366void ipmi_poll_interface(ipmi_user_t user);
376 367
@@ -422,12 +413,6 @@ int ipmi_get_maintenance_mode(ipmi_user_t user);
422int ipmi_set_maintenance_mode(ipmi_user_t user, int mode); 413int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);
423 414
424/* 415/*
425 * Allow run-to-completion mode to be set for the interface of
426 * a specific user.
427 */
428void ipmi_user_set_run_to_completion(ipmi_user_t user, int val);
429
430/*
431 * When the user is created, it will not receive IPMI events by 416 * When the user is created, it will not receive IPMI events by
432 * default. The user must set this to TRUE to get incoming events. 417 * default. The user must set this to TRUE to get incoming events.
433 * The first user that sets this to TRUE will receive all events that 418 * The first user that sets this to TRUE will receive all events that
@@ -440,8 +425,7 @@ int ipmi_set_gets_events(ipmi_user_t user, int val);
440 * every existing interface when a new watcher is registered with 425 * every existing interface when a new watcher is registered with
441 * ipmi_smi_watcher_register(). 426 * ipmi_smi_watcher_register().
442 */ 427 */
443struct ipmi_smi_watcher 428struct ipmi_smi_watcher {
444{
445 struct list_head link; 429 struct list_head link;
446 430
447 /* You must set the owner to the current module, if you are in 431 /* You must set the owner to the current module, if you are in
@@ -512,8 +496,7 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len);
512 496
513 497
514/* Messages sent to the interface are this format. */ 498/* Messages sent to the interface are this format. */
515struct ipmi_req 499struct ipmi_req {
516{
517 unsigned char __user *addr; /* Address to send the message to. */ 500 unsigned char __user *addr; /* Address to send the message to. */
518 unsigned int addr_len; 501 unsigned int addr_len;
519 502
@@ -538,12 +521,11 @@ struct ipmi_req
538 521
539/* Messages sent to the interface with timing parameters are this 522/* Messages sent to the interface with timing parameters are this
540 format. */ 523 format. */
541struct ipmi_req_settime 524struct ipmi_req_settime {
542{
543 struct ipmi_req req; 525 struct ipmi_req req;
544 526
545 /* See ipmi_request_settime() above for details on these 527 /* See ipmi_request_settime() above for details on these
546 values. */ 528 values. */
547 int retries; 529 int retries;
548 unsigned int retry_time_ms; 530 unsigned int retry_time_ms;
549}; 531};
@@ -560,8 +542,7 @@ struct ipmi_req_settime
560 struct ipmi_req_settime) 542 struct ipmi_req_settime)
561 543
562/* Messages received from the interface are this format. */ 544/* Messages received from the interface are this format. */
563struct ipmi_recv 545struct ipmi_recv {
564{
565 int recv_type; /* Is this a command, response or an 546 int recv_type; /* Is this a command, response or an
566 asyncronous event. */ 547 asyncronous event. */
567 548
@@ -607,13 +588,12 @@ struct ipmi_recv
607 struct ipmi_recv) 588 struct ipmi_recv)
608 589
609/* Register to get commands from other entities on this interface. */ 590/* Register to get commands from other entities on this interface. */
610struct ipmi_cmdspec 591struct ipmi_cmdspec {
611{
612 unsigned char netfn; 592 unsigned char netfn;
613 unsigned char cmd; 593 unsigned char cmd;
614}; 594};
615 595
616/* 596/*
617 * Register to receive a specific command. error values: 597 * Register to receive a specific command. error values:
618 * - EFAULT - an address supplied was invalid. 598 * - EFAULT - an address supplied was invalid.
619 * - EBUSY - The netfn/cmd supplied was already in use. 599 * - EBUSY - The netfn/cmd supplied was already in use.
@@ -636,8 +616,7 @@ struct ipmi_cmdspec
636 * else. The chans field is a bitmask, (1 << channel) for each channel. 616 * else. The chans field is a bitmask, (1 << channel) for each channel.
637 * It may be IPMI_CHAN_ALL for all channels. 617 * It may be IPMI_CHAN_ALL for all channels.
638 */ 618 */
639struct ipmi_cmdspec_chans 619struct ipmi_cmdspec_chans {
640{
641 unsigned int netfn; 620 unsigned int netfn;
642 unsigned int cmd; 621 unsigned int cmd;
643 unsigned int chans; 622 unsigned int chans;
@@ -659,7 +638,7 @@ struct ipmi_cmdspec_chans
659#define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29, \ 638#define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29, \
660 struct ipmi_cmdspec_chans) 639 struct ipmi_cmdspec_chans)
661 640
662/* 641/*
663 * Set whether this interface receives events. Note that the first 642 * Set whether this interface receives events. Note that the first
664 * user registered for events will get all pending events for the 643 * user registered for events will get all pending events for the
665 * interface. error values: 644 * interface. error values:
@@ -675,15 +654,18 @@ struct ipmi_cmdspec_chans
675 * things it takes to determine your address (if not the BMC) and set 654 * things it takes to determine your address (if not the BMC) and set
676 * it for everyone else. You should probably leave the LUN alone. 655 * it for everyone else. You should probably leave the LUN alone.
677 */ 656 */
678struct ipmi_channel_lun_address_set 657struct ipmi_channel_lun_address_set {
679{
680 unsigned short channel; 658 unsigned short channel;
681 unsigned char value; 659 unsigned char value;
682}; 660};
683#define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set) 661#define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD \
684#define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set) 662 _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set)
685#define IPMICTL_SET_MY_CHANNEL_LUN_CMD _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set) 663#define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD \
686#define IPMICTL_GET_MY_CHANNEL_LUN_CMD _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set) 664 _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set)
665#define IPMICTL_SET_MY_CHANNEL_LUN_CMD \
666 _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set)
667#define IPMICTL_GET_MY_CHANNEL_LUN_CMD \
668 _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set)
687/* Legacy interfaces, these only set IPMB 0. */ 669/* Legacy interfaces, these only set IPMB 0. */
688#define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int) 670#define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int)
689#define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int) 671#define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
@@ -694,8 +676,7 @@ struct ipmi_channel_lun_address_set
694 * Get/set the default timing values for an interface. You shouldn't 676 * Get/set the default timing values for an interface. You shouldn't
695 * generally mess with these. 677 * generally mess with these.
696 */ 678 */
697struct ipmi_timing_parms 679struct ipmi_timing_parms {
698{
699 int retries; 680 int retries;
700 unsigned int retry_time_ms; 681 unsigned int retry_time_ms;
701}; 682};
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
index 6e8cec503380..62b73668b602 100644
--- a/include/linux/ipmi_smi.h
+++ b/include/linux/ipmi_smi.h
@@ -60,8 +60,7 @@ typedef struct ipmi_smi *ipmi_smi_t;
60 * asynchronous data and messages and request them from the 60 * asynchronous data and messages and request them from the
61 * interface. 61 * interface.
62 */ 62 */
63struct ipmi_smi_msg 63struct ipmi_smi_msg {
64{
65 struct list_head link; 64 struct list_head link;
66 65
67 long msgid; 66 long msgid;
@@ -74,12 +73,11 @@ struct ipmi_smi_msg
74 unsigned char rsp[IPMI_MAX_MSG_LENGTH]; 73 unsigned char rsp[IPMI_MAX_MSG_LENGTH];
75 74
76 /* Will be called when the system is done with the message 75 /* Will be called when the system is done with the message
77 (presumably to free it). */ 76 (presumably to free it). */
78 void (*done)(struct ipmi_smi_msg *msg); 77 void (*done)(struct ipmi_smi_msg *msg);
79}; 78};
80 79
81struct ipmi_smi_handlers 80struct ipmi_smi_handlers {
82{
83 struct module *owner; 81 struct module *owner;
84 82
85 /* The low-level interface cannot start sending messages to 83 /* The low-level interface cannot start sending messages to
@@ -231,7 +229,7 @@ static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
231 directory for this interface. Note that the entry will 229 directory for this interface. Note that the entry will
232 automatically be dstroyed when the interface is destroyed. */ 230 automatically be dstroyed when the interface is destroyed. */
233int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 231int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
234 read_proc_t *read_proc, write_proc_t *write_proc, 232 read_proc_t *read_proc,
235 void *data, struct module *owner); 233 void *data, struct module *owner);
236 234
237#endif /* __LINUX_IPMI_SMI_H */ 235#endif /* __LINUX_IPMI_SMI_H */
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 134c8e5cf07c..10b666b61add 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -160,6 +160,9 @@ struct ipv6_devconf {
160#ifdef CONFIG_IPV6_OPTIMISTIC_DAD 160#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
161 __s32 optimistic_dad; 161 __s32 optimistic_dad;
162#endif 162#endif
163#ifdef CONFIG_IPV6_MROUTE
164 __s32 mc_forwarding;
165#endif
163 void *sysctl; 166 void *sysctl;
164}; 167};
165 168
@@ -190,6 +193,7 @@ enum {
190 DEVCONF_PROXY_NDP, 193 DEVCONF_PROXY_NDP,
191 DEVCONF_OPTIMISTIC_DAD, 194 DEVCONF_OPTIMISTIC_DAD,
192 DEVCONF_ACCEPT_SOURCE_ROUTE, 195 DEVCONF_ACCEPT_SOURCE_ROUTE,
196 DEVCONF_MC_FORWARDING,
193 DEVCONF_MAX 197 DEVCONF_MAX
194}; 198};
195 199
@@ -230,6 +234,7 @@ struct inet6_skb_parm {
230#endif 234#endif
231 235
232#define IP6SKB_XFRM_TRANSFORMED 1 236#define IP6SKB_XFRM_TRANSFORMED 1
237#define IP6SKB_FORWARDED 2
233}; 238};
234 239
235#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb)) 240#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
@@ -274,8 +279,29 @@ struct ipv6_pinfo {
274 279
275 __be32 flow_label; 280 __be32 flow_label;
276 __u32 frag_size; 281 __u32 frag_size;
277 __s16 hop_limit; 282
278 __s16 mcast_hops; 283 /*
284 * Packed in 16bits.
285 * Omit one shift by by putting the signed field at MSB.
286 */
287#if defined(__BIG_ENDIAN_BITFIELD)
288 __s16 hop_limit:9;
289 __u16 __unused_1:7;
290#else
291 __u16 __unused_1:7;
292 __s16 hop_limit:9;
293#endif
294
295#if defined(__BIG_ENDIAN_BITFIELD)
296 /* Packed in 16bits. */
297 __s16 mcast_hops:9;
298 __u16 __unused_2:6,
299 mc_loop:1;
300#else
301 __u16 mc_loop:1,
302 __unused_2:6;
303 __s16 mcast_hops:9;
304#endif
279 int mcast_oif; 305 int mcast_oif;
280 306
281 /* pktoption flags */ 307 /* pktoption flags */
@@ -298,11 +324,14 @@ struct ipv6_pinfo {
298 } rxopt; 324 } rxopt;
299 325
300 /* sockopt flags */ 326 /* sockopt flags */
301 __u8 mc_loop:1, 327 __u8 recverr:1,
302 recverr:1,
303 sndflow:1, 328 sndflow:1,
304 pmtudisc:2, 329 pmtudisc:2,
305 ipv6only:1; 330 ipv6only:1,
331 srcprefs:3; /* 001: prefer temporary address
332 * 010: prefer public address
333 * 100: prefer care-of address
334 */
306 __u8 tclass; 335 __u8 tclass;
307 336
308 __u32 dst_cookie; 337 __u32 dst_cookie;
@@ -315,9 +344,8 @@ struct ipv6_pinfo {
315 struct sk_buff *pktoptions; 344 struct sk_buff *pktoptions;
316 struct { 345 struct {
317 struct ipv6_txoptions *opt; 346 struct ipv6_txoptions *opt;
318 struct rt6_info *rt; 347 u8 hop_limit;
319 int hop_limit; 348 u8 tclass;
320 int tclass;
321 } cork; 349 } cork;
322}; 350};
323 351
@@ -458,7 +486,7 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)
458#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ 486#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
459 487
460#define INET6_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif)\ 488#define INET6_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif)\
461 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ 489 (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \
462 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 490 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \
463 ((__sk)->sk_family == AF_INET6) && \ 491 ((__sk)->sk_family == AF_INET6) && \
464 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \ 492 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \
@@ -466,7 +494,7 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)
466 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 494 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
467 495
468#define INET6_TW_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif) \ 496#define INET6_TW_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif) \
469 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ 497 (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \
470 (*((__portpair *)&(inet_twsk(__sk)->tw_dport)) == (__ports)) && \ 498 (*((__portpair *)&(inet_twsk(__sk)->tw_dport)) == (__ports)) && \
471 ((__sk)->sk_family == PF_INET6) && \ 499 ((__sk)->sk_family == PF_INET6) && \
472 (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_daddr, (__saddr))) && \ 500 (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_daddr, (__saddr))) && \
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 176e5e790a44..1883a85625dd 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -228,21 +228,11 @@ static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
228 228
229#endif /* CONFIG_GENERIC_PENDING_IRQ */ 229#endif /* CONFIG_GENERIC_PENDING_IRQ */
230 230
231extern int irq_set_affinity(unsigned int irq, cpumask_t cpumask);
232extern int irq_can_set_affinity(unsigned int irq);
233
234#else /* CONFIG_SMP */ 231#else /* CONFIG_SMP */
235 232
236#define move_native_irq(x) 233#define move_native_irq(x)
237#define move_masked_irq(x) 234#define move_masked_irq(x)
238 235
239static inline int irq_set_affinity(unsigned int irq, cpumask_t cpumask)
240{
241 return -EINVAL;
242}
243
244static inline int irq_can_set_affinity(unsigned int irq) { return 0; }
245
246#endif /* CONFIG_SMP */ 236#endif /* CONFIG_SMP */
247 237
248#ifdef CONFIG_IRQBALANCE 238#ifdef CONFIG_IRQBALANCE
diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
index 412e025bc5c7..e600c4e9b8c5 100644
--- a/include/linux/irqflags.h
+++ b/include/linux/irqflags.h
@@ -84,10 +84,10 @@
84 84
85#define irqs_disabled() \ 85#define irqs_disabled() \
86({ \ 86({ \
87 unsigned long flags; \ 87 unsigned long _flags; \
88 \ 88 \
89 raw_local_save_flags(flags); \ 89 raw_local_save_flags(_flags); \
90 raw_irqs_disabled_flags(flags); \ 90 raw_irqs_disabled_flags(_flags); \
91}) 91})
92 92
93#define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags) 93#define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags)
diff --git a/include/linux/isapnp.h b/include/linux/isapnp.h
index 1e8728a9ee8a..cd5a269fdb5e 100644
--- a/include/linux/isapnp.h
+++ b/include/linux/isapnp.h
@@ -26,16 +26,6 @@
26#include <linux/pnp.h> 26#include <linux/pnp.h>
27 27
28/* 28/*
29 * Configuration registers (TODO: change by specification)
30 */
31
32#define ISAPNP_CFG_ACTIVATE 0x30 /* byte */
33#define ISAPNP_CFG_MEM 0x40 /* 4 * dword */
34#define ISAPNP_CFG_PORT 0x60 /* 8 * word */
35#define ISAPNP_CFG_IRQ 0x70 /* 2 * word */
36#define ISAPNP_CFG_DMA 0x74 /* 2 * byte */
37
38/*
39 * 29 *
40 */ 30 */
41 31
diff --git a/include/linux/iscsi_ibft.h b/include/linux/iscsi_ibft.h
new file mode 100644
index 000000000000..6092487e2950
--- /dev/null
+++ b/include/linux/iscsi_ibft.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright 2007 Red Hat, Inc.
3 * by Peter Jones <pjones@redhat.com>
4 * Copyright 2007 IBM, Inc.
5 * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
6 * Copyright 2008
7 * by Konrad Rzeszutek <ketuzsezr@darnok.org>
8 *
9 * This code exposes the iSCSI Boot Format Table to userland via sysfs.
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 v2.0 as published by
13 * the Free Software Foundation
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
21#ifndef ISCSI_IBFT_H
22#define ISCSI_IBFT_H
23
24struct ibft_table_header {
25 char signature[4];
26 u32 length;
27 u8 revision;
28 u8 checksum;
29 char oem_id[6];
30 char oem_table_id[8];
31 char reserved[24];
32} __attribute__((__packed__));
33
34/*
35 * Logical location of iSCSI Boot Format Table.
36 * If the value is NULL there is no iBFT on the machine.
37 */
38extern struct ibft_table_header *ibft_addr;
39
40/*
41 * Routine used to find and reserve the iSCSI Boot Format Table. The
42 * mapped address is set in the ibft_addr variable.
43 */
44#ifdef CONFIG_ISCSI_IBFT_FIND
45extern void __init reserve_ibft_region(void);
46#else
47static inline void reserve_ibft_region(void) { }
48#endif
49
50#endif /* ISCSI_IBFT_H */
diff --git a/include/linux/isdn.h b/include/linux/isdn.h
index 9cb2855bb170..44cd663c53b6 100644
--- a/include/linux/isdn.h
+++ b/include/linux/isdn.h
@@ -16,14 +16,8 @@
16 16
17#include <linux/ioctl.h> 17#include <linux/ioctl.h>
18 18
19#ifdef CONFIG_COBALT_MICRO_SERVER
20/* Save memory */
21#define ISDN_MAX_DRIVERS 2
22#define ISDN_MAX_CHANNELS 8
23#else
24#define ISDN_MAX_DRIVERS 32 19#define ISDN_MAX_DRIVERS 32
25#define ISDN_MAX_CHANNELS 64 20#define ISDN_MAX_CHANNELS 64
26#endif
27 21
28/* New ioctl-codes */ 22/* New ioctl-codes */
29#define IIOCNETAIF _IO('I',1) 23#define IIOCNETAIF _IO('I',1)
diff --git a/include/linux/isicom.h b/include/linux/isicom.h
index 8f4c71759d73..bbd42197298f 100644
--- a/include/linux/isicom.h
+++ b/include/linux/isicom.h
@@ -1,11 +1,6 @@
1#ifndef _LINUX_ISICOM_H 1#ifndef _LINUX_ISICOM_H
2#define _LINUX_ISICOM_H 2#define _LINUX_ISICOM_H
3 3
4/*#define ISICOM_DEBUG*/
5/*#define ISICOM_DEBUG_DTR_RTS*/
6
7#ifdef __KERNEL__
8
9#define YES 1 4#define YES 1
10#define NO 0 5#define NO 0
11 6
@@ -85,6 +80,4 @@
85 80
86#define ISI_TXOK 0x0001 81#define ISI_TXOK 0x0001
87 82
88#endif /* __KERNEL__ */
89
90#endif /* ISICOM_H */ 83#endif /* ISICOM_H */
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index 423f58272188..07a9b52a2654 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -32,8 +32,6 @@
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/lockdep.h> 33#include <linux/lockdep.h>
34 34
35#include <asm/semaphore.h>
36
37#define journal_oom_retry 1 35#define journal_oom_retry 1
38 36
39/* 37/*
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 2cbf6fdb1799..05e2b307161a 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -30,8 +30,6 @@
30#include <linux/bit_spinlock.h> 30#include <linux/bit_spinlock.h>
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/timer.h> 32#include <linux/timer.h>
33
34#include <asm/semaphore.h>
35#endif 33#endif
36 34
37#define journal_oom_retry 1 35#define journal_oom_retry 1
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index e0b5b684d83f..abb6ac639e8e 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -1,7 +1,7 @@
1#ifndef _LINUX_JIFFIES_H 1#ifndef _LINUX_JIFFIES_H
2#define _LINUX_JIFFIES_H 2#define _LINUX_JIFFIES_H
3 3
4#include <linux/calc64.h> 4#include <linux/math64.h>
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/time.h> 7#include <linux/time.h>
@@ -36,7 +36,7 @@
36#elif HZ >= 6144 && HZ < 12288 36#elif HZ >= 6144 && HZ < 12288
37# define SHIFT_HZ 13 37# define SHIFT_HZ 13
38#else 38#else
39# error You lose. 39# error Invalid value of HZ.
40#endif 40#endif
41 41
42/* LATCH is used in the interval timer and ftape setup. */ 42/* LATCH is used in the interval timer and ftape setup. */
@@ -135,6 +135,22 @@ static inline u64 get_jiffies_64(void)
135#define time_before_eq64(a,b) time_after_eq64(b,a) 135#define time_before_eq64(a,b) time_after_eq64(b,a)
136 136
137/* 137/*
138 * These four macros compare jiffies and 'a' for convenience.
139 */
140
141/* time_is_before_jiffies(a) return true if a is before jiffies */
142#define time_is_before_jiffies(a) time_after(jiffies, a)
143
144/* time_is_after_jiffies(a) return true if a is after jiffies */
145#define time_is_after_jiffies(a) time_before(jiffies, a)
146
147/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/
148#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)
149
150/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/
151#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)
152
153/*
138 * Have the 32 bit jiffies value wrap 5 minutes after boot 154 * Have the 32 bit jiffies value wrap 5 minutes after boot
139 * so jiffies wrap bugs show up earlier. 155 * so jiffies wrap bugs show up earlier.
140 */ 156 */
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
new file mode 100644
index 000000000000..22a72198c14b
--- /dev/null
+++ b/include/linux/kbuild.h
@@ -0,0 +1,15 @@
1#ifndef __LINUX_KBUILD_H
2#define __LINUX_KBUILD_H
3
4#define DEFINE(sym, val) \
5 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
6
7#define BLANK() asm volatile("\n->" : : )
8
9#define OFFSET(sym, str, mem) \
10 DEFINE(sym, offsetof(struct str, mem))
11
12#define COMMENT(x) \
13 asm volatile("\n->#" x)
14
15#endif
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2df44e773270..4d46e299afb5 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -20,6 +20,9 @@
20extern const char linux_banner[]; 20extern const char linux_banner[];
21extern const char linux_proc_banner[]; 21extern const char linux_proc_banner[];
22 22
23#define USHORT_MAX ((u16)(~0U))
24#define SHORT_MAX ((s16)(USHORT_MAX>>1))
25#define SHORT_MIN (-SHORT_MAX - 1)
23#define INT_MAX ((int)(~0U>>1)) 26#define INT_MAX ((int)(~0U>>1))
24#define INT_MIN (-INT_MAX - 1) 27#define INT_MIN (-INT_MAX - 1)
25#define UINT_MAX (~0U) 28#define UINT_MAX (~0U)
@@ -188,6 +191,7 @@ extern int log_buf_copy(char *dest, int idx, int len);
188extern int printk_ratelimit_jiffies; 191extern int printk_ratelimit_jiffies;
189extern int printk_ratelimit_burst; 192extern int printk_ratelimit_burst;
190extern int printk_ratelimit(void); 193extern int printk_ratelimit(void);
194extern int __ratelimit(int ratelimit_jiffies, int ratelimit_burst);
191extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst); 195extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
192extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, 196extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
193 unsigned int interval_msec); 197 unsigned int interval_msec);
@@ -255,6 +259,7 @@ extern enum system_states {
255#define TAINT_USER (1<<6) 259#define TAINT_USER (1<<6)
256#define TAINT_DIE (1<<7) 260#define TAINT_DIE (1<<7)
257#define TAINT_OVERRIDDEN_ACPI_TABLE (1<<8) 261#define TAINT_OVERRIDDEN_ACPI_TABLE (1<<8)
262#define TAINT_WARN (1<<9)
258 263
259extern void dump_stack(void) __cold; 264extern void dump_stack(void) __cold;
260 265
@@ -293,10 +298,8 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
293#define pr_debug(fmt, arg...) \ 298#define pr_debug(fmt, arg...) \
294 printk(KERN_DEBUG fmt, ##arg) 299 printk(KERN_DEBUG fmt, ##arg)
295#else 300#else
296static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char * fmt, ...) 301#define pr_debug(fmt, arg...) \
297{ 302 ({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; })
298 return 0;
299}
300#endif 303#endif
301 304
302/* 305/*
@@ -335,33 +338,90 @@ static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char *
335#endif /* __LITTLE_ENDIAN */ 338#endif /* __LITTLE_ENDIAN */
336 339
337/* 340/*
338 * min()/max() macros that also do 341 * min()/max()/clamp() macros that also do
339 * strict type-checking.. See the 342 * strict type-checking.. See the
340 * "unnecessary" pointer comparison. 343 * "unnecessary" pointer comparison.
341 */ 344 */
342#define min(x,y) ({ \ 345#define min(x, y) ({ \
343 typeof(x) _x = (x); \ 346 typeof(x) _min1 = (x); \
344 typeof(y) _y = (y); \ 347 typeof(y) _min2 = (y); \
345 (void) (&_x == &_y); \ 348 (void) (&_min1 == &_min2); \
346 _x < _y ? _x : _y; }) 349 _min1 < _min2 ? _min1 : _min2; })
347 350
348#define max(x,y) ({ \ 351#define max(x, y) ({ \
349 typeof(x) _x = (x); \ 352 typeof(x) _max1 = (x); \
350 typeof(y) _y = (y); \ 353 typeof(y) _max2 = (y); \
351 (void) (&_x == &_y); \ 354 (void) (&_max1 == &_max2); \
352 _x > _y ? _x : _y; }) 355 _max1 > _max2 ? _max1 : _max2; })
356
357/**
358 * clamp - return a value clamped to a given range with strict typechecking
359 * @val: current value
360 * @min: minimum allowable value
361 * @max: maximum allowable value
362 *
363 * This macro does strict typechecking of min/max to make sure they are of the
364 * same type as val. See the unnecessary pointer comparisons.
365 */
366#define clamp(val, min, max) ({ \
367 typeof(val) __val = (val); \
368 typeof(min) __min = (min); \
369 typeof(max) __max = (max); \
370 (void) (&__val == &__min); \
371 (void) (&__val == &__max); \
372 __val = __val < __min ? __min: __val; \
373 __val > __max ? __max: __val; })
353 374
354/* 375/*
355 * ..and if you can't take the strict 376 * ..and if you can't take the strict
356 * types, you can specify one yourself. 377 * types, you can specify one yourself.
357 * 378 *
358 * Or not use min/max at all, of course. 379 * Or not use min/max/clamp at all, of course.
359 */ 380 */
360#define min_t(type,x,y) \ 381#define min_t(type, x, y) ({ \
361 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) 382 type __min1 = (x); \
362#define max_t(type,x,y) \ 383 type __min2 = (y); \
363 ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) 384 __min1 < __min2 ? __min1: __min2; })
385
386#define max_t(type, x, y) ({ \
387 type __max1 = (x); \
388 type __max2 = (y); \
389 __max1 > __max2 ? __max1: __max2; })
364 390
391/**
392 * clamp_t - return a value clamped to a given range using a given type
393 * @type: the type of variable to use
394 * @val: current value
395 * @min: minimum allowable value
396 * @max: maximum allowable value
397 *
398 * This macro does no typechecking and uses temporary variables of type
399 * 'type' to make all the comparisons.
400 */
401#define clamp_t(type, val, min, max) ({ \
402 type __val = (val); \
403 type __min = (min); \
404 type __max = (max); \
405 __val = __val < __min ? __min: __val; \
406 __val > __max ? __max: __val; })
407
408/**
409 * clamp_val - return a value clamped to a given range using val's type
410 * @val: current value
411 * @min: minimum allowable value
412 * @max: maximum allowable value
413 *
414 * This macro does no typechecking and uses temporary variables of whatever
415 * type the input argument 'val' is. This is useful when val is an unsigned
416 * type and min and max are literals that will otherwise be assigned a signed
417 * integer type.
418 */
419#define clamp_val(val, min, max) ({ \
420 typeof(val) __val = (val); \
421 typeof(val) __min = (min); \
422 typeof(val) __max = (max); \
423 __val = __val < __min ? __min: __val; \
424 __val > __max ? __max: __val; })
365 425
366/** 426/**
367 * container_of - cast a member of a structure out to the containing structure 427 * container_of - cast a member of a structure out to the containing structure
diff --git a/include/linux/kernelcapi.h b/include/linux/kernelcapi.h
index 8c4350a9ed87..a53e932f80fb 100644
--- a/include/linux/kernelcapi.h
+++ b/include/linux/kernelcapi.h
@@ -48,7 +48,6 @@ typedef struct kcapi_carddef {
48#include <linux/list.h> 48#include <linux/list.h>
49#include <linux/skbuff.h> 49#include <linux/skbuff.h>
50#include <linux/workqueue.h> 50#include <linux/workqueue.h>
51#include <asm/semaphore.h>
52 51
53#define KCI_CONTRUP 0 /* arg: struct capi_profile */ 52#define KCI_CONTRUP 0 /* arg: struct capi_profile */
54#define KCI_CONTRDOWN 1 /* arg: NULL */ 53#define KCI_CONTRDOWN 1 /* arg: NULL */
diff --git a/include/linux/key.h b/include/linux/key.h
index a70b8a8f2005..c45c962d1cc5 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -19,6 +19,7 @@
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/rbtree.h> 20#include <linux/rbtree.h>
21#include <linux/rcupdate.h> 21#include <linux/rcupdate.h>
22#include <linux/sysctl.h>
22#include <asm/atomic.h> 23#include <asm/atomic.h>
23 24
24#ifdef __KERNEL__ 25#ifdef __KERNEL__
@@ -67,6 +68,8 @@ struct key;
67#define KEY_OTH_SETATTR 0x00000020 68#define KEY_OTH_SETATTR 0x00000020
68#define KEY_OTH_ALL 0x0000003f 69#define KEY_OTH_ALL 0x0000003f
69 70
71#define KEY_PERM_UNDEF 0xffffffff
72
70struct seq_file; 73struct seq_file;
71struct user_struct; 74struct user_struct;
72struct signal_struct; 75struct signal_struct;
@@ -208,16 +211,19 @@ extern struct key *request_key(struct key_type *type,
208 211
209extern struct key *request_key_with_auxdata(struct key_type *type, 212extern struct key *request_key_with_auxdata(struct key_type *type,
210 const char *description, 213 const char *description,
211 const char *callout_info, 214 const void *callout_info,
215 size_t callout_len,
212 void *aux); 216 void *aux);
213 217
214extern struct key *request_key_async(struct key_type *type, 218extern struct key *request_key_async(struct key_type *type,
215 const char *description, 219 const char *description,
216 const char *callout_info); 220 const void *callout_info,
221 size_t callout_len);
217 222
218extern struct key *request_key_async_with_auxdata(struct key_type *type, 223extern struct key *request_key_async_with_auxdata(struct key_type *type,
219 const char *description, 224 const char *description,
220 const char *callout_info, 225 const void *callout_info,
226 size_t callout_len,
221 void *aux); 227 void *aux);
222 228
223extern int wait_for_key_construction(struct key *key, bool intr); 229extern int wait_for_key_construction(struct key *key, bool intr);
@@ -229,6 +235,7 @@ extern key_ref_t key_create_or_update(key_ref_t keyring,
229 const char *description, 235 const char *description,
230 const void *payload, 236 const void *payload,
231 size_t plen, 237 size_t plen,
238 key_perm_t perm,
232 unsigned long flags); 239 unsigned long flags);
233 240
234extern int key_update(key_ref_t key, 241extern int key_update(key_ref_t key,
@@ -257,14 +264,18 @@ extern int keyring_add_key(struct key *keyring,
257 264
258extern struct key *key_lookup(key_serial_t id); 265extern struct key *key_lookup(key_serial_t id);
259 266
260#define key_serial(key) ((key) ? (key)->serial : 0) 267static inline key_serial_t key_serial(struct key *key)
268{
269 return key ? key->serial : 0;
270}
271
272#ifdef CONFIG_SYSCTL
273extern ctl_table key_sysctls[];
274#endif
261 275
262/* 276/*
263 * the userspace interface 277 * the userspace interface
264 */ 278 */
265extern struct key root_user_keyring, root_session_keyring;
266extern int alloc_uid_keyring(struct user_struct *user,
267 struct task_struct *ctx);
268extern void switch_uid_keyring(struct user_struct *new_user); 279extern void switch_uid_keyring(struct user_struct *new_user);
269extern int copy_keys(unsigned long clone_flags, struct task_struct *tsk); 280extern int copy_keys(unsigned long clone_flags, struct task_struct *tsk);
270extern int copy_thread_group_keys(struct task_struct *tsk); 281extern int copy_thread_group_keys(struct task_struct *tsk);
@@ -293,7 +304,6 @@ extern void key_init(void);
293#define make_key_ref(k, p) ({ NULL; }) 304#define make_key_ref(k, p) ({ NULL; })
294#define key_ref_to_ptr(k) ({ NULL; }) 305#define key_ref_to_ptr(k) ({ NULL; })
295#define is_key_possessed(k) 0 306#define is_key_possessed(k) 0
296#define alloc_uid_keyring(u,c) 0
297#define switch_uid_keyring(u) do { } while(0) 307#define switch_uid_keyring(u) do { } while(0)
298#define __install_session_keyring(t, k) ({ NULL; }) 308#define __install_session_keyring(t, k) ({ NULL; })
299#define copy_keys(f,t) 0 309#define copy_keys(f,t) 0
@@ -306,10 +316,6 @@ extern void key_init(void);
306#define key_fsgid_changed(t) do { } while(0) 316#define key_fsgid_changed(t) do { } while(0)
307#define key_init() do { } while(0) 317#define key_init() do { } while(0)
308 318
309/* Initial keyrings */
310extern struct key root_user_keyring;
311extern struct key root_session_keyring;
312
313#endif /* CONFIG_KEYS */ 319#endif /* CONFIG_KEYS */
314#endif /* __KERNEL__ */ 320#endif /* __KERNEL__ */
315#endif /* _LINUX_KEY_H */ 321#endif /* _LINUX_KEY_H */
diff --git a/include/linux/keyboard.h b/include/linux/keyboard.h
index 65c2d70853e9..a3c984d780f0 100644
--- a/include/linux/keyboard.h
+++ b/include/linux/keyboard.h
@@ -33,6 +33,7 @@ struct keyboard_notifier_param {
33 struct vc_data *vc; /* VC on which the keyboard press was done */ 33 struct vc_data *vc; /* VC on which the keyboard press was done */
34 int down; /* Pressure of the key? */ 34 int down; /* Pressure of the key? */
35 int shift; /* Current shift mask */ 35 int shift; /* Current shift mask */
36 int ledstate; /* Current led state */
36 unsigned int value; /* keycode, unicode value or keysym */ 37 unsigned int value; /* keycode, unicode value or keysym */
37}; 38};
38 39
diff --git a/include/linux/keyctl.h b/include/linux/keyctl.h
index 3365945640c9..656ee6b77a4a 100644
--- a/include/linux/keyctl.h
+++ b/include/linux/keyctl.h
@@ -49,5 +49,6 @@
49#define KEYCTL_SET_REQKEY_KEYRING 14 /* set default request-key keyring */ 49#define KEYCTL_SET_REQKEY_KEYRING 14 /* set default request-key keyring */
50#define KEYCTL_SET_TIMEOUT 15 /* set key timeout */ 50#define KEYCTL_SET_TIMEOUT 15 /* set key timeout */
51#define KEYCTL_ASSUME_AUTHORITY 16 /* assume request_key() authorisation */ 51#define KEYCTL_ASSUME_AUTHORITY 16 /* assume request_key() authorisation */
52#define KEYCTL_GET_SECURITY 17 /* get key security label */
52 53
53#endif /* _LINUX_KEYCTL_H */ 54#endif /* _LINUX_KEYCTL_H */
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 404f4464cb1a..29f62e1733ff 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -21,8 +21,6 @@
21#ifndef _LINUX_KFIFO_H 21#ifndef _LINUX_KFIFO_H
22#define _LINUX_KFIFO_H 22#define _LINUX_KFIFO_H
23 23
24#ifdef __KERNEL__
25
26#include <linux/kernel.h> 24#include <linux/kernel.h>
27#include <linux/spinlock.h> 25#include <linux/spinlock.h>
28 26
@@ -151,7 +149,4 @@ static inline unsigned int kfifo_len(struct kfifo *fifo)
151 return ret; 149 return ret;
152} 150}
153 151
154#else
155#warning "don't include kernel headers in userspace"
156#endif /* __KERNEL__ */
157#endif 152#endif
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
new file mode 100644
index 000000000000..9757b1a6d9dc
--- /dev/null
+++ b/include/linux/kgdb.h
@@ -0,0 +1,281 @@
1/*
2 * This provides the callbacks and functions that KGDB needs to share between
3 * the core, I/O and arch-specific portions.
4 *
5 * Author: Amit Kale <amitkale@linsyssoft.com> and
6 * Tom Rini <trini@kernel.crashing.org>
7 *
8 * 2001-2004 (c) Amit S. Kale and 2003-2005 (c) MontaVista Software, Inc.
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 */
13#ifndef _KGDB_H_
14#define _KGDB_H_
15
16#include <linux/serial_8250.h>
17#include <linux/linkage.h>
18#include <linux/init.h>
19
20#include <asm/atomic.h>
21#include <asm/kgdb.h>
22
23struct pt_regs;
24
25/**
26 * kgdb_skipexception - (optional) exit kgdb_handle_exception early
27 * @exception: Exception vector number
28 * @regs: Current &struct pt_regs.
29 *
30 * On some architectures it is required to skip a breakpoint
31 * exception when it occurs after a breakpoint has been removed.
32 * This can be implemented in the architecture specific portion of
33 * for kgdb.
34 */
35extern int kgdb_skipexception(int exception, struct pt_regs *regs);
36
37/**
38 * kgdb_post_primary_code - (optional) Save error vector/code numbers.
39 * @regs: Original pt_regs.
40 * @e_vector: Original error vector.
41 * @err_code: Original error code.
42 *
43 * This is usually needed on architectures which support SMP and
44 * KGDB. This function is called after all the secondary cpus have
45 * been put to a know spin state and the primary CPU has control over
46 * KGDB.
47 */
48extern void kgdb_post_primary_code(struct pt_regs *regs, int e_vector,
49 int err_code);
50
51/**
52 * kgdb_disable_hw_debug - (optional) Disable hardware debugging hook
53 * @regs: Current &struct pt_regs.
54 *
55 * This function will be called if the particular architecture must
56 * disable hardware debugging while it is processing gdb packets or
57 * handling exception.
58 */
59extern void kgdb_disable_hw_debug(struct pt_regs *regs);
60
61struct tasklet_struct;
62struct task_struct;
63struct uart_port;
64
65/**
66 * kgdb_breakpoint - compiled in breakpoint
67 *
68 * This will be impelmented a static inline per architecture. This
69 * function is called by the kgdb core to execute an architecture
70 * specific trap to cause kgdb to enter the exception processing.
71 *
72 */
73void kgdb_breakpoint(void);
74
75extern int kgdb_connected;
76
77extern atomic_t kgdb_setting_breakpoint;
78extern atomic_t kgdb_cpu_doing_single_step;
79
80extern struct task_struct *kgdb_usethread;
81extern struct task_struct *kgdb_contthread;
82
83enum kgdb_bptype {
84 BP_BREAKPOINT = 0,
85 BP_HARDWARE_BREAKPOINT,
86 BP_WRITE_WATCHPOINT,
87 BP_READ_WATCHPOINT,
88 BP_ACCESS_WATCHPOINT
89};
90
91enum kgdb_bpstate {
92 BP_UNDEFINED = 0,
93 BP_REMOVED,
94 BP_SET,
95 BP_ACTIVE
96};
97
98struct kgdb_bkpt {
99 unsigned long bpt_addr;
100 unsigned char saved_instr[BREAK_INSTR_SIZE];
101 enum kgdb_bptype type;
102 enum kgdb_bpstate state;
103};
104
105#ifndef KGDB_MAX_BREAKPOINTS
106# define KGDB_MAX_BREAKPOINTS 1000
107#endif
108
109#define KGDB_HW_BREAKPOINT 1
110
111/*
112 * Functions each KGDB-supporting architecture must provide:
113 */
114
115/**
116 * kgdb_arch_init - Perform any architecture specific initalization.
117 *
118 * This function will handle the initalization of any architecture
119 * specific callbacks.
120 */
121extern int kgdb_arch_init(void);
122
123/**
124 * kgdb_arch_exit - Perform any architecture specific uninitalization.
125 *
126 * This function will handle the uninitalization of any architecture
127 * specific callbacks, for dynamic registration and unregistration.
128 */
129extern void kgdb_arch_exit(void);
130
131/**
132 * pt_regs_to_gdb_regs - Convert ptrace regs to GDB regs
133 * @gdb_regs: A pointer to hold the registers in the order GDB wants.
134 * @regs: The &struct pt_regs of the current process.
135 *
136 * Convert the pt_regs in @regs into the format for registers that
137 * GDB expects, stored in @gdb_regs.
138 */
139extern void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs);
140
141/**
142 * sleeping_thread_to_gdb_regs - Convert ptrace regs to GDB regs
143 * @gdb_regs: A pointer to hold the registers in the order GDB wants.
144 * @p: The &struct task_struct of the desired process.
145 *
146 * Convert the register values of the sleeping process in @p to
147 * the format that GDB expects.
148 * This function is called when kgdb does not have access to the
149 * &struct pt_regs and therefore it should fill the gdb registers
150 * @gdb_regs with what has been saved in &struct thread_struct
151 * thread field during switch_to.
152 */
153extern void
154sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p);
155
156/**
157 * gdb_regs_to_pt_regs - Convert GDB regs to ptrace regs.
158 * @gdb_regs: A pointer to hold the registers we've received from GDB.
159 * @regs: A pointer to a &struct pt_regs to hold these values in.
160 *
161 * Convert the GDB regs in @gdb_regs into the pt_regs, and store them
162 * in @regs.
163 */
164extern void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs);
165
166/**
167 * kgdb_arch_handle_exception - Handle architecture specific GDB packets.
168 * @vector: The error vector of the exception that happened.
169 * @signo: The signal number of the exception that happened.
170 * @err_code: The error code of the exception that happened.
171 * @remcom_in_buffer: The buffer of the packet we have read.
172 * @remcom_out_buffer: The buffer of %BUFMAX bytes to write a packet into.
173 * @regs: The &struct pt_regs of the current process.
174 *
175 * This function MUST handle the 'c' and 's' command packets,
176 * as well packets to set / remove a hardware breakpoint, if used.
177 * If there are additional packets which the hardware needs to handle,
178 * they are handled here. The code should return -1 if it wants to
179 * process more packets, and a %0 or %1 if it wants to exit from the
180 * kgdb callback.
181 */
182extern int
183kgdb_arch_handle_exception(int vector, int signo, int err_code,
184 char *remcom_in_buffer,
185 char *remcom_out_buffer,
186 struct pt_regs *regs);
187
188/**
189 * kgdb_roundup_cpus - Get other CPUs into a holding pattern
190 * @flags: Current IRQ state
191 *
192 * On SMP systems, we need to get the attention of the other CPUs
193 * and get them be in a known state. This should do what is needed
194 * to get the other CPUs to call kgdb_wait(). Note that on some arches,
195 * the NMI approach is not used for rounding up all the CPUs. For example,
196 * in case of MIPS, smp_call_function() is used to roundup CPUs. In
197 * this case, we have to make sure that interrupts are enabled before
198 * calling smp_call_function(). The argument to this function is
199 * the flags that will be used when restoring the interrupts. There is
200 * local_irq_save() call before kgdb_roundup_cpus().
201 *
202 * On non-SMP systems, this is not called.
203 */
204extern void kgdb_roundup_cpus(unsigned long flags);
205
206/* Optional functions. */
207extern int kgdb_validate_break_address(unsigned long addr);
208extern int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr);
209extern int kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle);
210
211/**
212 * struct kgdb_arch - Describe architecture specific values.
213 * @gdb_bpt_instr: The instruction to trigger a breakpoint.
214 * @flags: Flags for the breakpoint, currently just %KGDB_HW_BREAKPOINT.
215 * @set_breakpoint: Allow an architecture to specify how to set a software
216 * breakpoint.
217 * @remove_breakpoint: Allow an architecture to specify how to remove a
218 * software breakpoint.
219 * @set_hw_breakpoint: Allow an architecture to specify how to set a hardware
220 * breakpoint.
221 * @remove_hw_breakpoint: Allow an architecture to specify how to remove a
222 * hardware breakpoint.
223 * @remove_all_hw_break: Allow an architecture to specify how to remove all
224 * hardware breakpoints.
225 * @correct_hw_break: Allow an architecture to specify how to correct the
226 * hardware debug registers.
227 */
228struct kgdb_arch {
229 unsigned char gdb_bpt_instr[BREAK_INSTR_SIZE];
230 unsigned long flags;
231
232 int (*set_breakpoint)(unsigned long, char *);
233 int (*remove_breakpoint)(unsigned long, char *);
234 int (*set_hw_breakpoint)(unsigned long, int, enum kgdb_bptype);
235 int (*remove_hw_breakpoint)(unsigned long, int, enum kgdb_bptype);
236 void (*remove_all_hw_break)(void);
237 void (*correct_hw_break)(void);
238};
239
240/**
241 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
242 * @name: Name of the I/O driver.
243 * @read_char: Pointer to a function that will return one char.
244 * @write_char: Pointer to a function that will write one char.
245 * @flush: Pointer to a function that will flush any pending writes.
246 * @init: Pointer to a function that will initialize the device.
247 * @pre_exception: Pointer to a function that will do any prep work for
248 * the I/O driver.
249 * @post_exception: Pointer to a function that will do any cleanup work
250 * for the I/O driver.
251 */
252struct kgdb_io {
253 const char *name;
254 int (*read_char) (void);
255 void (*write_char) (u8);
256 void (*flush) (void);
257 int (*init) (void);
258 void (*pre_exception) (void);
259 void (*post_exception) (void);
260};
261
262extern struct kgdb_arch arch_kgdb_ops;
263
264extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops);
265extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops);
266
267extern int kgdb_hex2long(char **ptr, long *long_val);
268extern int kgdb_mem2hex(char *mem, char *buf, int count);
269extern int kgdb_hex2mem(char *buf, char *mem, int count);
270
271extern int kgdb_isremovedbreak(unsigned long addr);
272
273extern int
274kgdb_handle_exception(int ex_vector, int signo, int err_code,
275 struct pt_regs *regs);
276extern int kgdb_nmicallback(int cpu, void *regs);
277
278extern int kgdb_single_step;
279extern atomic_t kgdb_active;
280
281#endif /* _KGDB_H_ */
diff --git a/include/linux/klist.h b/include/linux/klist.h
index 74071254c9d3..06c338ef7f1b 100644
--- a/include/linux/klist.h
+++ b/include/linux/klist.h
@@ -25,37 +25,47 @@ struct klist {
25 void (*put)(struct klist_node *); 25 void (*put)(struct klist_node *);
26}; 26};
27 27
28#define KLIST_INIT(_name, _get, _put) \
29 { .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \
30 .k_list = LIST_HEAD_INIT(_name.k_list), \
31 .get = _get, \
32 .put = _put, }
28 33
29extern void klist_init(struct klist * k, void (*get)(struct klist_node *), 34#define DEFINE_KLIST(_name, _get, _put) \
35 struct klist _name = KLIST_INIT(_name, _get, _put)
36
37extern void klist_init(struct klist *k, void (*get)(struct klist_node *),
30 void (*put)(struct klist_node *)); 38 void (*put)(struct klist_node *));
31 39
32struct klist_node { 40struct klist_node {
33 struct klist * n_klist; 41 struct klist *n_klist;
34 struct list_head n_node; 42 struct list_head n_node;
35 struct kref n_ref; 43 struct kref n_ref;
36 struct completion n_removed; 44 struct completion n_removed;
37}; 45};
38 46
39extern void klist_add_tail(struct klist_node * n, struct klist * k); 47extern void klist_add_tail(struct klist_node *n, struct klist *k);
40extern void klist_add_head(struct klist_node * n, struct klist * k); 48extern void klist_add_head(struct klist_node *n, struct klist *k);
49extern void klist_add_after(struct klist_node *n, struct klist_node *pos);
50extern void klist_add_before(struct klist_node *n, struct klist_node *pos);
41 51
42extern void klist_del(struct klist_node * n); 52extern void klist_del(struct klist_node *n);
43extern void klist_remove(struct klist_node * n); 53extern void klist_remove(struct klist_node *n);
44 54
45extern int klist_node_attached(struct klist_node * n); 55extern int klist_node_attached(struct klist_node *n);
46 56
47 57
48struct klist_iter { 58struct klist_iter {
49 struct klist * i_klist; 59 struct klist *i_klist;
50 struct list_head * i_head; 60 struct list_head *i_head;
51 struct klist_node * i_cur; 61 struct klist_node *i_cur;
52}; 62};
53 63
54 64
55extern void klist_iter_init(struct klist * k, struct klist_iter * i); 65extern void klist_iter_init(struct klist *k, struct klist_iter *i);
56extern void klist_iter_init_node(struct klist * k, struct klist_iter * i, 66extern void klist_iter_init_node(struct klist *k, struct klist_iter *i,
57 struct klist_node * n); 67 struct klist_node *n);
58extern void klist_iter_exit(struct klist_iter * i); 68extern void klist_iter_exit(struct klist_iter *i);
59extern struct klist_node * klist_next(struct klist_iter * i); 69extern struct klist_node *klist_next(struct klist_iter *i);
60 70
61#endif 71#endif
diff --git a/include/linux/kobj_map.h b/include/linux/kobj_map.h
index bafe178a381f..73717ed9ea79 100644
--- a/include/linux/kobj_map.h
+++ b/include/linux/kobj_map.h
@@ -1,5 +1,3 @@
1#ifdef __KERNEL__
2
3#include <linux/mutex.h> 1#include <linux/mutex.h>
4 2
5typedef struct kobject *kobj_probe_t(dev_t, int *, void *); 3typedef struct kobject *kobj_probe_t(dev_t, int *, void *);
@@ -10,5 +8,3 @@ int kobj_map(struct kobj_map *, dev_t, unsigned long, struct module *,
10void kobj_unmap(struct kobj_map *, dev_t, unsigned long); 8void kobj_unmap(struct kobj_map *, dev_t, unsigned long);
11struct kobject *kobj_lookup(struct kobj_map *, dev_t, int *); 9struct kobject *kobj_lookup(struct kobj_map *, dev_t, int *);
12struct kobj_map *kobj_map_init(kobj_probe_t *, struct mutex *); 10struct kobj_map *kobj_map_init(kobj_probe_t *, struct mutex *);
13
14#endif
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index caa3f411f15d..39e709f88aa0 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -16,8 +16,6 @@
16#ifndef _KOBJECT_H_ 16#ifndef _KOBJECT_H_
17#define _KOBJECT_H_ 17#define _KOBJECT_H_
18 18
19#ifdef __KERNEL__
20
21#include <linux/types.h> 19#include <linux/types.h>
22#include <linux/list.h> 20#include <linux/list.h>
23#include <linux/sysfs.h> 21#include <linux/sysfs.h>
@@ -224,5 +222,4 @@ static inline int kobject_action_type(const char *buf, size_t count,
224{ return -EINVAL; } 222{ return -EINVAL; }
225#endif 223#endif
226 224
227#endif /* __KERNEL__ */
228#endif /* _KOBJECT_H_ */ 225#endif /* _KOBJECT_H_ */
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 0f28486f6360..1036631ff4fa 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -173,6 +173,13 @@ struct kretprobe_blackpoint {
173 const char *name; 173 const char *name;
174 void *addr; 174 void *addr;
175}; 175};
176
177struct kprobe_blackpoint {
178 const char *name;
179 unsigned long start_addr;
180 unsigned long range;
181};
182
176extern struct kretprobe_blackpoint kretprobe_blacklist[]; 183extern struct kretprobe_blackpoint kretprobe_blacklist[];
177 184
178static inline void kretprobe_assert(struct kretprobe_instance *ri, 185static inline void kretprobe_assert(struct kretprobe_instance *ri,
@@ -227,15 +234,21 @@ static inline struct kprobe_ctlblk *get_kprobe_ctlblk(void)
227 234
228int register_kprobe(struct kprobe *p); 235int register_kprobe(struct kprobe *p);
229void unregister_kprobe(struct kprobe *p); 236void unregister_kprobe(struct kprobe *p);
237int register_kprobes(struct kprobe **kps, int num);
238void unregister_kprobes(struct kprobe **kps, int num);
230int setjmp_pre_handler(struct kprobe *, struct pt_regs *); 239int setjmp_pre_handler(struct kprobe *, struct pt_regs *);
231int longjmp_break_handler(struct kprobe *, struct pt_regs *); 240int longjmp_break_handler(struct kprobe *, struct pt_regs *);
232int register_jprobe(struct jprobe *p); 241int register_jprobe(struct jprobe *p);
233void unregister_jprobe(struct jprobe *p); 242void unregister_jprobe(struct jprobe *p);
243int register_jprobes(struct jprobe **jps, int num);
244void unregister_jprobes(struct jprobe **jps, int num);
234void jprobe_return(void); 245void jprobe_return(void);
235unsigned long arch_deref_entry_point(void *); 246unsigned long arch_deref_entry_point(void *);
236 247
237int register_kretprobe(struct kretprobe *rp); 248int register_kretprobe(struct kretprobe *rp);
238void unregister_kretprobe(struct kretprobe *rp); 249void unregister_kretprobe(struct kretprobe *rp);
250int register_kretprobes(struct kretprobe **rps, int num);
251void unregister_kretprobes(struct kretprobe **rps, int num);
239 252
240void kprobe_flush_task(struct task_struct *tk); 253void kprobe_flush_task(struct task_struct *tk);
241void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head); 254void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
@@ -254,16 +267,30 @@ static inline int register_kprobe(struct kprobe *p)
254{ 267{
255 return -ENOSYS; 268 return -ENOSYS;
256} 269}
270static inline int register_kprobes(struct kprobe **kps, int num)
271{
272 return -ENOSYS;
273}
257static inline void unregister_kprobe(struct kprobe *p) 274static inline void unregister_kprobe(struct kprobe *p)
258{ 275{
259} 276}
277static inline void unregister_kprobes(struct kprobe **kps, int num)
278{
279}
260static inline int register_jprobe(struct jprobe *p) 280static inline int register_jprobe(struct jprobe *p)
261{ 281{
262 return -ENOSYS; 282 return -ENOSYS;
263} 283}
284static inline int register_jprobes(struct jprobe **jps, int num)
285{
286 return -ENOSYS;
287}
264static inline void unregister_jprobe(struct jprobe *p) 288static inline void unregister_jprobe(struct jprobe *p)
265{ 289{
266} 290}
291static inline void unregister_jprobes(struct jprobe **jps, int num)
292{
293}
267static inline void jprobe_return(void) 294static inline void jprobe_return(void)
268{ 295{
269} 296}
@@ -271,9 +298,16 @@ static inline int register_kretprobe(struct kretprobe *rp)
271{ 298{
272 return -ENOSYS; 299 return -ENOSYS;
273} 300}
301static inline int register_kretprobes(struct kretprobe **rps, int num)
302{
303 return -ENOSYS;
304}
274static inline void unregister_kretprobe(struct kretprobe *rp) 305static inline void unregister_kretprobe(struct kretprobe *rp)
275{ 306{
276} 307}
308static inline void unregister_kretprobes(struct kretprobe **rps, int num)
309{
310}
277static inline void kprobe_flush_task(struct task_struct *tk) 311static inline void kprobe_flush_task(struct task_struct *tk)
278{ 312{
279} 313}
diff --git a/include/linux/kref.h b/include/linux/kref.h
index 5d185635786e..0cef6badd6fb 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -15,8 +15,6 @@
15#ifndef _KREF_H_ 15#ifndef _KREF_H_
16#define _KREF_H_ 16#define _KREF_H_
17 17
18#ifdef __KERNEL__
19
20#include <linux/types.h> 18#include <linux/types.h>
21#include <asm/atomic.h> 19#include <asm/atomic.h>
22 20
@@ -29,5 +27,4 @@ void kref_init(struct kref *kref);
29void kref_get(struct kref *kref); 27void kref_get(struct kref *kref);
30int kref_put(struct kref *kref, void (*release) (struct kref *kref)); 28int kref_put(struct kref *kref, void (*release) (struct kref *kref));
31 29
32#endif /* __KERNEL__ */
33#endif /* _KREF_H_ */ 30#endif /* _KREF_H_ */
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 2cd7fa73d1af..ce5983225be4 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -327,4 +327,10 @@ extern void ktime_get_ts(struct timespec *ts);
327/* Get the real (wall-) time in timespec format: */ 327/* Get the real (wall-) time in timespec format: */
328#define ktime_get_real_ts(ts) getnstimeofday(ts) 328#define ktime_get_real_ts(ts) getnstimeofday(ts)
329 329
330static inline ktime_t ns_to_ktime(u64 ns)
331{
332 static const ktime_t ktime_zero = { .tv64 = 0 };
333 return ktime_add_ns(ktime_zero, ns);
334}
335
330#endif 336#endif
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c1ec04fd000d..a281afeddfbb 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -8,11 +8,18 @@
8 */ 8 */
9 9
10#include <asm/types.h> 10#include <asm/types.h>
11#include <linux/compiler.h>
11#include <linux/ioctl.h> 12#include <linux/ioctl.h>
12#include <asm/kvm.h> 13#include <asm/kvm.h>
13 14
14#define KVM_API_VERSION 12 15#define KVM_API_VERSION 12
15 16
17/* for KVM_TRACE_ENABLE */
18struct kvm_user_trace_setup {
19 __u32 buf_size; /* sub_buffer size of each per-cpu */
20 __u32 buf_nr; /* the number of sub_buffers of each per-cpu */
21};
22
16/* for KVM_CREATE_MEMORY_REGION */ 23/* for KVM_CREATE_MEMORY_REGION */
17struct kvm_memory_region { 24struct kvm_memory_region {
18 __u32 slot; 25 __u32 slot;
@@ -73,6 +80,9 @@ struct kvm_irqchip {
73#define KVM_EXIT_INTR 10 80#define KVM_EXIT_INTR 10
74#define KVM_EXIT_SET_TPR 11 81#define KVM_EXIT_SET_TPR 11
75#define KVM_EXIT_TPR_ACCESS 12 82#define KVM_EXIT_TPR_ACCESS 12
83#define KVM_EXIT_S390_SIEIC 13
84#define KVM_EXIT_S390_RESET 14
85#define KVM_EXIT_DCR 15
76 86
77/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 87/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
78struct kvm_run { 88struct kvm_run {
@@ -137,6 +147,27 @@ struct kvm_run {
137 __u32 is_write; 147 __u32 is_write;
138 __u32 pad; 148 __u32 pad;
139 } tpr_access; 149 } tpr_access;
150 /* KVM_EXIT_S390_SIEIC */
151 struct {
152 __u8 icptcode;
153 __u64 mask; /* psw upper half */
154 __u64 addr; /* psw lower half */
155 __u16 ipa;
156 __u32 ipb;
157 } s390_sieic;
158 /* KVM_EXIT_S390_RESET */
159#define KVM_S390_RESET_POR 1
160#define KVM_S390_RESET_CLEAR 2
161#define KVM_S390_RESET_SUBSYSTEM 4
162#define KVM_S390_RESET_CPU_INIT 8
163#define KVM_S390_RESET_IPL 16
164 __u64 s390_reset_flags;
165 /* KVM_EXIT_DCR */
166 struct {
167 __u32 dcrn;
168 __u32 data;
169 __u8 is_write;
170 } dcr;
140 /* Fix the size of the union. */ 171 /* Fix the size of the union. */
141 char padding[256]; 172 char padding[256];
142 }; 173 };
@@ -204,6 +235,74 @@ struct kvm_vapic_addr {
204 __u64 vapic_addr; 235 __u64 vapic_addr;
205}; 236};
206 237
238/* for KVM_SET_MPSTATE */
239
240#define KVM_MP_STATE_RUNNABLE 0
241#define KVM_MP_STATE_UNINITIALIZED 1
242#define KVM_MP_STATE_INIT_RECEIVED 2
243#define KVM_MP_STATE_HALTED 3
244#define KVM_MP_STATE_SIPI_RECEIVED 4
245
246struct kvm_mp_state {
247 __u32 mp_state;
248};
249
250struct kvm_s390_psw {
251 __u64 mask;
252 __u64 addr;
253};
254
255/* valid values for type in kvm_s390_interrupt */
256#define KVM_S390_SIGP_STOP 0xfffe0000u
257#define KVM_S390_PROGRAM_INT 0xfffe0001u
258#define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u
259#define KVM_S390_RESTART 0xfffe0003u
260#define KVM_S390_INT_VIRTIO 0xffff2603u
261#define KVM_S390_INT_SERVICE 0xffff2401u
262#define KVM_S390_INT_EMERGENCY 0xffff1201u
263
264struct kvm_s390_interrupt {
265 __u32 type;
266 __u32 parm;
267 __u64 parm64;
268};
269
270#define KVM_TRC_SHIFT 16
271/*
272 * kvm trace categories
273 */
274#define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT)
275#define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1)) /* only 12 bits */
276
277/*
278 * kvm trace action
279 */
280#define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01)
281#define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02)
282#define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01)
283
284#define KVM_TRC_HEAD_SIZE 12
285#define KVM_TRC_CYCLE_SIZE 8
286#define KVM_TRC_EXTRA_MAX 7
287
288/* This structure represents a single trace buffer record. */
289struct kvm_trace_rec {
290 __u32 event:28;
291 __u32 extra_u32:3;
292 __u32 cycle_in:1;
293 __u32 pid;
294 __u32 vcpu_id;
295 union {
296 struct {
297 __u32 cycle_lo, cycle_hi;
298 __u32 extra_u32[KVM_TRC_EXTRA_MAX];
299 } cycle;
300 struct {
301 __u32 extra_u32[KVM_TRC_EXTRA_MAX];
302 } nocycle;
303 } u;
304};
305
207#define KVMIO 0xAE 306#define KVMIO 0xAE
208 307
209/* 308/*
@@ -212,6 +311,8 @@ struct kvm_vapic_addr {
212#define KVM_GET_API_VERSION _IO(KVMIO, 0x00) 311#define KVM_GET_API_VERSION _IO(KVMIO, 0x00)
213#define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ 312#define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */
214#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) 313#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list)
314
315#define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06)
215/* 316/*
216 * Check if a kvm extension is available. Argument is extension number, 317 * Check if a kvm extension is available. Argument is extension number,
217 * return is 1 (yes) or 0 (no, sorry). 318 * return is 1 (yes) or 0 (no, sorry).
@@ -222,7 +323,12 @@ struct kvm_vapic_addr {
222 */ 323 */
223#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 324#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */
224#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) 325#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
225 326/*
327 * ioctls for kvm trace
328 */
329#define KVM_TRACE_ENABLE _IOW(KVMIO, 0x06, struct kvm_user_trace_setup)
330#define KVM_TRACE_PAUSE _IO(KVMIO, 0x07)
331#define KVM_TRACE_DISABLE _IO(KVMIO, 0x08)
226/* 332/*
227 * Extension capability list. 333 * Extension capability list.
228 */ 334 */
@@ -233,6 +339,13 @@ struct kvm_vapic_addr {
233#define KVM_CAP_SET_TSS_ADDR 4 339#define KVM_CAP_SET_TSS_ADDR 4
234#define KVM_CAP_VAPIC 6 340#define KVM_CAP_VAPIC 6
235#define KVM_CAP_EXT_CPUID 7 341#define KVM_CAP_EXT_CPUID 7
342#define KVM_CAP_CLOCKSOURCE 8
343#define KVM_CAP_NR_VCPUS 9 /* returns max vcpus per vm */
344#define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */
345#define KVM_CAP_PIT 11
346#define KVM_CAP_NOP_IO_DELAY 12
347#define KVM_CAP_PV_MMU 13
348#define KVM_CAP_MP_STATE 14
236 349
237/* 350/*
238 * ioctls for VM fds 351 * ioctls for VM fds
@@ -255,6 +368,9 @@ struct kvm_vapic_addr {
255#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 368#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level)
256#define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) 369#define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip)
257#define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) 370#define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip)
371#define KVM_CREATE_PIT _IO(KVMIO, 0x64)
372#define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state)
373#define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state)
258 374
259/* 375/*
260 * ioctls for vcpu fds 376 * ioctls for vcpu fds
@@ -281,5 +397,17 @@ struct kvm_vapic_addr {
281#define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) 397#define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)
282/* Available with KVM_CAP_VAPIC */ 398/* Available with KVM_CAP_VAPIC */
283#define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) 399#define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr)
400/* valid for virtual machine (for floating interrupt)_and_ vcpu */
401#define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt)
402/* store status for s390 */
403#define KVM_S390_STORE_STATUS_NOADDR (-1ul)
404#define KVM_S390_STORE_STATUS_PREFIXED (-2ul)
405#define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long)
406/* initial ipl psw for s390 */
407#define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw)
408/* initial reset for s390 */
409#define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97)
410#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state)
411#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state)
284 412
285#endif 413#endif
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 928b0d59e9ba..398978972b7a 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -15,6 +15,7 @@
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/preempt.h> 17#include <linux/preempt.h>
18#include <linux/marker.h>
18#include <asm/signal.h> 19#include <asm/signal.h>
19 20
20#include <linux/kvm.h> 21#include <linux/kvm.h>
@@ -24,29 +25,18 @@
24 25
25#include <asm/kvm_host.h> 26#include <asm/kvm_host.h>
26 27
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/* 28/*
35 * vcpu->requests bit members 29 * vcpu->requests bit members
36 */ 30 */
37#define KVM_REQ_TLB_FLUSH 0 31#define KVM_REQ_TLB_FLUSH 0
38#define KVM_REQ_MIGRATE_TIMER 1 32#define KVM_REQ_MIGRATE_TIMER 1
39#define KVM_REQ_REPORT_TPR_ACCESS 2 33#define KVM_REQ_REPORT_TPR_ACCESS 2
34#define KVM_REQ_MMU_RELOAD 3
35#define KVM_REQ_TRIPLE_FAULT 4
40 36
41struct kvm_vcpu; 37struct kvm_vcpu;
42extern struct kmem_cache *kvm_vcpu_cache; 38extern struct kmem_cache *kvm_vcpu_cache;
43 39
44struct kvm_guest_debug {
45 int enabled;
46 unsigned long bp[4];
47 int singlestep;
48};
49
50/* 40/*
51 * It would be nice to use something smarter than a linear search, TBD... 41 * 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 :), 42 * Thankfully we dont expect many devices to register (famous last words :),
@@ -67,7 +57,9 @@ void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
67 57
68struct kvm_vcpu { 58struct kvm_vcpu {
69 struct kvm *kvm; 59 struct kvm *kvm;
60#ifdef CONFIG_PREEMPT_NOTIFIERS
70 struct preempt_notifier preempt_notifier; 61 struct preempt_notifier preempt_notifier;
62#endif
71 int vcpu_id; 63 int vcpu_id;
72 struct mutex mutex; 64 struct mutex mutex;
73 int cpu; 65 int cpu;
@@ -100,6 +92,10 @@ struct kvm_memory_slot {
100 unsigned long flags; 92 unsigned long flags;
101 unsigned long *rmap; 93 unsigned long *rmap;
102 unsigned long *dirty_bitmap; 94 unsigned long *dirty_bitmap;
95 struct {
96 unsigned long rmap_pde;
97 int write_count;
98 } *lpage_info;
103 unsigned long userspace_addr; 99 unsigned long userspace_addr;
104 int user_alloc; 100 int user_alloc;
105}; 101};
@@ -114,11 +110,11 @@ struct kvm {
114 KVM_PRIVATE_MEM_SLOTS]; 110 KVM_PRIVATE_MEM_SLOTS];
115 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; 111 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
116 struct list_head vm_list; 112 struct list_head vm_list;
117 struct file *filp;
118 struct kvm_io_bus mmio_bus; 113 struct kvm_io_bus mmio_bus;
119 struct kvm_io_bus pio_bus; 114 struct kvm_io_bus pio_bus;
120 struct kvm_vm_stat stat; 115 struct kvm_vm_stat stat;
121 struct kvm_arch arch; 116 struct kvm_arch arch;
117 atomic_t users_count;
122}; 118};
123 119
124/* The guest did something we don't support. */ 120/* The guest did something we don't support. */
@@ -145,14 +141,19 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
145 struct module *module); 141 struct module *module);
146void kvm_exit(void); 142void kvm_exit(void);
147 143
144void kvm_get_kvm(struct kvm *kvm);
145void kvm_put_kvm(struct kvm *kvm);
146
148#define HPA_MSB ((sizeof(hpa_t) * 8) - 1) 147#define HPA_MSB ((sizeof(hpa_t) * 8) - 1)
149#define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB) 148#define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB)
150static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; } 149static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }
151struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva); 150struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);
152 151
153extern struct page *bad_page; 152extern struct page *bad_page;
153extern pfn_t bad_pfn;
154 154
155int is_error_page(struct page *page); 155int is_error_page(struct page *page);
156int is_error_pfn(pfn_t pfn);
156int kvm_is_error_hva(unsigned long addr); 157int kvm_is_error_hva(unsigned long addr);
157int kvm_set_memory_region(struct kvm *kvm, 158int kvm_set_memory_region(struct kvm *kvm,
158 struct kvm_userspace_memory_region *mem, 159 struct kvm_userspace_memory_region *mem,
@@ -166,8 +167,19 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
166 int user_alloc); 167 int user_alloc);
167gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); 168gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn);
168struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); 169struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
170unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
169void kvm_release_page_clean(struct page *page); 171void kvm_release_page_clean(struct page *page);
170void kvm_release_page_dirty(struct page *page); 172void kvm_release_page_dirty(struct page *page);
173void kvm_set_page_dirty(struct page *page);
174void kvm_set_page_accessed(struct page *page);
175
176pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn);
177void kvm_release_pfn_dirty(pfn_t);
178void kvm_release_pfn_clean(pfn_t pfn);
179void kvm_set_pfn_dirty(pfn_t pfn);
180void kvm_set_pfn_accessed(pfn_t pfn);
181void kvm_get_pfn(pfn_t pfn);
182
171int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset, 183int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
172 int len); 184 int len);
173int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data, 185int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data,
@@ -188,6 +200,7 @@ void kvm_resched(struct kvm_vcpu *vcpu);
188void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); 200void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
189void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); 201void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
190void kvm_flush_remote_tlbs(struct kvm *kvm); 202void kvm_flush_remote_tlbs(struct kvm *kvm);
203void kvm_reload_remote_mmus(struct kvm *kvm);
191 204
192long kvm_arch_dev_ioctl(struct file *filp, 205long kvm_arch_dev_ioctl(struct file *filp,
193 unsigned int ioctl, unsigned long arg); 206 unsigned int ioctl, unsigned long arg);
@@ -223,6 +236,10 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
223 struct kvm_sregs *sregs); 236 struct kvm_sregs *sregs);
224int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, 237int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
225 struct kvm_sregs *sregs); 238 struct kvm_sregs *sregs);
239int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
240 struct kvm_mp_state *mp_state);
241int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
242 struct kvm_mp_state *mp_state);
226int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, 243int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
227 struct kvm_debug_guest *dbg); 244 struct kvm_debug_guest *dbg);
228int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); 245int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
@@ -255,6 +272,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm);
255 272
256int kvm_cpu_get_interrupt(struct kvm_vcpu *v); 273int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
257int kvm_cpu_has_interrupt(struct kvm_vcpu *v); 274int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
275int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
258void kvm_vcpu_kick(struct kvm_vcpu *vcpu); 276void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
259 277
260static inline void kvm_guest_enter(void) 278static inline void kvm_guest_enter(void)
@@ -296,5 +314,18 @@ struct kvm_stats_debugfs_item {
296 struct dentry *dentry; 314 struct dentry *dentry;
297}; 315};
298extern struct kvm_stats_debugfs_item debugfs_entries[]; 316extern struct kvm_stats_debugfs_item debugfs_entries[];
317extern struct dentry *kvm_debugfs_dir;
318
319#ifdef CONFIG_KVM_TRACE
320int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg);
321void kvm_trace_cleanup(void);
322#else
323static inline
324int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg)
325{
326 return -EINVAL;
327}
328#define kvm_trace_cleanup() ((void)0)
329#endif
299 330
300#endif 331#endif
diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h
index 5497aac0d2f8..3ddce03766ca 100644
--- a/include/linux/kvm_para.h
+++ b/include/linux/kvm_para.h
@@ -11,8 +11,11 @@
11 11
12/* Return values for hypercalls */ 12/* Return values for hypercalls */
13#define KVM_ENOSYS 1000 13#define KVM_ENOSYS 1000
14#define KVM_EFAULT EFAULT
15#define KVM_E2BIG E2BIG
14 16
15#define KVM_HC_VAPIC_POLL_IRQ 1 17#define KVM_HC_VAPIC_POLL_IRQ 1
18#define KVM_HC_MMU_OP 2
16 19
17/* 20/*
18 * hypercalls use architecture specific 21 * hypercalls use architecture specific
@@ -20,6 +23,12 @@
20#include <asm/kvm_para.h> 23#include <asm/kvm_para.h>
21 24
22#ifdef __KERNEL__ 25#ifdef __KERNEL__
26#ifdef CONFIG_KVM_GUEST
27void __init kvm_guest_init(void);
28#else
29#define kvm_guest_init() do { } while (0)
30#endif
31
23static inline int kvm_para_has_feature(unsigned int feature) 32static inline int kvm_para_has_feature(unsigned int feature)
24{ 33{
25 if (kvm_arch_para_features() & (1UL << feature)) 34 if (kvm_arch_para_features() & (1UL << feature))
diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h
index 1c4e46decb22..9b6f395c9625 100644
--- a/include/linux/kvm_types.h
+++ b/include/linux/kvm_types.h
@@ -38,6 +38,8 @@ typedef unsigned long hva_t;
38typedef u64 hpa_t; 38typedef u64 hpa_t;
39typedef unsigned long hfn_t; 39typedef unsigned long hfn_t;
40 40
41typedef hfn_t pfn_t;
42
41struct kvm_pio_request { 43struct kvm_pio_request {
42 unsigned long count; 44 unsigned long count;
43 int cur_count; 45 int cur_count;
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 0201f6f51cea..519df72e939d 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -35,8 +35,11 @@ struct led_classdev {
35#define LED_SUSPENDED (1 << 0) 35#define LED_SUSPENDED (1 << 0)
36 36
37 /* Set LED brightness level */ 37 /* Set LED brightness level */
38 /* Must not sleep, use a workqueue if needed */
38 void (*brightness_set)(struct led_classdev *led_cdev, 39 void (*brightness_set)(struct led_classdev *led_cdev,
39 enum led_brightness brightness); 40 enum led_brightness brightness);
41 /* Get LED brightness level */
42 enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
40 43
41 /* Activate hardware accelerated blink */ 44 /* Activate hardware accelerated blink */
42 int (*blink_set)(struct led_classdev *led_cdev, 45 int (*blink_set)(struct led_classdev *led_cdev,
@@ -59,15 +62,7 @@ struct led_classdev {
59 62
60extern int led_classdev_register(struct device *parent, 63extern int led_classdev_register(struct device *parent,
61 struct led_classdev *led_cdev); 64 struct led_classdev *led_cdev);
62extern void __led_classdev_unregister(struct led_classdev *led_cdev, bool sus); 65extern void led_classdev_unregister(struct led_classdev *lcd);
63static inline void led_classdev_unregister(struct led_classdev *lcd)
64{
65 __led_classdev_unregister(lcd, false);
66}
67static inline void led_classdev_unregister_suspended(struct led_classdev *lcd)
68{
69 __led_classdev_unregister(lcd, true);
70}
71extern void led_classdev_suspend(struct led_classdev *led_cdev); 66extern void led_classdev_suspend(struct led_classdev *led_cdev);
72extern void led_classdev_resume(struct led_classdev *led_cdev); 67extern void led_classdev_resume(struct led_classdev *led_cdev);
73 68
@@ -134,6 +129,9 @@ struct gpio_led {
134struct gpio_led_platform_data { 129struct gpio_led_platform_data {
135 int num_leds; 130 int num_leds;
136 struct gpio_led *leds; 131 struct gpio_led *leds;
132 int (*gpio_blink_set)(unsigned gpio,
133 unsigned long *delay_on,
134 unsigned long *delay_off);
137}; 135};
138 136
139 137
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 37ee881c42ac..d1dfe872ee30 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -122,6 +122,8 @@ enum {
122 122
123 ATAPI_MAX_DRAIN = 16 << 10, 123 ATAPI_MAX_DRAIN = 16 << 10,
124 124
125 ATA_ALL_DEVICES = (1 << ATA_MAX_DEVICES) - 1,
126
125 ATA_SHT_EMULATED = 1, 127 ATA_SHT_EMULATED = 1,
126 ATA_SHT_CMD_PER_LUN = 1, 128 ATA_SHT_CMD_PER_LUN = 1,
127 ATA_SHT_THIS_ID = -1, 129 ATA_SHT_THIS_ID = -1,
@@ -163,9 +165,6 @@ enum {
163 ATA_DEV_NONE = 9, /* no device */ 165 ATA_DEV_NONE = 9, /* no device */
164 166
165 /* struct ata_link flags */ 167 /* struct ata_link flags */
166 ATA_LFLAG_HRST_TO_RESUME = (1 << 0), /* hardreset to resume link */
167 ATA_LFLAG_SKIP_D2H_BSY = (1 << 1), /* can't wait for the first D2H
168 * Register FIS clearing BSY */
169 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */ 168 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */
170 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */ 169 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */
171 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */ 170 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */
@@ -225,6 +224,7 @@ enum {
225 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ 224 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */
226 ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ 225 ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */
227 ATA_QCFLAG_QUIET = (1 << 6), /* don't report device error */ 226 ATA_QCFLAG_QUIET = (1 << 6), /* don't report device error */
227 ATA_QCFLAG_RETRY = (1 << 7), /* retry after failure */
228 228
229 ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ 229 ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */
230 ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ 230 ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */
@@ -249,6 +249,25 @@ enum {
249 */ 249 */
250 ATA_TMOUT_FF_WAIT = 4 * HZ / 5, 250 ATA_TMOUT_FF_WAIT = 4 * HZ / 5,
251 251
252 /* Spec mandates to wait for ">= 2ms" before checking status
253 * after reset. We wait 150ms, because that was the magic
254 * delay used for ATAPI devices in Hale Landis's ATADRVR, for
255 * the period of time between when the ATA command register is
256 * written, and then status is checked. Because waiting for
257 * "a while" before checking status is fine, post SRST, we
258 * perform this magic delay here as well.
259 *
260 * Old drivers/ide uses the 2mS rule and then waits for ready.
261 */
262 ATA_WAIT_AFTER_RESET_MSECS = 150,
263
264 /* If PMP is supported, we have to do follow-up SRST. As some
265 * PMPs don't send D2H Reg FIS after hardreset, LLDs are
266 * advised to wait only for the following duration before
267 * doing SRST.
268 */
269 ATA_TMOUT_PMP_SRST_WAIT = 1 * HZ,
270
252 /* ATA bus states */ 271 /* ATA bus states */
253 BUS_UNKNOWN = 0, 272 BUS_UNKNOWN = 0,
254 BUS_DMA = 1, 273 BUS_DMA = 1,
@@ -292,17 +311,16 @@ enum {
292 311
293 /* reset / recovery action types */ 312 /* reset / recovery action types */
294 ATA_EH_REVALIDATE = (1 << 0), 313 ATA_EH_REVALIDATE = (1 << 0),
295 ATA_EH_SOFTRESET = (1 << 1), 314 ATA_EH_SOFTRESET = (1 << 1), /* meaningful only in ->prereset */
296 ATA_EH_HARDRESET = (1 << 2), 315 ATA_EH_HARDRESET = (1 << 2), /* meaningful only in ->prereset */
316 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
297 ATA_EH_ENABLE_LINK = (1 << 3), 317 ATA_EH_ENABLE_LINK = (1 << 3),
298 ATA_EH_LPM = (1 << 4), /* link power management action */ 318 ATA_EH_LPM = (1 << 4), /* link power management action */
299 319
300 ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
301 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, 320 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE,
302 321
303 /* ata_eh_info->flags */ 322 /* ata_eh_info->flags */
304 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 323 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
305 ATA_EHI_RESUME_LINK = (1 << 1), /* resume link (reset modifier) */
306 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ 324 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */
307 ATA_EHI_QUIET = (1 << 3), /* be quiet */ 325 ATA_EHI_QUIET = (1 << 3), /* be quiet */
308 326
@@ -313,7 +331,6 @@ enum {
313 ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */ 331 ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */
314 332
315 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, 333 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
316 ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK,
317 334
318 /* max tries if error condition is still set after ->error_handler */ 335 /* max tries if error condition is still set after ->error_handler */
319 ATA_EH_MAX_TRIES = 5, 336 ATA_EH_MAX_TRIES = 5,
@@ -352,6 +369,22 @@ enum {
352 ATAPI_READ_CD = 2, /* READ CD [MSF] */ 369 ATAPI_READ_CD = 2, /* READ CD [MSF] */
353 ATAPI_PASS_THRU = 3, /* SAT pass-thru */ 370 ATAPI_PASS_THRU = 3, /* SAT pass-thru */
354 ATAPI_MISC = 4, /* the rest */ 371 ATAPI_MISC = 4, /* the rest */
372
373 /* Timing constants */
374 ATA_TIMING_SETUP = (1 << 0),
375 ATA_TIMING_ACT8B = (1 << 1),
376 ATA_TIMING_REC8B = (1 << 2),
377 ATA_TIMING_CYC8B = (1 << 3),
378 ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B |
379 ATA_TIMING_CYC8B,
380 ATA_TIMING_ACTIVE = (1 << 4),
381 ATA_TIMING_RECOVER = (1 << 5),
382 ATA_TIMING_CYCLE = (1 << 6),
383 ATA_TIMING_UDMA = (1 << 7),
384 ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B |
385 ATA_TIMING_REC8B | ATA_TIMING_CYC8B |
386 ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER |
387 ATA_TIMING_CYCLE | ATA_TIMING_UDMA,
355}; 388};
356 389
357enum ata_xfer_mask { 390enum ata_xfer_mask {
@@ -410,8 +443,9 @@ enum link_pm {
410 MAX_PERFORMANCE, 443 MAX_PERFORMANCE,
411 MEDIUM_POWER, 444 MEDIUM_POWER,
412}; 445};
413extern struct class_device_attribute class_device_attr_link_power_management_policy; 446extern struct device_attribute dev_attr_link_power_management_policy;
414 447
448#ifdef CONFIG_ATA_SFF
415struct ata_ioports { 449struct ata_ioports {
416 void __iomem *cmd_addr; 450 void __iomem *cmd_addr;
417 void __iomem *data_addr; 451 void __iomem *data_addr;
@@ -429,6 +463,7 @@ struct ata_ioports {
429 void __iomem *bmdma_addr; 463 void __iomem *bmdma_addr;
430 void __iomem *scr_addr; 464 void __iomem *scr_addr;
431}; 465};
466#endif /* CONFIG_ATA_SFF */
432 467
433struct ata_host { 468struct ata_host {
434 spinlock_t lock; 469 spinlock_t lock;
@@ -436,7 +471,7 @@ struct ata_host {
436 void __iomem * const *iomap; 471 void __iomem * const *iomap;
437 unsigned int n_ports; 472 unsigned int n_ports;
438 void *private_data; 473 void *private_data;
439 const struct ata_port_operations *ops; 474 struct ata_port_operations *ops;
440 unsigned long flags; 475 unsigned long flags;
441#ifdef CONFIG_ATA_ACPI 476#ifdef CONFIG_ATA_ACPI
442 acpi_handle acpi_handle; 477 acpi_handle acpi_handle;
@@ -513,11 +548,6 @@ struct ata_device {
513 u64 n_sectors; /* size of device, if ATA */ 548 u64 n_sectors; /* size of device, if ATA */
514 unsigned int class; /* ATA_DEV_xxx */ 549 unsigned int class; /* ATA_DEV_xxx */
515 550
516 union {
517 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
518 u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
519 };
520
521 u8 pio_mode; 551 u8 pio_mode;
522 u8 dma_mode; 552 u8 dma_mode;
523 u8 xfer_mode; 553 u8 xfer_mode;
@@ -539,8 +569,13 @@ struct ata_device {
539 u16 sectors; /* Number of sectors per track */ 569 u16 sectors; /* Number of sectors per track */
540 570
541 /* error history */ 571 /* error history */
542 struct ata_ering ering;
543 int spdn_cnt; 572 int spdn_cnt;
573 struct ata_ering ering;
574
575 union {
576 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
577 u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
578 };
544}; 579};
545 580
546/* Offset into struct ata_device. Fields above it are maintained 581/* Offset into struct ata_device. Fields above it are maintained
@@ -605,7 +640,7 @@ struct ata_link {
605 640
606struct ata_port { 641struct ata_port {
607 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ 642 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */
608 const struct ata_port_operations *ops; 643 struct ata_port_operations *ops;
609 spinlock_t *lock; 644 spinlock_t *lock;
610 unsigned long flags; /* ATA_FLAG_xxx */ 645 unsigned long flags; /* ATA_FLAG_xxx */
611 unsigned int pflags; /* ATA_PFLAG_xxx */ 646 unsigned int pflags; /* ATA_PFLAG_xxx */
@@ -615,7 +650,9 @@ struct ata_port {
615 struct ata_prd *prd; /* our SG list */ 650 struct ata_prd *prd; /* our SG list */
616 dma_addr_t prd_dma; /* and its DMA mapping */ 651 dma_addr_t prd_dma; /* and its DMA mapping */
617 652
653#ifdef CONFIG_ATA_SFF
618 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ 654 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */
655#endif /* CONFIG_ATA_SFF */
619 656
620 u8 ctl; /* cache of ATA control register */ 657 u8 ctl; /* cache of ATA control register */
621 u8 last_ctl; /* Cache last written value */ 658 u8 last_ctl; /* Cache last written value */
@@ -667,81 +704,108 @@ struct ata_port {
667 u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ 704 u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */
668}; 705};
669 706
670struct ata_port_operations { 707/* The following initializer overrides a method to NULL whether one of
671 void (*dev_config) (struct ata_device *); 708 * its parent has the method defined or not. This is equivalent to
672 709 * ERR_PTR(-ENOENT). Unfortunately, ERR_PTR doesn't render a constant
673 void (*set_piomode) (struct ata_port *, struct ata_device *); 710 * expression and thus can't be used as an initializer.
674 void (*set_dmamode) (struct ata_port *, struct ata_device *); 711 */
675 unsigned long (*mode_filter) (struct ata_device *, unsigned long); 712#define ATA_OP_NULL (void *)(unsigned long)(-ENOENT)
676
677 void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf);
678 void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
679
680 void (*exec_command)(struct ata_port *ap, const struct ata_taskfile *tf);
681 u8 (*check_status)(struct ata_port *ap);
682 u8 (*check_altstatus)(struct ata_port *ap);
683 void (*dev_select)(struct ata_port *ap, unsigned int device);
684
685 void (*phy_reset) (struct ata_port *ap); /* obsolete */
686 int (*set_mode) (struct ata_link *link, struct ata_device **r_failed_dev);
687
688 int (*cable_detect) (struct ata_port *ap);
689
690 int (*check_atapi_dma) (struct ata_queued_cmd *qc);
691
692 void (*bmdma_setup) (struct ata_queued_cmd *qc);
693 void (*bmdma_start) (struct ata_queued_cmd *qc);
694
695 unsigned int (*data_xfer) (struct ata_device *dev, unsigned char *buf,
696 unsigned int buflen, int rw);
697
698 int (*qc_defer) (struct ata_queued_cmd *qc);
699 void (*qc_prep) (struct ata_queued_cmd *qc);
700 unsigned int (*qc_issue) (struct ata_queued_cmd *qc);
701
702 /* port multiplier */
703 void (*pmp_attach) (struct ata_port *ap);
704 void (*pmp_detach) (struct ata_port *ap);
705 713
706 /* Error handlers. ->error_handler overrides ->eng_timeout and 714struct ata_port_operations {
707 * indicates that new-style EH is in place. 715 /*
716 * Command execution
708 */ 717 */
709 void (*eng_timeout) (struct ata_port *ap); /* obsolete */ 718 int (*qc_defer)(struct ata_queued_cmd *qc);
710 719 int (*check_atapi_dma)(struct ata_queued_cmd *qc);
711 void (*freeze) (struct ata_port *ap); 720 void (*qc_prep)(struct ata_queued_cmd *qc);
712 void (*thaw) (struct ata_port *ap); 721 unsigned int (*qc_issue)(struct ata_queued_cmd *qc);
713 void (*error_handler) (struct ata_port *ap); 722 bool (*qc_fill_rtf)(struct ata_queued_cmd *qc);
714 void (*post_internal_cmd) (struct ata_queued_cmd *qc); 723
715 724 /*
716 irq_handler_t irq_handler; 725 * Configuration and exception handling
717 void (*irq_clear) (struct ata_port *); 726 */
718 u8 (*irq_on) (struct ata_port *); 727 int (*cable_detect)(struct ata_port *ap);
719 728 unsigned long (*mode_filter)(struct ata_device *dev, unsigned long xfer_mask);
720 int (*scr_read) (struct ata_port *ap, unsigned int sc_reg, u32 *val); 729 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev);
721 int (*scr_write) (struct ata_port *ap, unsigned int sc_reg, u32 val); 730 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev);
731 int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev);
732
733 void (*dev_config)(struct ata_device *dev);
734
735 void (*freeze)(struct ata_port *ap);
736 void (*thaw)(struct ata_port *ap);
737 ata_prereset_fn_t prereset;
738 ata_reset_fn_t softreset;
739 ata_reset_fn_t hardreset;
740 ata_postreset_fn_t postreset;
741 ata_prereset_fn_t pmp_prereset;
742 ata_reset_fn_t pmp_softreset;
743 ata_reset_fn_t pmp_hardreset;
744 ata_postreset_fn_t pmp_postreset;
745 void (*error_handler)(struct ata_port *ap);
746 void (*post_internal_cmd)(struct ata_queued_cmd *qc);
747
748 /*
749 * Optional features
750 */
751 int (*scr_read)(struct ata_port *ap, unsigned int sc_reg, u32 *val);
752 int (*scr_write)(struct ata_port *ap, unsigned int sc_reg, u32 val);
753 void (*pmp_attach)(struct ata_port *ap);
754 void (*pmp_detach)(struct ata_port *ap);
755 int (*enable_pm)(struct ata_port *ap, enum link_pm policy);
756 void (*disable_pm)(struct ata_port *ap);
757
758 /*
759 * Start, stop, suspend and resume
760 */
761 int (*port_suspend)(struct ata_port *ap, pm_message_t mesg);
762 int (*port_resume)(struct ata_port *ap);
763 int (*port_start)(struct ata_port *ap);
764 void (*port_stop)(struct ata_port *ap);
765 void (*host_stop)(struct ata_host *host);
766
767#ifdef CONFIG_ATA_SFF
768 /*
769 * SFF / taskfile oriented ops
770 */
771 void (*sff_dev_select)(struct ata_port *ap, unsigned int device);
772 u8 (*sff_check_status)(struct ata_port *ap);
773 u8 (*sff_check_altstatus)(struct ata_port *ap);
774 void (*sff_tf_load)(struct ata_port *ap, const struct ata_taskfile *tf);
775 void (*sff_tf_read)(struct ata_port *ap, struct ata_taskfile *tf);
776 void (*sff_exec_command)(struct ata_port *ap,
777 const struct ata_taskfile *tf);
778 unsigned int (*sff_data_xfer)(struct ata_device *dev,
779 unsigned char *buf, unsigned int buflen, int rw);
780 u8 (*sff_irq_on)(struct ata_port *);
781 void (*sff_irq_clear)(struct ata_port *);
722 782
723 int (*port_suspend) (struct ata_port *ap, pm_message_t mesg); 783 void (*bmdma_setup)(struct ata_queued_cmd *qc);
724 int (*port_resume) (struct ata_port *ap); 784 void (*bmdma_start)(struct ata_queued_cmd *qc);
725 int (*enable_pm) (struct ata_port *ap, enum link_pm policy); 785 void (*bmdma_stop)(struct ata_queued_cmd *qc);
726 void (*disable_pm) (struct ata_port *ap); 786 u8 (*bmdma_status)(struct ata_port *ap);
727 int (*port_start) (struct ata_port *ap); 787#endif /* CONFIG_ATA_SFF */
728 void (*port_stop) (struct ata_port *ap);
729 788
730 void (*host_stop) (struct ata_host *host); 789 /*
790 * Obsolete
791 */
792 void (*phy_reset)(struct ata_port *ap);
793 void (*eng_timeout)(struct ata_port *ap);
731 794
732 void (*bmdma_stop) (struct ata_queued_cmd *qc); 795 /*
733 u8 (*bmdma_status) (struct ata_port *ap); 796 * ->inherits must be the last field and all the preceding
797 * fields must be pointers.
798 */
799 const struct ata_port_operations *inherits;
734}; 800};
735 801
736struct ata_port_info { 802struct ata_port_info {
737 struct scsi_host_template *sht;
738 unsigned long flags; 803 unsigned long flags;
739 unsigned long link_flags; 804 unsigned long link_flags;
740 unsigned long pio_mask; 805 unsigned long pio_mask;
741 unsigned long mwdma_mask; 806 unsigned long mwdma_mask;
742 unsigned long udma_mask; 807 unsigned long udma_mask;
743 const struct ata_port_operations *port_ops; 808 struct ata_port_operations *port_ops;
744 irq_handler_t irq_handler;
745 void *private_data; 809 void *private_data;
746}; 810};
747 811
@@ -759,11 +823,14 @@ struct ata_timing {
759 823
760#define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin) 824#define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin)
761 825
826/*
827 * Core layer - drivers/ata/libata-core.c
828 */
762extern const unsigned long sata_deb_timing_normal[]; 829extern const unsigned long sata_deb_timing_normal[];
763extern const unsigned long sata_deb_timing_hotplug[]; 830extern const unsigned long sata_deb_timing_hotplug[];
764extern const unsigned long sata_deb_timing_long[]; 831extern const unsigned long sata_deb_timing_long[];
765 832
766extern const struct ata_port_operations ata_dummy_port_ops; 833extern struct ata_port_operations ata_dummy_port_ops;
767extern const struct ata_port_info ata_dummy_port_info; 834extern const struct ata_port_info ata_dummy_port_info;
768 835
769static inline const unsigned long * 836static inline const unsigned long *
@@ -780,24 +847,22 @@ static inline int ata_port_is_dummy(struct ata_port *ap)
780 return ap->ops == &ata_dummy_port_ops; 847 return ap->ops == &ata_dummy_port_ops;
781} 848}
782 849
783extern void sata_print_link_status(struct ata_link *link);
784extern void ata_port_probe(struct ata_port *); 850extern void ata_port_probe(struct ata_port *);
785extern void ata_bus_reset(struct ata_port *ap);
786extern int sata_set_spd(struct ata_link *link); 851extern int sata_set_spd(struct ata_link *link);
852extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
853extern int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
854 int (*check_ready)(struct ata_link *link));
787extern int sata_link_debounce(struct ata_link *link, 855extern int sata_link_debounce(struct ata_link *link,
788 const unsigned long *params, unsigned long deadline); 856 const unsigned long *params, unsigned long deadline);
789extern int sata_link_resume(struct ata_link *link, const unsigned long *params, 857extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
790 unsigned long deadline); 858 unsigned long deadline);
791extern int ata_std_prereset(struct ata_link *link, unsigned long deadline);
792extern int ata_std_softreset(struct ata_link *link, unsigned int *classes,
793 unsigned long deadline);
794extern int sata_link_hardreset(struct ata_link *link, 859extern int sata_link_hardreset(struct ata_link *link,
795 const unsigned long *timing, unsigned long deadline); 860 const unsigned long *timing, unsigned long deadline,
861 bool *online, int (*check_ready)(struct ata_link *));
796extern int sata_std_hardreset(struct ata_link *link, unsigned int *class, 862extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
797 unsigned long deadline); 863 unsigned long deadline);
798extern void ata_std_postreset(struct ata_link *link, unsigned int *classes); 864extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
799extern void ata_port_disable(struct ata_port *); 865extern void ata_port_disable(struct ata_port *);
800extern void ata_std_ports(struct ata_ioports *ioaddr);
801 866
802extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); 867extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
803extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 868extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
@@ -810,7 +875,7 @@ extern int ata_host_activate(struct ata_host *host, int irq,
810 struct scsi_host_template *sht); 875 struct scsi_host_template *sht);
811extern void ata_host_detach(struct ata_host *host); 876extern void ata_host_detach(struct ata_host *host);
812extern void ata_host_init(struct ata_host *, struct device *, 877extern void ata_host_init(struct ata_host *, struct device *,
813 unsigned long, const struct ata_port_operations *); 878 unsigned long, struct ata_port_operations *);
814extern int ata_scsi_detect(struct scsi_host_template *sht); 879extern int ata_scsi_detect(struct scsi_host_template *sht);
815extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 880extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
816extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); 881extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
@@ -823,7 +888,6 @@ extern void ata_sas_port_stop(struct ata_port *ap);
823extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *); 888extern int ata_sas_slave_configure(struct scsi_device *, struct ata_port *);
824extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), 889extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
825 struct ata_port *ap); 890 struct ata_port *ap);
826extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
827extern int sata_scr_valid(struct ata_link *link); 891extern int sata_scr_valid(struct ata_link *link);
828extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); 892extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
829extern int sata_scr_write(struct ata_link *link, int reg, u32 val); 893extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
@@ -835,21 +899,9 @@ extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
835extern void ata_host_resume(struct ata_host *host); 899extern void ata_host_resume(struct ata_host *host);
836#endif 900#endif
837extern int ata_ratelimit(void); 901extern int ata_ratelimit(void);
838extern int ata_busy_sleep(struct ata_port *ap,
839 unsigned long timeout_pat, unsigned long timeout);
840extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline);
841extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline);
842extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 902extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
843 unsigned long interval_msec, 903 unsigned long interval_msec,
844 unsigned long timeout_msec); 904 unsigned long timeout_msec);
845extern unsigned int ata_dev_try_classify(struct ata_device *dev, int present,
846 u8 *r_err);
847
848/*
849 * Default driver ops implementations
850 */
851extern void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
852extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
853extern int atapi_cmd_type(u8 opcode); 905extern int atapi_cmd_type(u8 opcode);
854extern void ata_tf_to_fis(const struct ata_taskfile *tf, 906extern void ata_tf_to_fis(const struct ata_taskfile *tf,
855 u8 pmp, int is_cmd, u8 *fis); 907 u8 pmp, int is_cmd, u8 *fis);
@@ -864,23 +916,9 @@ extern unsigned long ata_xfer_mode2mask(u8 xfer_mode);
864extern int ata_xfer_mode2shift(unsigned long xfer_mode); 916extern int ata_xfer_mode2shift(unsigned long xfer_mode);
865extern const char *ata_mode_string(unsigned long xfer_mask); 917extern const char *ata_mode_string(unsigned long xfer_mask);
866extern unsigned long ata_id_xfermask(const u16 *id); 918extern unsigned long ata_id_xfermask(const u16 *id);
867extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device);
868extern void ata_std_dev_select(struct ata_port *ap, unsigned int device);
869extern u8 ata_check_status(struct ata_port *ap);
870extern u8 ata_altstatus(struct ata_port *ap);
871extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
872extern int ata_port_start(struct ata_port *ap); 919extern int ata_port_start(struct ata_port *ap);
873extern int ata_sff_port_start(struct ata_port *ap);
874extern irqreturn_t ata_interrupt(int irq, void *dev_instance);
875extern unsigned int ata_data_xfer(struct ata_device *dev,
876 unsigned char *buf, unsigned int buflen, int rw);
877extern unsigned int ata_data_xfer_noirq(struct ata_device *dev,
878 unsigned char *buf, unsigned int buflen, int rw);
879extern int ata_std_qc_defer(struct ata_queued_cmd *qc); 920extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
880extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc);
881extern void ata_qc_prep(struct ata_queued_cmd *qc);
882extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); 921extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
883extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
884extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 922extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
885 unsigned int n_elem); 923 unsigned int n_elem);
886extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); 924extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
@@ -889,24 +927,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
889 unsigned int ofs, unsigned int len); 927 unsigned int ofs, unsigned int len);
890extern void ata_id_c_string(const u16 *id, unsigned char *s, 928extern void ata_id_c_string(const u16 *id, unsigned char *s,
891 unsigned int ofs, unsigned int len); 929 unsigned int ofs, unsigned int len);
892extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
893extern void ata_bmdma_start(struct ata_queued_cmd *qc);
894extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
895extern u8 ata_bmdma_status(struct ata_port *ap);
896extern void ata_bmdma_irq_clear(struct ata_port *ap);
897extern void ata_bmdma_freeze(struct ata_port *ap);
898extern void ata_bmdma_thaw(struct ata_port *ap);
899extern void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
900 ata_reset_fn_t softreset,
901 ata_reset_fn_t hardreset,
902 ata_postreset_fn_t postreset);
903extern void ata_bmdma_error_handler(struct ata_port *ap);
904extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc);
905extern int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
906 u8 status, int in_wq);
907extern void ata_qc_complete(struct ata_queued_cmd *qc); 930extern void ata_qc_complete(struct ata_queued_cmd *qc);
908extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active, 931extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active);
909 void (*finish_qc)(struct ata_queued_cmd *));
910extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, 932extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
911 void (*done)(struct scsi_cmnd *)); 933 void (*done)(struct scsi_cmnd *));
912extern int ata_std_bios_param(struct scsi_device *sdev, 934extern int ata_std_bios_param(struct scsi_device *sdev,
@@ -918,7 +940,6 @@ extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
918 int queue_depth); 940 int queue_depth);
919extern struct ata_device *ata_dev_pair(struct ata_device *adev); 941extern struct ata_device *ata_dev_pair(struct ata_device *adev);
920extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 942extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
921extern u8 ata_irq_on(struct ata_port *ap);
922 943
923extern int ata_cable_40wire(struct ata_port *ap); 944extern int ata_cable_40wire(struct ata_port *ap);
924extern int ata_cable_80wire(struct ata_port *ap); 945extern int ata_cable_80wire(struct ata_port *ap);
@@ -926,10 +947,7 @@ extern int ata_cable_sata(struct ata_port *ap);
926extern int ata_cable_ignore(struct ata_port *ap); 947extern int ata_cable_ignore(struct ata_port *ap);
927extern int ata_cable_unknown(struct ata_port *ap); 948extern int ata_cable_unknown(struct ata_port *ap);
928 949
929/* 950/* Timing helpers */
930 * Timing helpers
931 */
932
933extern unsigned int ata_pio_need_iordy(const struct ata_device *); 951extern unsigned int ata_pio_need_iordy(const struct ata_device *);
934extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode); 952extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode);
935extern int ata_timing_compute(struct ata_device *, unsigned short, 953extern int ata_timing_compute(struct ata_device *, unsigned short,
@@ -939,24 +957,31 @@ extern void ata_timing_merge(const struct ata_timing *,
939 unsigned int); 957 unsigned int);
940extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle); 958extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle);
941 959
942enum { 960/* PCI */
943 ATA_TIMING_SETUP = (1 << 0), 961#ifdef CONFIG_PCI
944 ATA_TIMING_ACT8B = (1 << 1), 962struct pci_dev;
945 ATA_TIMING_REC8B = (1 << 2), 963
946 ATA_TIMING_CYC8B = (1 << 3), 964struct pci_bits {
947 ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B | 965 unsigned int reg; /* PCI config register to read */
948 ATA_TIMING_CYC8B, 966 unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
949 ATA_TIMING_ACTIVE = (1 << 4), 967 unsigned long mask;
950 ATA_TIMING_RECOVER = (1 << 5), 968 unsigned long val;
951 ATA_TIMING_CYCLE = (1 << 6),
952 ATA_TIMING_UDMA = (1 << 7),
953 ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B |
954 ATA_TIMING_REC8B | ATA_TIMING_CYC8B |
955 ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER |
956 ATA_TIMING_CYCLE | ATA_TIMING_UDMA,
957}; 969};
958 970
959/* libata-acpi.c */ 971extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
972extern void ata_pci_remove_one(struct pci_dev *pdev);
973
974#ifdef CONFIG_PM
975extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
976extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
977extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
978extern int ata_pci_device_resume(struct pci_dev *pdev);
979#endif /* CONFIG_PM */
980#endif /* CONFIG_PCI */
981
982/*
983 * ACPI - drivers/ata/libata-acpi.c
984 */
960#ifdef CONFIG_ATA_ACPI 985#ifdef CONFIG_ATA_ACPI
961static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) 986static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
962{ 987{
@@ -1000,56 +1025,8 @@ static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
1000} 1025}
1001#endif 1026#endif
1002 1027
1003#ifdef CONFIG_PCI
1004struct pci_dev;
1005
1006extern int ata_pci_init_one(struct pci_dev *pdev,
1007 const struct ata_port_info * const * ppi);
1008extern void ata_pci_remove_one(struct pci_dev *pdev);
1009#ifdef CONFIG_PM
1010extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
1011extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
1012extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
1013extern int ata_pci_device_resume(struct pci_dev *pdev);
1014#endif
1015extern int ata_pci_clear_simplex(struct pci_dev *pdev);
1016
1017struct pci_bits {
1018 unsigned int reg; /* PCI config register to read */
1019 unsigned int width; /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
1020 unsigned long mask;
1021 unsigned long val;
1022};
1023
1024extern int ata_pci_init_sff_host(struct ata_host *host);
1025extern int ata_pci_init_bmdma(struct ata_host *host);
1026extern int ata_pci_prepare_sff_host(struct pci_dev *pdev,
1027 const struct ata_port_info * const * ppi,
1028 struct ata_host **r_host);
1029extern int ata_pci_activate_sff_host(struct ata_host *host,
1030 irq_handler_t irq_handler,
1031 struct scsi_host_template *sht);
1032extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
1033extern unsigned long ata_pci_default_filter(struct ata_device *dev,
1034 unsigned long xfer_mask);
1035#endif /* CONFIG_PCI */
1036
1037/* 1028/*
1038 * PMP 1029 * EH - drivers/ata/libata-eh.c
1039 */
1040extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
1041extern int sata_pmp_std_prereset(struct ata_link *link, unsigned long deadline);
1042extern int sata_pmp_std_hardreset(struct ata_link *link, unsigned int *class,
1043 unsigned long deadline);
1044extern void sata_pmp_std_postreset(struct ata_link *link, unsigned int *class);
1045extern void sata_pmp_do_eh(struct ata_port *ap,
1046 ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
1047 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset,
1048 ata_prereset_fn_t pmp_prereset, ata_reset_fn_t pmp_softreset,
1049 ata_reset_fn_t pmp_hardreset, ata_postreset_fn_t pmp_postreset);
1050
1051/*
1052 * EH
1053 */ 1030 */
1054extern void ata_port_schedule_eh(struct ata_port *ap); 1031extern void ata_port_schedule_eh(struct ata_port *ap);
1055extern int ata_link_abort(struct ata_link *link); 1032extern int ata_link_abort(struct ata_link *link);
@@ -1066,6 +1043,92 @@ extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
1066extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, 1043extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
1067 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 1044 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
1068 ata_postreset_fn_t postreset); 1045 ata_postreset_fn_t postreset);
1046extern void ata_std_error_handler(struct ata_port *ap);
1047
1048/*
1049 * Base operations to inherit from and initializers for sht
1050 *
1051 * Operations
1052 *
1053 * base : Common to all libata drivers.
1054 * sata : SATA controllers w/ native interface.
1055 * pmp : SATA controllers w/ PMP support.
1056 * sff : SFF ATA controllers w/o BMDMA support.
1057 * bmdma : SFF ATA controllers w/ BMDMA support.
1058 *
1059 * sht initializers
1060 *
1061 * BASE : Common to all libata drivers. The user must set
1062 * sg_tablesize and dma_boundary.
1063 * PIO : SFF ATA controllers w/ only PIO support.
1064 * BMDMA : SFF ATA controllers w/ BMDMA support. sg_tablesize and
1065 * dma_boundary are set to BMDMA limits.
1066 * NCQ : SATA controllers supporting NCQ. The user must set
1067 * sg_tablesize, dma_boundary and can_queue.
1068 */
1069extern const struct ata_port_operations ata_base_port_ops;
1070extern const struct ata_port_operations sata_port_ops;
1071
1072#define ATA_BASE_SHT(drv_name) \
1073 .module = THIS_MODULE, \
1074 .name = drv_name, \
1075 .ioctl = ata_scsi_ioctl, \
1076 .queuecommand = ata_scsi_queuecmd, \
1077 .can_queue = ATA_DEF_QUEUE, \
1078 .this_id = ATA_SHT_THIS_ID, \
1079 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, \
1080 .emulated = ATA_SHT_EMULATED, \
1081 .use_clustering = ATA_SHT_USE_CLUSTERING, \
1082 .proc_name = drv_name, \
1083 .slave_configure = ata_scsi_slave_config, \
1084 .slave_destroy = ata_scsi_slave_destroy, \
1085 .bios_param = ata_std_bios_param
1086
1087#define ATA_NCQ_SHT(drv_name) \
1088 ATA_BASE_SHT(drv_name), \
1089 .change_queue_depth = ata_scsi_change_queue_depth
1090
1091/*
1092 * PMP helpers
1093 */
1094#ifdef CONFIG_SATA_PMP
1095static inline bool sata_pmp_supported(struct ata_port *ap)
1096{
1097 return ap->flags & ATA_FLAG_PMP;
1098}
1099
1100static inline bool sata_pmp_attached(struct ata_port *ap)
1101{
1102 return ap->nr_pmp_links != 0;
1103}
1104
1105static inline int ata_is_host_link(const struct ata_link *link)
1106{
1107 return link == &link->ap->link;
1108}
1109#else /* CONFIG_SATA_PMP */
1110static inline bool sata_pmp_supported(struct ata_port *ap)
1111{
1112 return false;
1113}
1114
1115static inline bool sata_pmp_attached(struct ata_port *ap)
1116{
1117 return false;
1118}
1119
1120static inline int ata_is_host_link(const struct ata_link *link)
1121{
1122 return 1;
1123}
1124#endif /* CONFIG_SATA_PMP */
1125
1126static inline int sata_srst_pmp(struct ata_link *link)
1127{
1128 if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
1129 return SATA_PMP_CTRL_PORT;
1130 return link->pmp;
1131}
1069 1132
1070/* 1133/*
1071 * printk helpers 1134 * printk helpers
@@ -1074,7 +1137,7 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
1074 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1137 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
1075 1138
1076#define ata_link_printk(link, lv, fmt, args...) do { \ 1139#define ata_link_printk(link, lv, fmt, args...) do { \
1077 if ((link)->ap->nr_pmp_links) \ 1140 if (sata_pmp_attached((link)->ap)) \
1078 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1141 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
1079 (link)->pmp , ##args); \ 1142 (link)->pmp , ##args); \
1080 else \ 1143 else \
@@ -1094,18 +1157,11 @@ extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...)
1094 __attribute__ ((format (printf, 2, 3))); 1157 __attribute__ ((format (printf, 2, 3)));
1095extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); 1158extern void ata_ehi_clear_desc(struct ata_eh_info *ehi);
1096 1159
1097static inline void ata_ehi_schedule_probe(struct ata_eh_info *ehi)
1098{
1099 ehi->flags |= ATA_EHI_RESUME_LINK;
1100 ehi->action |= ATA_EH_SOFTRESET;
1101 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
1102}
1103
1104static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) 1160static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi)
1105{ 1161{
1106 ata_ehi_schedule_probe(ehi); 1162 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
1107 ehi->flags |= ATA_EHI_HOTPLUGGED; 1163 ehi->flags |= ATA_EHI_HOTPLUGGED;
1108 ehi->action |= ATA_EH_ENABLE_LINK; 1164 ehi->action |= ATA_EH_RESET | ATA_EH_ENABLE_LINK;
1109 ehi->err_mask |= AC_ERR_ATA_BUS; 1165 ehi->err_mask |= AC_ERR_ATA_BUS;
1110} 1166}
1111 1167
@@ -1126,7 +1182,7 @@ static inline unsigned int ata_tag_valid(unsigned int tag)
1126 1182
1127static inline unsigned int ata_tag_internal(unsigned int tag) 1183static inline unsigned int ata_tag_internal(unsigned int tag)
1128{ 1184{
1129 return tag == ATA_MAX_QUEUE - 1; 1185 return tag == ATA_TAG_INTERNAL;
1130} 1186}
1131 1187
1132/* 1188/*
@@ -1167,11 +1223,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
1167/* 1223/*
1168 * link helpers 1224 * link helpers
1169 */ 1225 */
1170static inline int ata_is_host_link(const struct ata_link *link)
1171{
1172 return link == &link->ap->link;
1173}
1174
1175static inline int ata_link_max_devices(const struct ata_link *link) 1226static inline int ata_link_max_devices(const struct ata_link *link)
1176{ 1227{
1177 if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS) 1228 if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS)
@@ -1186,7 +1237,7 @@ static inline int ata_link_active(struct ata_link *link)
1186 1237
1187static inline struct ata_link *ata_port_first_link(struct ata_port *ap) 1238static inline struct ata_link *ata_port_first_link(struct ata_port *ap)
1188{ 1239{
1189 if (ap->nr_pmp_links) 1240 if (sata_pmp_attached(ap))
1190 return ap->pmp_link; 1241 return ap->pmp_link;
1191 return &ap->link; 1242 return &ap->link;
1192} 1243}
@@ -1195,8 +1246,8 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1195{ 1246{
1196 struct ata_port *ap = link->ap; 1247 struct ata_port *ap = link->ap;
1197 1248
1198 if (link == &ap->link) { 1249 if (ata_is_host_link(link)) {
1199 if (!ap->nr_pmp_links) 1250 if (!sata_pmp_attached(ap))
1200 return NULL; 1251 return NULL;
1201 return ap->pmp_link; 1252 return ap->pmp_link;
1202 } 1253 }
@@ -1222,11 +1273,6 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1222 for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \ 1273 for ((dev) = (link)->device + ata_link_max_devices(link) - 1; \
1223 (dev) >= (link)->device || ((dev) = NULL); (dev)--) 1274 (dev) >= (link)->device || ((dev) = NULL); (dev)--)
1224 1275
1225static inline u8 ata_chk_status(struct ata_port *ap)
1226{
1227 return ap->ops->check_status(ap);
1228}
1229
1230/** 1276/**
1231 * ata_ncq_enabled - Test whether NCQ is enabled 1277 * ata_ncq_enabled - Test whether NCQ is enabled
1232 * @dev: ATA device to test for 1278 * @dev: ATA device to test for
@@ -1243,74 +1289,6 @@ static inline int ata_ncq_enabled(struct ata_device *dev)
1243 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; 1289 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
1244} 1290}
1245 1291
1246/**
1247 * ata_pause - Flush writes and pause 400 nanoseconds.
1248 * @ap: Port to wait for.
1249 *
1250 * LOCKING:
1251 * Inherited from caller.
1252 */
1253
1254static inline void ata_pause(struct ata_port *ap)
1255{
1256 ata_altstatus(ap);
1257 ndelay(400);
1258}
1259
1260
1261/**
1262 * ata_busy_wait - Wait for a port status register
1263 * @ap: Port to wait for.
1264 * @bits: bits that must be clear
1265 * @max: number of 10uS waits to perform
1266 *
1267 * Waits up to max*10 microseconds for the selected bits in the port's
1268 * status register to be cleared.
1269 * Returns final value of status register.
1270 *
1271 * LOCKING:
1272 * Inherited from caller.
1273 */
1274
1275static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
1276 unsigned int max)
1277{
1278 u8 status;
1279
1280 do {
1281 udelay(10);
1282 status = ata_chk_status(ap);
1283 max--;
1284 } while (status != 0xff && (status & bits) && (max > 0));
1285
1286 return status;
1287}
1288
1289
1290/**
1291 * ata_wait_idle - Wait for a port to be idle.
1292 * @ap: Port to wait for.
1293 *
1294 * Waits up to 10ms for port's BUSY and DRQ signals to clear.
1295 * Returns final value of status register.
1296 *
1297 * LOCKING:
1298 * Inherited from caller.
1299 */
1300
1301static inline u8 ata_wait_idle(struct ata_port *ap)
1302{
1303 u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
1304
1305#ifdef ATA_DEBUG
1306 if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
1307 ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n",
1308 status);
1309#endif
1310
1311 return status;
1312}
1313
1314static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) 1292static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
1315{ 1293{
1316 qc->tf.ctl |= ATA_NIEN; 1294 qc->tf.ctl |= ATA_NIEN;
@@ -1403,4 +1381,171 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
1403 return *(struct ata_port **)&host->hostdata[0]; 1381 return *(struct ata_port **)&host->hostdata[0];
1404} 1382}
1405 1383
1384
1385/**************************************************************************
1386 * PMP - drivers/ata/libata-pmp.c
1387 */
1388#ifdef CONFIG_SATA_PMP
1389
1390extern const struct ata_port_operations sata_pmp_port_ops;
1391
1392extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
1393extern void sata_pmp_error_handler(struct ata_port *ap);
1394
1395#else /* CONFIG_SATA_PMP */
1396
1397#define sata_pmp_port_ops sata_port_ops
1398#define sata_pmp_qc_defer_cmd_switch ata_std_qc_defer
1399#define sata_pmp_error_handler ata_std_error_handler
1400
1401#endif /* CONFIG_SATA_PMP */
1402
1403
1404/**************************************************************************
1405 * SFF - drivers/ata/libata-sff.c
1406 */
1407#ifdef CONFIG_ATA_SFF
1408
1409extern const struct ata_port_operations ata_sff_port_ops;
1410extern const struct ata_port_operations ata_bmdma_port_ops;
1411
1412/* PIO only, sg_tablesize and dma_boundary limits can be removed */
1413#define ATA_PIO_SHT(drv_name) \
1414 ATA_BASE_SHT(drv_name), \
1415 .sg_tablesize = LIBATA_MAX_PRD, \
1416 .dma_boundary = ATA_DMA_BOUNDARY
1417
1418#define ATA_BMDMA_SHT(drv_name) \
1419 ATA_BASE_SHT(drv_name), \
1420 .sg_tablesize = LIBATA_MAX_PRD, \
1421 .dma_boundary = ATA_DMA_BOUNDARY
1422
1423extern void ata_sff_qc_prep(struct ata_queued_cmd *qc);
1424extern void ata_sff_dumb_qc_prep(struct ata_queued_cmd *qc);
1425extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device);
1426extern u8 ata_sff_check_status(struct ata_port *ap);
1427extern u8 ata_sff_altstatus(struct ata_port *ap);
1428extern int ata_sff_busy_sleep(struct ata_port *ap,
1429 unsigned long timeout_pat, unsigned long timeout);
1430extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline);
1431extern void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
1432extern void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
1433extern void ata_sff_exec_command(struct ata_port *ap,
1434 const struct ata_taskfile *tf);
1435extern unsigned int ata_sff_data_xfer(struct ata_device *dev,
1436 unsigned char *buf, unsigned int buflen, int rw);
1437extern unsigned int ata_sff_data_xfer_noirq(struct ata_device *dev,
1438 unsigned char *buf, unsigned int buflen, int rw);
1439extern u8 ata_sff_irq_on(struct ata_port *ap);
1440extern void ata_sff_irq_clear(struct ata_port *ap);
1441extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
1442 u8 status, int in_wq);
1443extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc);
1444extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);
1445extern unsigned int ata_sff_host_intr(struct ata_port *ap,
1446 struct ata_queued_cmd *qc);
1447extern irqreturn_t ata_sff_interrupt(int irq, void *dev_instance);
1448extern void ata_sff_freeze(struct ata_port *ap);
1449extern void ata_sff_thaw(struct ata_port *ap);
1450extern int ata_sff_prereset(struct ata_link *link, unsigned long deadline);
1451extern unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,
1452 u8 *r_err);
1453extern int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask,
1454 unsigned long deadline);
1455extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes,
1456 unsigned long deadline);
1457extern int sata_sff_hardreset(struct ata_link *link, unsigned int *class,
1458 unsigned long deadline);
1459extern void ata_sff_postreset(struct ata_link *link, unsigned int *classes);
1460extern void ata_sff_error_handler(struct ata_port *ap);
1461extern void ata_sff_post_internal_cmd(struct ata_queued_cmd *qc);
1462extern int ata_sff_port_start(struct ata_port *ap);
1463extern void ata_sff_std_ports(struct ata_ioports *ioaddr);
1464extern unsigned long ata_bmdma_mode_filter(struct ata_device *dev,
1465 unsigned long xfer_mask);
1466extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
1467extern void ata_bmdma_start(struct ata_queued_cmd *qc);
1468extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
1469extern u8 ata_bmdma_status(struct ata_port *ap);
1470extern void ata_bus_reset(struct ata_port *ap);
1471
1472#ifdef CONFIG_PCI
1473extern int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev);
1474extern int ata_pci_bmdma_init(struct ata_host *host);
1475extern int ata_pci_sff_init_host(struct ata_host *host);
1476extern int ata_pci_sff_prepare_host(struct pci_dev *pdev,
1477 const struct ata_port_info * const * ppi,
1478 struct ata_host **r_host);
1479extern int ata_pci_sff_activate_host(struct ata_host *host,
1480 irq_handler_t irq_handler,
1481 struct scsi_host_template *sht);
1482extern int ata_pci_sff_init_one(struct pci_dev *pdev,
1483 const struct ata_port_info * const * ppi,
1484 struct scsi_host_template *sht, void *host_priv);
1485#endif /* CONFIG_PCI */
1486
1487/**
1488 * ata_sff_pause - Flush writes and pause 400 nanoseconds.
1489 * @ap: Port to wait for.
1490 *
1491 * LOCKING:
1492 * Inherited from caller.
1493 */
1494static inline void ata_sff_pause(struct ata_port *ap)
1495{
1496 ata_sff_altstatus(ap);
1497 ndelay(400);
1498}
1499
1500/**
1501 * ata_sff_busy_wait - Wait for a port status register
1502 * @ap: Port to wait for.
1503 * @bits: bits that must be clear
1504 * @max: number of 10uS waits to perform
1505 *
1506 * Waits up to max*10 microseconds for the selected bits in the port's
1507 * status register to be cleared.
1508 * Returns final value of status register.
1509 *
1510 * LOCKING:
1511 * Inherited from caller.
1512 */
1513static inline u8 ata_sff_busy_wait(struct ata_port *ap, unsigned int bits,
1514 unsigned int max)
1515{
1516 u8 status;
1517
1518 do {
1519 udelay(10);
1520 status = ap->ops->sff_check_status(ap);
1521 max--;
1522 } while (status != 0xff && (status & bits) && (max > 0));
1523
1524 return status;
1525}
1526
1527/**
1528 * ata_wait_idle - Wait for a port to be idle.
1529 * @ap: Port to wait for.
1530 *
1531 * Waits up to 10ms for port's BUSY and DRQ signals to clear.
1532 * Returns final value of status register.
1533 *
1534 * LOCKING:
1535 * Inherited from caller.
1536 */
1537static inline u8 ata_wait_idle(struct ata_port *ap)
1538{
1539 u8 status = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
1540
1541#ifdef ATA_DEBUG
1542 if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
1543 ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n",
1544 status);
1545#endif
1546
1547 return status;
1548}
1549#endif /* CONFIG_ATA_SFF */
1550
1406#endif /* __LINUX_LIBATA_H__ */ 1551#endif /* __LINUX_LIBATA_H__ */
diff --git a/include/linux/list.h b/include/linux/list.h
index 75ce2cb4ff6e..08cf4f651889 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -1,8 +1,6 @@
1#ifndef _LINUX_LIST_H 1#ifndef _LINUX_LIST_H
2#define _LINUX_LIST_H 2#define _LINUX_LIST_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/stddef.h> 4#include <linux/stddef.h>
7#include <linux/poison.h> 5#include <linux/poison.h>
8#include <linux/prefetch.h> 6#include <linux/prefetch.h>
@@ -319,7 +317,16 @@ static inline int list_empty_careful(const struct list_head *head)
319 return (next == head) && (next == head->prev); 317 return (next == head) && (next == head->prev);
320} 318}
321 319
322static inline void __list_splice(struct list_head *list, 320/**
321 * list_is_singular - tests whether a list has just one entry.
322 * @head: the list to test.
323 */
324static inline int list_is_singular(const struct list_head *head)
325{
326 return !list_empty(head) && (head->next == head->prev);
327}
328
329static inline void __list_splice(const struct list_head *list,
323 struct list_head *head) 330 struct list_head *head)
324{ 331{
325 struct list_head *first = list->next; 332 struct list_head *first = list->next;
@@ -338,7 +345,8 @@ static inline void __list_splice(struct list_head *list,
338 * @list: the new list to add. 345 * @list: the new list to add.
339 * @head: the place to add it in the first list. 346 * @head: the place to add it in the first list.
340 */ 347 */
341static inline void list_splice(struct list_head *list, struct list_head *head) 348static inline void list_splice(const struct list_head *list,
349 struct list_head *head)
342{ 350{
343 if (!list_empty(list)) 351 if (!list_empty(list))
344 __list_splice(list, head); 352 __list_splice(list, head);
@@ -631,31 +639,14 @@ static inline void list_splice_init_rcu(struct list_head *list,
631 * as long as the traversal is guarded by rcu_read_lock(). 639 * as long as the traversal is guarded by rcu_read_lock().
632 */ 640 */
633#define list_for_each_rcu(pos, head) \ 641#define list_for_each_rcu(pos, head) \
634 for (pos = (head)->next; \ 642 for (pos = rcu_dereference((head)->next); \
635 prefetch(rcu_dereference(pos)->next), pos != (head); \ 643 prefetch(pos->next), pos != (head); \
636 pos = pos->next) 644 pos = rcu_dereference(pos->next))
637 645
638#define __list_for_each_rcu(pos, head) \ 646#define __list_for_each_rcu(pos, head) \
639 for (pos = (head)->next; \ 647 for (pos = rcu_dereference((head)->next); \
640 rcu_dereference(pos) != (head); \ 648 pos != (head); \
641 pos = pos->next) 649 pos = rcu_dereference(pos->next))
642
643/**
644 * list_for_each_safe_rcu
645 * @pos: the &struct list_head to use as a loop cursor.
646 * @n: another &struct list_head to use as temporary storage
647 * @head: the head for your list.
648 *
649 * Iterate over an rcu-protected list, safe against removal of list entry.
650 *
651 * This list-traversal primitive may safely run concurrently with
652 * the _rcu list-mutation primitives such as list_add_rcu()
653 * as long as the traversal is guarded by rcu_read_lock().
654 */
655#define list_for_each_safe_rcu(pos, n, head) \
656 for (pos = (head)->next; \
657 n = rcu_dereference(pos)->next, pos != (head); \
658 pos = n)
659 650
660/** 651/**
661 * list_for_each_entry_rcu - iterate over rcu list of given type 652 * list_for_each_entry_rcu - iterate over rcu list of given type
@@ -668,10 +659,9 @@ static inline void list_splice_init_rcu(struct list_head *list,
668 * as long as the traversal is guarded by rcu_read_lock(). 659 * as long as the traversal is guarded by rcu_read_lock().
669 */ 660 */
670#define list_for_each_entry_rcu(pos, head, member) \ 661#define list_for_each_entry_rcu(pos, head, member) \
671 for (pos = list_entry((head)->next, typeof(*pos), member); \ 662 for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), member); \
672 prefetch(rcu_dereference(pos)->member.next), \ 663 prefetch(pos->member.next), &pos->member != (head); \
673 &pos->member != (head); \ 664 pos = list_entry(rcu_dereference(pos->member.next), typeof(*pos), member))
674 pos = list_entry(pos->member.next, typeof(*pos), member))
675 665
676 666
677/** 667/**
@@ -686,9 +676,9 @@ static inline void list_splice_init_rcu(struct list_head *list,
686 * as long as the traversal is guarded by rcu_read_lock(). 676 * as long as the traversal is guarded by rcu_read_lock().
687 */ 677 */
688#define list_for_each_continue_rcu(pos, head) \ 678#define list_for_each_continue_rcu(pos, head) \
689 for ((pos) = (pos)->next; \ 679 for ((pos) = rcu_dereference((pos)->next); \
690 prefetch(rcu_dereference((pos))->next), (pos) != (head); \ 680 prefetch((pos)->next), (pos) != (head); \
691 (pos) = (pos)->next) 681 (pos) = rcu_dereference((pos)->next))
692 682
693/* 683/*
694 * Double linked lists with a single pointer list head. 684 * Double linked lists with a single pointer list head.
@@ -986,12 +976,9 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
986 * as long as the traversal is guarded by rcu_read_lock(). 976 * as long as the traversal is guarded by rcu_read_lock().
987 */ 977 */
988#define hlist_for_each_entry_rcu(tpos, pos, head, member) \ 978#define hlist_for_each_entry_rcu(tpos, pos, head, member) \
989 for (pos = (head)->first; \ 979 for (pos = rcu_dereference((head)->first); \
990 rcu_dereference(pos) && ({ prefetch(pos->next); 1;}) && \ 980 pos && ({ prefetch(pos->next); 1;}) && \
991 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 981 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
992 pos = pos->next) 982 pos = rcu_dereference(pos->next))
993 983
994#else
995#warning "don't include kernel headers in userspace"
996#endif /* __KERNEL__ */
997#endif 984#endif
diff --git a/include/linux/lm_interface.h b/include/linux/lm_interface.h
index 1418fdc9ac02..f274997bc283 100644
--- a/include/linux/lm_interface.h
+++ b/include/linux/lm_interface.h
@@ -21,9 +21,15 @@ typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data);
21 * modify the filesystem. The lock module shouldn't assign a journal to the FS 21 * modify the filesystem. The lock module shouldn't assign a journal to the FS
22 * mount. It shouldn't send recovery callbacks to the FS mount. If the node 22 * mount. It shouldn't send recovery callbacks to the FS mount. If the node
23 * dies or withdraws, all locks can be wiped immediately. 23 * dies or withdraws, all locks can be wiped immediately.
24 *
25 * LM_MFLAG_CONV_NODROP
26 * Do not allow the dlm to internally resolve conversion deadlocks by demoting
27 * the lock to unlocked and then reacquiring it in the requested mode. Instead,
28 * it should cancel the request and return LM_OUT_CONV_DEADLK.
24 */ 29 */
25 30
26#define LM_MFLAG_SPECTATOR 0x00000001 31#define LM_MFLAG_SPECTATOR 0x00000001
32#define LM_MFLAG_CONV_NODROP 0x00000002
27 33
28/* 34/*
29 * lm_lockstruct flags 35 * lm_lockstruct flags
@@ -110,6 +116,9 @@ typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data);
110 * 116 *
111 * LM_OUT_ASYNC 117 * LM_OUT_ASYNC
112 * The result of the request will be returned in an LM_CB_ASYNC callback. 118 * The result of the request will be returned in an LM_CB_ASYNC callback.
119 *
120 * LM_OUT_CONV_DEADLK
121 * The lock request was canceled do to a conversion deadlock.
113 */ 122 */
114 123
115#define LM_OUT_ST_MASK 0x00000003 124#define LM_OUT_ST_MASK 0x00000003
@@ -117,6 +126,7 @@ typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data);
117#define LM_OUT_CANCELED 0x00000008 126#define LM_OUT_CANCELED 0x00000008
118#define LM_OUT_ASYNC 0x00000080 127#define LM_OUT_ASYNC 0x00000080
119#define LM_OUT_ERROR 0x00000100 128#define LM_OUT_ERROR 0x00000100
129#define LM_OUT_CONV_DEADLK 0x00000200
120 130
121/* 131/*
122 * lm_callback_t types 132 * lm_callback_t types
diff --git a/include/linux/lmb.h b/include/linux/lmb.h
new file mode 100644
index 000000000000..c46c89505dac
--- /dev/null
+++ b/include/linux/lmb.h
@@ -0,0 +1,87 @@
1#ifndef _LINUX_LMB_H
2#define _LINUX_LMB_H
3#ifdef __KERNEL__
4
5/*
6 * Logical memory blocks.
7 *
8 * Copyright (C) 2001 Peter Bergner, IBM Corp.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#include <linux/init.h>
17#include <linux/mm.h>
18
19#define MAX_LMB_REGIONS 128
20
21struct lmb_property {
22 u64 base;
23 u64 size;
24};
25
26struct lmb_region {
27 unsigned long cnt;
28 u64 size;
29 struct lmb_property region[MAX_LMB_REGIONS+1];
30};
31
32struct lmb {
33 unsigned long debug;
34 u64 rmo_size;
35 struct lmb_region memory;
36 struct lmb_region reserved;
37};
38
39extern struct lmb lmb;
40
41extern void __init lmb_init(void);
42extern void __init lmb_analyze(void);
43extern long lmb_add(u64 base, u64 size);
44extern long lmb_remove(u64 base, u64 size);
45extern long __init lmb_reserve(u64 base, u64 size);
46extern u64 __init lmb_alloc_nid(u64 size, u64 align, int nid,
47 u64 (*nid_range)(u64, u64, int *));
48extern u64 __init lmb_alloc(u64 size, u64 align);
49extern u64 __init lmb_alloc_base(u64 size,
50 u64, u64 max_addr);
51extern u64 __init __lmb_alloc_base(u64 size,
52 u64 align, u64 max_addr);
53extern u64 __init lmb_phys_mem_size(void);
54extern u64 __init lmb_end_of_DRAM(void);
55extern void __init lmb_enforce_memory_limit(u64 memory_limit);
56extern int __init lmb_is_reserved(u64 addr);
57extern int lmb_find(struct lmb_property *res);
58
59extern void lmb_dump_all(void);
60
61static inline u64
62lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
63{
64 return type->region[region_nr].size;
65}
66static inline u64
67lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
68{
69 return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
70}
71static inline u64
72lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
73{
74 return type->region[region_nr].base >> PAGE_SHIFT;
75}
76static inline u64
77lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
78{
79 return lmb_start_pfn(type, region_nr) +
80 lmb_size_pages(type, region_nr);
81}
82
83#include <asm/lmb.h>
84
85#endif /* __KERNEL__ */
86
87#endif /* _LINUX_LMB_H */
diff --git a/include/linux/lock_dlm_plock.h b/include/linux/lock_dlm_plock.h
deleted file mode 100644
index fc3415113973..000000000000
--- a/include/linux/lock_dlm_plock.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * Copyright (C) 2005 Red Hat, Inc. All rights reserved.
3 *
4 * This copyrighted material is made available to anyone wishing to use,
5 * modify, copy, or redistribute it subject to the terms and conditions
6 * of the GNU General Public License v.2.
7 */
8
9#ifndef __LOCK_DLM_PLOCK_DOT_H__
10#define __LOCK_DLM_PLOCK_DOT_H__
11
12#define GDLM_PLOCK_MISC_NAME "lock_dlm_plock"
13
14#define GDLM_PLOCK_VERSION_MAJOR 1
15#define GDLM_PLOCK_VERSION_MINOR 1
16#define GDLM_PLOCK_VERSION_PATCH 0
17
18enum {
19 GDLM_PLOCK_OP_LOCK = 1,
20 GDLM_PLOCK_OP_UNLOCK,
21 GDLM_PLOCK_OP_GET,
22};
23
24struct gdlm_plock_info {
25 __u32 version[3];
26 __u8 optype;
27 __u8 ex;
28 __u8 wait;
29 __u8 pad;
30 __u32 pid;
31 __s32 nodeid;
32 __s32 rv;
33 __u32 fsid;
34 __u64 number;
35 __u64 start;
36 __u64 end;
37 __u64 owner;
38};
39
40#endif
41
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 4babb2a129ac..102d928f7206 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -91,6 +91,7 @@ struct nlm_wait;
91 */ 91 */
92#define NLMCLNT_OHSIZE ((__NEW_UTS_LEN) + 10u) 92#define NLMCLNT_OHSIZE ((__NEW_UTS_LEN) + 10u)
93struct nlm_rqst { 93struct nlm_rqst {
94 atomic_t a_count;
94 unsigned int a_flags; /* initial RPC task flags */ 95 unsigned int a_flags; /* initial RPC task flags */
95 struct nlm_host * a_host; /* host handle */ 96 struct nlm_host * a_host; /* host handle */
96 struct nlm_args a_args; /* arguments */ 97 struct nlm_args a_args; /* arguments */
@@ -173,8 +174,10 @@ void nlmclnt_next_cookie(struct nlm_cookie *);
173/* 174/*
174 * Host cache 175 * Host cache
175 */ 176 */
176struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *, int, int, 177struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *sin,
177 const char *, unsigned int); 178 int proto, u32 version,
179 const char *hostname,
180 unsigned int hostname_len);
178struct nlm_host *nlmsvc_lookup_host(struct svc_rqst *, const char *, 181struct nlm_host *nlmsvc_lookup_host(struct svc_rqst *, const char *,
179 unsigned int); 182 unsigned int);
180struct rpc_clnt * nlm_bind_host(struct nlm_host *); 183struct rpc_clnt * nlm_bind_host(struct nlm_host *);
@@ -191,7 +194,7 @@ void nsm_release(struct nsm_handle *);
191 * This is used in garbage collection and resource reclaim 194 * This is used in garbage collection and resource reclaim
192 * A return value != 0 means destroy the lock/block/share 195 * A return value != 0 means destroy the lock/block/share
193 */ 196 */
194typedef int (*nlm_host_match_fn_t)(struct nlm_host *cur, struct nlm_host *ref); 197typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref);
195 198
196/* 199/*
197 * Server-side lock handling 200 * Server-side lock handling
@@ -217,8 +220,13 @@ void nlmsvc_mark_resources(void);
217void nlmsvc_free_host_resources(struct nlm_host *); 220void nlmsvc_free_host_resources(struct nlm_host *);
218void nlmsvc_invalidate_all(void); 221void nlmsvc_invalidate_all(void);
219 222
220static __inline__ struct inode * 223/*
221nlmsvc_file_inode(struct nlm_file *file) 224 * Cluster failover support
225 */
226int nlmsvc_unlock_all_by_sb(struct super_block *sb);
227int nlmsvc_unlock_all_by_ip(__be32 server_addr);
228
229static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
222{ 230{
223 return file->f_file->f_path.dentry->d_inode; 231 return file->f_file->f_path.dentry->d_inode;
224} 232}
@@ -226,8 +234,8 @@ nlmsvc_file_inode(struct nlm_file *file)
226/* 234/*
227 * Compare two host addresses (needs modifying for ipv6) 235 * Compare two host addresses (needs modifying for ipv6)
228 */ 236 */
229static __inline__ int 237static inline int nlm_cmp_addr(const struct sockaddr_in *sin1,
230nlm_cmp_addr(const struct sockaddr_in *sin1, const struct sockaddr_in *sin2) 238 const struct sockaddr_in *sin2)
231{ 239{
232 return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; 240 return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
233} 241}
@@ -236,8 +244,8 @@ nlm_cmp_addr(const struct sockaddr_in *sin1, const struct sockaddr_in *sin2)
236 * Compare two NLM locks. 244 * Compare two NLM locks.
237 * When the second lock is of type F_UNLCK, this acts like a wildcard. 245 * When the second lock is of type F_UNLCK, this acts like a wildcard.
238 */ 246 */
239static __inline__ int 247static inline int nlm_compare_locks(const struct file_lock *fl1,
240nlm_compare_locks(const struct file_lock *fl1, const struct file_lock *fl2) 248 const struct file_lock *fl2)
241{ 249{
242 return fl1->fl_pid == fl2->fl_pid 250 return fl1->fl_pid == fl2->fl_pid
243 && fl1->fl_owner == fl2->fl_owner 251 && fl1->fl_owner == fl2->fl_owner
diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h
index 22a645828f26..5a5448bdb17d 100644
--- a/include/linux/lockd/sm_inter.h
+++ b/include/linux/lockd/sm_inter.h
@@ -19,6 +19,7 @@
19#define SM_NOTIFY 6 19#define SM_NOTIFY 6
20 20
21#define SM_MAXSTRLEN 1024 21#define SM_MAXSTRLEN 1024
22#define SM_PRIV_SIZE 16
22 23
23/* 24/*
24 * Arguments for all calls to statd 25 * Arguments for all calls to statd
diff --git a/include/linux/math64.h b/include/linux/math64.h
new file mode 100644
index 000000000000..c1a5f81501ff
--- /dev/null
+++ b/include/linux/math64.h
@@ -0,0 +1,84 @@
1#ifndef _LINUX_MATH64_H
2#define _LINUX_MATH64_H
3
4#include <linux/types.h>
5#include <asm/div64.h>
6
7#if BITS_PER_LONG == 64
8
9/**
10 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
11 *
12 * This is commonly provided by 32bit archs to provide an optimized 64bit
13 * divide.
14 */
15static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16{
17 *remainder = dividend % divisor;
18 return dividend / divisor;
19}
20
21/**
22 * div_s64_rem - signed 64bit divide with 32bit divisor with remainder
23 */
24static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
25{
26 *remainder = dividend % divisor;
27 return dividend / divisor;
28}
29
30/**
31 * div64_u64 - unsigned 64bit divide with 64bit divisor
32 */
33static inline u64 div64_u64(u64 dividend, u64 divisor)
34{
35 return dividend / divisor;
36}
37
38#elif BITS_PER_LONG == 32
39
40#ifndef div_u64_rem
41static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
42{
43 *remainder = do_div(dividend, divisor);
44 return dividend;
45}
46#endif
47
48#ifndef div_s64_rem
49extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
50#endif
51
52#ifndef div64_u64
53extern u64 div64_u64(u64 dividend, u64 divisor);
54#endif
55
56#endif /* BITS_PER_LONG */
57
58/**
59 * div_u64 - unsigned 64bit divide with 32bit divisor
60 *
61 * This is the most common 64bit divide and should be used if possible,
62 * as many 32bit archs can optimize this variant better than a full 64bit
63 * divide.
64 */
65#ifndef div_u64
66static inline u64 div_u64(u64 dividend, u32 divisor)
67{
68 u32 remainder;
69 return div_u64_rem(dividend, divisor, &remainder);
70}
71#endif
72
73/**
74 * div_s64 - signed 64bit divide with 32bit divisor
75 */
76#ifndef div_s64
77static inline s64 div_s64(s64 dividend, s32 divisor)
78{
79 s32 remainder;
80 return div_s64_rem(dividend, divisor, &remainder);
81}
82#endif
83
84#endif /* _LINUX_MATH64_H */
diff --git a/include/linux/mbus.h b/include/linux/mbus.h
new file mode 100644
index 000000000000..c11ff2932549
--- /dev/null
+++ b/include/linux/mbus.h
@@ -0,0 +1,36 @@
1/*
2 * Marvell MBUS common definitions.
3 *
4 * Copyright (C) 2008 Marvell Semiconductor
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 __LINUX_MBUS_H
12#define __LINUX_MBUS_H
13
14struct mbus_dram_target_info
15{
16 /*
17 * The 4-bit MBUS target ID of the DRAM controller.
18 */
19 u8 mbus_dram_target_id;
20
21 /*
22 * The base address, size, and MBUS attribute ID for each
23 * of the possible DRAM chip selects. Peripherals are
24 * required to support at least 4 decode windows.
25 */
26 int num_cs;
27 struct mbus_dram_window {
28 u8 cs_index;
29 u8 mbus_attr;
30 u32 base;
31 u32 size;
32 } cs[4];
33};
34
35
36#endif
diff --git a/include/linux/mca-legacy.h b/include/linux/mca-legacy.h
index f2bb770e530a..7a3aea845902 100644
--- a/include/linux/mca-legacy.h
+++ b/include/linux/mca-legacy.h
@@ -34,7 +34,6 @@
34extern int mca_find_adapter(int id, int start); 34extern int mca_find_adapter(int id, int start);
35extern int mca_find_unused_adapter(int id, int start); 35extern int mca_find_unused_adapter(int id, int start);
36 36
37extern int mca_is_adapter_used(int slot);
38extern int mca_mark_as_used(int slot); 37extern int mca_mark_as_used(int slot);
39extern void mca_mark_as_unused(int slot); 38extern void mca_mark_as_unused(int slot);
40 39
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 8b1c4295848b..e6608776bc96 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -27,9 +27,6 @@ struct mm_struct;
27 27
28#ifdef CONFIG_CGROUP_MEM_RES_CTLR 28#ifdef CONFIG_CGROUP_MEM_RES_CTLR
29 29
30extern void mm_init_cgroup(struct mm_struct *mm, struct task_struct *p);
31extern void mm_free_cgroup(struct mm_struct *mm);
32
33#define page_reset_bad_cgroup(page) ((page)->page_cgroup = 0) 30#define page_reset_bad_cgroup(page) ((page)->page_cgroup = 0)
34 31
35extern struct page_cgroup *page_get_page_cgroup(struct page *page); 32extern struct page_cgroup *page_get_page_cgroup(struct page *page);
@@ -48,8 +45,10 @@ extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
48extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask); 45extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask);
49int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); 46int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
50 47
48extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
49
51#define mm_match_cgroup(mm, cgroup) \ 50#define mm_match_cgroup(mm, cgroup) \
52 ((cgroup) == rcu_dereference((mm)->mem_cgroup)) 51 ((cgroup) == mem_cgroup_from_task((mm)->owner))
53 52
54extern int mem_cgroup_prepare_migration(struct page *page); 53extern int mem_cgroup_prepare_migration(struct page *page);
55extern void mem_cgroup_end_migration(struct page *page); 54extern void mem_cgroup_end_migration(struct page *page);
@@ -73,15 +72,6 @@ extern long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem,
73 struct zone *zone, int priority); 72 struct zone *zone, int priority);
74 73
75#else /* CONFIG_CGROUP_MEM_RES_CTLR */ 74#else /* CONFIG_CGROUP_MEM_RES_CTLR */
76static inline void mm_init_cgroup(struct mm_struct *mm,
77 struct task_struct *p)
78{
79}
80
81static inline void mm_free_cgroup(struct mm_struct *mm)
82{
83}
84
85static inline void page_reset_bad_cgroup(struct page *page) 75static inline void page_reset_bad_cgroup(struct page *page)
86{ 76{
87} 77}
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 33f0ff0cf634..2f5f8a5ef2a0 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -18,8 +18,7 @@
18#include <linux/sysdev.h> 18#include <linux/sysdev.h>
19#include <linux/node.h> 19#include <linux/node.h>
20#include <linux/compiler.h> 20#include <linux/compiler.h>
21 21#include <linux/mutex.h>
22#include <asm/semaphore.h>
23 22
24struct memory_block { 23struct memory_block {
25 unsigned long phys_index; 24 unsigned long phys_index;
@@ -30,7 +29,7 @@ struct memory_block {
30 * created long after the critical areas during 29 * created long after the critical areas during
31 * initialization. 30 * initialization.
32 */ 31 */
33 struct semaphore state_sem; 32 struct mutex state_mutex;
34 int phys_device; /* to which fru does this belong? */ 33 int phys_device; /* to which fru does this belong? */
35 void *hw; /* optional pointer to fw/hw data */ 34 void *hw; /* optional pointer to fw/hw data */
36 int (*phys_callback)(struct memory_block *); 35 int (*phys_callback)(struct memory_block *);
@@ -54,6 +53,13 @@ struct memory_notify {
54struct notifier_block; 53struct notifier_block;
55struct mem_section; 54struct mem_section;
56 55
56/*
57 * Priorities for the hotplug memory callback routines (stored in decreasing
58 * order in the callback chain)
59 */
60#define SLAB_CALLBACK_PRI 1
61#define IPC_CALLBACK_PRI 10
62
57#ifndef CONFIG_MEMORY_HOTPLUG_SPARSE 63#ifndef CONFIG_MEMORY_HOTPLUG_SPARSE
58static inline int memory_dev_init(void) 64static inline int memory_dev_init(void)
59{ 65{
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 8fee7a45736b..73e358612eaf 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -8,8 +8,18 @@
8struct page; 8struct page;
9struct zone; 9struct zone;
10struct pglist_data; 10struct pglist_data;
11struct mem_section;
11 12
12#ifdef CONFIG_MEMORY_HOTPLUG 13#ifdef CONFIG_MEMORY_HOTPLUG
14
15/*
16 * Magic number for free bootmem.
17 * The normal smallest mapcount is -1. Here is smaller value than it.
18 */
19#define SECTION_INFO 0xfffffffe
20#define MIX_INFO 0xfffffffd
21#define NODE_INFO 0xfffffffc
22
13/* 23/*
14 * pgdat resizing functions 24 * pgdat resizing functions
15 */ 25 */
@@ -64,9 +74,11 @@ extern int offline_pages(unsigned long, unsigned long, unsigned long);
64/* reasonably generic interface to expand the physical pages in a zone */ 74/* reasonably generic interface to expand the physical pages in a zone */
65extern int __add_pages(struct zone *zone, unsigned long start_pfn, 75extern int __add_pages(struct zone *zone, unsigned long start_pfn,
66 unsigned long nr_pages); 76 unsigned long nr_pages);
77extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
78 unsigned long nr_pages);
67 79
68/* 80/*
69 * Walk thorugh all memory which is registered as resource. 81 * Walk through all memory which is registered as resource.
70 * arg is (start_pfn, nr_pages, private_arg_pointer) 82 * arg is (start_pfn, nr_pages, private_arg_pointer)
71 */ 83 */
72extern int walk_memory_resource(unsigned long start_pfn, 84extern int walk_memory_resource(unsigned long start_pfn,
@@ -142,6 +154,18 @@ static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
142#endif /* CONFIG_NUMA */ 154#endif /* CONFIG_NUMA */
143#endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */ 155#endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */
144 156
157#ifdef CONFIG_SPARSEMEM_VMEMMAP
158static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
159{
160}
161static inline void put_page_bootmem(struct page *page)
162{
163}
164#else
165extern void register_page_bootmem_info_node(struct pglist_data *pgdat);
166extern void put_page_bootmem(struct page *page);
167#endif
168
145#else /* ! CONFIG_MEMORY_HOTPLUG */ 169#else /* ! CONFIG_MEMORY_HOTPLUG */
146/* 170/*
147 * Stub functions for when hotplug is off 171 * Stub functions for when hotplug is off
@@ -169,6 +193,10 @@ static inline int mhp_notimplemented(const char *func)
169 return -ENOSYS; 193 return -ENOSYS;
170} 194}
171 195
196static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
197{
198}
199
172#endif /* ! CONFIG_MEMORY_HOTPLUG */ 200#endif /* ! CONFIG_MEMORY_HOTPLUG */
173 201
174extern int add_memory(int nid, u64 start, u64 size); 202extern int add_memory(int nid, u64 start, u64 size);
@@ -176,5 +204,8 @@ extern int arch_add_memory(int nid, u64 start, u64 size);
176extern int remove_memory(u64 start, u64 size); 204extern int remove_memory(u64 start, u64 size);
177extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn, 205extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
178 int nr_pages); 206 int nr_pages);
207extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms);
208extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map,
209 unsigned long pnum);
179 210
180#endif /* __LINUX_MEMORY_HOTPLUG_H */ 211#endif /* __LINUX_MEMORY_HOTPLUG_H */
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 59c4865bc85f..3a39570b81b8 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -8,15 +8,32 @@
8 * Copyright 2003,2004 Andi Kleen SuSE Labs 8 * Copyright 2003,2004 Andi Kleen SuSE Labs
9 */ 9 */
10 10
11/*
12 * Both the MPOL_* mempolicy mode and the MPOL_F_* optional mode flags are
13 * passed by the user to either set_mempolicy() or mbind() in an 'int' actual.
14 * The MPOL_MODE_FLAGS macro determines the legal set of optional mode flags.
15 */
16
11/* Policies */ 17/* Policies */
12#define MPOL_DEFAULT 0 18enum {
13#define MPOL_PREFERRED 1 19 MPOL_DEFAULT,
14#define MPOL_BIND 2 20 MPOL_PREFERRED,
15#define MPOL_INTERLEAVE 3 21 MPOL_BIND,
22 MPOL_INTERLEAVE,
23 MPOL_MAX, /* always last member of enum */
24};
16 25
17#define MPOL_MAX MPOL_INTERLEAVE 26/* Flags for set_mempolicy */
27#define MPOL_F_STATIC_NODES (1 << 15)
28#define MPOL_F_RELATIVE_NODES (1 << 14)
18 29
19/* Flags for get_mem_policy */ 30/*
31 * MPOL_MODE_FLAGS is the union of all possible optional mode flags passed to
32 * either set_mempolicy() or mbind().
33 */
34#define MPOL_MODE_FLAGS (MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES)
35
36/* Flags for get_mempolicy */
20#define MPOL_F_NODE (1<<0) /* return next IL mode instead of node mask */ 37#define MPOL_F_NODE (1<<0) /* return next IL mode instead of node mask */
21#define MPOL_F_ADDR (1<<1) /* look up vma using address */ 38#define MPOL_F_ADDR (1<<1) /* look up vma using address */
22#define MPOL_F_MEMS_ALLOWED (1<<2) /* return allowed memories */ 39#define MPOL_F_MEMS_ALLOWED (1<<2) /* return allowed memories */
@@ -27,6 +44,14 @@
27#define MPOL_MF_MOVE_ALL (1<<2) /* Move every page to conform to mapping */ 44#define MPOL_MF_MOVE_ALL (1<<2) /* Move every page to conform to mapping */
28#define MPOL_MF_INTERNAL (1<<3) /* Internal flags start here */ 45#define MPOL_MF_INTERNAL (1<<3) /* Internal flags start here */
29 46
47/*
48 * Internal flags that share the struct mempolicy flags word with
49 * "mode flags". These flags are allocated from bit 0 up, as they
50 * are never OR'ed into the mode in mempolicy API arguments.
51 */
52#define MPOL_F_SHARED (1 << 0) /* identify shared policies */
53#define MPOL_F_LOCAL (1 << 1) /* preferred local allocation */
54
30#ifdef __KERNEL__ 55#ifdef __KERNEL__
31 56
32#include <linux/mmzone.h> 57#include <linux/mmzone.h>
@@ -35,7 +60,6 @@
35#include <linux/spinlock.h> 60#include <linux/spinlock.h>
36#include <linux/nodemask.h> 61#include <linux/nodemask.h>
37 62
38struct vm_area_struct;
39struct mm_struct; 63struct mm_struct;
40 64
41#ifdef CONFIG_NUMA 65#ifdef CONFIG_NUMA
@@ -54,22 +78,27 @@ struct mm_struct;
54 * mmap_sem. 78 * mmap_sem.
55 * 79 *
56 * Freeing policy: 80 * Freeing policy:
57 * When policy is MPOL_BIND v.zonelist is kmalloc'ed and must be kfree'd. 81 * Mempolicy objects are reference counted. A mempolicy will be freed when
58 * All other policies don't have any external state. mpol_free() handles this. 82 * mpol_put() decrements the reference count to zero.
59 * 83 *
60 * Copying policy objects: 84 * Duplicating policy objects:
61 * For MPOL_BIND the zonelist must be always duplicated. mpol_clone() does this. 85 * mpol_dup() allocates a new mempolicy and copies the specified mempolicy
86 * to the new storage. The reference count of the new object is initialized
87 * to 1, representing the caller of mpol_dup().
62 */ 88 */
63struct mempolicy { 89struct mempolicy {
64 atomic_t refcnt; 90 atomic_t refcnt;
65 short policy; /* See MPOL_* above */ 91 unsigned short mode; /* See MPOL_* above */
92 unsigned short flags; /* See set_mempolicy() MPOL_F_* above */
66 union { 93 union {
67 struct zonelist *zonelist; /* bind */
68 short preferred_node; /* preferred */ 94 short preferred_node; /* preferred */
69 nodemask_t nodes; /* interleave */ 95 nodemask_t nodes; /* interleave/bind */
70 /* undefined for default */ 96 /* undefined for default */
71 } v; 97 } v;
72 nodemask_t cpuset_mems_allowed; /* mempolicy relative to these nodes */ 98 union {
99 nodemask_t cpuset_mems_allowed; /* relative to these nodes */
100 nodemask_t user_nodemask; /* nodemask passed by user */
101 } w;
73}; 102};
74 103
75/* 104/*
@@ -77,18 +106,43 @@ struct mempolicy {
77 * The default fast path of a NULL MPOL_DEFAULT policy is always inlined. 106 * The default fast path of a NULL MPOL_DEFAULT policy is always inlined.
78 */ 107 */
79 108
80extern void __mpol_free(struct mempolicy *pol); 109extern void __mpol_put(struct mempolicy *pol);
81static inline void mpol_free(struct mempolicy *pol) 110static inline void mpol_put(struct mempolicy *pol)
82{ 111{
83 if (pol) 112 if (pol)
84 __mpol_free(pol); 113 __mpol_put(pol);
85} 114}
86 115
87extern struct mempolicy *__mpol_copy(struct mempolicy *pol); 116/*
88static inline struct mempolicy *mpol_copy(struct mempolicy *pol) 117 * Does mempolicy pol need explicit unref after use?
118 * Currently only needed for shared policies.
119 */
120static inline int mpol_needs_cond_ref(struct mempolicy *pol)
121{
122 return (pol && (pol->flags & MPOL_F_SHARED));
123}
124
125static inline void mpol_cond_put(struct mempolicy *pol)
126{
127 if (mpol_needs_cond_ref(pol))
128 __mpol_put(pol);
129}
130
131extern struct mempolicy *__mpol_cond_copy(struct mempolicy *tompol,
132 struct mempolicy *frompol);
133static inline struct mempolicy *mpol_cond_copy(struct mempolicy *tompol,
134 struct mempolicy *frompol)
135{
136 if (!frompol)
137 return frompol;
138 return __mpol_cond_copy(tompol, frompol);
139}
140
141extern struct mempolicy *__mpol_dup(struct mempolicy *pol);
142static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
89{ 143{
90 if (pol) 144 if (pol)
91 pol = __mpol_copy(pol); 145 pol = __mpol_dup(pol);
92 return pol; 146 return pol;
93} 147}
94 148
@@ -108,11 +162,6 @@ static inline int mpol_equal(struct mempolicy *a, struct mempolicy *b)
108 return 1; 162 return 1;
109 return __mpol_equal(a, b); 163 return __mpol_equal(a, b);
110} 164}
111#define vma_mpol_equal(a,b) mpol_equal(vma_policy(a), vma_policy(b))
112
113/* Could later add inheritance of the process policy here. */
114
115#define mpol_set_vma_default(vma) ((vma)->vm_policy = NULL)
116 165
117/* 166/*
118 * Tree of shared policies for a shared memory region. 167 * Tree of shared policies for a shared memory region.
@@ -133,8 +182,7 @@ struct shared_policy {
133 spinlock_t lock; 182 spinlock_t lock;
134}; 183};
135 184
136void mpol_shared_policy_init(struct shared_policy *info, int policy, 185void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol);
137 nodemask_t *nodes);
138int mpol_set_shared_policy(struct shared_policy *info, 186int mpol_set_shared_policy(struct shared_policy *info,
139 struct vm_area_struct *vma, 187 struct vm_area_struct *vma,
140 struct mempolicy *new); 188 struct mempolicy *new);
@@ -149,9 +197,9 @@ extern void mpol_rebind_task(struct task_struct *tsk,
149extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new); 197extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new);
150extern void mpol_fix_fork_child_flag(struct task_struct *p); 198extern void mpol_fix_fork_child_flag(struct task_struct *p);
151 199
152extern struct mempolicy default_policy;
153extern struct zonelist *huge_zonelist(struct vm_area_struct *vma, 200extern struct zonelist *huge_zonelist(struct vm_area_struct *vma,
154 unsigned long addr, gfp_t gfp_flags, struct mempolicy **mpol); 201 unsigned long addr, gfp_t gfp_flags,
202 struct mempolicy **mpol, nodemask_t **nodemask);
155extern unsigned slab_node(struct mempolicy *policy); 203extern unsigned slab_node(struct mempolicy *policy);
156 204
157extern enum zone_type policy_zone; 205extern enum zone_type policy_zone;
@@ -165,6 +213,13 @@ static inline void check_highest_zone(enum zone_type k)
165int do_migrate_pages(struct mm_struct *mm, 213int do_migrate_pages(struct mm_struct *mm,
166 const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags); 214 const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags);
167 215
216
217#ifdef CONFIG_TMPFS
218extern int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context);
219
220extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,
221 int no_context);
222#endif
168#else 223#else
169 224
170struct mempolicy {}; 225struct mempolicy {};
@@ -173,19 +228,26 @@ static inline int mpol_equal(struct mempolicy *a, struct mempolicy *b)
173{ 228{
174 return 1; 229 return 1;
175} 230}
176#define vma_mpol_equal(a,b) 1
177 231
178#define mpol_set_vma_default(vma) do {} while(0) 232static inline void mpol_put(struct mempolicy *p)
233{
234}
235
236static inline void mpol_cond_put(struct mempolicy *pol)
237{
238}
179 239
180static inline void mpol_free(struct mempolicy *p) 240static inline struct mempolicy *mpol_cond_copy(struct mempolicy *to,
241 struct mempolicy *from)
181{ 242{
243 return from;
182} 244}
183 245
184static inline void mpol_get(struct mempolicy *pol) 246static inline void mpol_get(struct mempolicy *pol)
185{ 247{
186} 248}
187 249
188static inline struct mempolicy *mpol_copy(struct mempolicy *old) 250static inline struct mempolicy *mpol_dup(struct mempolicy *old)
189{ 251{
190 return NULL; 252 return NULL;
191} 253}
@@ -199,8 +261,8 @@ static inline int mpol_set_shared_policy(struct shared_policy *info,
199 return -EINVAL; 261 return -EINVAL;
200} 262}
201 263
202static inline void mpol_shared_policy_init(struct shared_policy *info, 264static inline void mpol_shared_policy_init(struct shared_policy *sp,
203 int policy, nodemask_t *nodes) 265 struct mempolicy *mpol)
204{ 266{
205} 267}
206 268
@@ -239,9 +301,12 @@ static inline void mpol_fix_fork_child_flag(struct task_struct *p)
239} 301}
240 302
241static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma, 303static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma,
242 unsigned long addr, gfp_t gfp_flags, struct mempolicy **mpol) 304 unsigned long addr, gfp_t gfp_flags,
305 struct mempolicy **mpol, nodemask_t **nodemask)
243{ 306{
244 return NODE_DATA(0)->node_zonelists + gfp_zone(gfp_flags); 307 *mpol = NULL;
308 *nodemask = NULL;
309 return node_zonelist(0, gfp_flags);
245} 310}
246 311
247static inline int do_migrate_pages(struct mm_struct *mm, 312static inline int do_migrate_pages(struct mm_struct *mm,
@@ -254,6 +319,21 @@ static inline int do_migrate_pages(struct mm_struct *mm,
254static inline void check_highest_zone(int k) 319static inline void check_highest_zone(int k)
255{ 320{
256} 321}
322
323#ifdef CONFIG_TMPFS
324static inline int mpol_parse_str(char *str, struct mempolicy **mpol,
325 int no_context)
326{
327 return 1; /* error */
328}
329
330static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,
331 int no_context)
332{
333 return 0;
334}
335#endif
336
257#endif /* CONFIG_NUMA */ 337#endif /* CONFIG_NUMA */
258#endif /* __KERNEL__ */ 338#endif /* __KERNEL__ */
259 339
diff --git a/include/linux/memstick.h b/include/linux/memstick.h
index 3e686ec6a967..37a5cdb03918 100644
--- a/include/linux/memstick.h
+++ b/include/linux/memstick.h
@@ -276,7 +276,7 @@ struct memstick_host {
276#define MEMSTICK_CAP_PAR8 4 276#define MEMSTICK_CAP_PAR8 4
277 277
278 struct work_struct media_checker; 278 struct work_struct media_checker;
279 struct class_device cdev; 279 struct device dev;
280 280
281 struct memstick_dev *card; 281 struct memstick_dev *card;
282 unsigned int retries; 282 unsigned int retries;
diff --git a/include/linux/meye.h b/include/linux/meye.h
index 39fd9c8ddd4b..12010ace1f04 100644
--- a/include/linux/meye.h
+++ b/include/linux/meye.h
@@ -58,7 +58,7 @@ struct meye_params {
58 58
59/* V4L2 private controls */ 59/* V4L2 private controls */
60#define V4L2_CID_AGC V4L2_CID_PRIVATE_BASE 60#define V4L2_CID_AGC V4L2_CID_PRIVATE_BASE
61#define V4L2_CID_SHARPNESS (V4L2_CID_PRIVATE_BASE + 1) 61#define V4L2_CID_MEYE_SHARPNESS (V4L2_CID_PRIVATE_BASE + 1)
62#define V4L2_CID_PICTURE (V4L2_CID_PRIVATE_BASE + 2) 62#define V4L2_CID_PICTURE (V4L2_CID_PRIVATE_BASE + 2)
63#define V4L2_CID_JPEGQUAL (V4L2_CID_PRIVATE_BASE + 3) 63#define V4L2_CID_JPEGQUAL (V4L2_CID_PRIVATE_BASE + 3)
64#define V4L2_CID_FRAMERATE (V4L2_CID_PRIVATE_BASE + 4) 64#define V4L2_CID_FRAMERATE (V4L2_CID_PRIVATE_BASE + 4)
diff --git a/include/linux/mfd/htc-egpio.h b/include/linux/mfd/htc-egpio.h
new file mode 100644
index 000000000000..b4201c971367
--- /dev/null
+++ b/include/linux/mfd/htc-egpio.h
@@ -0,0 +1,57 @@
1/*
2 * HTC simple EGPIO irq and gpio extender
3 */
4
5#ifndef __HTC_EGPIO_H__
6#define __HTC_EGPIO_H__
7
8#include <linux/gpio.h>
9
10/* Descriptive values for all-in or all-out htc_egpio_chip descriptors. */
11#define HTC_EGPIO_OUTPUT (~0)
12#define HTC_EGPIO_INPUT 0
13
14/**
15 * struct htc_egpio_chip - descriptor to create gpio_chip for register range
16 * @reg_start: index of first register
17 * @gpio_base: gpio number of first pin in this register range
18 * @num_gpios: number of gpios in this register range, max BITS_PER_LONG
19 * (number of registers = DIV_ROUND_UP(num_gpios, reg_width))
20 * @direction: bitfield, '0' = input, '1' = output,
21 */
22struct htc_egpio_chip {
23 int reg_start;
24 int gpio_base;
25 int num_gpios;
26 unsigned long direction;
27 unsigned long initial_values;
28};
29
30/**
31 * struct htc_egpio_platform_data - description provided by the arch
32 * @irq_base: beginning of available IRQs (eg, IRQ_BOARD_START)
33 * @num_irqs: number of irqs
34 * @reg_width: number of bits per register, either 8 or 16 bit
35 * @bus_width: alignment of the registers, either 16 or 32 bit
36 * @invert_acks: set if chip requires writing '0' to ack an irq, instead of '1'
37 * @ack_register: location of the irq/ack register
38 * @chip: pointer to array of htc_egpio_chip descriptors
39 * @num_chips: number of egpio chip descriptors
40 */
41struct htc_egpio_platform_data {
42 int bus_width;
43 int reg_width;
44
45 int irq_base;
46 int num_irqs;
47 int invert_acks;
48 int ack_register;
49
50 struct htc_egpio_chip *chip;
51 int num_chips;
52};
53
54/* Determine the wakeup irq, to be called during early resume */
55extern int htc_egpio_get_wakeup_irq(struct device *dev);
56
57#endif
diff --git a/include/linux/mfd/htc-pasic3.h b/include/linux/mfd/htc-pasic3.h
new file mode 100644
index 000000000000..b4294f12c4f8
--- /dev/null
+++ b/include/linux/mfd/htc-pasic3.h
@@ -0,0 +1,55 @@
1/*
2 * HTC PASIC3 driver - LEDs and DS1WM
3 *
4 * Copyright (c) 2007 Philipp Zabel <philipp.zabel@gmail.com>
5 *
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 for
8 * more details.
9 *
10 */
11
12#ifndef __PASIC3_H
13#define __PASIC3_H
14
15#include <linux/platform_device.h>
16#include <linux/leds.h>
17
18extern void pasic3_write_register(struct device *dev, u32 reg, u8 val);
19extern u8 pasic3_read_register(struct device *dev, u32 reg);
20
21/*
22 * mask for registers 0x20,0x21,0x22
23 */
24#define PASIC3_MASK_LED0 0x04
25#define PASIC3_MASK_LED1 0x08
26#define PASIC3_MASK_LED2 0x40
27
28/*
29 * bits in register 0x06
30 */
31#define PASIC3_BIT2_LED0 0x08
32#define PASIC3_BIT2_LED1 0x10
33#define PASIC3_BIT2_LED2 0x20
34
35struct pasic3_led {
36 struct led_classdev led;
37 unsigned int hw_num;
38 unsigned int bit2;
39 unsigned int mask;
40 struct pasic3_leds_machinfo *pdata;
41};
42
43struct pasic3_leds_machinfo {
44 unsigned int num_leds;
45 unsigned int power_gpio;
46 struct pasic3_led *leds;
47};
48
49struct pasic3_platform_data {
50 struct pasic3_leds_machinfo *led_pdata;
51 unsigned int bus_shift;
52 unsigned int clock_rate;
53};
54
55#endif
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index 24b30b9b4f8a..26433ec520b3 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -43,15 +43,7 @@ struct miscdevice {
43}; 43};
44 44
45extern int misc_register(struct miscdevice * misc); 45extern int misc_register(struct miscdevice * misc);
46extern int __misc_deregister(struct miscdevice *misc, bool suspended); 46extern int misc_deregister(struct miscdevice *misc);
47static inline int misc_deregister(struct miscdevice *misc)
48{
49 return __misc_deregister(misc, false);
50}
51static inline int misc_deregister_suspended(struct miscdevice *misc)
52{
53 return __misc_deregister(misc, true);
54}
55 47
56#define MODULE_ALIAS_MISCDEV(minor) \ 48#define MODULE_ALIAS_MISCDEV(minor) \
57 MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \ 49 MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \
diff --git a/include/linux/mlx4/cmd.h b/include/linux/mlx4/cmd.h
index 7d1eaa97de13..77323a72dd3c 100644
--- a/include/linux/mlx4/cmd.h
+++ b/include/linux/mlx4/cmd.h
@@ -81,7 +81,7 @@ enum {
81 MLX4_CMD_SW2HW_CQ = 0x16, 81 MLX4_CMD_SW2HW_CQ = 0x16,
82 MLX4_CMD_HW2SW_CQ = 0x17, 82 MLX4_CMD_HW2SW_CQ = 0x17,
83 MLX4_CMD_QUERY_CQ = 0x18, 83 MLX4_CMD_QUERY_CQ = 0x18,
84 MLX4_CMD_RESIZE_CQ = 0x2c, 84 MLX4_CMD_MODIFY_CQ = 0x2c,
85 85
86 /* SRQ commands */ 86 /* SRQ commands */
87 MLX4_CMD_SW2HW_SRQ = 0x35, 87 MLX4_CMD_SW2HW_SRQ = 0x35,
diff --git a/include/linux/mlx4/cq.h b/include/linux/mlx4/cq.h
index 0181e0a57cbf..071cf96cf01f 100644
--- a/include/linux/mlx4/cq.h
+++ b/include/linux/mlx4/cq.h
@@ -45,11 +45,11 @@ struct mlx4_cqe {
45 u8 sl; 45 u8 sl;
46 u8 reserved1; 46 u8 reserved1;
47 __be16 rlid; 47 __be16 rlid;
48 u32 reserved2; 48 __be32 ipoib_status;
49 __be32 byte_cnt; 49 __be32 byte_cnt;
50 __be16 wqe_index; 50 __be16 wqe_index;
51 __be16 checksum; 51 __be16 checksum;
52 u8 reserved3[3]; 52 u8 reserved2[3];
53 u8 owner_sr_opcode; 53 u8 owner_sr_opcode;
54}; 54};
55 55
@@ -85,6 +85,16 @@ enum {
85 MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR = 0x22, 85 MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR = 0x22,
86}; 86};
87 87
88enum {
89 MLX4_CQE_IPOIB_STATUS_IPV4 = 1 << 22,
90 MLX4_CQE_IPOIB_STATUS_IPV4F = 1 << 23,
91 MLX4_CQE_IPOIB_STATUS_IPV6 = 1 << 24,
92 MLX4_CQE_IPOIB_STATUS_IPV4OPT = 1 << 25,
93 MLX4_CQE_IPOIB_STATUS_TCP = 1 << 26,
94 MLX4_CQE_IPOIB_STATUS_UDP = 1 << 27,
95 MLX4_CQE_IPOIB_STATUS_IPOK = 1 << 28,
96};
97
88static inline void mlx4_cq_arm(struct mlx4_cq *cq, u32 cmd, 98static inline void mlx4_cq_arm(struct mlx4_cq *cq, u32 cmd,
89 void __iomem *uar_page, 99 void __iomem *uar_page,
90 spinlock_t *doorbell_lock) 100 spinlock_t *doorbell_lock)
@@ -120,4 +130,9 @@ enum {
120 MLX4_CQ_DB_REQ_NOT = 2 << 24 130 MLX4_CQ_DB_REQ_NOT = 2 << 24
121}; 131};
122 132
133int mlx4_cq_modify(struct mlx4_dev *dev, struct mlx4_cq *cq,
134 u16 count, u16 period);
135int mlx4_cq_resize(struct mlx4_dev *dev, struct mlx4_cq *cq,
136 int entries, struct mlx4_mtt *mtt);
137
123#endif /* MLX4_CQ_H */ 138#endif /* MLX4_CQ_H */
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 6cdf813cd478..a744383d16e9 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -186,6 +186,7 @@ struct mlx4_caps {
186 u32 flags; 186 u32 flags;
187 u16 stat_rate_support; 187 u16 stat_rate_support;
188 u8 port_width_cap[MLX4_MAX_PORTS + 1]; 188 u8 port_width_cap[MLX4_MAX_PORTS + 1];
189 int max_gso_sz;
189}; 190};
190 191
191struct mlx4_buf_list { 192struct mlx4_buf_list {
@@ -207,6 +208,38 @@ struct mlx4_mtt {
207 int page_shift; 208 int page_shift;
208}; 209};
209 210
211enum {
212 MLX4_DB_PER_PAGE = PAGE_SIZE / 4
213};
214
215struct mlx4_db_pgdir {
216 struct list_head list;
217 DECLARE_BITMAP(order0, MLX4_DB_PER_PAGE);
218 DECLARE_BITMAP(order1, MLX4_DB_PER_PAGE / 2);
219 unsigned long *bits[2];
220 __be32 *db_page;
221 dma_addr_t db_dma;
222};
223
224struct mlx4_ib_user_db_page;
225
226struct mlx4_db {
227 __be32 *db;
228 union {
229 struct mlx4_db_pgdir *pgdir;
230 struct mlx4_ib_user_db_page *user_page;
231 } u;
232 dma_addr_t dma;
233 int index;
234 int order;
235};
236
237struct mlx4_hwq_resources {
238 struct mlx4_db db;
239 struct mlx4_mtt mtt;
240 struct mlx4_buf buf;
241};
242
210struct mlx4_mr { 243struct mlx4_mr {
211 struct mlx4_mtt mtt; 244 struct mlx4_mtt mtt;
212 u64 iova; 245 u64 iova;
@@ -340,8 +373,17 @@ int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
340int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, 373int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
341 struct mlx4_buf *buf); 374 struct mlx4_buf *buf);
342 375
376int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order);
377void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db);
378
379int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres,
380 int size, int max_direct);
381void mlx4_free_hwq_res(struct mlx4_dev *mdev, struct mlx4_hwq_resources *wqres,
382 int size);
383
343int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, 384int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,
344 struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq); 385 struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq,
386 int collapsed);
345void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq); 387void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq);
346 388
347int mlx4_qp_alloc(struct mlx4_dev *dev, int sqpn, struct mlx4_qp *qp); 389int mlx4_qp_alloc(struct mlx4_dev *dev, int sqpn, struct mlx4_qp *qp);
diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h
index 1b835ca49df1..53c5fdb6eac4 100644
--- a/include/linux/mlx4/driver.h
+++ b/include/linux/mlx4/driver.h
@@ -48,8 +48,7 @@ struct mlx4_interface {
48 void * (*add) (struct mlx4_dev *dev); 48 void * (*add) (struct mlx4_dev *dev);
49 void (*remove)(struct mlx4_dev *dev, void *context); 49 void (*remove)(struct mlx4_dev *dev, void *context);
50 void (*event) (struct mlx4_dev *dev, void *context, 50 void (*event) (struct mlx4_dev *dev, void *context,
51 enum mlx4_dev_event event, int subtype, 51 enum mlx4_dev_event event, int port);
52 int port);
53 struct list_head list; 52 struct list_head list;
54}; 53};
55 54
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index 09a2230923f2..7f128b266faa 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -158,10 +158,12 @@ struct mlx4_qp_context {
158#define MLX4_FW_VER_WQE_CTRL_NEC mlx4_fw_ver(2, 2, 232) 158#define MLX4_FW_VER_WQE_CTRL_NEC mlx4_fw_ver(2, 2, 232)
159 159
160enum { 160enum {
161 MLX4_WQE_CTRL_NEC = 1 << 29, 161 MLX4_WQE_CTRL_NEC = 1 << 29,
162 MLX4_WQE_CTRL_FENCE = 1 << 6, 162 MLX4_WQE_CTRL_FENCE = 1 << 6,
163 MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2, 163 MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2,
164 MLX4_WQE_CTRL_SOLICITED = 1 << 1, 164 MLX4_WQE_CTRL_SOLICITED = 1 << 1,
165 MLX4_WQE_CTRL_IP_CSUM = 1 << 4,
166 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5,
165}; 167};
166 168
167struct mlx4_wqe_ctrl_seg { 169struct mlx4_wqe_ctrl_seg {
@@ -217,6 +219,11 @@ struct mlx4_wqe_datagram_seg {
217 __be32 reservd[2]; 219 __be32 reservd[2];
218}; 220};
219 221
222struct mlx4_lso_seg {
223 __be32 mss_hdr_size;
224 __be32 header[0];
225};
226
220struct mlx4_wqe_bind_seg { 227struct mlx4_wqe_bind_seg {
221 __be32 flags1; 228 __be32 flags1;
222 __be32 flags2; 229 __be32 flags2;
@@ -289,6 +296,10 @@ int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
289int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp, 296int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
290 struct mlx4_qp_context *context); 297 struct mlx4_qp_context *context);
291 298
299int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
300 struct mlx4_qp_context *context,
301 struct mlx4_qp *qp, enum mlx4_qp_state *qp_state);
302
292static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn) 303static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn)
293{ 304{
294 return radix_tree_lookup(&dev->qp_table_tree, qpn & (dev->caps.num_qps - 1)); 305 return radix_tree_lookup(&dev->qp_table_tree, qpn & (dev->caps.num_qps - 1));
diff --git a/include/linux/mm.h b/include/linux/mm.h
index b695875d63e3..c31a9cd2a30e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -107,6 +107,7 @@ extern unsigned int kobjsize(const void *objp);
107#define VM_ALWAYSDUMP 0x04000000 /* Always include in core dumps */ 107#define VM_ALWAYSDUMP 0x04000000 /* Always include in core dumps */
108 108
109#define VM_CAN_NONLINEAR 0x08000000 /* Has ->fault & does nonlinear pages */ 109#define VM_CAN_NONLINEAR 0x08000000 /* Has ->fault & does nonlinear pages */
110#define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
110 111
111#ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */ 112#ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */
112#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS 113#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
@@ -164,8 +165,6 @@ struct vm_operations_struct {
164 void (*open)(struct vm_area_struct * area); 165 void (*open)(struct vm_area_struct * area);
165 void (*close)(struct vm_area_struct * area); 166 void (*close)(struct vm_area_struct * area);
166 int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf); 167 int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf);
167 struct page *(*nopage)(struct vm_area_struct *area,
168 unsigned long address, int *type);
169 unsigned long (*nopfn)(struct vm_area_struct *area, 168 unsigned long (*nopfn)(struct vm_area_struct *area,
170 unsigned long address); 169 unsigned long address);
171 170
@@ -173,7 +172,25 @@ struct vm_operations_struct {
173 * writable, if an error is returned it will cause a SIGBUS */ 172 * writable, if an error is returned it will cause a SIGBUS */
174 int (*page_mkwrite)(struct vm_area_struct *vma, struct page *page); 173 int (*page_mkwrite)(struct vm_area_struct *vma, struct page *page);
175#ifdef CONFIG_NUMA 174#ifdef CONFIG_NUMA
175 /*
176 * set_policy() op must add a reference to any non-NULL @new mempolicy
177 * to hold the policy upon return. Caller should pass NULL @new to
178 * remove a policy and fall back to surrounding context--i.e. do not
179 * install a MPOL_DEFAULT policy, nor the task or system default
180 * mempolicy.
181 */
176 int (*set_policy)(struct vm_area_struct *vma, struct mempolicy *new); 182 int (*set_policy)(struct vm_area_struct *vma, struct mempolicy *new);
183
184 /*
185 * get_policy() op must add reference [mpol_get()] to any policy at
186 * (vma,addr) marked as MPOL_SHARED. The shared policy infrastructure
187 * in mm/mempolicy.c will do this automatically.
188 * get_policy() must NOT add a ref if the policy at (vma,addr) is not
189 * marked as MPOL_SHARED. vma policies are protected by the mmap_sem.
190 * If no [shared/vma] mempolicy exists at the addr, get_policy() op
191 * must return NULL--i.e., do not "fallback" to task or system default
192 * policy.
193 */
177 struct mempolicy *(*get_policy)(struct vm_area_struct *vma, 194 struct mempolicy *(*get_policy)(struct vm_area_struct *vma,
178 unsigned long addr); 195 unsigned long addr);
179 int (*migrate)(struct vm_area_struct *vma, const nodemask_t *from, 196 int (*migrate)(struct vm_area_struct *vma, const nodemask_t *from,
@@ -397,11 +414,11 @@ static inline void set_compound_order(struct page *page, unsigned long order)
397 * we have run out of space and have to fall back to an 414 * we have run out of space and have to fall back to an
398 * alternate (slower) way of determining the node. 415 * alternate (slower) way of determining the node.
399 * 416 *
400 * No sparsemem: | NODE | ZONE | ... | FLAGS | 417 * No sparsemem or sparsemem vmemmap: | NODE | ZONE | ... | FLAGS |
401 * with space for node: | SECTION | NODE | ZONE | ... | FLAGS | 418 * classic sparse with space for node:| SECTION | NODE | ZONE | ... | FLAGS |
402 * no space for node: | SECTION | ZONE | ... | FLAGS | 419 * classic sparse no space for node: | SECTION | ZONE | ... | FLAGS |
403 */ 420 */
404#ifdef CONFIG_SPARSEMEM 421#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
405#define SECTIONS_WIDTH SECTIONS_SHIFT 422#define SECTIONS_WIDTH SECTIONS_SHIFT
406#else 423#else
407#define SECTIONS_WIDTH 0 424#define SECTIONS_WIDTH 0
@@ -409,9 +426,12 @@ static inline void set_compound_order(struct page *page, unsigned long order)
409 426
410#define ZONES_WIDTH ZONES_SHIFT 427#define ZONES_WIDTH ZONES_SHIFT
411 428
412#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= FLAGS_RESERVED 429#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS
413#define NODES_WIDTH NODES_SHIFT 430#define NODES_WIDTH NODES_SHIFT
414#else 431#else
432#ifdef CONFIG_SPARSEMEM_VMEMMAP
433#error "Vmemmap: No space for nodes field in page flags"
434#endif
415#define NODES_WIDTH 0 435#define NODES_WIDTH 0
416#endif 436#endif
417 437
@@ -454,8 +474,8 @@ static inline void set_compound_order(struct page *page, unsigned long order)
454 474
455#define ZONEID_PGSHIFT (ZONEID_PGOFF * (ZONEID_SHIFT != 0)) 475#define ZONEID_PGSHIFT (ZONEID_PGOFF * (ZONEID_SHIFT != 0))
456 476
457#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED 477#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS
458#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED 478#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS
459#endif 479#endif
460 480
461#define ZONES_MASK ((1UL << ZONES_WIDTH) - 1) 481#define ZONES_MASK ((1UL << ZONES_WIDTH) - 1)
@@ -504,10 +524,12 @@ static inline struct zone *page_zone(struct page *page)
504 return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; 524 return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)];
505} 525}
506 526
527#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
507static inline unsigned long page_to_section(struct page *page) 528static inline unsigned long page_to_section(struct page *page)
508{ 529{
509 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; 530 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
510} 531}
532#endif
511 533
512static inline void set_page_zone(struct page *page, enum zone_type zone) 534static inline void set_page_zone(struct page *page, enum zone_type zone)
513{ 535{
@@ -602,9 +624,12 @@ static inline struct address_space *page_mapping(struct page *page)
602 struct address_space *mapping = page->mapping; 624 struct address_space *mapping = page->mapping;
603 625
604 VM_BUG_ON(PageSlab(page)); 626 VM_BUG_ON(PageSlab(page));
627#ifdef CONFIG_SWAP
605 if (unlikely(PageSwapCache(page))) 628 if (unlikely(PageSwapCache(page)))
606 mapping = &swapper_space; 629 mapping = &swapper_space;
607 else if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON)) 630 else
631#endif
632 if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON))
608 mapping = NULL; 633 mapping = NULL;
609 return mapping; 634 return mapping;
610} 635}
@@ -649,12 +674,6 @@ static inline int page_mapped(struct page *page)
649} 674}
650 675
651/* 676/*
652 * Error return values for the *_nopage functions
653 */
654#define NOPAGE_SIGBUS (NULL)
655#define NOPAGE_OOM ((struct page *) (-1))
656
657/*
658 * Error return values for the *_nopfn functions 677 * Error return values for the *_nopfn functions
659 */ 678 */
660#define NOPFN_SIGBUS ((unsigned long) -1) 679#define NOPFN_SIGBUS ((unsigned long) -1)
@@ -720,7 +739,9 @@ struct zap_details {
720 unsigned long truncate_count; /* Compare vm_truncate_count */ 739 unsigned long truncate_count; /* Compare vm_truncate_count */
721}; 740};
722 741
723struct page *vm_normal_page(struct vm_area_struct *, unsigned long, pte_t); 742struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
743 pte_t pte);
744
724unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address, 745unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
725 unsigned long size, struct zap_details *); 746 unsigned long size, struct zap_details *);
726unsigned long unmap_vmas(struct mmu_gather **tlb, 747unsigned long unmap_vmas(struct mmu_gather **tlb,
@@ -1045,6 +1066,19 @@ extern void unlink_file_vma(struct vm_area_struct *);
1045extern struct vm_area_struct *copy_vma(struct vm_area_struct **, 1066extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
1046 unsigned long addr, unsigned long len, pgoff_t pgoff); 1067 unsigned long addr, unsigned long len, pgoff_t pgoff);
1047extern void exit_mmap(struct mm_struct *); 1068extern void exit_mmap(struct mm_struct *);
1069
1070#ifdef CONFIG_PROC_FS
1071/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */
1072extern void added_exe_file_vma(struct mm_struct *mm);
1073extern void removed_exe_file_vma(struct mm_struct *mm);
1074#else
1075static inline void added_exe_file_vma(struct mm_struct *mm)
1076{}
1077
1078static inline void removed_exe_file_vma(struct mm_struct *mm)
1079{}
1080#endif /* CONFIG_PROC_FS */
1081
1048extern int may_expand_vm(struct mm_struct *mm, unsigned long npages); 1082extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
1049extern int install_special_mapping(struct mm_struct *mm, 1083extern int install_special_mapping(struct mm_struct *mm,
1050 unsigned long addr, unsigned long len, 1084 unsigned long addr, unsigned long len,
@@ -1149,6 +1183,8 @@ int remap_pfn_range(struct vm_area_struct *, unsigned long addr,
1149int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); 1183int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *);
1150int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, 1184int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
1151 unsigned long pfn); 1185 unsigned long pfn);
1186int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
1187 unsigned long pfn);
1152 1188
1153struct page *follow_page(struct vm_area_struct *, unsigned long address, 1189struct page *follow_page(struct vm_area_struct *, unsigned long address,
1154 unsigned int foll_flags); 1190 unsigned int foll_flags);
@@ -1207,8 +1243,6 @@ int drop_caches_sysctl_handler(struct ctl_table *, int, struct file *,
1207 void __user *, size_t *, loff_t *); 1243 void __user *, size_t *, loff_t *);
1208unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, 1244unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
1209 unsigned long lru_pages); 1245 unsigned long lru_pages);
1210void drop_pagecache(void);
1211void drop_slab(void);
1212 1246
1213#ifndef CONFIG_MMU 1247#ifndef CONFIG_MMU
1214#define randomize_va_space 0 1248#define randomize_va_space 0
@@ -1229,6 +1263,7 @@ void vmemmap_verify(pte_t *, int, unsigned long, unsigned long);
1229int vmemmap_populate_basepages(struct page *start_page, 1263int vmemmap_populate_basepages(struct page *start_page,
1230 unsigned long pages, int node); 1264 unsigned long pages, int node);
1231int vmemmap_populate(struct page *start_page, unsigned long pages, int node); 1265int vmemmap_populate(struct page *start_page, unsigned long pages, int node);
1266void vmemmap_populate_print_last(void);
1232 1267
1233#endif /* __KERNEL__ */ 1268#endif /* __KERNEL__ */
1234#endif /* _LINUX_MM_H */ 1269#endif /* _LINUX_MM_H */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index af190ceab971..eb7c16cc9559 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -42,7 +42,10 @@ struct page {
42 * to show when page is mapped 42 * to show when page is mapped
43 * & limit reverse map searches. 43 * & limit reverse map searches.
44 */ 44 */
45 unsigned int inuse; /* SLUB: Nr of objects */ 45 struct { /* SLUB */
46 u16 inuse;
47 u16 objects;
48 };
46 }; 49 };
47 union { 50 union {
48 struct { 51 struct {
@@ -172,6 +175,7 @@ struct mm_struct {
172 atomic_t mm_users; /* How many users with user space? */ 175 atomic_t mm_users; /* How many users with user space? */
173 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */ 176 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */
174 int map_count; /* number of VMAs */ 177 int map_count; /* number of VMAs */
178 int core_waiters;
175 struct rw_semaphore mmap_sem; 179 struct rw_semaphore mmap_sem;
176 spinlock_t page_table_lock; /* Protects page tables and some counters */ 180 spinlock_t page_table_lock; /* Protects page tables and some counters */
177 181
@@ -216,14 +220,20 @@ struct mm_struct {
216 unsigned long flags; /* Must use atomic bitops to access the bits */ 220 unsigned long flags; /* Must use atomic bitops to access the bits */
217 221
218 /* coredumping support */ 222 /* coredumping support */
219 int core_waiters;
220 struct completion *core_startup_done, core_done; 223 struct completion *core_startup_done, core_done;
221 224
222 /* aio bits */ 225 /* aio bits */
223 rwlock_t ioctx_list_lock; 226 rwlock_t ioctx_list_lock; /* aio lock */
224 struct kioctx *ioctx_list; 227 struct kioctx *ioctx_list;
225#ifdef CONFIG_CGROUP_MEM_RES_CTLR 228#ifdef CONFIG_MM_OWNER
226 struct mem_cgroup *mem_cgroup; 229 struct task_struct *owner; /* The thread group leader that */
230 /* owns the mm_struct. */
231#endif
232
233#ifdef CONFIG_PROC_FS
234 /* store ref to file /proc/<pid>/exe symlink points to */
235 struct file *exe_file;
236 unsigned long num_exe_file_vmas;
227#endif 237#endif
228}; 238};
229 239
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 8d8d1977736e..c463cd8a15a4 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1,8 +1,8 @@
1#ifndef _LINUX_MMZONE_H 1#ifndef _LINUX_MMZONE_H
2#define _LINUX_MMZONE_H 2#define _LINUX_MMZONE_H
3 3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5#ifndef __GENERATING_BOUNDS_H
6 6
7#include <linux/spinlock.h> 7#include <linux/spinlock.h>
8#include <linux/list.h> 8#include <linux/list.h>
@@ -15,6 +15,7 @@
15#include <linux/seqlock.h> 15#include <linux/seqlock.h>
16#include <linux/nodemask.h> 16#include <linux/nodemask.h>
17#include <linux/pageblock-flags.h> 17#include <linux/pageblock-flags.h>
18#include <linux/bounds.h>
18#include <asm/atomic.h> 19#include <asm/atomic.h>
19#include <asm/page.h> 20#include <asm/page.h>
20 21
@@ -95,6 +96,7 @@ enum zone_stat_item {
95 NR_UNSTABLE_NFS, /* NFS unstable pages */ 96 NR_UNSTABLE_NFS, /* NFS unstable pages */
96 NR_BOUNCE, 97 NR_BOUNCE,
97 NR_VMSCAN_WRITE, 98 NR_VMSCAN_WRITE,
99 NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */
98#ifdef CONFIG_NUMA 100#ifdef CONFIG_NUMA
99 NUMA_HIT, /* allocated in intended node */ 101 NUMA_HIT, /* allocated in intended node */
100 NUMA_MISS, /* allocated in non intended node */ 102 NUMA_MISS, /* allocated in non intended node */
@@ -129,6 +131,8 @@ struct per_cpu_pageset {
129#define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)]) 131#define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)])
130#endif 132#endif
131 133
134#endif /* !__GENERATING_BOUNDS.H */
135
132enum zone_type { 136enum zone_type {
133#ifdef CONFIG_ZONE_DMA 137#ifdef CONFIG_ZONE_DMA
134 /* 138 /*
@@ -177,9 +181,11 @@ enum zone_type {
177 ZONE_HIGHMEM, 181 ZONE_HIGHMEM,
178#endif 182#endif
179 ZONE_MOVABLE, 183 ZONE_MOVABLE,
180 MAX_NR_ZONES 184 __MAX_NR_ZONES
181}; 185};
182 186
187#ifndef __GENERATING_BOUNDS_H
188
183/* 189/*
184 * When a memory allocation must conform to specific limitations (such 190 * When a memory allocation must conform to specific limitations (such
185 * as being suitable for DMA) the caller will pass in hints to the 191 * as being suitable for DMA) the caller will pass in hints to the
@@ -188,28 +194,15 @@ enum zone_type {
188 * match the requested limits. See gfp_zone() in include/linux/gfp.h 194 * match the requested limits. See gfp_zone() in include/linux/gfp.h
189 */ 195 */
190 196
191/* 197#if MAX_NR_ZONES < 2
192 * Count the active zones. Note that the use of defined(X) outside
193 * #if and family is not necessarily defined so ensure we cannot use
194 * it later. Use __ZONE_COUNT to work out how many shift bits we need.
195 */
196#define __ZONE_COUNT ( \
197 defined(CONFIG_ZONE_DMA) \
198 + defined(CONFIG_ZONE_DMA32) \
199 + 1 \
200 + defined(CONFIG_HIGHMEM) \
201 + 1 \
202)
203#if __ZONE_COUNT < 2
204#define ZONES_SHIFT 0 198#define ZONES_SHIFT 0
205#elif __ZONE_COUNT <= 2 199#elif MAX_NR_ZONES <= 2
206#define ZONES_SHIFT 1 200#define ZONES_SHIFT 1
207#elif __ZONE_COUNT <= 4 201#elif MAX_NR_ZONES <= 4
208#define ZONES_SHIFT 2 202#define ZONES_SHIFT 2
209#else 203#else
210#error ZONES_SHIFT -- too many zones configured adjust calculation 204#error ZONES_SHIFT -- too many zones configured adjust calculation
211#endif 205#endif
212#undef __ZONE_COUNT
213 206
214struct zone { 207struct zone {
215 /* Fields commonly accessed by the page allocator */ 208 /* Fields commonly accessed by the page allocator */
@@ -393,10 +386,10 @@ static inline int zone_is_oom_locked(const struct zone *zone)
393 * The NUMA zonelists are doubled becausse we need zonelists that restrict the 386 * The NUMA zonelists are doubled becausse we need zonelists that restrict the
394 * allocations to a single node for GFP_THISNODE. 387 * allocations to a single node for GFP_THISNODE.
395 * 388 *
396 * [0 .. MAX_NR_ZONES -1] : Zonelists with fallback 389 * [0] : Zonelist with fallback
397 * [MAZ_NR_ZONES ... MAZ_ZONELISTS -1] : No fallback (GFP_THISNODE) 390 * [1] : No fallback (GFP_THISNODE)
398 */ 391 */
399#define MAX_ZONELISTS (2 * MAX_NR_ZONES) 392#define MAX_ZONELISTS 2
400 393
401 394
402/* 395/*
@@ -464,11 +457,20 @@ struct zonelist_cache {
464 unsigned long last_full_zap; /* when last zap'd (jiffies) */ 457 unsigned long last_full_zap; /* when last zap'd (jiffies) */
465}; 458};
466#else 459#else
467#define MAX_ZONELISTS MAX_NR_ZONES 460#define MAX_ZONELISTS 1
468struct zonelist_cache; 461struct zonelist_cache;
469#endif 462#endif
470 463
471/* 464/*
465 * This struct contains information about a zone in a zonelist. It is stored
466 * here to avoid dereferences into large structures and lookups of tables
467 */
468struct zoneref {
469 struct zone *zone; /* Pointer to actual zone */
470 int zone_idx; /* zone_idx(zoneref->zone) */
471};
472
473/*
472 * One allocation request operates on a zonelist. A zonelist 474 * One allocation request operates on a zonelist. A zonelist
473 * is a list of zones, the first one is the 'goal' of the 475 * is a list of zones, the first one is the 'goal' of the
474 * allocation, the other zones are fallback zones, in decreasing 476 * allocation, the other zones are fallback zones, in decreasing
@@ -476,34 +478,23 @@ struct zonelist_cache;
476 * 478 *
477 * If zlcache_ptr is not NULL, then it is just the address of zlcache, 479 * If zlcache_ptr is not NULL, then it is just the address of zlcache,
478 * as explained above. If zlcache_ptr is NULL, there is no zlcache. 480 * as explained above. If zlcache_ptr is NULL, there is no zlcache.
481 * *
482 * To speed the reading of the zonelist, the zonerefs contain the zone index
483 * of the entry being read. Helper functions to access information given
484 * a struct zoneref are
485 *
486 * zonelist_zone() - Return the struct zone * for an entry in _zonerefs
487 * zonelist_zone_idx() - Return the index of the zone for an entry
488 * zonelist_node_idx() - Return the index of the node for an entry
479 */ 489 */
480
481struct zonelist { 490struct zonelist {
482 struct zonelist_cache *zlcache_ptr; // NULL or &zlcache 491 struct zonelist_cache *zlcache_ptr; // NULL or &zlcache
483 struct zone *zones[MAX_ZONES_PER_ZONELIST + 1]; // NULL delimited 492 struct zoneref _zonerefs[MAX_ZONES_PER_ZONELIST + 1];
484#ifdef CONFIG_NUMA 493#ifdef CONFIG_NUMA
485 struct zonelist_cache zlcache; // optional ... 494 struct zonelist_cache zlcache; // optional ...
486#endif 495#endif
487}; 496};
488 497
489#ifdef CONFIG_NUMA
490/*
491 * Only custom zonelists like MPOL_BIND need to be filtered as part of
492 * policies. As described in the comment for struct zonelist_cache, these
493 * zonelists will not have a zlcache so zlcache_ptr will not be set. Use
494 * that to determine if the zonelists needs to be filtered or not.
495 */
496static inline int alloc_should_filter_zonelist(struct zonelist *zonelist)
497{
498 return !zonelist->zlcache_ptr;
499}
500#else
501static inline int alloc_should_filter_zonelist(struct zonelist *zonelist)
502{
503 return 0;
504}
505#endif /* CONFIG_NUMA */
506
507#ifdef CONFIG_ARCH_POPULATES_NODE_MAP 498#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
508struct node_active_region { 499struct node_active_region {
509 unsigned long start_pfn; 500 unsigned long start_pfn;
@@ -637,9 +628,10 @@ static inline int is_normal_idx(enum zone_type idx)
637static inline int is_highmem(struct zone *zone) 628static inline int is_highmem(struct zone *zone)
638{ 629{
639#ifdef CONFIG_HIGHMEM 630#ifdef CONFIG_HIGHMEM
640 int zone_idx = zone - zone->zone_pgdat->node_zones; 631 int zone_off = (char *)zone - (char *)zone->zone_pgdat->node_zones;
641 return zone_idx == ZONE_HIGHMEM || 632 return zone_off == ZONE_HIGHMEM * sizeof(*zone) ||
642 (zone_idx == ZONE_MOVABLE && zone_movable_is_highmem()); 633 (zone_off == ZONE_MOVABLE * sizeof(*zone) &&
634 zone_movable_is_highmem());
643#else 635#else
644 return 0; 636 return 0;
645#endif 637#endif
@@ -699,7 +691,6 @@ extern char numa_zonelist_order[];
699extern struct pglist_data contig_page_data; 691extern struct pglist_data contig_page_data;
700#define NODE_DATA(nid) (&contig_page_data) 692#define NODE_DATA(nid) (&contig_page_data)
701#define NODE_MEM_MAP(nid) mem_map 693#define NODE_MEM_MAP(nid) mem_map
702#define MAX_NODES_SHIFT 1
703 694
704#else /* CONFIG_NEED_MULTIPLE_NODES */ 695#else /* CONFIG_NEED_MULTIPLE_NODES */
705 696
@@ -731,32 +722,103 @@ extern struct zone *next_zone(struct zone *zone);
731 zone; \ 722 zone; \
732 zone = next_zone(zone)) 723 zone = next_zone(zone))
733 724
734#ifdef CONFIG_SPARSEMEM 725static inline struct zone *zonelist_zone(struct zoneref *zoneref)
735#include <asm/sparsemem.h> 726{
736#endif 727 return zoneref->zone;
728}
737 729
738#if BITS_PER_LONG == 32 730static inline int zonelist_zone_idx(struct zoneref *zoneref)
739/* 731{
740 * with 32 bit page->flags field, we reserve 9 bits for node/zone info. 732 return zoneref->zone_idx;
741 * there are 4 zones (3 bits) and this leaves 9-3=6 bits for nodes. 733}
734
735static inline int zonelist_node_idx(struct zoneref *zoneref)
736{
737#ifdef CONFIG_NUMA
738 /* zone_to_nid not available in this context */
739 return zoneref->zone->node;
740#else
741 return 0;
742#endif /* CONFIG_NUMA */
743}
744
745/**
746 * next_zones_zonelist - Returns the next zone at or below highest_zoneidx within the allowed nodemask using a cursor within a zonelist as a starting point
747 * @z - The cursor used as a starting point for the search
748 * @highest_zoneidx - The zone index of the highest zone to return
749 * @nodes - An optional nodemask to filter the zonelist with
750 * @zone - The first suitable zone found is returned via this parameter
751 *
752 * This function returns the next zone at or below a given zone index that is
753 * within the allowed nodemask using a cursor as the starting point for the
754 * search. The zoneref returned is a cursor that is used as the next starting
755 * point for future calls to next_zones_zonelist().
742 */ 756 */
743#define FLAGS_RESERVED 9 757struct zoneref *next_zones_zonelist(struct zoneref *z,
758 enum zone_type highest_zoneidx,
759 nodemask_t *nodes,
760 struct zone **zone);
744 761
745#elif BITS_PER_LONG == 64 762/**
746/* 763 * first_zones_zonelist - Returns the first zone at or below highest_zoneidx within the allowed nodemask in a zonelist
747 * with 64 bit flags field, there's plenty of room. 764 * @zonelist - The zonelist to search for a suitable zone
765 * @highest_zoneidx - The zone index of the highest zone to return
766 * @nodes - An optional nodemask to filter the zonelist with
767 * @zone - The first suitable zone found is returned via this parameter
768 *
769 * This function returns the first zone at or below a given zone index that is
770 * within the allowed nodemask. The zoneref returned is a cursor that can be
771 * used to iterate the zonelist with next_zones_zonelist. The cursor should
772 * not be used by the caller as it does not match the value of the zone
773 * returned.
748 */ 774 */
749#define FLAGS_RESERVED 32 775static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
776 enum zone_type highest_zoneidx,
777 nodemask_t *nodes,
778 struct zone **zone)
779{
780 return next_zones_zonelist(zonelist->_zonerefs, highest_zoneidx, nodes,
781 zone);
782}
750 783
751#else 784/**
785 * for_each_zone_zonelist_nodemask - helper macro to iterate over valid zones in a zonelist at or below a given zone index and within a nodemask
786 * @zone - The current zone in the iterator
787 * @z - The current pointer within zonelist->zones being iterated
788 * @zlist - The zonelist being iterated
789 * @highidx - The zone index of the highest zone to return
790 * @nodemask - Nodemask allowed by the allocator
791 *
792 * This iterator iterates though all zones at or below a given zone index and
793 * within a given nodemask
794 */
795#define for_each_zone_zonelist_nodemask(zone, z, zlist, highidx, nodemask) \
796 for (z = first_zones_zonelist(zlist, highidx, nodemask, &zone); \
797 zone; \
798 z = next_zones_zonelist(z, highidx, nodemask, &zone)) \
752 799
753#error BITS_PER_LONG not defined 800/**
801 * for_each_zone_zonelist - helper macro to iterate over valid zones in a zonelist at or below a given zone index
802 * @zone - The current zone in the iterator
803 * @z - The current pointer within zonelist->zones being iterated
804 * @zlist - The zonelist being iterated
805 * @highidx - The zone index of the highest zone to return
806 *
807 * This iterator iterates though all zones at or below a given zone index.
808 */
809#define for_each_zone_zonelist(zone, z, zlist, highidx) \
810 for_each_zone_zonelist_nodemask(zone, z, zlist, highidx, NULL)
754 811
812#ifdef CONFIG_SPARSEMEM
813#include <asm/sparsemem.h>
755#endif 814#endif
756 815
757#if !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) && \ 816#if !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) && \
758 !defined(CONFIG_ARCH_POPULATES_NODE_MAP) 817 !defined(CONFIG_ARCH_POPULATES_NODE_MAP)
759#define early_pfn_to_nid(nid) (0UL) 818static inline unsigned long early_pfn_to_nid(unsigned long pfn)
819{
820 return 0;
821}
760#endif 822#endif
761 823
762#ifdef CONFIG_FLATMEM 824#ifdef CONFIG_FLATMEM
@@ -834,6 +896,7 @@ static inline struct mem_section *__nr_to_section(unsigned long nr)
834 return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; 896 return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK];
835} 897}
836extern int __section_nr(struct mem_section* ms); 898extern int __section_nr(struct mem_section* ms);
899extern unsigned long usemap_size(void);
837 900
838/* 901/*
839 * We use the lower bits of the mem_map pointer to store 902 * We use the lower bits of the mem_map pointer to store
@@ -939,6 +1002,6 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
939#define pfn_valid_within(pfn) (1) 1002#define pfn_valid_within(pfn) (1)
940#endif 1003#endif
941 1004
1005#endif /* !__GENERATING_BOUNDS.H */
942#endif /* !__ASSEMBLY__ */ 1006#endif /* !__ASSEMBLY__ */
943#endif /* __KERNEL__ */
944#endif /* _LINUX_MMZONE_H */ 1007#endif /* _LINUX_MMZONE_H */
diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h
index 8eed44f8ca73..830bbcd449d6 100644
--- a/include/linux/mnt_namespace.h
+++ b/include/linux/mnt_namespace.h
@@ -5,6 +5,7 @@
5#include <linux/mount.h> 5#include <linux/mount.h>
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/nsproxy.h> 7#include <linux/nsproxy.h>
8#include <linux/seq_file.h>
8 9
9struct mnt_namespace { 10struct mnt_namespace {
10 atomic_t count; 11 atomic_t count;
@@ -14,6 +15,13 @@ struct mnt_namespace {
14 int event; 15 int event;
15}; 16};
16 17
18struct proc_mounts {
19 struct seq_file m; /* must be the first element */
20 struct mnt_namespace *ns;
21 struct path root;
22 int event;
23};
24
17extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, 25extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *,
18 struct fs_struct *); 26 struct fs_struct *);
19extern void __put_mnt_ns(struct mnt_namespace *ns); 27extern void __put_mnt_ns(struct mnt_namespace *ns);
@@ -37,5 +45,9 @@ static inline void get_mnt_ns(struct mnt_namespace *ns)
37 atomic_inc(&ns->count); 45 atomic_inc(&ns->count);
38} 46}
39 47
48extern const struct seq_operations mounts_op;
49extern const struct seq_operations mountinfo_op;
50extern const struct seq_operations mountstats_op;
51
40#endif 52#endif
41#endif 53#endif
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 139d49d2f078..d73eceaa7afb 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -368,4 +368,15 @@ struct virtio_device_id {
368}; 368};
369#define VIRTIO_DEV_ANY_ID 0xffffffff 369#define VIRTIO_DEV_ANY_ID 0xffffffff
370 370
371/* i2c */
372
373#define I2C_NAME_SIZE 20
374#define I2C_MODULE_PREFIX "i2c:"
375
376struct i2c_device_id {
377 char name[I2C_NAME_SIZE];
378 kernel_ulong_t driver_data; /* Data private to the driver */
379};
380
381
371#endif /* LINUX_MOD_DEVICETABLE_H */ 382#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/include/linux/module.h b/include/linux/module.h
index 819c4e889bf1..3e03b1acbc94 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -190,7 +190,7 @@ void *__symbol_get_gpl(const char *symbol);
190 extern typeof(sym) sym; \ 190 extern typeof(sym) sym; \
191 __CRC_SYMBOL(sym, sec) \ 191 __CRC_SYMBOL(sym, sec) \
192 static const char __kstrtab_##sym[] \ 192 static const char __kstrtab_##sym[] \
193 __attribute__((section("__ksymtab_strings"))) \ 193 __attribute__((section("__ksymtab_strings"), aligned(1))) \
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 __used \ 196 __used \
@@ -229,23 +229,6 @@ enum module_state
229 MODULE_STATE_GOING, 229 MODULE_STATE_GOING,
230}; 230};
231 231
232/* Similar stuff for section attributes. */
233struct module_sect_attr
234{
235 struct module_attribute mattr;
236 char *name;
237 unsigned long address;
238};
239
240struct module_sect_attrs
241{
242 struct attribute_group grp;
243 int nsections;
244 struct module_sect_attr attrs[0];
245};
246
247struct module_param_attrs;
248
249struct module 232struct module
250{ 233{
251 enum module_state state; 234 enum module_state state;
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 5ee2df217cdf..4374d1adeb4b 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -10,10 +10,10 @@
10 */ 10 */
11#ifndef _LINUX_MOUNT_H 11#ifndef _LINUX_MOUNT_H
12#define _LINUX_MOUNT_H 12#define _LINUX_MOUNT_H
13#ifdef __KERNEL__
14 13
15#include <linux/types.h> 14#include <linux/types.h>
16#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/nodemask.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <asm/atomic.h> 18#include <asm/atomic.h>
19 19
@@ -28,8 +28,10 @@ struct mnt_namespace;
28#define MNT_NOATIME 0x08 28#define MNT_NOATIME 0x08
29#define MNT_NODIRATIME 0x10 29#define MNT_NODIRATIME 0x10
30#define MNT_RELATIME 0x20 30#define MNT_RELATIME 0x20
31#define MNT_READONLY 0x40 /* does the user want this to be r/o? */
31 32
32#define MNT_SHRINKABLE 0x100 33#define MNT_SHRINKABLE 0x100
34#define MNT_IMBALANCED_WRITE_COUNT 0x200 /* just for debugging */
33 35
34#define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */ 36#define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */
35#define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */ 37#define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
@@ -53,6 +55,8 @@ struct vfsmount {
53 struct list_head mnt_slave; /* slave list entry */ 55 struct list_head mnt_slave; /* slave list entry */
54 struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ 56 struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */
55 struct mnt_namespace *mnt_ns; /* containing namespace */ 57 struct mnt_namespace *mnt_ns; /* containing namespace */
58 int mnt_id; /* mount identifier */
59 int mnt_group_id; /* peer group identifier */
56 /* 60 /*
57 * We put mnt_count & mnt_expiry_mark at the end of struct vfsmount 61 * We put mnt_count & mnt_expiry_mark at the end of struct vfsmount
58 * to let these frequently modified fields in a separate cache line 62 * to let these frequently modified fields in a separate cache line
@@ -62,6 +66,11 @@ struct vfsmount {
62 int mnt_expiry_mark; /* true if marked for expiry */ 66 int mnt_expiry_mark; /* true if marked for expiry */
63 int mnt_pinned; 67 int mnt_pinned;
64 int mnt_ghosts; 68 int mnt_ghosts;
69 /*
70 * This value is not stable unless all of the mnt_writers[] spinlocks
71 * are held, and all mnt_writer[]s on this mount have 0 as their ->count
72 */
73 atomic_t __mnt_writers;
65}; 74};
66 75
67static inline struct vfsmount *mntget(struct vfsmount *mnt) 76static inline struct vfsmount *mntget(struct vfsmount *mnt)
@@ -71,9 +80,12 @@ static inline struct vfsmount *mntget(struct vfsmount *mnt)
71 return mnt; 80 return mnt;
72} 81}
73 82
83extern int mnt_want_write(struct vfsmount *mnt);
84extern void mnt_drop_write(struct vfsmount *mnt);
74extern void mntput_no_expire(struct vfsmount *mnt); 85extern void mntput_no_expire(struct vfsmount *mnt);
75extern void mnt_pin(struct vfsmount *mnt); 86extern void mnt_pin(struct vfsmount *mnt);
76extern void mnt_unpin(struct vfsmount *mnt); 87extern void mnt_unpin(struct vfsmount *mnt);
88extern int __mnt_is_readonly(struct vfsmount *mnt);
77 89
78static inline void mntput(struct vfsmount *mnt) 90static inline void mntput(struct vfsmount *mnt)
79{ 91{
@@ -83,8 +95,6 @@ static inline void mntput(struct vfsmount *mnt)
83 } 95 }
84} 96}
85 97
86extern void free_vfsmnt(struct vfsmount *mnt);
87extern struct vfsmount *alloc_vfsmnt(const char *name);
88extern struct vfsmount *do_kern_mount(const char *fstype, int flags, 98extern struct vfsmount *do_kern_mount(const char *fstype, int flags,
89 const char *name, void *data); 99 const char *name, void *data);
90 100
@@ -103,5 +113,4 @@ extern void mark_mounts_for_expiry(struct list_head *mounts);
103extern spinlock_t vfsmount_lock; 113extern spinlock_t vfsmount_lock;
104extern dev_t name_to_dev_t(char *name); 114extern dev_t name_to_dev_t(char *name);
105 115
106#endif
107#endif /* _LINUX_MOUNT_H */ 116#endif /* _LINUX_MOUNT_H */
diff --git a/include/linux/mroute.h b/include/linux/mroute.h
index 35a8277ec1bd..de4decfa1bfc 100644
--- a/include/linux/mroute.h
+++ b/include/linux/mroute.h
@@ -2,7 +2,11 @@
2#define __LINUX_MROUTE_H 2#define __LINUX_MROUTE_H
3 3
4#include <linux/sockios.h> 4#include <linux/sockios.h>
5#include <linux/types.h>
6#ifdef __KERNEL__
5#include <linux/in.h> 7#include <linux/in.h>
8#endif
9#include <linux/pim.h>
6 10
7/* 11/*
8 * Based on the MROUTING 3.5 defines primarily to keep 12 * Based on the MROUTING 3.5 defines primarily to keep
@@ -210,27 +214,6 @@ struct mfc_cache
210#define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */ 214#define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
211 215
212#ifdef __KERNEL__ 216#ifdef __KERNEL__
213
214#define PIM_V1_VERSION __constant_htonl(0x10000000)
215#define PIM_V1_REGISTER 1
216
217#define PIM_VERSION 2
218#define PIM_REGISTER 1
219
220#define PIM_NULL_REGISTER __constant_htonl(0x40000000)
221
222/* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
223
224struct pimreghdr
225{
226 __u8 type;
227 __u8 reserved;
228 __be16 csum;
229 __be32 flags;
230};
231
232extern int pim_rcv_v1(struct sk_buff *);
233
234struct rtmsg; 217struct rtmsg;
235extern int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait); 218extern int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait);
236#endif 219#endif
diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h
new file mode 100644
index 000000000000..e7989593142b
--- /dev/null
+++ b/include/linux/mroute6.h
@@ -0,0 +1,228 @@
1#ifndef __LINUX_MROUTE6_H
2#define __LINUX_MROUTE6_H
3
4#include <linux/types.h>
5#include <linux/sockios.h>
6
7/*
8 * Based on the MROUTING 3.5 defines primarily to keep
9 * source compatibility with BSD.
10 *
11 * See the pim6sd code for the original history.
12 *
13 * Protocol Independent Multicast (PIM) data structures included
14 * Carlos Picoto (cap@di.fc.ul.pt)
15 *
16 */
17
18#define MRT6_BASE 200
19#define MRT6_INIT (MRT6_BASE) /* Activate the kernel mroute code */
20#define MRT6_DONE (MRT6_BASE+1) /* Shutdown the kernel mroute */
21#define MRT6_ADD_MIF (MRT6_BASE+2) /* Add a virtual interface */
22#define MRT6_DEL_MIF (MRT6_BASE+3) /* Delete a virtual interface */
23#define MRT6_ADD_MFC (MRT6_BASE+4) /* Add a multicast forwarding entry */
24#define MRT6_DEL_MFC (MRT6_BASE+5) /* Delete a multicast forwarding entry */
25#define MRT6_VERSION (MRT6_BASE+6) /* Get the kernel multicast version */
26#define MRT6_ASSERT (MRT6_BASE+7) /* Activate PIM assert mode */
27#define MRT6_PIM (MRT6_BASE+8) /* enable PIM code */
28
29#define SIOCGETMIFCNT_IN6 SIOCPROTOPRIVATE /* IP protocol privates */
30#define SIOCGETSGCNT_IN6 (SIOCPROTOPRIVATE+1)
31#define SIOCGETRPF (SIOCPROTOPRIVATE+2)
32
33#define MAXMIFS 32
34typedef unsigned long mifbitmap_t; /* User mode code depends on this lot */
35typedef unsigned short mifi_t;
36#define ALL_MIFS ((mifi_t)(-1))
37
38#ifndef IF_SETSIZE
39#define IF_SETSIZE 256
40#endif
41
42typedef __u32 if_mask;
43#define NIFBITS (sizeof(if_mask) * 8) /* bits per mask */
44
45#if !defined(__KERNEL__) && !defined(DIV_ROUND_UP)
46#define DIV_ROUND_UP(x,y) (((x) + ((y) - 1)) / (y))
47#endif
48
49typedef struct if_set {
50 if_mask ifs_bits[DIV_ROUND_UP(IF_SETSIZE, NIFBITS)];
51} if_set;
52
53#define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
54#define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
55#define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
56#define IF_COPY(f, t) bcopy(f, t, sizeof(*(f)))
57#define IF_ZERO(p) bzero(p, sizeof(*(p)))
58
59/*
60 * Passed by mrouted for an MRT_ADD_MIF - again we use the
61 * mrouted 3.6 structures for compatibility
62 */
63
64struct mif6ctl {
65 mifi_t mif6c_mifi; /* Index of MIF */
66 unsigned char mif6c_flags; /* MIFF_ flags */
67 unsigned char vifc_threshold; /* ttl limit */
68 u_short mif6c_pifi; /* the index of the physical IF */
69 unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
70};
71
72#define MIFF_REGISTER 0x1 /* register vif */
73
74/*
75 * Cache manipulation structures for mrouted and PIMd
76 */
77
78struct mf6cctl
79{
80 struct sockaddr_in6 mf6cc_origin; /* Origin of mcast */
81 struct sockaddr_in6 mf6cc_mcastgrp; /* Group in question */
82 mifi_t mf6cc_parent; /* Where it arrived */
83 struct if_set mf6cc_ifset; /* Where it is going */
84};
85
86/*
87 * Group count retrieval for pim6sd
88 */
89
90struct sioc_sg_req6
91{
92 struct sockaddr_in6 src;
93 struct sockaddr_in6 grp;
94 unsigned long pktcnt;
95 unsigned long bytecnt;
96 unsigned long wrong_if;
97};
98
99/*
100 * To get vif packet counts
101 */
102
103struct sioc_mif_req6
104{
105 mifi_t mifi; /* Which iface */
106 unsigned long icount; /* In packets */
107 unsigned long ocount; /* Out packets */
108 unsigned long ibytes; /* In bytes */
109 unsigned long obytes; /* Out bytes */
110};
111
112/*
113 * That's all usermode folks
114 */
115
116#ifdef __KERNEL__
117
118#include <linux/skbuff.h> /* for struct sk_buff_head */
119
120#ifdef CONFIG_IPV6_MROUTE
121static inline int ip6_mroute_opt(int opt)
122{
123 return (opt >= MRT6_BASE) && (opt <= MRT6_BASE + 10);
124}
125#else
126static inline int ip6_mroute_opt(int opt)
127{
128 return 0;
129}
130#endif
131
132struct sock;
133
134extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, int);
135extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
136extern int ip6_mr_input(struct sk_buff *skb);
137extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
138extern void ip6_mr_init(void);
139
140struct mif_device
141{
142 struct net_device *dev; /* Device we are using */
143 unsigned long bytes_in,bytes_out;
144 unsigned long pkt_in,pkt_out; /* Statistics */
145 unsigned long rate_limit; /* Traffic shaping (NI) */
146 unsigned char threshold; /* TTL threshold */
147 unsigned short flags; /* Control flags */
148 int link; /* Physical interface index */
149};
150
151#define VIFF_STATIC 0x8000
152
153struct mfc6_cache
154{
155 struct mfc6_cache *next; /* Next entry on cache line */
156 struct in6_addr mf6c_mcastgrp; /* Group the entry belongs to */
157 struct in6_addr mf6c_origin; /* Source of packet */
158 mifi_t mf6c_parent; /* Source interface */
159 int mfc_flags; /* Flags on line */
160
161 union {
162 struct {
163 unsigned long expires;
164 struct sk_buff_head unresolved; /* Unresolved buffers */
165 } unres;
166 struct {
167 unsigned long last_assert;
168 int minvif;
169 int maxvif;
170 unsigned long bytes;
171 unsigned long pkt;
172 unsigned long wrong_if;
173 unsigned char ttls[MAXMIFS]; /* TTL thresholds */
174 } res;
175 } mfc_un;
176};
177
178#define MFC_STATIC 1
179#define MFC_NOTIFY 2
180
181#define MFC6_LINES 64
182
183#define MFC6_HASH(a, g) (((__force u32)(a)->s6_addr32[0] ^ \
184 (__force u32)(a)->s6_addr32[1] ^ \
185 (__force u32)(a)->s6_addr32[2] ^ \
186 (__force u32)(a)->s6_addr32[3] ^ \
187 (__force u32)(g)->s6_addr32[0] ^ \
188 (__force u32)(g)->s6_addr32[1] ^ \
189 (__force u32)(g)->s6_addr32[2] ^ \
190 (__force u32)(g)->s6_addr32[3]) % MFC6_LINES)
191
192#define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
193
194#endif
195
196#ifdef __KERNEL__
197struct rtmsg;
198extern int ip6mr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait);
199
200#ifdef CONFIG_IPV6_MROUTE
201extern struct sock *mroute6_socket;
202extern int ip6mr_sk_done(struct sock *sk);
203#else
204#define mroute6_socket NULL
205static inline int ip6mr_sk_done(struct sock *sk) { return 0; }
206#endif
207#endif
208
209/*
210 * Structure used to communicate from kernel to multicast router.
211 * We'll overlay the structure onto an MLD header (not an IPv6 heder like igmpmsg{}
212 * used for IPv4 implementation). This is because this structure will be passed via an
213 * IPv6 raw socket, on wich an application will only receiver the payload i.e the data after
214 * the IPv6 header and all the extension headers. (See section 3 of RFC 3542)
215 */
216
217struct mrt6msg {
218#define MRT6MSG_NOCACHE 1
219#define MRT6MSG_WRONGMIF 2
220#define MRT6MSG_WHOLEPKT 3 /* used for use level encap */
221 __u8 im6_mbz; /* must be zero */
222 __u8 im6_msgtype; /* what type of message */
223 __u16 im6_mif; /* mif rec'd on */
224 __u32 im6_pad; /* padding for 64 bit arch */
225 struct in6_addr im6_src, im6_dst;
226};
227
228#endif
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index f950921523f5..b03b27457413 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -58,7 +58,11 @@
58#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */ 58#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */
59 59
60/* media of boot sector */ 60/* media of boot sector */
61#define FAT_VALID_MEDIA(x) ((0xF8 <= (x) && (x) <= 0xFF) || (x) == 0xF0) 61static inline int fat_valid_media(u8 media)
62{
63 return 0xf8 <= media || media == 0xf0;
64}
65
62#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \ 66#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
63 MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x)) 67 MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
64 68
@@ -195,6 +199,7 @@ struct fat_mount_options {
195 char *iocharset; /* Charset used for filename input/display */ 199 char *iocharset; /* Charset used for filename input/display */
196 unsigned short shortname; /* flags for shortname display/create rule */ 200 unsigned short shortname; /* flags for shortname display/create rule */
197 unsigned char name_check; /* r = relaxed, n = normal, s = strict */ 201 unsigned char name_check; /* r = relaxed, n = normal, s = strict */
202 unsigned short allow_utime;/* permission for setting the [am]time */
198 unsigned quiet:1, /* set = fake successful chmods and chowns */ 203 unsigned quiet:1, /* set = fake successful chmods and chowns */
199 showexec:1, /* set = only set x bit for com/exe/bat */ 204 showexec:1, /* set = only set x bit for com/exe/bat */
200 sys_immutable:1, /* set = system files are immutable */ 205 sys_immutable:1, /* set = system files are immutable */
@@ -232,6 +237,7 @@ struct msdos_sb_info {
232 struct mutex fat_lock; 237 struct mutex fat_lock;
233 unsigned int prev_free; /* previously allocated cluster number */ 238 unsigned int prev_free; /* previously allocated cluster number */
234 unsigned int free_clusters; /* -1 if undefined */ 239 unsigned int free_clusters; /* -1 if undefined */
240 unsigned int free_clus_valid; /* is free_clusters valid? */
235 struct fat_mount_options options; 241 struct fat_mount_options options;
236 struct nls_table *nls_disk; /* Codepage used on disk */ 242 struct nls_table *nls_disk; /* Codepage used on disk */
237 struct nls_table *nls_io; /* Charset used for input and display */ 243 struct nls_table *nls_io; /* Charset used for input and display */
@@ -401,7 +407,7 @@ extern int fat_generic_ioctl(struct inode *inode, struct file *filp,
401 unsigned int cmd, unsigned long arg); 407 unsigned int cmd, unsigned long arg);
402extern const struct file_operations fat_file_operations; 408extern const struct file_operations fat_file_operations;
403extern const struct inode_operations fat_file_inode_operations; 409extern const struct inode_operations fat_file_inode_operations;
404extern int fat_notify_change(struct dentry * dentry, struct iattr * attr); 410extern int fat_setattr(struct dentry * dentry, struct iattr * attr);
405extern void fat_truncate(struct inode *inode); 411extern void fat_truncate(struct inode *inode);
406extern int fat_getattr(struct vfsmount *mnt, struct dentry *dentry, 412extern int fat_getattr(struct vfsmount *mnt, struct dentry *dentry,
407 struct kstat *stat); 413 struct kstat *stat);
diff --git a/include/linux/msg.h b/include/linux/msg.h
index 10a3d5a1abff..6f3b8e79a991 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -49,16 +49,26 @@ struct msginfo {
49 unsigned short msgseg; 49 unsigned short msgseg;
50}; 50};
51 51
52/*
53 * Scaling factor to compute msgmni:
54 * the memory dedicated to msg queues (msgmni * msgmnb) should occupy
55 * at most 1/MSG_MEM_SCALE of the lowmem (see the formula in ipc/msg.c):
56 * up to 8MB : msgmni = 16 (MSGMNI)
57 * 4 GB : msgmni = 8K
58 * more than 16 GB : msgmni = 32K (IPCMNI)
59 */
60#define MSG_MEM_SCALE 32
61
52#define MSGMNI 16 /* <= IPCMNI */ /* max # of msg queue identifiers */ 62#define MSGMNI 16 /* <= IPCMNI */ /* max # of msg queue identifiers */
53#define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */ 63#define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */
54#define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */ 64#define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */
55 65
56/* unused */ 66/* unused */
57#define MSGPOOL (MSGMNI*MSGMNB/1024) /* size in kilobytes of message pool */ 67#define MSGPOOL (MSGMNI * MSGMNB) /* size in bytes of message pool */
58#define MSGTQL MSGMNB /* number of system message headers */ 68#define MSGTQL MSGMNB /* number of system message headers */
59#define MSGMAP MSGMNB /* number of entries in message map */ 69#define MSGMAP MSGMNB /* number of entries in message map */
60#define MSGSSZ 16 /* message segment size */ 70#define MSGSSZ 16 /* message segment size */
61#define __MSGSEG ((MSGPOOL*1024)/ MSGSSZ) /* max no. of segments */ 71#define __MSGSEG (MSGPOOL / MSGSSZ) /* max no. of segments */
62#define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff) 72#define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
63 73
64#ifdef __KERNEL__ 74#ifdef __KERNEL__
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 94bb46d82efd..8f2939227207 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -22,6 +22,7 @@ struct msi_desc {
22 __u8 masked : 1; 22 __u8 masked : 1;
23 __u8 is_64 : 1; /* Address size: 0=32bit 1=64bit */ 23 __u8 is_64 : 1; /* Address size: 0=32bit 1=64bit */
24 __u8 pos; /* Location of the msi capability */ 24 __u8 pos; /* Location of the msi capability */
25 __u32 maskbits_mask; /* mask bits mask */
25 __u16 entry_nr; /* specific enabled entry */ 26 __u16 entry_nr; /* specific enabled entry */
26 unsigned default_irq; /* default pre-assigned irq */ 27 unsigned default_irq; /* default pre-assigned irq */
27 }msi_attrib; 28 }msi_attrib;
diff --git a/include/linux/mtd/inftl.h b/include/linux/mtd/inftl.h
index 6977780e548f..85fd041d44ad 100644
--- a/include/linux/mtd/inftl.h
+++ b/include/linux/mtd/inftl.h
@@ -57,6 +57,11 @@ extern char inftlmountrev[];
57void INFTL_dumptables(struct INFTLrecord *s); 57void INFTL_dumptables(struct INFTLrecord *s);
58void INFTL_dumpVUchains(struct INFTLrecord *s); 58void INFTL_dumpVUchains(struct INFTLrecord *s);
59 59
60int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
61 size_t *retlen, uint8_t *buf);
62int inftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
63 size_t *retlen, uint8_t *buf);
64
60#endif /* __KERNEL__ */ 65#endif /* __KERNEL__ */
61 66
62#endif /* __MTD_INFTL_H__ */ 67#endif /* __MTD_INFTL_H__ */
diff --git a/include/linux/mtd/jedec.h b/include/linux/mtd/jedec.h
deleted file mode 100644
index 9006feb218b9..000000000000
--- a/include/linux/mtd/jedec.h
+++ /dev/null
@@ -1,66 +0,0 @@
1
2/* JEDEC Flash Interface.
3 * This is an older type of interface for self programming flash. It is
4 * commonly use in older AMD chips and is obsolete compared with CFI.
5 * It is called JEDEC because the JEDEC association distributes the ID codes
6 * for the chips.
7 *
8 * See the AMD flash databook for information on how to operate the interface.
9 *
10 * $Id: jedec.h,v 1.4 2005/11/07 11:14:54 gleixner Exp $
11 */
12
13#ifndef __LINUX_MTD_JEDEC_H__
14#define __LINUX_MTD_JEDEC_H__
15
16#include <linux/types.h>
17
18#define MAX_JEDEC_CHIPS 16
19
20// Listing of all supported chips and their information
21struct JEDECTable
22{
23 __u16 jedec;
24 char *name;
25 unsigned long size;
26 unsigned long sectorsize;
27 __u32 capabilities;
28};
29
30// JEDEC being 0 is the end of the chip array
31struct jedec_flash_chip
32{
33 __u16 jedec;
34 unsigned long size;
35 unsigned long sectorsize;
36
37 // *(__u8*)(base + (adder << addrshift)) = data << datashift
38 // Address size = size << addrshift
39 unsigned long base; // Byte 0 of the flash, will be unaligned
40 unsigned int datashift; // Useful for 32bit/16bit accesses
41 unsigned int addrshift;
42 unsigned long offset; // linerized start. base==offset for unbanked, uninterleaved flash
43
44 __u32 capabilities;
45
46 // These markers are filled in by the flash_chip_scan function
47 unsigned long start;
48 unsigned long length;
49};
50
51struct jedec_private
52{
53 unsigned long size; // Total size of all the devices
54
55 /* Bank handling. If sum(bank_fill) == size then this is linear flash.
56 Otherwise the mapping has holes in it. bank_fill may be used to
57 find the holes, but in the common symetric case
58 bank_fill[0] == bank_fill[*], thus addresses may be computed
59 mathmatically. bank_fill must be powers of two */
60 unsigned is_banked;
61 unsigned long bank_fill[MAX_JEDEC_CHIPS];
62
63 struct jedec_flash_chip chips[MAX_JEDEC_CHIPS];
64};
65
66#endif
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 0a13bb35f044..245f9098e171 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -143,10 +143,12 @@ struct mtd_info {
143 int (*erase) (struct mtd_info *mtd, struct erase_info *instr); 143 int (*erase) (struct mtd_info *mtd, struct erase_info *instr);
144 144
145 /* This stuff for eXecute-In-Place */ 145 /* This stuff for eXecute-In-Place */
146 int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf); 146 /* phys is optional and may be set to NULL */
147 int (*point) (struct mtd_info *mtd, loff_t from, size_t len,
148 size_t *retlen, void **virt, resource_size_t *phys);
147 149
148 /* We probably shouldn't allow XIP if the unpoint isn't a NULL */ 150 /* We probably shouldn't allow XIP if the unpoint isn't a NULL */
149 void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len); 151 void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
150 152
151 153
152 int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); 154 int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
diff --git a/include/linux/mtd/nftl.h b/include/linux/mtd/nftl.h
index bcf2fb3fa4a7..001eec50cac6 100644
--- a/include/linux/mtd/nftl.h
+++ b/include/linux/mtd/nftl.h
@@ -43,6 +43,11 @@ struct NFTLrecord {
43int NFTL_mount(struct NFTLrecord *s); 43int NFTL_mount(struct NFTLrecord *s);
44int NFTL_formatblock(struct NFTLrecord *s, int block); 44int NFTL_formatblock(struct NFTLrecord *s, int block);
45 45
46int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
47 size_t *retlen, uint8_t *buf);
48int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
49 size_t *retlen, uint8_t *buf);
50
46#ifndef NFTL_MAJOR 51#ifndef NFTL_MAJOR
47#define NFTL_MAJOR 93 52#define NFTL_MAJOR 93
48#endif 53#endif
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h
index fd0a260e070b..9aa2a9149b58 100644
--- a/include/linux/mtd/onenand.h
+++ b/include/linux/mtd/onenand.h
@@ -187,4 +187,7 @@ struct onenand_manufacturers {
187 char *name; 187 char *name;
188}; 188};
189 189
190int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from,
191 struct mtd_oob_ops *ops);
192
190#endif /* __LINUX_MTD_ONENAND_H */ 193#endif /* __LINUX_MTD_ONENAND_H */
diff --git a/include/linux/mtd/plat-ram.h b/include/linux/mtd/plat-ram.h
index 9667863bd7e3..0e37ad07bce2 100644
--- a/include/linux/mtd/plat-ram.h
+++ b/include/linux/mtd/plat-ram.h
@@ -21,8 +21,9 @@
21#define PLATRAM_RW (1) 21#define PLATRAM_RW (1)
22 22
23struct platdata_mtd_ram { 23struct platdata_mtd_ram {
24 char *mapname; 24 const char *mapname;
25 char **probes; 25 const char **map_probes;
26 const char **probes;
26 struct mtd_partition *partitions; 27 struct mtd_partition *partitions;
27 int nr_partitions; 28 int nr_partitions;
28 int bankwidth; 29 int bankwidth;
diff --git a/include/linux/mtd/pmc551.h b/include/linux/mtd/pmc551.h
index a7f6d20ad407..5cc070c24d88 100644
--- a/include/linux/mtd/pmc551.h
+++ b/include/linux/mtd/pmc551.h
@@ -36,8 +36,9 @@ struct mypriv {
36 * Function Prototypes 36 * Function Prototypes
37 */ 37 */
38static int pmc551_erase(struct mtd_info *, struct erase_info *); 38static int pmc551_erase(struct mtd_info *, struct erase_info *);
39static void pmc551_unpoint(struct mtd_info *, u_char *, loff_t, size_t); 39static void pmc551_unpoint(struct mtd_info *, loff_t, size_t);
40static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf); 40static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
41 size_t *retlen, void **virt, resource_size_t *phys);
41static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); 42static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
42static int pmc551_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 43static int pmc551_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
43 44
diff --git a/include/linux/mtio.h b/include/linux/mtio.h
index 6f8d2d45a8fb..ef01d6aa5934 100644
--- a/include/linux/mtio.h
+++ b/include/linux/mtio.h
@@ -192,6 +192,7 @@ struct mtpos {
192#define MT_ST_SCSI2LOGICAL 0x800 192#define MT_ST_SCSI2LOGICAL 0x800
193#define MT_ST_SYSV 0x1000 193#define MT_ST_SYSV 0x1000
194#define MT_ST_NOWAIT 0x2000 194#define MT_ST_NOWAIT 0x2000
195#define MT_ST_SILI 0x4000
195 196
196/* The mode parameters to be controlled. Parameter chosen with bits 20-28 */ 197/* The mode parameters to be controlled. Parameter chosen with bits 20-28 */
197#define MT_ST_CLEAR_DEFAULT 0xfffff 198#define MT_ST_CLEAR_DEFAULT 0xfffff
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index 986572081e19..155719dab813 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -56,9 +56,11 @@ struct nbd_device {
56 int magic; 56 int magic;
57 57
58 spinlock_t queue_lock; 58 spinlock_t queue_lock;
59 struct list_head queue_head;/* Requests are added here... */ 59 struct list_head queue_head; /* Requests waiting result */
60 struct request *active_req; 60 struct request *active_req;
61 wait_queue_head_t active_wq; 61 wait_queue_head_t active_wq;
62 struct list_head waiting_queue; /* Requests to be sent */
63 wait_queue_head_t waiting_wq;
62 64
63 struct mutex tx_lock; 65 struct mutex tx_lock;
64 struct gendisk *disk; 66 struct gendisk *disk;
@@ -86,11 +88,7 @@ struct nbd_request {
86 char handle[8]; 88 char handle[8];
87 __be64 from; 89 __be64 from;
88 __be32 len; 90 __be32 len;
89} 91} __attribute__ ((packed));
90#ifdef __GNUC__
91 __attribute__ ((packed))
92#endif
93;
94 92
95/* 93/*
96 * This is the reply packet that nbd-server sends back to the client after 94 * This is the reply packet that nbd-server sends back to the client after
diff --git a/include/linux/ncp_fs.h b/include/linux/ncp_fs.h
index 88766e43e121..9f2d76347f19 100644
--- a/include/linux/ncp_fs.h
+++ b/include/linux/ncp_fs.h
@@ -204,6 +204,7 @@ void ncp_update_inode2(struct inode *, struct ncp_entry_info *);
204/* linux/fs/ncpfs/dir.c */ 204/* linux/fs/ncpfs/dir.c */
205extern const struct inode_operations ncp_dir_inode_operations; 205extern const struct inode_operations ncp_dir_inode_operations;
206extern const struct file_operations ncp_dir_operations; 206extern const struct file_operations ncp_dir_operations;
207extern struct dentry_operations ncp_root_dentry_operations;
207int ncp_conn_logged_in(struct super_block *); 208int ncp_conn_logged_in(struct super_block *);
208int ncp_date_dos2unix(__le16 time, __le16 date); 209int ncp_date_dos2unix(__le16 time, __le16 date);
209void ncp_date_unix2dos(int unix_date, __le16 * time, __le16 * date); 210void ncp_date_unix2dos(int unix_date, __le16 * time, __le16 * date);
@@ -223,6 +224,12 @@ int ncp_disconnect(struct ncp_server *server);
223void ncp_lock_server(struct ncp_server *server); 224void ncp_lock_server(struct ncp_server *server);
224void ncp_unlock_server(struct ncp_server *server); 225void ncp_unlock_server(struct ncp_server *server);
225 226
227/* linux/fs/ncpfs/symlink.c */
228#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
229extern const struct address_space_operations ncp_symlink_aops;
230int ncp_symlink(struct inode*, struct dentry*, const char*);
231#endif
232
226/* linux/fs/ncpfs/file.c */ 233/* linux/fs/ncpfs/file.c */
227extern const struct inode_operations ncp_file_inode_operations; 234extern const struct inode_operations ncp_file_inode_operations;
228extern const struct file_operations ncp_file_operations; 235extern const struct file_operations ncp_file_operations;
diff --git a/include/linux/ncp_fs_i.h b/include/linux/ncp_fs_i.h
index bdb4c8ae6924..4b0bec477846 100644
--- a/include/linux/ncp_fs_i.h
+++ b/include/linux/ncp_fs_i.h
@@ -8,8 +8,6 @@
8#ifndef _LINUX_NCP_FS_I 8#ifndef _LINUX_NCP_FS_I
9#define _LINUX_NCP_FS_I 9#define _LINUX_NCP_FS_I
10 10
11#ifdef __KERNEL__
12
13/* 11/*
14 * This is the ncpfs part of the inode structure. This must contain 12 * This is the ncpfs part of the inode structure. This must contain
15 * all the information we need to work with an inode after creation. 13 * all the information we need to work with an inode after creation.
@@ -28,6 +26,4 @@ struct ncp_inode_info {
28 struct inode vfs_inode; 26 struct inode vfs_inode;
29}; 27};
30 28
31#endif /* __KERNEL__ */
32
33#endif /* _LINUX_NCP_FS_I */ 29#endif /* _LINUX_NCP_FS_I */
diff --git a/include/linux/net.h b/include/linux/net.h
index c414d90e647b..71f7dd559285 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -19,6 +19,7 @@
19#define _LINUX_NET_H 19#define _LINUX_NET_H
20 20
21#include <linux/wait.h> 21#include <linux/wait.h>
22#include <linux/socket.h>
22#include <asm/socket.h> 23#include <asm/socket.h>
23 24
24struct poll_table_struct; 25struct poll_table_struct;
@@ -26,7 +27,7 @@ struct pipe_inode_info;
26struct inode; 27struct inode;
27struct net; 28struct net;
28 29
29#define NPROTO 34 /* should be enough for now.. */ 30#define NPROTO AF_MAX
30 31
31#define SYS_SOCKET 1 /* sys_socket(2) */ 32#define SYS_SOCKET 1 /* sys_socket(2) */
32#define SYS_BIND 2 /* sys_bind(2) */ 33#define SYS_BIND 2 /* sys_bind(2) */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ee81906b5164..7c1d4466583b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -710,8 +710,10 @@ struct net_device
710 void (*poll_controller)(struct net_device *dev); 710 void (*poll_controller)(struct net_device *dev);
711#endif 711#endif
712 712
713#ifdef CONFIG_NET_NS
713 /* Network namespace this network device is inside */ 714 /* Network namespace this network device is inside */
714 struct net *nd_net; 715 struct net *nd_net;
716#endif
715 717
716 /* bridge stuff */ 718 /* bridge stuff */
717 struct net_bridge_port *br_port; 719 struct net_bridge_port *br_port;
@@ -726,6 +728,10 @@ struct net_device
726 /* rtnetlink link ops */ 728 /* rtnetlink link ops */
727 const struct rtnl_link_ops *rtnl_link_ops; 729 const struct rtnl_link_ops *rtnl_link_ops;
728 730
731 /* for setting kernel sock attribute on TCP connection setup */
732#define GSO_MAX_SIZE 65536
733 unsigned int gso_max_size;
734
729 /* The TX queue control structures */ 735 /* The TX queue control structures */
730 unsigned int egress_subqueue_count; 736 unsigned int egress_subqueue_count;
731 struct net_device_subqueue egress_subqueue[1]; 737 struct net_device_subqueue egress_subqueue[1];
@@ -735,6 +741,28 @@ struct net_device
735#define NETDEV_ALIGN 32 741#define NETDEV_ALIGN 32
736#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) 742#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
737 743
744/*
745 * Net namespace inlines
746 */
747static inline
748struct net *dev_net(const struct net_device *dev)
749{
750#ifdef CONFIG_NET_NS
751 return dev->nd_net;
752#else
753 return &init_net;
754#endif
755}
756
757static inline
758void dev_net_set(struct net_device *dev, struct net *net)
759{
760#ifdef CONFIG_NET_NS
761 release_net(dev->nd_net);
762 dev->nd_net = hold_net(net);
763#endif
764}
765
738/** 766/**
739 * netdev_priv - access network device private data 767 * netdev_priv - access network device private data
740 * @dev: network device 768 * @dev: network device
@@ -811,7 +839,7 @@ static inline struct net_device *next_net_device(struct net_device *dev)
811 struct list_head *lh; 839 struct list_head *lh;
812 struct net *net; 840 struct net *net;
813 841
814 net = dev->nd_net; 842 net = dev_net(dev);
815 lh = dev->dev_list.next; 843 lh = dev->dev_list.next;
816 return lh == &net->dev_base_head ? NULL : net_device_entry(lh); 844 return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
817} 845}
@@ -1479,6 +1507,12 @@ static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
1479 unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); 1507 unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
1480} 1508}
1481 1509
1510static inline void netif_set_gso_max_size(struct net_device *dev,
1511 unsigned int size)
1512{
1513 dev->gso_max_size = size;
1514}
1515
1482/* On bonding slaves other than the currently active slave, suppress 1516/* On bonding slaves other than the currently active slave, suppress
1483 * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and 1517 * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and
1484 * ARP on active-backup slaves with arp_validate enabled. 1518 * ARP on active-backup slaves with arp_validate enabled.
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index f0680c2bee73..e4c66593b5c6 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -6,11 +6,13 @@
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/skbuff.h> 7#include <linux/skbuff.h>
8#include <linux/net.h> 8#include <linux/net.h>
9#include <linux/netdevice.h>
9#include <linux/if.h> 10#include <linux/if.h>
10#include <linux/in.h> 11#include <linux/in.h>
11#include <linux/in6.h> 12#include <linux/in6.h>
12#include <linux/wait.h> 13#include <linux/wait.h>
13#include <linux/list.h> 14#include <linux/list.h>
15#include <net/net_namespace.h>
14#endif 16#endif
15#include <linux/compiler.h> 17#include <linux/compiler.h>
16 18
@@ -61,13 +63,21 @@ union nf_inet_addr {
61#ifdef __KERNEL__ 63#ifdef __KERNEL__
62#ifdef CONFIG_NETFILTER 64#ifdef CONFIG_NETFILTER
63 65
66static inline int nf_inet_addr_cmp(const union nf_inet_addr *a1,
67 const union nf_inet_addr *a2)
68{
69 return a1->all[0] == a2->all[0] &&
70 a1->all[1] == a2->all[1] &&
71 a1->all[2] == a2->all[2] &&
72 a1->all[3] == a2->all[3];
73}
74
64extern void netfilter_init(void); 75extern void netfilter_init(void);
65 76
66/* Largest hook number + 1 */ 77/* Largest hook number + 1 */
67#define NF_MAX_HOOKS 8 78#define NF_MAX_HOOKS 8
68 79
69struct sk_buff; 80struct sk_buff;
70struct net_device;
71 81
72typedef unsigned int nf_hookfn(unsigned int hooknum, 82typedef unsigned int nf_hookfn(unsigned int hooknum,
73 struct sk_buff *skb, 83 struct sk_buff *skb,
@@ -224,6 +234,11 @@ struct nf_afinfo {
224 unsigned short family; 234 unsigned short family;
225 __sum16 (*checksum)(struct sk_buff *skb, unsigned int hook, 235 __sum16 (*checksum)(struct sk_buff *skb, unsigned int hook,
226 unsigned int dataoff, u_int8_t protocol); 236 unsigned int dataoff, u_int8_t protocol);
237 __sum16 (*checksum_partial)(struct sk_buff *skb,
238 unsigned int hook,
239 unsigned int dataoff,
240 unsigned int len,
241 u_int8_t protocol);
227 int (*route)(struct dst_entry **dst, struct flowi *fl); 242 int (*route)(struct dst_entry **dst, struct flowi *fl);
228 void (*saveroute)(const struct sk_buff *skb, 243 void (*saveroute)(const struct sk_buff *skb,
229 struct nf_queue_entry *entry); 244 struct nf_queue_entry *entry);
@@ -253,6 +268,23 @@ nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
253 return csum; 268 return csum;
254} 269}
255 270
271static inline __sum16
272nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
273 unsigned int dataoff, unsigned int len,
274 u_int8_t protocol, unsigned short family)
275{
276 const struct nf_afinfo *afinfo;
277 __sum16 csum = 0;
278
279 rcu_read_lock();
280 afinfo = nf_get_afinfo(family);
281 if (afinfo)
282 csum = afinfo->checksum_partial(skb, hook, dataoff, len,
283 protocol);
284 rcu_read_unlock();
285 return csum;
286}
287
256extern int nf_register_afinfo(const struct nf_afinfo *afinfo); 288extern int nf_register_afinfo(const struct nf_afinfo *afinfo);
257extern void nf_unregister_afinfo(const struct nf_afinfo *afinfo); 289extern void nf_unregister_afinfo(const struct nf_afinfo *afinfo);
258 290
@@ -311,5 +343,56 @@ extern void (*nf_ct_destroy)(struct nf_conntrack *);
311static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} 343static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
312#endif 344#endif
313 345
346static inline struct net *nf_pre_routing_net(const struct net_device *in,
347 const struct net_device *out)
348{
349#ifdef CONFIG_NET_NS
350 return in->nd_net;
351#else
352 return &init_net;
353#endif
354}
355
356static inline struct net *nf_local_in_net(const struct net_device *in,
357 const struct net_device *out)
358{
359#ifdef CONFIG_NET_NS
360 return in->nd_net;
361#else
362 return &init_net;
363#endif
364}
365
366static inline struct net *nf_forward_net(const struct net_device *in,
367 const struct net_device *out)
368{
369#ifdef CONFIG_NET_NS
370 BUG_ON(in->nd_net != out->nd_net);
371 return in->nd_net;
372#else
373 return &init_net;
374#endif
375}
376
377static inline struct net *nf_local_out_net(const struct net_device *in,
378 const struct net_device *out)
379{
380#ifdef CONFIG_NET_NS
381 return out->nd_net;
382#else
383 return &init_net;
384#endif
385}
386
387static inline struct net *nf_post_routing_net(const struct net_device *in,
388 const struct net_device *out)
389{
390#ifdef CONFIG_NET_NS
391 return out->nd_net;
392#else
393 return &init_net;
394#endif
395}
396
314#endif /*__KERNEL__*/ 397#endif /*__KERNEL__*/
315#endif /*__LINUX_NETFILTER_H*/ 398#endif /*__LINUX_NETFILTER_H*/
diff --git a/include/linux/netfilter/nf_conntrack_dccp.h b/include/linux/netfilter/nf_conntrack_dccp.h
new file mode 100644
index 000000000000..40dcc82058d1
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_dccp.h
@@ -0,0 +1,40 @@
1#ifndef _NF_CONNTRACK_DCCP_H
2#define _NF_CONNTRACK_DCCP_H
3
4/* Exposed to userspace over nfnetlink */
5enum ct_dccp_states {
6 CT_DCCP_NONE,
7 CT_DCCP_REQUEST,
8 CT_DCCP_RESPOND,
9 CT_DCCP_PARTOPEN,
10 CT_DCCP_OPEN,
11 CT_DCCP_CLOSEREQ,
12 CT_DCCP_CLOSING,
13 CT_DCCP_TIMEWAIT,
14 CT_DCCP_IGNORE,
15 CT_DCCP_INVALID,
16 __CT_DCCP_MAX
17};
18#define CT_DCCP_MAX (__CT_DCCP_MAX - 1)
19
20enum ct_dccp_roles {
21 CT_DCCP_ROLE_CLIENT,
22 CT_DCCP_ROLE_SERVER,
23 __CT_DCCP_ROLE_MAX
24};
25#define CT_DCCP_ROLE_MAX (__CT_DCCP_ROLE_MAX - 1)
26
27#ifdef __KERNEL__
28#include <net/netfilter/nf_conntrack_tuple.h>
29
30struct nf_ct_dccp {
31 u_int8_t role[IP_CT_DIR_MAX];
32 u_int8_t state;
33 u_int8_t last_pkt;
34 u_int8_t last_dir;
35 u_int64_t handshake_seq;
36};
37
38#endif /* __KERNEL__ */
39
40#endif /* _NF_CONNTRACK_DCCP_H */
diff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h
index 8e5ce1ca7bfc..5da04e586a3f 100644
--- a/include/linux/netfilter/nf_conntrack_sip.h
+++ b/include/linux/netfilter/nf_conntrack_sip.h
@@ -5,37 +5,164 @@
5#define SIP_PORT 5060 5#define SIP_PORT 5060
6#define SIP_TIMEOUT 3600 6#define SIP_TIMEOUT 3600
7 7
8enum sip_header_pos { 8struct nf_ct_sip_master {
9 POS_REG_REQ_URI, 9 unsigned int register_cseq;
10 POS_REQ_URI, 10};
11 POS_FROM, 11
12 POS_TO, 12enum sip_expectation_classes {
13 POS_VIA, 13 SIP_EXPECT_SIGNALLING,
14 POS_CONTACT, 14 SIP_EXPECT_AUDIO,
15 POS_CONTENT, 15 SIP_EXPECT_VIDEO,
16 POS_MEDIA, 16 __SIP_EXPECT_MAX
17 POS_OWNER_IP4, 17};
18 POS_CONNECTION_IP4, 18#define SIP_EXPECT_MAX (__SIP_EXPECT_MAX - 1)
19 POS_OWNER_IP6, 19
20 POS_CONNECTION_IP6, 20struct sdp_media_type {
21 POS_SDP_HEADER, 21 const char *name;
22 unsigned int len;
23 enum sip_expectation_classes class;
24};
25
26#define SDP_MEDIA_TYPE(__name, __class) \
27{ \
28 .name = (__name), \
29 .len = sizeof(__name) - 1, \
30 .class = (__class), \
31}
32
33struct sip_handler {
34 const char *method;
35 unsigned int len;
36 int (*request)(struct sk_buff *skb,
37 const char **dptr, unsigned int *datalen,
38 unsigned int cseq);
39 int (*response)(struct sk_buff *skb,
40 const char **dptr, unsigned int *datalen,
41 unsigned int cseq, unsigned int code);
42};
43
44#define SIP_HANDLER(__method, __request, __response) \
45{ \
46 .method = (__method), \
47 .len = sizeof(__method) - 1, \
48 .request = (__request), \
49 .response = (__response), \
50}
51
52struct sip_header {
53 const char *name;
54 const char *cname;
55 const char *search;
56 unsigned int len;
57 unsigned int clen;
58 unsigned int slen;
59 int (*match_len)(const struct nf_conn *ct,
60 const char *dptr, const char *limit,
61 int *shift);
62};
63
64#define __SIP_HDR(__name, __cname, __search, __match) \
65{ \
66 .name = (__name), \
67 .len = sizeof(__name) - 1, \
68 .cname = (__cname), \
69 .clen = (__cname) ? sizeof(__cname) - 1 : 0, \
70 .search = (__search), \
71 .slen = (__search) ? sizeof(__search) - 1 : 0, \
72 .match_len = (__match), \
73}
74
75#define SIP_HDR(__name, __cname, __search, __match) \
76 __SIP_HDR(__name, __cname, __search, __match)
77
78#define SDP_HDR(__name, __search, __match) \
79 __SIP_HDR(__name, NULL, __search, __match)
80
81enum sip_header_types {
82 SIP_HDR_CSEQ,
83 SIP_HDR_FROM,
84 SIP_HDR_TO,
85 SIP_HDR_CONTACT,
86 SIP_HDR_VIA,
87 SIP_HDR_EXPIRES,
88 SIP_HDR_CONTENT_LENGTH,
89};
90
91enum sdp_header_types {
92 SDP_HDR_UNSPEC,
93 SDP_HDR_VERSION,
94 SDP_HDR_OWNER_IP4,
95 SDP_HDR_CONNECTION_IP4,
96 SDP_HDR_OWNER_IP6,
97 SDP_HDR_CONNECTION_IP6,
98 SDP_HDR_MEDIA,
22}; 99};
23 100
24extern unsigned int (*nf_nat_sip_hook)(struct sk_buff *skb, 101extern unsigned int (*nf_nat_sip_hook)(struct sk_buff *skb,
25 enum ip_conntrack_info ctinfo, 102 const char **dptr,
26 struct nf_conn *ct, 103 unsigned int *datalen);
27 const char **dptr); 104extern unsigned int (*nf_nat_sip_expect_hook)(struct sk_buff *skb,
28extern unsigned int (*nf_nat_sdp_hook)(struct sk_buff *skb, 105 const char **dptr,
29 enum ip_conntrack_info ctinfo, 106 unsigned int *datalen,
30 struct nf_conntrack_expect *exp, 107 struct nf_conntrack_expect *exp,
31 const char *dptr); 108 unsigned int matchoff,
32 109 unsigned int matchlen);
33extern int ct_sip_get_info(const struct nf_conn *ct, const char *dptr, 110extern unsigned int (*nf_nat_sdp_addr_hook)(struct sk_buff *skb,
34 size_t dlen, unsigned int *matchoff, 111 const char **dptr,
35 unsigned int *matchlen, enum sip_header_pos pos); 112 unsigned int dataoff,
36extern int ct_sip_lnlen(const char *line, const char *limit); 113 unsigned int *datalen,
37extern const char *ct_sip_search(const char *needle, const char *haystack, 114 enum sdp_header_types type,
38 size_t needle_len, size_t haystack_len, 115 enum sdp_header_types term,
39 int case_sensitive); 116 const union nf_inet_addr *addr);
117extern unsigned int (*nf_nat_sdp_port_hook)(struct sk_buff *skb,
118 const char **dptr,
119 unsigned int *datalen,
120 unsigned int matchoff,
121 unsigned int matchlen,
122 u_int16_t port);
123extern unsigned int (*nf_nat_sdp_session_hook)(struct sk_buff *skb,
124 const char **dptr,
125 unsigned int dataoff,
126 unsigned int *datalen,
127 const union nf_inet_addr *addr);
128extern unsigned int (*nf_nat_sdp_media_hook)(struct sk_buff *skb,
129 const char **dptr,
130 unsigned int *datalen,
131 struct nf_conntrack_expect *rtp_exp,
132 struct nf_conntrack_expect *rtcp_exp,
133 unsigned int mediaoff,
134 unsigned int medialen,
135 union nf_inet_addr *rtp_addr);
136
137extern int ct_sip_parse_request(const struct nf_conn *ct,
138 const char *dptr, unsigned int datalen,
139 unsigned int *matchoff, unsigned int *matchlen,
140 union nf_inet_addr *addr, __be16 *port);
141extern int ct_sip_get_header(const struct nf_conn *ct, const char *dptr,
142 unsigned int dataoff, unsigned int datalen,
143 enum sip_header_types type,
144 unsigned int *matchoff, unsigned int *matchlen);
145extern int ct_sip_parse_header_uri(const struct nf_conn *ct, const char *dptr,
146 unsigned int *dataoff, unsigned int datalen,
147 enum sip_header_types type, int *in_header,
148 unsigned int *matchoff, unsigned int *matchlen,
149 union nf_inet_addr *addr, __be16 *port);
150extern int ct_sip_parse_address_param(const struct nf_conn *ct, const char *dptr,
151 unsigned int dataoff, unsigned int datalen,
152 const char *name,
153 unsigned int *matchoff, unsigned int *matchlen,
154 union nf_inet_addr *addr);
155extern int ct_sip_parse_numerical_param(const struct nf_conn *ct, const char *dptr,
156 unsigned int off, unsigned int datalen,
157 const char *name,
158 unsigned int *matchoff, unsigned int *matchen,
159 unsigned int *val);
160
161extern int ct_sip_get_sdp_header(const struct nf_conn *ct, const char *dptr,
162 unsigned int dataoff, unsigned int datalen,
163 enum sdp_header_types type,
164 enum sdp_header_types term,
165 unsigned int *matchoff, unsigned int *matchlen);
166
40#endif /* __KERNEL__ */ 167#endif /* __KERNEL__ */
41#endif /* __NF_CONNTRACK_SIP_H__ */ 168#endif /* __NF_CONNTRACK_SIP_H__ */
diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h
index e3e1533aba2d..0a383ac083cb 100644
--- a/include/linux/netfilter/nfnetlink_conntrack.h
+++ b/include/linux/netfilter/nfnetlink_conntrack.h
@@ -80,6 +80,7 @@ enum ctattr_l4proto {
80enum ctattr_protoinfo { 80enum ctattr_protoinfo {
81 CTA_PROTOINFO_UNSPEC, 81 CTA_PROTOINFO_UNSPEC,
82 CTA_PROTOINFO_TCP, 82 CTA_PROTOINFO_TCP,
83 CTA_PROTOINFO_DCCP,
83 __CTA_PROTOINFO_MAX 84 __CTA_PROTOINFO_MAX
84}; 85};
85#define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1) 86#define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1)
@@ -95,6 +96,13 @@ enum ctattr_protoinfo_tcp {
95}; 96};
96#define CTA_PROTOINFO_TCP_MAX (__CTA_PROTOINFO_TCP_MAX - 1) 97#define CTA_PROTOINFO_TCP_MAX (__CTA_PROTOINFO_TCP_MAX - 1)
97 98
99enum ctattr_protoinfo_dccp {
100 CTA_PROTOINFO_DCCP_UNSPEC,
101 CTA_PROTOINFO_DCCP_STATE,
102 __CTA_PROTOINFO_DCCP_MAX,
103};
104#define CTA_PROTOINFO_DCCP_MAX (__CTA_PROTOINFO_DCCP_MAX - 1)
105
98enum ctattr_counters { 106enum ctattr_counters {
99 CTA_COUNTERS_UNSPEC, 107 CTA_COUNTERS_UNSPEC,
100 CTA_COUNTERS_PACKETS, /* old 64bit counters */ 108 CTA_COUNTERS_PACKETS, /* old 64bit counters */
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index b2c62cc618f5..2326296b6f25 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -430,13 +430,13 @@ extern int xt_compat_add_offset(int af, unsigned int offset, short delta);
430extern void xt_compat_flush_offsets(int af); 430extern void xt_compat_flush_offsets(int af);
431extern short xt_compat_calc_jump(int af, unsigned int offset); 431extern short xt_compat_calc_jump(int af, unsigned int offset);
432 432
433extern int xt_compat_match_offset(struct xt_match *match); 433extern int xt_compat_match_offset(const struct xt_match *match);
434extern int xt_compat_match_from_user(struct xt_entry_match *m, 434extern int xt_compat_match_from_user(struct xt_entry_match *m,
435 void **dstptr, unsigned int *size); 435 void **dstptr, unsigned int *size);
436extern int xt_compat_match_to_user(struct xt_entry_match *m, 436extern int xt_compat_match_to_user(struct xt_entry_match *m,
437 void __user **dstptr, unsigned int *size); 437 void __user **dstptr, unsigned int *size);
438 438
439extern int xt_compat_target_offset(struct xt_target *target); 439extern int xt_compat_target_offset(const struct xt_target *target);
440extern void xt_compat_target_from_user(struct xt_entry_target *t, 440extern void xt_compat_target_from_user(struct xt_entry_target *t,
441 void **dstptr, unsigned int *size); 441 void **dstptr, unsigned int *size);
442extern int xt_compat_target_to_user(struct xt_entry_target *t, 442extern int xt_compat_target_to_user(struct xt_entry_target *t,
diff --git a/include/linux/netfilter/xt_sctp.h b/include/linux/netfilter/xt_sctp.h
index dd5a4fd4cfd3..32000ba6ecef 100644
--- a/include/linux/netfilter/xt_sctp.h
+++ b/include/linux/netfilter/xt_sctp.h
@@ -37,68 +37,54 @@ struct xt_sctp_info {
37 37
38#define SCTP_CHUNKMAP_SET(chunkmap, type) \ 38#define SCTP_CHUNKMAP_SET(chunkmap, type) \
39 do { \ 39 do { \
40 chunkmap[type / bytes(u_int32_t)] |= \ 40 (chunkmap)[type / bytes(u_int32_t)] |= \
41 1 << (type % bytes(u_int32_t)); \ 41 1 << (type % bytes(u_int32_t)); \
42 } while (0) 42 } while (0)
43 43
44#define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \ 44#define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \
45 do { \ 45 do { \
46 chunkmap[type / bytes(u_int32_t)] &= \ 46 (chunkmap)[type / bytes(u_int32_t)] &= \
47 ~(1 << (type % bytes(u_int32_t))); \ 47 ~(1 << (type % bytes(u_int32_t))); \
48 } while (0) 48 } while (0)
49 49
50#define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \ 50#define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \
51({ \ 51({ \
52 (chunkmap[type / bytes (u_int32_t)] & \ 52 ((chunkmap)[type / bytes (u_int32_t)] & \
53 (1 << (type % bytes (u_int32_t)))) ? 1: 0; \ 53 (1 << (type % bytes (u_int32_t)))) ? 1: 0; \
54}) 54})
55 55
56#define SCTP_CHUNKMAP_RESET(chunkmap) \ 56#define SCTP_CHUNKMAP_RESET(chunkmap) \
57 do { \ 57 memset((chunkmap), 0, sizeof(chunkmap))
58 int i; \ 58
59 for (i = 0; i < ARRAY_SIZE(chunkmap); i++) \ 59#define SCTP_CHUNKMAP_SET_ALL(chunkmap) \
60 chunkmap[i] = 0; \ 60 memset((chunkmap), ~0U, sizeof(chunkmap))
61 } while (0) 61
62 62#define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
63#define SCTP_CHUNKMAP_SET_ALL(chunkmap) \ 63 memcpy((destmap), (srcmap), sizeof(srcmap))
64 do { \ 64
65 int i; \ 65#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
66 for (i = 0; i < ARRAY_SIZE(chunkmap); i++) \ 66 __sctp_chunkmap_is_clear((chunkmap), ARRAY_SIZE(chunkmap))
67 chunkmap[i] = ~0; \ 67static inline bool
68 } while (0) 68__sctp_chunkmap_is_clear(const u_int32_t *chunkmap, unsigned int n)
69 69{
70#define SCTP_CHUNKMAP_COPY(destmap, srcmap) \ 70 unsigned int i;
71 do { \ 71 for (i = 0; i < n; ++i)
72 int i; \ 72 if (chunkmap[i])
73 for (i = 0; i < ARRAY_SIZE(srcmap); i++) \ 73 return false;
74 destmap[i] = srcmap[i]; \ 74 return true;
75 } while (0) 75}
76 76
77#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \ 77#define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
78({ \ 78 __sctp_chunkmap_is_all_set((chunkmap), ARRAY_SIZE(chunkmap))
79 int i; \ 79static inline bool
80 int flag = 1; \ 80__sctp_chunkmap_is_all_set(const u_int32_t *chunkmap, unsigned int n)
81 for (i = 0; i < ARRAY_SIZE(chunkmap); i++) { \ 81{
82 if (chunkmap[i]) { \ 82 unsigned int i;
83 flag = 0; \ 83 for (i = 0; i < n; ++i)
84 break; \ 84 if (chunkmap[i] != ~0U)
85 } \ 85 return false;
86 } \ 86 return true;
87 flag; \ 87}
88})
89
90#define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
91({ \
92 int i; \
93 int flag = 1; \
94 for (i = 0; i < ARRAY_SIZE(chunkmap); i++) { \
95 if (chunkmap[i] != ~0) { \
96 flag = 0; \
97 break; \
98 } \
99 } \
100 flag; \
101})
102 88
103#endif /* _XT_SCTP_H_ */ 89#endif /* _XT_SCTP_H_ */
104 90
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index db223ca92c8b..dd9c97f2d436 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -23,8 +23,6 @@
23 23
24#define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN 24#define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
25#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN 25#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
26#define arpt_target xt_target
27#define arpt_table xt_table
28 26
29#define ARPT_DEV_ADDR_LEN_MAX 16 27#define ARPT_DEV_ADDR_LEN_MAX 16
30 28
@@ -266,20 +264,15 @@ struct arpt_error
266 .target.errorname = "ERROR", \ 264 .target.errorname = "ERROR", \
267} 265}
268 266
269#define arpt_register_target(tgt) \ 267extern struct xt_table *arpt_register_table(struct net *net,
270({ (tgt)->family = NF_ARP; \ 268 struct xt_table *table,
271 xt_register_target(tgt); }) 269 const struct arpt_replace *repl);
272#define arpt_unregister_target(tgt) xt_unregister_target(tgt) 270extern void arpt_unregister_table(struct xt_table *table);
273
274extern struct arpt_table *arpt_register_table(struct net *net,
275 struct arpt_table *table,
276 const struct arpt_replace *repl);
277extern void arpt_unregister_table(struct arpt_table *table);
278extern unsigned int arpt_do_table(struct sk_buff *skb, 271extern unsigned int arpt_do_table(struct sk_buff *skb,
279 unsigned int hook, 272 unsigned int hook,
280 const struct net_device *in, 273 const struct net_device *in,
281 const struct net_device *out, 274 const struct net_device *out,
282 struct arpt_table *table); 275 struct xt_table *table);
283 276
284#define ARPT_ALIGN(s) XT_ALIGN(s) 277#define ARPT_ALIGN(s) XT_ALIGN(s)
285 278
diff --git a/include/linux/netfilter_bridge/ebt_nflog.h b/include/linux/netfilter_bridge/ebt_nflog.h
new file mode 100644
index 000000000000..052817849b83
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_nflog.h
@@ -0,0 +1,21 @@
1#ifndef __LINUX_BRIDGE_EBT_NFLOG_H
2#define __LINUX_BRIDGE_EBT_NFLOG_H
3
4#define EBT_NFLOG_MASK 0x0
5
6#define EBT_NFLOG_PREFIX_SIZE 64
7#define EBT_NFLOG_WATCHER "nflog"
8
9#define EBT_NFLOG_DEFAULT_GROUP 0x1
10#define EBT_NFLOG_DEFAULT_THRESHOLD 1
11
12struct ebt_nflog_info {
13 u_int32_t len;
14 u_int16_t group;
15 u_int16_t threshold;
16 u_int16_t flags;
17 u_int16_t pad;
18 char prefix[EBT_NFLOG_PREFIX_SIZE];
19};
20
21#endif /* __LINUX_BRIDGE_EBT_NFLOG_H */
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
index 9a10092e358c..650318b0c405 100644
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -62,8 +62,6 @@ enum nf_ip_hook_priorities {
62 NF_IP_PRI_FILTER = 0, 62 NF_IP_PRI_FILTER = 0,
63 NF_IP_PRI_NAT_SRC = 100, 63 NF_IP_PRI_NAT_SRC = 100,
64 NF_IP_PRI_SELINUX_LAST = 225, 64 NF_IP_PRI_SELINUX_LAST = 225,
65 NF_IP_PRI_CONNTRACK_HELPER = INT_MAX - 2,
66 NF_IP_PRI_NAT_SEQ_ADJUST = INT_MAX - 1,
67 NF_IP_PRI_CONNTRACK_CONFIRM = INT_MAX, 65 NF_IP_PRI_CONNTRACK_CONFIRM = INT_MAX,
68 NF_IP_PRI_LAST = INT_MAX, 66 NF_IP_PRI_LAST = INT_MAX,
69}; 67};
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index fb0713b6ffaf..bec1062a25a1 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -166,6 +166,7 @@ struct netlink_skb_parms
166 __u32 dst_group; 166 __u32 dst_group;
167 kernel_cap_t eff_cap; 167 kernel_cap_t eff_cap;
168 __u32 loginuid; /* Login (audit) uid */ 168 __u32 loginuid; /* Login (audit) uid */
169 __u32 sessionid; /* Session id (audit) */
169 __u32 sid; /* SELinux security id */ 170 __u32 sid; /* SELinux security id */
170}; 171};
171 172
diff --git a/include/linux/nfs3.h b/include/linux/nfs3.h
index 7f11fa589207..539f3b550eab 100644
--- a/include/linux/nfs3.h
+++ b/include/linux/nfs3.h
@@ -96,7 +96,7 @@ struct nfs3_fh {
96#define MOUNTPROC3_UMNTALL 4 96#define MOUNTPROC3_UMNTALL 4
97 97
98 98
99#if defined(__KERNEL__) || defined(NFS_NEED_KERNEL_TYPES) 99#if defined(__KERNEL__)
100 100
101/* Number of 32bit words in post_op_attr */ 101/* Number of 32bit words in post_op_attr */
102#define NFS3_POST_OP_ATTR_WORDS 22 102#define NFS3_POST_OP_ATTR_WORDS 22
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index f4a0e4c218df..27d6a8d98cef 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -430,7 +430,6 @@ extern void nfs_unregister_sysctl(void);
430/* 430/*
431 * linux/fs/nfs/namespace.c 431 * linux/fs/nfs/namespace.c
432 */ 432 */
433extern struct list_head nfs_automount_list;
434extern const struct inode_operations nfs_mountpoint_inode_operations; 433extern const struct inode_operations nfs_mountpoint_inode_operations;
435extern const struct inode_operations nfs_referral_inode_operations; 434extern const struct inode_operations nfs_referral_inode_operations;
436extern int nfs_mountpoint_expiry_timeout; 435extern int nfs_mountpoint_expiry_timeout;
@@ -466,9 +465,9 @@ extern int nfs_wb_page(struct inode *inode, struct page* page);
466extern int nfs_wb_page_cancel(struct inode *inode, struct page* page); 465extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
467#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 466#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
468extern int nfs_commit_inode(struct inode *, int); 467extern int nfs_commit_inode(struct inode *, int);
469extern struct nfs_write_data *nfs_commit_alloc(void); 468extern struct nfs_write_data *nfs_commitdata_alloc(void);
470extern void nfs_commit_free(struct nfs_write_data *wdata); 469extern void nfs_commit_free(struct nfs_write_data *wdata);
471extern void nfs_commit_release(void *wdata); 470extern void nfs_commitdata_release(void *wdata);
472#else 471#else
473static inline int 472static inline int
474nfs_commit_inode(struct inode *inode, int how) 473nfs_commit_inode(struct inode *inode, int how)
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 3423c6761bf7..c9beacd16c00 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -32,6 +32,8 @@ struct nfs_client {
32 const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */ 32 const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
33 int cl_proto; /* Network transport protocol */ 33 int cl_proto; /* Network transport protocol */
34 34
35 struct rpc_cred *cl_machine_cred;
36
35#ifdef CONFIG_NFS_V4 37#ifdef CONFIG_NFS_V4
36 u64 cl_clientid; /* constant */ 38 u64 cl_clientid; /* constant */
37 nfs4_verifier cl_confirm; 39 nfs4_verifier cl_confirm;
@@ -93,6 +95,7 @@ struct nfs_server {
93 unsigned int wpages; /* write size (in pages) */ 95 unsigned int wpages; /* write size (in pages) */
94 unsigned int wtmult; /* server disk block size */ 96 unsigned int wtmult; /* server disk block size */
95 unsigned int dtsize; /* readdir size */ 97 unsigned int dtsize; /* readdir size */
98 unsigned short port; /* "port=" setting */
96 unsigned int bsize; /* server block size */ 99 unsigned int bsize; /* server block size */
97 unsigned int acregmin; /* attr cache timeouts */ 100 unsigned int acregmin; /* attr cache timeouts */
98 unsigned int acregmax; 101 unsigned int acregmax;
@@ -117,6 +120,13 @@ struct nfs_server {
117 120
118 atomic_t active; /* Keep trace of any activity to this server */ 121 atomic_t active; /* Keep trace of any activity to this server */
119 wait_queue_head_t active_wq; /* Wait for any activity to stop */ 122 wait_queue_head_t active_wq; /* Wait for any activity to stop */
123
124 /* mountd-related mount options */
125 struct sockaddr_storage mountd_address;
126 size_t mountd_addrlen;
127 u32 mountd_version;
128 unsigned short mountd_port;
129 unsigned short mountd_protocol;
120}; 130};
121 131
122/* Server capabilities */ 132/* Server capabilities */
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index f301d0b8babc..24263bb8e0be 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -140,6 +140,7 @@ struct nfs_openres {
140 __u32 rflags; 140 __u32 rflags;
141 struct nfs_fattr * f_attr; 141 struct nfs_fattr * f_attr;
142 struct nfs_fattr * dir_attr; 142 struct nfs_fattr * dir_attr;
143 struct nfs_seqid * seqid;
143 const struct nfs_server *server; 144 const struct nfs_server *server;
144 int delegation_type; 145 int delegation_type;
145 nfs4_stateid delegation; 146 nfs4_stateid delegation;
@@ -159,6 +160,7 @@ struct nfs_open_confirmargs {
159 160
160struct nfs_open_confirmres { 161struct nfs_open_confirmres {
161 nfs4_stateid stateid; 162 nfs4_stateid stateid;
163 struct nfs_seqid * seqid;
162}; 164};
163 165
164/* 166/*
@@ -175,6 +177,7 @@ struct nfs_closeargs {
175struct nfs_closeres { 177struct nfs_closeres {
176 nfs4_stateid stateid; 178 nfs4_stateid stateid;
177 struct nfs_fattr * fattr; 179 struct nfs_fattr * fattr;
180 struct nfs_seqid * seqid;
178 const struct nfs_server *server; 181 const struct nfs_server *server;
179}; 182};
180/* 183/*
@@ -199,7 +202,9 @@ struct nfs_lock_args {
199}; 202};
200 203
201struct nfs_lock_res { 204struct nfs_lock_res {
202 nfs4_stateid stateid; 205 nfs4_stateid stateid;
206 struct nfs_seqid * lock_seqid;
207 struct nfs_seqid * open_seqid;
203}; 208};
204 209
205struct nfs_locku_args { 210struct nfs_locku_args {
@@ -210,7 +215,8 @@ struct nfs_locku_args {
210}; 215};
211 216
212struct nfs_locku_res { 217struct nfs_locku_res {
213 nfs4_stateid stateid; 218 nfs4_stateid stateid;
219 struct nfs_seqid * seqid;
214}; 220};
215 221
216struct nfs_lockt_args { 222struct nfs_lockt_args {
diff --git a/include/linux/nfsd/Kbuild b/include/linux/nfsd/Kbuild
index e726fc3a4375..fc972048e572 100644
--- a/include/linux/nfsd/Kbuild
+++ b/include/linux/nfsd/Kbuild
@@ -1,6 +1,6 @@
1unifdef-y += const.h 1unifdef-y += const.h
2unifdef-y += debug.h
2unifdef-y += export.h 3unifdef-y += export.h
4unifdef-y += nfsfh.h
3unifdef-y += stats.h 5unifdef-y += stats.h
4unifdef-y += syscall.h 6unifdef-y += syscall.h
5unifdef-y += nfsfh.h
6unifdef-y += debug.h
diff --git a/include/linux/nfsd/cache.h b/include/linux/nfsd/cache.h
index 7b5d784cc858..04b355c801d8 100644
--- a/include/linux/nfsd/cache.h
+++ b/include/linux/nfsd/cache.h
@@ -10,7 +10,6 @@
10#ifndef NFSCACHE_H 10#ifndef NFSCACHE_H
11#define NFSCACHE_H 11#define NFSCACHE_H
12 12
13#ifdef __KERNEL__
14#include <linux/in.h> 13#include <linux/in.h>
15#include <linux/uio.h> 14#include <linux/uio.h>
16 15
@@ -77,5 +76,4 @@ void nfsd_reply_cache_shutdown(void);
77int nfsd_cache_lookup(struct svc_rqst *, int); 76int nfsd_cache_lookup(struct svc_rqst *, int);
78void nfsd_cache_update(struct svc_rqst *, int, __be32 *); 77void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
79 78
80#endif /* __KERNEL__ */
81#endif /* NFSCACHE_H */ 79#endif /* NFSCACHE_H */
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h
index 8caf4c4f64e6..41d30c9c9de6 100644
--- a/include/linux/nfsd/nfsd.h
+++ b/include/linux/nfsd/nfsd.h
@@ -27,7 +27,6 @@
27#define NFSD_VERSION "0.5" 27#define NFSD_VERSION "0.5"
28#define NFSD_SUPPORTED_MINOR_VERSION 0 28#define NFSD_SUPPORTED_MINOR_VERSION 0
29 29
30#ifdef __KERNEL__
31/* 30/*
32 * Special flags for nfsd_permission. These must be different from MAY_READ, 31 * Special flags for nfsd_permission. These must be different from MAY_READ,
33 * MAY_WRITE, and MAY_EXEC. 32 * MAY_WRITE, and MAY_EXEC.
@@ -56,12 +55,20 @@ extern struct svc_program nfsd_program;
56extern struct svc_version nfsd_version2, nfsd_version3, 55extern struct svc_version nfsd_version2, nfsd_version3,
57 nfsd_version4; 56 nfsd_version4;
58extern struct svc_serv *nfsd_serv; 57extern struct svc_serv *nfsd_serv;
58
59extern struct seq_operations nfs_exports_op;
60
59/* 61/*
60 * Function prototypes. 62 * Function prototypes.
61 */ 63 */
62int nfsd_svc(unsigned short port, int nrservs); 64int nfsd_svc(unsigned short port, int nrservs);
63int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp); 65int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp);
64 66
67int nfsd_nrthreads(void);
68int nfsd_nrpools(void);
69int nfsd_get_nrthreads(int n, int *);
70int nfsd_set_nrthreads(int n, int *);
71
65/* nfsd/vfs.c */ 72/* nfsd/vfs.c */
66int fh_lock_parent(struct svc_fh *, struct dentry *); 73int fh_lock_parent(struct svc_fh *, struct dentry *);
67int nfsd_racache_init(int); 74int nfsd_racache_init(int);
@@ -322,10 +329,8 @@ extern struct timeval nfssvc_boot;
322(FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL ) 329(FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL )
323#define NFSD_WRITEABLE_ATTRS_WORD1 \ 330#define NFSD_WRITEABLE_ATTRS_WORD1 \
324(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \ 331(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \
325 | FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_MODIFY_SET) 332 | FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET)
326 333
327#endif /* CONFIG_NFSD_V4 */ 334#endif /* CONFIG_NFSD_V4 */
328 335
329#endif /* __KERNEL__ */
330
331#endif /* LINUX_NFSD_NFSD_H */ 336#endif /* LINUX_NFSD_NFSD_H */
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 9fecf902419c..ea6517e58b04 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -78,6 +78,18 @@
78 * or, if no MAC address given, all stations, on the interface identified 78 * or, if no MAC address given, all stations, on the interface identified
79 * by %NL80211_ATTR_IFINDEX. 79 * by %NL80211_ATTR_IFINDEX.
80 * 80 *
81 * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to
82 * destination %NL80211_ATTR_MAC on the interface identified by
83 * %NL80211_ATTR_IFINDEX.
84 * @NL80211_CMD_SET_MPATH: Set mesh path attributes for mesh path to
85 * destination %NL80211_ATTR_MAC on the interface identified by
86 * %NL80211_ATTR_IFINDEX.
87 * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the
88 * the interface identified by %NL80211_ATTR_IFINDEX.
89 * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
90 * or, if no MAC address given, all mesh paths, on the interface identified
91 * by %NL80211_ATTR_IFINDEX.
92 *
81 * @NL80211_CMD_MAX: highest used command number 93 * @NL80211_CMD_MAX: highest used command number
82 * @__NL80211_CMD_AFTER_LAST: internal use 94 * @__NL80211_CMD_AFTER_LAST: internal use
83 */ 95 */
@@ -112,6 +124,11 @@ enum nl80211_commands {
112 124
113 /* add commands here */ 125 /* add commands here */
114 126
127 NL80211_CMD_GET_MPATH,
128 NL80211_CMD_SET_MPATH,
129 NL80211_CMD_NEW_MPATH,
130 NL80211_CMD_DEL_MPATH,
131
115 /* used to define NL80211_CMD_MAX below */ 132 /* used to define NL80211_CMD_MAX below */
116 __NL80211_CMD_AFTER_LAST, 133 __NL80211_CMD_AFTER_LAST,
117 NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1 134 NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
@@ -157,9 +174,23 @@ enum nl80211_commands {
157 * restriction (at most %NL80211_MAX_SUPP_RATES). 174 * restriction (at most %NL80211_MAX_SUPP_RATES).
158 * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station 175 * @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. 176 * 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 177 * @NL80211_ATTR_STA_INFO: information about a station, part of station info
161 * given for %NL80211_CMD_GET_STATION, nested attribute containing 178 * given for %NL80211_CMD_GET_STATION, nested attribute containing
162 * info as possible, see &enum nl80211_sta_stats. 179 * info as possible, see &enum nl80211_sta_info.
180 *
181 * @NL80211_ATTR_WIPHY_BANDS: Information about an operating bands,
182 * consisting of a nested array.
183 *
184 * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
185 * @NL80211_ATTR_PLINK_ACTION: action to perform on the mesh peer link.
186 * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
187 * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
188 * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
189 * &enum nl80211_mpath_info.
190 *
191 *
192 * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of
193 * &enum nl80211_mntr_flags.
163 * 194 *
164 * @NL80211_ATTR_MAX: highest attribute number currently defined 195 * @NL80211_ATTR_MAX: highest attribute number currently defined
165 * @__NL80211_ATTR_AFTER_LAST: internal use 196 * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -193,10 +224,19 @@ enum nl80211_attrs {
193 NL80211_ATTR_STA_LISTEN_INTERVAL, 224 NL80211_ATTR_STA_LISTEN_INTERVAL,
194 NL80211_ATTR_STA_SUPPORTED_RATES, 225 NL80211_ATTR_STA_SUPPORTED_RATES,
195 NL80211_ATTR_STA_VLAN, 226 NL80211_ATTR_STA_VLAN,
196 NL80211_ATTR_STA_STATS, 227 NL80211_ATTR_STA_INFO,
228
229 NL80211_ATTR_WIPHY_BANDS,
230
231 NL80211_ATTR_MNTR_FLAGS,
197 232
198 /* add attributes here, update the policy in nl80211.c */ 233 /* add attributes here, update the policy in nl80211.c */
199 234
235 NL80211_ATTR_MESH_ID,
236 NL80211_ATTR_STA_PLINK_ACTION,
237 NL80211_ATTR_MPATH_NEXT_HOP,
238 NL80211_ATTR_MPATH_INFO,
239
200 __NL80211_ATTR_AFTER_LAST, 240 __NL80211_ATTR_AFTER_LAST,
201 NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1 241 NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
202}; 242};
@@ -213,6 +253,7 @@ enum nl80211_attrs {
213 * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points 253 * @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points
214 * @NL80211_IFTYPE_WDS: wireless distribution interface 254 * @NL80211_IFTYPE_WDS: wireless distribution interface
215 * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames 255 * @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
256 * @NL80211_IFTYPE_MESH_POINT: mesh point
216 * @NL80211_IFTYPE_MAX: highest interface type number currently defined 257 * @NL80211_IFTYPE_MAX: highest interface type number currently defined
217 * @__NL80211_IFTYPE_AFTER_LAST: internal use 258 * @__NL80211_IFTYPE_AFTER_LAST: internal use
218 * 259 *
@@ -228,6 +269,7 @@ enum nl80211_iftype {
228 NL80211_IFTYPE_AP_VLAN, 269 NL80211_IFTYPE_AP_VLAN,
229 NL80211_IFTYPE_WDS, 270 NL80211_IFTYPE_WDS,
230 NL80211_IFTYPE_MONITOR, 271 NL80211_IFTYPE_MONITOR,
272 NL80211_IFTYPE_MESH_POINT,
231 273
232 /* keep last */ 274 /* keep last */
233 __NL80211_IFTYPE_AFTER_LAST, 275 __NL80211_IFTYPE_AFTER_LAST,
@@ -257,27 +299,167 @@ enum nl80211_sta_flags {
257}; 299};
258 300
259/** 301/**
260 * enum nl80211_sta_stats - station statistics 302 * enum nl80211_sta_info - station information
261 * 303 *
262 * These attribute types are used with %NL80211_ATTR_STA_STATS 304 * These attribute types are used with %NL80211_ATTR_STA_INFO
263 * when getting information about a station. 305 * when getting information about a station.
264 * 306 *
265 * @__NL80211_STA_STAT_INVALID: attribute number 0 is reserved 307 * @__NL80211_STA_INFO_INVALID: attribute number 0 is reserved
266 * @NL80211_STA_STAT_INACTIVE_TIME: time since last activity (u32, msecs) 308 * @NL80211_STA_INFO_INACTIVE_TIME: time since last activity (u32, msecs)
267 * @NL80211_STA_STAT_RX_BYTES: total received bytes (u32, from this station) 309 * @NL80211_STA_INFO_RX_BYTES: total received bytes (u32, from this station)
268 * @NL80211_STA_STAT_TX_BYTES: total transmitted bytes (u32, to this station) 310 * @NL80211_STA_INFO_TX_BYTES: total transmitted bytes (u32, to this station)
269 * @__NL80211_STA_STAT_AFTER_LAST: internal 311 * @__NL80211_STA_INFO_AFTER_LAST: internal
270 * @NL80211_STA_STAT_MAX: highest possible station stats attribute 312 * @NL80211_STA_INFO_MAX: highest possible station info attribute
313 */
314enum nl80211_sta_info {
315 __NL80211_STA_INFO_INVALID,
316 NL80211_STA_INFO_INACTIVE_TIME,
317 NL80211_STA_INFO_RX_BYTES,
318 NL80211_STA_INFO_TX_BYTES,
319 NL80211_STA_INFO_LLID,
320 NL80211_STA_INFO_PLID,
321 NL80211_STA_INFO_PLINK_STATE,
322
323 /* keep last */
324 __NL80211_STA_INFO_AFTER_LAST,
325 NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
326};
327
328/**
329 * enum nl80211_mpath_flags - nl80211 mesh path flags
330 *
331 * @NL80211_MPATH_FLAG_ACTIVE: the mesh path is active
332 * @NL80211_MPATH_FLAG_RESOLVING: the mesh path discovery process is running
333 * @NL80211_MPATH_FLAG_DSN_VALID: the mesh path contains a valid DSN
334 * @NL80211_MPATH_FLAG_FIXED: the mesh path has been manually set
335 * @NL80211_MPATH_FLAG_RESOLVED: the mesh path discovery process succeeded
336 */
337enum nl80211_mpath_flags {
338 NL80211_MPATH_FLAG_ACTIVE = 1<<0,
339 NL80211_MPATH_FLAG_RESOLVING = 1<<1,
340 NL80211_MPATH_FLAG_DSN_VALID = 1<<2,
341 NL80211_MPATH_FLAG_FIXED = 1<<3,
342 NL80211_MPATH_FLAG_RESOLVED = 1<<4,
343};
344
345/**
346 * enum nl80211_mpath_info - mesh path information
347 *
348 * These attribute types are used with %NL80211_ATTR_MPATH_INFO when getting
349 * information about a mesh path.
350 *
351 * @__NL80211_MPATH_INFO_INVALID: attribute number 0 is reserved
352 * @NL80211_ATTR_MPATH_FRAME_QLEN: number of queued frames for this destination
353 * @NL80211_ATTR_MPATH_DSN: destination sequence number
354 * @NL80211_ATTR_MPATH_METRIC: metric (cost) of this mesh path
355 * @NL80211_ATTR_MPATH_EXPTIME: expiration time for the path, in msec from now
356 * @NL80211_ATTR_MPATH_FLAGS: mesh path flags, enumerated in
357 * &enum nl80211_mpath_flags;
358 * @NL80211_ATTR_MPATH_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
359 * @NL80211_ATTR_MPATH_DISCOVERY_RETRIES: mesh path discovery retries
360 */
361enum nl80211_mpath_info {
362 __NL80211_MPATH_INFO_INVALID,
363 NL80211_MPATH_INFO_FRAME_QLEN,
364 NL80211_MPATH_INFO_DSN,
365 NL80211_MPATH_INFO_METRIC,
366 NL80211_MPATH_INFO_EXPTIME,
367 NL80211_MPATH_INFO_FLAGS,
368 NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
369 NL80211_MPATH_INFO_DISCOVERY_RETRIES,
370
371 /* keep last */
372 __NL80211_MPATH_INFO_AFTER_LAST,
373 NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1
374};
375
376/**
377 * enum nl80211_band_attr - band attributes
378 * @__NL80211_BAND_ATTR_INVALID: attribute number 0 is reserved
379 * @NL80211_BAND_ATTR_FREQS: supported frequencies in this band,
380 * an array of nested frequency attributes
381 * @NL80211_BAND_ATTR_RATES: supported bitrates in this band,
382 * an array of nested bitrate attributes
383 */
384enum nl80211_band_attr {
385 __NL80211_BAND_ATTR_INVALID,
386 NL80211_BAND_ATTR_FREQS,
387 NL80211_BAND_ATTR_RATES,
388
389 /* keep last */
390 __NL80211_BAND_ATTR_AFTER_LAST,
391 NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1
392};
393
394/**
395 * enum nl80211_frequency_attr - frequency attributes
396 * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
397 * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
398 * regulatory domain.
399 * @NL80211_FREQUENCY_ATTR_PASSIVE_SCAN: Only passive scanning is
400 * permitted on this channel in current regulatory domain.
401 * @NL80211_FREQUENCY_ATTR_NO_IBSS: IBSS networks are not permitted
402 * on this channel in current regulatory domain.
403 * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
404 * on this channel in current regulatory domain.
405 */
406enum nl80211_frequency_attr {
407 __NL80211_FREQUENCY_ATTR_INVALID,
408 NL80211_FREQUENCY_ATTR_FREQ,
409 NL80211_FREQUENCY_ATTR_DISABLED,
410 NL80211_FREQUENCY_ATTR_PASSIVE_SCAN,
411 NL80211_FREQUENCY_ATTR_NO_IBSS,
412 NL80211_FREQUENCY_ATTR_RADAR,
413
414 /* keep last */
415 __NL80211_FREQUENCY_ATTR_AFTER_LAST,
416 NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
417};
418
419/**
420 * enum nl80211_bitrate_attr - bitrate attributes
421 * @NL80211_BITRATE_ATTR_RATE: Bitrate in units of 100 kbps
422 * @NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE: Short preamble supported
423 * in 2.4 GHz band.
424 */
425enum nl80211_bitrate_attr {
426 __NL80211_BITRATE_ATTR_INVALID,
427 NL80211_BITRATE_ATTR_RATE,
428 NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE,
429
430 /* keep last */
431 __NL80211_BITRATE_ATTR_AFTER_LAST,
432 NL80211_BITRATE_ATTR_MAX = __NL80211_BITRATE_ATTR_AFTER_LAST - 1
433};
434
435/**
436 * enum nl80211_mntr_flags - monitor configuration flags
437 *
438 * Monitor configuration flags.
439 *
440 * @__NL80211_MNTR_FLAG_INVALID: reserved
441 *
442 * @NL80211_MNTR_FLAG_FCSFAIL: pass frames with bad FCS
443 * @NL80211_MNTR_FLAG_PLCPFAIL: pass frames with bad PLCP
444 * @NL80211_MNTR_FLAG_CONTROL: pass control frames
445 * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering
446 * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing.
447 * overrides all other flags.
448 *
449 * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
450 * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
271 */ 451 */
272enum nl80211_sta_stats { 452enum nl80211_mntr_flags {
273 __NL80211_STA_STAT_INVALID, 453 __NL80211_MNTR_FLAG_INVALID,
274 NL80211_STA_STAT_INACTIVE_TIME, 454 NL80211_MNTR_FLAG_FCSFAIL,
275 NL80211_STA_STAT_RX_BYTES, 455 NL80211_MNTR_FLAG_PLCPFAIL,
276 NL80211_STA_STAT_TX_BYTES, 456 NL80211_MNTR_FLAG_CONTROL,
457 NL80211_MNTR_FLAG_OTHER_BSS,
458 NL80211_MNTR_FLAG_COOK_FRAMES,
277 459
278 /* keep last */ 460 /* keep last */
279 __NL80211_STA_STAT_AFTER_LAST, 461 __NL80211_MNTR_FLAG_AFTER_LAST,
280 NL80211_STA_STAT_MAX = __NL80211_STA_STAT_AFTER_LAST - 1 462 NL80211_MNTR_FLAG_MAX = __NL80211_MNTR_FLAG_AFTER_LAST - 1
281}; 463};
282 464
283#endif /* __LINUX_NL80211_H */ 465#endif /* __LINUX_NL80211_H */
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 905e18f4b412..848025cd7087 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -14,6 +14,8 @@
14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c. 14 * bitmap_scnlistprintf() and bitmap_parselist(), also in bitmap.c.
15 * For details of node_remap(), see bitmap_bitremap in lib/bitmap.c. 15 * For details of node_remap(), see bitmap_bitremap in lib/bitmap.c.
16 * For details of nodes_remap(), see bitmap_remap in lib/bitmap.c. 16 * For details of nodes_remap(), see bitmap_remap in lib/bitmap.c.
17 * For details of nodes_onto(), see bitmap_onto in lib/bitmap.c.
18 * For details of nodes_fold(), see bitmap_fold in lib/bitmap.c.
17 * 19 *
18 * The available nodemask operations are: 20 * The available nodemask operations are:
19 * 21 *
@@ -55,7 +57,9 @@
55 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing 57 * int nodelist_scnprintf(buf, len, mask) Format nodemask as list for printing
56 * int nodelist_parse(buf, map) Parse ascii string as nodelist 58 * int nodelist_parse(buf, map) Parse ascii string as nodelist
57 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit) 59 * int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
58 * int nodes_remap(dst, src, old, new) *dst = map(old, new)(dst) 60 * void nodes_remap(dst, src, old, new) *dst = map(old, new)(src)
61 * void nodes_onto(dst, orig, relmap) *dst = orig relative to relmap
62 * void nodes_fold(dst, orig, sz) dst bits = orig bits mod sz
59 * 63 *
60 * for_each_node_mask(node, mask) for-loop node over mask 64 * for_each_node_mask(node, mask) for-loop node over mask
61 * 65 *
@@ -326,6 +330,22 @@ static inline void __nodes_remap(nodemask_t *dstp, const nodemask_t *srcp,
326 bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits); 330 bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits);
327} 331}
328 332
333#define nodes_onto(dst, orig, relmap) \
334 __nodes_onto(&(dst), &(orig), &(relmap), MAX_NUMNODES)
335static inline void __nodes_onto(nodemask_t *dstp, const nodemask_t *origp,
336 const nodemask_t *relmapp, int nbits)
337{
338 bitmap_onto(dstp->bits, origp->bits, relmapp->bits, nbits);
339}
340
341#define nodes_fold(dst, orig, sz) \
342 __nodes_fold(&(dst), &(orig), sz, MAX_NUMNODES)
343static inline void __nodes_fold(nodemask_t *dstp, const nodemask_t *origp,
344 int sz, int nbits)
345{
346 bitmap_fold(dstp->bits, origp->bits, sz, nbits);
347}
348
329#if MAX_NUMNODES > 1 349#if MAX_NUMNODES > 1
330#define for_each_node_mask(node, mask) \ 350#define for_each_node_mask(node, mask) \
331 for ((node) = first_node(mask); \ 351 for ((node) = first_node(mask); \
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index f4df40038f0c..0ff6224d172a 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -121,6 +121,10 @@ extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
121extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh, 121extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
122 struct notifier_block *nb); 122 struct notifier_block *nb);
123 123
124extern int blocking_notifier_chain_cond_register(
125 struct blocking_notifier_head *nh,
126 struct notifier_block *nb);
127
124extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, 128extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
125 struct notifier_block *nb); 129 struct notifier_block *nb);
126extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, 130extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh,
@@ -247,6 +251,7 @@ extern struct blocking_notifier_head reboot_notifier_list;
247#define VT_DEALLOCATE 0x0002 /* Console will be deallocated */ 251#define VT_DEALLOCATE 0x0002 /* Console will be deallocated */
248#define VT_WRITE 0x0003 /* A char got output */ 252#define VT_WRITE 0x0003 /* A char got output */
249#define VT_UPDATE 0x0004 /* A bigger update occurred */ 253#define VT_UPDATE 0x0004 /* A bigger update occurred */
254#define VT_PREWRITE 0x0005 /* A char is about to be written to the console */
250 255
251#endif /* __KERNEL__ */ 256#endif /* __KERNEL__ */
252#endif /* _LINUX_NOTIFIER_H */ 257#endif /* _LINUX_NOTIFIER_H */
diff --git a/include/linux/of.h b/include/linux/of.h
index 6981016dcc25..59a61bdc98b6 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -62,6 +62,7 @@ extern struct property *of_find_property(const struct device_node *np,
62 int *lenp); 62 int *lenp);
63extern int of_device_is_compatible(const struct device_node *device, 63extern int of_device_is_compatible(const struct device_node *device,
64 const char *); 64 const char *);
65extern int of_device_is_available(const struct device_node *device);
65extern const void *of_get_property(const struct device_node *node, 66extern const void *of_get_property(const struct device_node *node,
66 const char *name, 67 const char *name,
67 int *lenp); 68 int *lenp);
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 6dc11959770c..afe338217d91 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -1,6 +1,5 @@
1#ifndef _LINUX_OF_DEVICE_H 1#ifndef _LINUX_OF_DEVICE_H
2#define _LINUX_OF_DEVICE_H 2#define _LINUX_OF_DEVICE_H
3#ifdef __KERNEL__
4 3
5#include <linux/device.h> 4#include <linux/device.h>
6#include <linux/of.h> 5#include <linux/of.h>
@@ -25,5 +24,4 @@ static inline void of_device_free(struct of_device *dev)
25 of_release_dev(&dev->dev); 24 of_release_dev(&dev->dev);
26} 25}
27 26
28#endif /* __KERNEL__ */
29#endif /* _LINUX_OF_DEVICE_H */ 27#endif /* _LINUX_OF_DEVICE_H */
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
new file mode 100644
index 000000000000..2ee97e9877a7
--- /dev/null
+++ b/include/linux/of_gpio.h
@@ -0,0 +1,69 @@
1/*
2 * OF helpers for the GPIO API
3 *
4 * Copyright (c) 2007-2008 MontaVista Software, Inc.
5 *
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
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
14#ifndef __LINUX_OF_GPIO_H
15#define __LINUX_OF_GPIO_H
16
17#include <linux/errno.h>
18#include <asm/gpio.h>
19
20#ifdef CONFIG_OF_GPIO
21
22/*
23 * Generic OF GPIO chip
24 */
25struct of_gpio_chip {
26 struct gpio_chip gc;
27 int gpio_cells;
28 int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np,
29 const void *gpio_spec);
30};
31
32static inline struct of_gpio_chip *to_of_gpio_chip(struct gpio_chip *gc)
33{
34 return container_of(gc, struct of_gpio_chip, gc);
35}
36
37/*
38 * OF GPIO chip for memory mapped banks
39 */
40struct of_mm_gpio_chip {
41 struct of_gpio_chip of_gc;
42 void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
43 void __iomem *regs;
44};
45
46static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
47{
48 struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
49
50 return container_of(of_gc, struct of_mm_gpio_chip, of_gc);
51}
52
53extern int of_get_gpio(struct device_node *np, int index);
54extern int of_mm_gpiochip_add(struct device_node *np,
55 struct of_mm_gpio_chip *mm_gc);
56extern int of_gpio_simple_xlate(struct of_gpio_chip *of_gc,
57 struct device_node *np,
58 const void *gpio_spec);
59#else
60
61/* Drivers may not strictly depend on the GPIO support, so let them link. */
62static inline int of_get_gpio(struct device_node *np, int index)
63{
64 return -ENOSYS;
65}
66
67#endif /* CONFIG_OF_GPIO */
68
69#endif /* __LINUX_OF_GPIO_H */
diff --git a/include/linux/of_i2c.h b/include/linux/of_i2c.h
new file mode 100644
index 000000000000..2e5a96732042
--- /dev/null
+++ b/include/linux/of_i2c.h
@@ -0,0 +1,24 @@
1/*
2 * Generic I2C API implementation for PowerPC.
3 *
4 * Copyright (c) 2008 Jochen Friedrich <jochen@scram.de>
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
12#ifndef __LINUX_OF_I2C_H
13#define __LINUX_OF_I2C_H
14
15#include <linux/i2c.h>
16
17#ifdef CONFIG_OF_I2C
18
19void of_register_i2c_devices(struct i2c_adapter *adap,
20 struct device_node *adap_node);
21
22#endif /* CONFIG_OF_I2C */
23
24#endif /* __LINUX_OF_I2C_H */
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 3852436b652a..a7979baf1e39 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -23,8 +23,8 @@ enum oom_constraint {
23 CONSTRAINT_MEMORY_POLICY, 23 CONSTRAINT_MEMORY_POLICY,
24}; 24};
25 25
26extern int try_set_zone_oom(struct zonelist *zonelist); 26extern int try_set_zone_oom(struct zonelist *zonelist, gfp_t gfp_flags);
27extern void clear_zonelist_oom(struct zonelist *zonelist); 27extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
28 28
29extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order); 29extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order);
30extern int register_oom_notifier(struct notifier_block *nb); 30extern int register_oom_notifier(struct notifier_block *nb);
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index b5b30f1c1e59..590cff32415d 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -6,7 +6,10 @@
6#define PAGE_FLAGS_H 6#define PAGE_FLAGS_H
7 7
8#include <linux/types.h> 8#include <linux/types.h>
9#ifndef __GENERATING_BOUNDS_H
9#include <linux/mm_types.h> 10#include <linux/mm_types.h>
11#include <linux/bounds.h>
12#endif /* !__GENERATING_BOUNDS_H */
10 13
11/* 14/*
12 * Various page->flags bits: 15 * Various page->flags bits:
@@ -59,77 +62,138 @@
59 * extends from the high bits downwards. 62 * extends from the high bits downwards.
60 * 63 *
61 * | FIELD | ... | FLAGS | 64 * | FIELD | ... | FLAGS |
62 * N-1 ^ 0 65 * N-1 ^ 0
63 * (N-FLAGS_RESERVED) 66 * (NR_PAGEFLAGS)
64 * 67 *
65 * The fields area is reserved for fields mapping zone, node and SPARSEMEM 68 * The fields area is reserved for fields mapping zone, node (for NUMA) and
66 * section. The boundry between these two areas is defined by 69 * SPARSEMEM section (for variants of SPARSEMEM that require section ids like
67 * FLAGS_RESERVED which defines the width of the fields section 70 * SPARSEMEM_EXTREME with !SPARSEMEM_VMEMMAP).
68 * (see linux/mmzone.h). New flags must _not_ overlap with this area.
69 */ 71 */
70#define PG_locked 0 /* Page is locked. Don't touch. */ 72enum pageflags {
71#define PG_error 1 73 PG_locked, /* Page is locked. Don't touch. */
72#define PG_referenced 2 74 PG_error,
73#define PG_uptodate 3 75 PG_referenced,
76 PG_uptodate,
77 PG_dirty,
78 PG_lru,
79 PG_active,
80 PG_slab,
81 PG_owner_priv_1, /* Owner use. If pagecache, fs may use*/
82 PG_arch_1,
83 PG_reserved,
84 PG_private, /* If pagecache, has fs-private data */
85 PG_writeback, /* Page is under writeback */
86#ifdef CONFIG_PAGEFLAGS_EXTENDED
87 PG_head, /* A head page */
88 PG_tail, /* A tail page */
89#else
90 PG_compound, /* A compound page */
91#endif
92 PG_swapcache, /* Swap page: swp_entry_t in private */
93 PG_mappedtodisk, /* Has blocks allocated on-disk */
94 PG_reclaim, /* To be reclaimed asap */
95 PG_buddy, /* Page is free, on buddy lists */
96#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR
97 PG_uncached, /* Page has been mapped as uncached */
98#endif
99 __NR_PAGEFLAGS
100};
101
102#ifndef __GENERATING_BOUNDS_H
103
104/*
105 * Macros to create function definitions for page flags
106 */
107#define TESTPAGEFLAG(uname, lname) \
108static inline int Page##uname(struct page *page) \
109 { return test_bit(PG_##lname, &page->flags); }
74 110
75#define PG_dirty 4 111#define SETPAGEFLAG(uname, lname) \
76#define PG_lru 5 112static inline void SetPage##uname(struct page *page) \
77#define PG_active 6 113 { set_bit(PG_##lname, &page->flags); }
78#define PG_slab 7 /* slab debug (Suparna wants this) */
79 114
80#define PG_owner_priv_1 8 /* Owner use. If pagecache, fs may use*/ 115#define CLEARPAGEFLAG(uname, lname) \
81#define PG_arch_1 9 116static inline void ClearPage##uname(struct page *page) \
82#define PG_reserved 10 117 { clear_bit(PG_##lname, &page->flags); }
83#define PG_private 11 /* If pagecache, has fs-private data */
84 118
85#define PG_writeback 12 /* Page is under writeback */ 119#define __SETPAGEFLAG(uname, lname) \
86#define PG_compound 14 /* Part of a compound page */ 120static inline void __SetPage##uname(struct page *page) \
87#define PG_swapcache 15 /* Swap page: swp_entry_t in private */ 121 { __set_bit(PG_##lname, &page->flags); }
88 122
89#define PG_mappedtodisk 16 /* Has blocks allocated on-disk */ 123#define __CLEARPAGEFLAG(uname, lname) \
90#define PG_reclaim 17 /* To be reclaimed asap */ 124static inline void __ClearPage##uname(struct page *page) \
91#define PG_buddy 19 /* Page is free, on buddy lists */ 125 { __clear_bit(PG_##lname, &page->flags); }
126
127#define TESTSETFLAG(uname, lname) \
128static inline int TestSetPage##uname(struct page *page) \
129 { return test_and_set_bit(PG_##lname, &page->flags); }
130
131#define TESTCLEARFLAG(uname, lname) \
132static inline int TestClearPage##uname(struct page *page) \
133 { return test_and_clear_bit(PG_##lname, &page->flags); }
92 134
93/* PG_readahead is only used for file reads; PG_reclaim is only for writes */
94#define PG_readahead PG_reclaim /* Reminder to do async read-ahead */
95 135
96/* PG_owner_priv_1 users should have descriptive aliases */ 136#define PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \
97#define PG_checked PG_owner_priv_1 /* Used by some filesystems */ 137 SETPAGEFLAG(uname, lname) CLEARPAGEFLAG(uname, lname)
98#define PG_pinned PG_owner_priv_1 /* Xen pinned pagetable */ 138
139#define __PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname) \
140 __SETPAGEFLAG(uname, lname) __CLEARPAGEFLAG(uname, lname)
141
142#define PAGEFLAG_FALSE(uname) \
143static inline int Page##uname(struct page *page) \
144 { return 0; }
145
146#define TESTSCFLAG(uname, lname) \
147 TESTSETFLAG(uname, lname) TESTCLEARFLAG(uname, lname)
148
149struct page; /* forward declaration */
150
151PAGEFLAG(Locked, locked) TESTSCFLAG(Locked, locked)
152PAGEFLAG(Error, error)
153PAGEFLAG(Referenced, referenced) TESTCLEARFLAG(Referenced, referenced)
154PAGEFLAG(Dirty, dirty) TESTSCFLAG(Dirty, dirty) __CLEARPAGEFLAG(Dirty, dirty)
155PAGEFLAG(LRU, lru) __CLEARPAGEFLAG(LRU, lru)
156PAGEFLAG(Active, active) __CLEARPAGEFLAG(Active, active)
157__PAGEFLAG(Slab, slab)
158PAGEFLAG(Checked, owner_priv_1) /* Used by some filesystems */
159PAGEFLAG(Pinned, owner_priv_1) TESTSCFLAG(Pinned, owner_priv_1) /* Xen */
160PAGEFLAG(Reserved, reserved) __CLEARPAGEFLAG(Reserved, reserved)
161PAGEFLAG(Private, private) __CLEARPAGEFLAG(Private, private)
162 __SETPAGEFLAG(Private, private)
99 163
100#if (BITS_PER_LONG > 32)
101/* 164/*
102 * 64-bit-only flags build down from bit 31 165 * Only test-and-set exist for PG_writeback. The unconditional operators are
103 * 166 * risky: they bypass page accounting.
104 * 32 bit -------------------------------| FIELDS | FLAGS |
105 * 64 bit | FIELDS | ?????? FLAGS |
106 * 63 32 0
107 */ 167 */
108#define PG_uncached 31 /* Page has been mapped as uncached */ 168TESTPAGEFLAG(Writeback, writeback) TESTSCFLAG(Writeback, writeback)
109#endif 169__PAGEFLAG(Buddy, buddy)
170PAGEFLAG(MappedToDisk, mappedtodisk)
110 171
172/* PG_readahead is only used for file reads; PG_reclaim is only for writes */
173PAGEFLAG(Reclaim, reclaim) TESTCLEARFLAG(Reclaim, reclaim)
174PAGEFLAG(Readahead, reclaim) /* Reminder to do async read-ahead */
175
176#ifdef CONFIG_HIGHMEM
111/* 177/*
112 * Manipulation of page state flags 178 * Must use a macro here due to header dependency issues. page_zone() is not
179 * available at this point.
113 */ 180 */
114#define PageLocked(page) \ 181#define PageHighMem(__p) is_highmem(page_zone(__p))
115 test_bit(PG_locked, &(page)->flags) 182#else
116#define SetPageLocked(page) \ 183PAGEFLAG_FALSE(HighMem)
117 set_bit(PG_locked, &(page)->flags) 184#endif
118#define TestSetPageLocked(page) \ 185
119 test_and_set_bit(PG_locked, &(page)->flags) 186#ifdef CONFIG_SWAP
120#define ClearPageLocked(page) \ 187PAGEFLAG(SwapCache, swapcache)
121 clear_bit(PG_locked, &(page)->flags) 188#else
122#define TestClearPageLocked(page) \ 189PAGEFLAG_FALSE(SwapCache)
123 test_and_clear_bit(PG_locked, &(page)->flags) 190#endif
124 191
125#define PageError(page) test_bit(PG_error, &(page)->flags) 192#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR
126#define SetPageError(page) set_bit(PG_error, &(page)->flags) 193PAGEFLAG(Uncached, uncached)
127#define ClearPageError(page) clear_bit(PG_error, &(page)->flags) 194#else
128 195PAGEFLAG_FALSE(Uncached)
129#define PageReferenced(page) test_bit(PG_referenced, &(page)->flags) 196#endif
130#define SetPageReferenced(page) set_bit(PG_referenced, &(page)->flags)
131#define ClearPageReferenced(page) clear_bit(PG_referenced, &(page)->flags)
132#define TestClearPageReferenced(page) test_and_clear_bit(PG_referenced, &(page)->flags)
133 197
134static inline int PageUptodate(struct page *page) 198static inline int PageUptodate(struct page *page)
135{ 199{
@@ -177,97 +241,59 @@ static inline void SetPageUptodate(struct page *page)
177#endif 241#endif
178} 242}
179 243
180#define ClearPageUptodate(page) clear_bit(PG_uptodate, &(page)->flags) 244CLEARPAGEFLAG(Uptodate, uptodate)
181
182#define PageDirty(page) test_bit(PG_dirty, &(page)->flags)
183#define SetPageDirty(page) set_bit(PG_dirty, &(page)->flags)
184#define TestSetPageDirty(page) test_and_set_bit(PG_dirty, &(page)->flags)
185#define ClearPageDirty(page) clear_bit(PG_dirty, &(page)->flags)
186#define __ClearPageDirty(page) __clear_bit(PG_dirty, &(page)->flags)
187#define TestClearPageDirty(page) test_and_clear_bit(PG_dirty, &(page)->flags)
188
189#define PageLRU(page) test_bit(PG_lru, &(page)->flags)
190#define SetPageLRU(page) set_bit(PG_lru, &(page)->flags)
191#define ClearPageLRU(page) clear_bit(PG_lru, &(page)->flags)
192#define __ClearPageLRU(page) __clear_bit(PG_lru, &(page)->flags)
193
194#define PageActive(page) test_bit(PG_active, &(page)->flags)
195#define SetPageActive(page) set_bit(PG_active, &(page)->flags)
196#define ClearPageActive(page) clear_bit(PG_active, &(page)->flags)
197#define __ClearPageActive(page) __clear_bit(PG_active, &(page)->flags)
198
199#define PageSlab(page) test_bit(PG_slab, &(page)->flags)
200#define __SetPageSlab(page) __set_bit(PG_slab, &(page)->flags)
201#define __ClearPageSlab(page) __clear_bit(PG_slab, &(page)->flags)
202
203#ifdef CONFIG_HIGHMEM
204#define PageHighMem(page) is_highmem(page_zone(page))
205#else
206#define PageHighMem(page) 0 /* needed to optimize away at compile time */
207#endif
208 245
209#define PageChecked(page) test_bit(PG_checked, &(page)->flags) 246extern void cancel_dirty_page(struct page *page, unsigned int account_size);
210#define SetPageChecked(page) set_bit(PG_checked, &(page)->flags)
211#define ClearPageChecked(page) clear_bit(PG_checked, &(page)->flags)
212
213#define PagePinned(page) test_bit(PG_pinned, &(page)->flags)
214#define SetPagePinned(page) set_bit(PG_pinned, &(page)->flags)
215#define ClearPagePinned(page) clear_bit(PG_pinned, &(page)->flags)
216 247
217#define PageReserved(page) test_bit(PG_reserved, &(page)->flags) 248int test_clear_page_writeback(struct page *page);
218#define SetPageReserved(page) set_bit(PG_reserved, &(page)->flags) 249int test_set_page_writeback(struct page *page);
219#define ClearPageReserved(page) clear_bit(PG_reserved, &(page)->flags)
220#define __ClearPageReserved(page) __clear_bit(PG_reserved, &(page)->flags)
221 250
222#define SetPagePrivate(page) set_bit(PG_private, &(page)->flags) 251static inline void set_page_writeback(struct page *page)
223#define ClearPagePrivate(page) clear_bit(PG_private, &(page)->flags) 252{
224#define PagePrivate(page) test_bit(PG_private, &(page)->flags) 253 test_set_page_writeback(page);
225#define __SetPagePrivate(page) __set_bit(PG_private, &(page)->flags) 254}
226#define __ClearPagePrivate(page) __clear_bit(PG_private, &(page)->flags)
227 255
256#ifdef CONFIG_PAGEFLAGS_EXTENDED
228/* 257/*
229 * Only test-and-set exist for PG_writeback. The unconditional operators are 258 * System with lots of page flags available. This allows separate
230 * risky: they bypass page accounting. 259 * flags for PageHead() and PageTail() checks of compound pages so that bit
260 * tests can be used in performance sensitive paths. PageCompound is
261 * generally not used in hot code paths.
231 */ 262 */
232#define PageWriteback(page) test_bit(PG_writeback, &(page)->flags) 263__PAGEFLAG(Head, head)
233#define TestSetPageWriteback(page) test_and_set_bit(PG_writeback, \ 264__PAGEFLAG(Tail, tail)
234 &(page)->flags)
235#define TestClearPageWriteback(page) test_and_clear_bit(PG_writeback, \
236 &(page)->flags)
237 265
238#define PageBuddy(page) test_bit(PG_buddy, &(page)->flags) 266static inline int PageCompound(struct page *page)
239#define __SetPageBuddy(page) __set_bit(PG_buddy, &(page)->flags) 267{
240#define __ClearPageBuddy(page) __clear_bit(PG_buddy, &(page)->flags) 268 return page->flags & ((1L << PG_head) | (1L << PG_tail));
241
242#define PageMappedToDisk(page) test_bit(PG_mappedtodisk, &(page)->flags)
243#define SetPageMappedToDisk(page) set_bit(PG_mappedtodisk, &(page)->flags)
244#define ClearPageMappedToDisk(page) clear_bit(PG_mappedtodisk, &(page)->flags)
245
246#define PageReadahead(page) test_bit(PG_readahead, &(page)->flags)
247#define SetPageReadahead(page) set_bit(PG_readahead, &(page)->flags)
248#define ClearPageReadahead(page) clear_bit(PG_readahead, &(page)->flags)
249
250#define PageReclaim(page) test_bit(PG_reclaim, &(page)->flags)
251#define SetPageReclaim(page) set_bit(PG_reclaim, &(page)->flags)
252#define ClearPageReclaim(page) clear_bit(PG_reclaim, &(page)->flags)
253#define TestClearPageReclaim(page) test_and_clear_bit(PG_reclaim, &(page)->flags)
254 269
255#define PageCompound(page) test_bit(PG_compound, &(page)->flags) 270}
256#define __SetPageCompound(page) __set_bit(PG_compound, &(page)->flags) 271#else
257#define __ClearPageCompound(page) __clear_bit(PG_compound, &(page)->flags) 272/*
273 * Reduce page flag use as much as possible by overlapping
274 * compound page flags with the flags used for page cache pages. Possible
275 * because PageCompound is always set for compound pages and not for
276 * pages on the LRU and/or pagecache.
277 */
278TESTPAGEFLAG(Compound, compound)
279__PAGEFLAG(Head, compound)
258 280
259/* 281/*
260 * PG_reclaim is used in combination with PG_compound to mark the 282 * PG_reclaim is used in combination with PG_compound to mark the
261 * head and tail of a compound page 283 * head and tail of a compound page. This saves one page flag
284 * but makes it impossible to use compound pages for the page cache.
285 * The PG_reclaim bit would have to be used for reclaim or readahead
286 * if compound pages enter the page cache.
262 * 287 *
263 * PG_compound & PG_reclaim => Tail page 288 * PG_compound & PG_reclaim => Tail page
264 * PG_compound & ~PG_reclaim => Head page 289 * PG_compound & ~PG_reclaim => Head page
265 */ 290 */
266
267#define PG_head_tail_mask ((1L << PG_compound) | (1L << PG_reclaim)) 291#define PG_head_tail_mask ((1L << PG_compound) | (1L << PG_reclaim))
268 292
269#define PageTail(page) (((page)->flags & PG_head_tail_mask) \ 293static inline int PageTail(struct page *page)
270 == PG_head_tail_mask) 294{
295 return ((page->flags & PG_head_tail_mask) == PG_head_tail_mask);
296}
271 297
272static inline void __SetPageTail(struct page *page) 298static inline void __SetPageTail(struct page *page)
273{ 299{
@@ -279,33 +305,6 @@ static inline void __ClearPageTail(struct page *page)
279 page->flags &= ~PG_head_tail_mask; 305 page->flags &= ~PG_head_tail_mask;
280} 306}
281 307
282#define PageHead(page) (((page)->flags & PG_head_tail_mask) \ 308#endif /* !PAGEFLAGS_EXTENDED */
283 == (1L << PG_compound)) 309#endif /* !__GENERATING_BOUNDS_H */
284#define __SetPageHead(page) __SetPageCompound(page)
285#define __ClearPageHead(page) __ClearPageCompound(page)
286
287#ifdef CONFIG_SWAP
288#define PageSwapCache(page) test_bit(PG_swapcache, &(page)->flags)
289#define SetPageSwapCache(page) set_bit(PG_swapcache, &(page)->flags)
290#define ClearPageSwapCache(page) clear_bit(PG_swapcache, &(page)->flags)
291#else
292#define PageSwapCache(page) 0
293#endif
294
295#define PageUncached(page) test_bit(PG_uncached, &(page)->flags)
296#define SetPageUncached(page) set_bit(PG_uncached, &(page)->flags)
297#define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)
298
299struct page; /* forward declaration */
300
301extern void cancel_dirty_page(struct page *page, unsigned int account_size);
302
303int test_clear_page_writeback(struct page *page);
304int test_set_page_writeback(struct page *page);
305
306static inline void set_page_writeback(struct page *page)
307{
308 test_set_page_writeback(page);
309}
310
311#endif /* PAGE_FLAGS_H */ 310#endif /* PAGE_FLAGS_H */
diff --git a/include/linux/parport.h b/include/linux/parport.h
index d1ad546c8c9e..dcb9e01a69ca 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -101,9 +101,9 @@ typedef enum {
101#include <linux/spinlock.h> 101#include <linux/spinlock.h>
102#include <linux/wait.h> 102#include <linux/wait.h>
103#include <linux/irqreturn.h> 103#include <linux/irqreturn.h>
104#include <linux/semaphore.h>
104#include <asm/system.h> 105#include <asm/system.h>
105#include <asm/ptrace.h> 106#include <asm/ptrace.h>
106#include <asm/semaphore.h>
107 107
108/* Define this later. */ 108/* Define this later. */
109struct parport; 109struct parport;
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h
new file mode 100644
index 000000000000..a1a1e618e996
--- /dev/null
+++ b/include/linux/pci-aspm.h
@@ -0,0 +1,56 @@
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
31static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
32{
33}
34static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev)
35{
36}
37static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev)
38{
39}
40static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
41{
42}
43#endif
44
45#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */
46extern void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev);
47extern void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev);
48#else
49static inline void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev)
50{
51}
52static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
53{
54}
55#endif
56#endif /* LINUX_ASPM_H */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ea760e519c46..96acd0dae241 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -128,11 +128,13 @@ struct pci_cap_saved_state {
128 u32 data[0]; 128 u32 data[0];
129}; 129};
130 130
131struct pcie_link_state;
132struct pci_vpd;
133
131/* 134/*
132 * The pci_dev structure is used to describe PCI devices. 135 * The pci_dev structure is used to describe PCI devices.
133 */ 136 */
134struct pci_dev { 137struct pci_dev {
135 struct list_head global_list; /* node in list of all PCI devices */
136 struct list_head bus_list; /* node in per-bus list */ 138 struct list_head bus_list; /* node in per-bus list */
137 struct pci_bus *bus; /* bus this device is on */ 139 struct pci_bus *bus; /* bus this device is on */
138 struct pci_bus *subordinate; /* bus this device bridges to */ 140 struct pci_bus *subordinate; /* bus this device bridges to */
@@ -165,6 +167,10 @@ struct pci_dev {
165 this is D0-D3, D0 being fully functional, 167 this is D0-D3, D0 being fully functional,
166 and D3 being off. */ 168 and D3 being off. */
167 169
170#ifdef CONFIG_PCIEASPM
171 struct pcie_link_state *link_state; /* ASPM link state. */
172#endif
173
168 pci_channel_state_t error_state; /* current connectivity state */ 174 pci_channel_state_t error_state; /* current connectivity state */
169 struct device dev; /* Generic device interface */ 175 struct device dev; /* Generic device interface */
170 176
@@ -181,6 +187,7 @@ struct pci_dev {
181 unsigned int transparent:1; /* Transparent PCI bridge */ 187 unsigned int transparent:1; /* Transparent PCI bridge */
182 unsigned int multifunction:1;/* Part of multi-function device */ 188 unsigned int multifunction:1;/* Part of multi-function device */
183 /* keep track of device state */ 189 /* keep track of device state */
190 unsigned int is_added:1;
184 unsigned int is_busmaster:1; /* device is busmaster */ 191 unsigned int is_busmaster:1; /* device is busmaster */
185 unsigned int no_msi:1; /* device may not use msi */ 192 unsigned int no_msi:1; /* device may not use msi */
186 unsigned int no_d1d2:1; /* only allow d0 or d3 */ 193 unsigned int no_d1d2:1; /* only allow d0 or d3 */
@@ -201,11 +208,11 @@ struct pci_dev {
201#ifdef CONFIG_PCI_MSI 208#ifdef CONFIG_PCI_MSI
202 struct list_head msi_list; 209 struct list_head msi_list;
203#endif 210#endif
211 struct pci_vpd *vpd;
204}; 212};
205 213
206extern struct pci_dev *alloc_pci_dev(void); 214extern struct pci_dev *alloc_pci_dev(void);
207 215
208#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
209#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) 216#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
210#define to_pci_dev(n) container_of(n, struct pci_dev, dev) 217#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
211#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) 218#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
@@ -247,7 +254,7 @@ static inline void pci_add_saved_cap(struct pci_dev *pci_dev,
247#define PCI_NUM_RESOURCES 11 254#define PCI_NUM_RESOURCES 11
248 255
249#ifndef PCI_BUS_NUM_RESOURCES 256#ifndef PCI_BUS_NUM_RESOURCES
250#define PCI_BUS_NUM_RESOURCES 8 257#define PCI_BUS_NUM_RESOURCES 16
251#endif 258#endif
252 259
253#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ 260#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */
@@ -449,7 +456,6 @@ extern struct bus_type pci_bus_type;
449/* Do NOT directly access these two variables, unless you are arch specific pci 456/* Do NOT directly access these two variables, unless you are arch specific pci
450 * code, or pci core code. */ 457 * code, or pci core code. */
451extern struct list_head pci_root_buses; /* list of all known PCI buses */ 458extern struct list_head pci_root_buses; /* list of all known PCI buses */
452extern struct list_head pci_devices; /* list of all devices */
453/* Some device drivers need know if pci is initiated */ 459/* Some device drivers need know if pci is initiated */
454extern int no_pci_devices(void); 460extern int no_pci_devices(void);
455 461
@@ -517,17 +523,13 @@ struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
517 523
518struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, 524struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
519 struct pci_dev *from); 525 struct pci_dev *from);
520struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device,
521 struct pci_dev *from);
522
523struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, 526struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
524 unsigned int ss_vendor, unsigned int ss_device, 527 unsigned int ss_vendor, unsigned int ss_device,
525 struct pci_dev *from); 528 const struct pci_dev *from);
526struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn); 529struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
527struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn); 530struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn);
528struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from); 531struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
529int pci_dev_present(const struct pci_device_id *ids); 532int pci_dev_present(const struct pci_device_id *ids);
530const struct pci_device_id *pci_find_present(const struct pci_device_id *ids);
531 533
532int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn, 534int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
533 int where, u8 *val); 535 int where, u8 *val);
@@ -601,7 +603,6 @@ int pcie_get_readrq(struct pci_dev *dev);
601int pcie_set_readrq(struct pci_dev *dev, int rq); 603int pcie_set_readrq(struct pci_dev *dev, int rq);
602void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); 604void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno);
603int __must_check pci_assign_resource(struct pci_dev *dev, int i); 605int __must_check pci_assign_resource(struct pci_dev *dev, int i);
604int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i);
605int pci_select_bars(struct pci_dev *dev, unsigned long flags); 606int pci_select_bars(struct pci_dev *dev, unsigned long flags);
606 607
607/* ROM control related routines */ 608/* ROM control related routines */
@@ -626,6 +627,7 @@ int pci_claim_resource(struct pci_dev *, int);
626void pci_assign_unassigned_resources(void); 627void pci_assign_unassigned_resources(void);
627void pdev_enable_device(struct pci_dev *); 628void pdev_enable_device(struct pci_dev *);
628void pdev_sort_resources(struct pci_dev *, struct resource_list *); 629void pdev_sort_resources(struct pci_dev *, struct resource_list *);
630int pci_enable_resources(struct pci_dev *, int mask);
629void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), 631void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
630 int (*)(struct pci_dev *, u8, u8)); 632 int (*)(struct pci_dev *, u8, u8));
631#define HAVE_PCI_REQ_REGIONS 2 633#define HAVE_PCI_REQ_REGIONS 2
@@ -664,6 +666,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
664 666
665void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), 667void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
666 void *userdata); 668 void *userdata);
669int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix);
667int pci_cfg_space_size(struct pci_dev *dev); 670int pci_cfg_space_size(struct pci_dev *dev);
668unsigned char pci_bus_max_busnr(struct pci_bus *bus); 671unsigned char pci_bus_max_busnr(struct pci_bus *bus);
669 672
@@ -699,6 +702,8 @@ static inline int pci_enable_msi(struct pci_dev *dev)
699 return -1; 702 return -1;
700} 703}
701 704
705static inline void pci_msi_shutdown(struct pci_dev *dev)
706{ }
702static inline void pci_disable_msi(struct pci_dev *dev) 707static inline void pci_disable_msi(struct pci_dev *dev)
703{ } 708{ }
704 709
@@ -708,6 +713,8 @@ static inline int pci_enable_msix(struct pci_dev *dev,
708 return -1; 713 return -1;
709} 714}
710 715
716static inline void pci_msix_shutdown(struct pci_dev *dev)
717{ }
711static inline void pci_disable_msix(struct pci_dev *dev) 718static inline void pci_disable_msix(struct pci_dev *dev)
712{ } 719{ }
713 720
@@ -718,9 +725,11 @@ static inline void pci_restore_msi_state(struct pci_dev *dev)
718{ } 725{ }
719#else 726#else
720extern int pci_enable_msi(struct pci_dev *dev); 727extern int pci_enable_msi(struct pci_dev *dev);
728extern void pci_msi_shutdown(struct pci_dev *dev);
721extern void pci_disable_msi(struct pci_dev *dev); 729extern void pci_disable_msi(struct pci_dev *dev);
722extern int pci_enable_msix(struct pci_dev *dev, 730extern int pci_enable_msix(struct pci_dev *dev,
723 struct msix_entry *entries, int nvec); 731 struct msix_entry *entries, int nvec);
732extern void pci_msix_shutdown(struct pci_dev *dev);
724extern void pci_disable_msix(struct pci_dev *dev); 733extern void pci_disable_msix(struct pci_dev *dev);
725extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); 734extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
726extern void pci_restore_msi_state(struct pci_dev *dev); 735extern void pci_restore_msi_state(struct pci_dev *dev);
@@ -793,18 +802,11 @@ static inline struct pci_dev *pci_get_device(unsigned int vendor,
793 return NULL; 802 return NULL;
794} 803}
795 804
796static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor,
797 unsigned int device,
798 struct pci_dev *from)
799{
800 return NULL;
801}
802
803static inline struct pci_dev *pci_get_subsys(unsigned int vendor, 805static inline struct pci_dev *pci_get_subsys(unsigned int vendor,
804 unsigned int device, 806 unsigned int device,
805 unsigned int ss_vendor, 807 unsigned int ss_vendor,
806 unsigned int ss_device, 808 unsigned int ss_device,
807 struct pci_dev *from) 809 const struct pci_dev *from)
808{ 810{
809 return NULL; 811 return NULL;
810} 812}
@@ -817,7 +819,6 @@ static inline struct pci_dev *pci_get_class(unsigned int class,
817 819
818#define pci_dev_present(ids) (0) 820#define pci_dev_present(ids) (0)
819#define no_pci_devices() (1) 821#define no_pci_devices() (1)
820#define pci_find_present(ids) (NULL)
821#define pci_dev_put(dev) do { } while (0) 822#define pci_dev_put(dev) do { } while (0)
822 823
823static inline void pci_set_master(struct pci_dev *dev) 824static inline void pci_set_master(struct pci_dev *dev)
@@ -1059,5 +1060,13 @@ extern unsigned long pci_cardbus_mem_size;
1059 1060
1060extern int pcibios_add_platform_entries(struct pci_dev *dev); 1061extern int pcibios_add_platform_entries(struct pci_dev *dev);
1061 1062
1063#ifdef CONFIG_PCI_MMCONFIG
1064extern void __init pci_mmcfg_early_init(void);
1065extern void __init pci_mmcfg_late_init(void);
1066#else
1067static inline void pci_mmcfg_early_init(void) { }
1068static inline void pci_mmcfg_late_init(void) { }
1069#endif
1070
1062#endif /* __KERNEL__ */ 1071#endif /* __KERNEL__ */
1063#endif /* LINUX_PCI_H */ 1072#endif /* LINUX_PCI_H */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 70eb3c803d47..cf6dbd759395 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1429,6 +1429,7 @@
1429#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 1429#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9
1430#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA 1430#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA
1431#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB 1431#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB
1432#define PCIE_DEVICE_ID_NEO_4_IBM 0x00F4
1432 1433
1433#define PCI_VENDOR_ID_XIRCOM 0x115d 1434#define PCI_VENDOR_ID_XIRCOM 0x115d
1434#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 1435#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101
@@ -2413,6 +2414,8 @@
2413#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0 2414#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0
2414#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 2415#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2
2415#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 2416#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
2417#define PCI_DEVICE_ID_INTEL_SCH_LPC 0x8119
2418#define PCI_DEVICE_ID_INTEL_SCH_IDE 0x811a
2416#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 2419#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4
2417#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5 2420#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5
2418#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca 2421#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
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
deleted file mode 100644
index a82d9f2628ca..000000000000
--- a/include/linux/pcounter.h
+++ /dev/null
@@ -1,74 +0,0 @@
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/percpu.h b/include/linux/percpu.h
index 1ac969724bb2..d746a2abb322 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -4,7 +4,6 @@
4#include <linux/preempt.h> 4#include <linux/preempt.h>
5#include <linux/slab.h> /* For kmalloc() */ 5#include <linux/slab.h> /* For kmalloc() */
6#include <linux/smp.h> 6#include <linux/smp.h>
7#include <linux/string.h> /* For memset() */
8#include <linux/cpumask.h> 7#include <linux/cpumask.h>
9 8
10#include <asm/percpu.h> 9#include <asm/percpu.h>
diff --git a/include/linux/personality.h b/include/linux/personality.h
index 012cd558189b..a84e9ff9b27e 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -105,10 +105,6 @@ struct exec_domain {
105 */ 105 */
106#define personality(pers) (pers & PER_MASK) 106#define personality(pers) (pers & PER_MASK)
107 107
108/*
109 * Personality of the currently running process.
110 */
111#define get_personality (current->personality)
112 108
113/* 109/*
114 * Change personality of the currently running process. 110 * Change personality of the currently running process.
diff --git a/include/linux/phantom.h b/include/linux/phantom.h
index 96f4048a6cc3..02268c54c250 100644
--- a/include/linux/phantom.h
+++ b/include/linux/phantom.h
@@ -27,14 +27,17 @@ struct phm_regs {
27 27
28#define PH_IOC_MAGIC 'p' 28#define PH_IOC_MAGIC 'p'
29#define PHN_GET_REG _IOWR(PH_IOC_MAGIC, 0, struct phm_reg *) 29#define PHN_GET_REG _IOWR(PH_IOC_MAGIC, 0, struct phm_reg *)
30#define PHN_SET_REG _IOW (PH_IOC_MAGIC, 1, struct phm_reg *) 30#define PHN_SET_REG _IOW(PH_IOC_MAGIC, 1, struct phm_reg *)
31#define PHN_GET_REGS _IOWR(PH_IOC_MAGIC, 2, struct phm_regs *) 31#define PHN_GET_REGS _IOWR(PH_IOC_MAGIC, 2, struct phm_regs *)
32#define PHN_SET_REGS _IOW (PH_IOC_MAGIC, 3, struct phm_regs *) 32#define PHN_SET_REGS _IOW(PH_IOC_MAGIC, 3, struct phm_regs *)
33/* this ioctl tells the driver, that the caller is not OpenHaptics and might 33/* this ioctl tells the driver, that the caller is not OpenHaptics and might
34 * use improved registers update (no more phantom switchoffs when using 34 * use improved registers update (no more phantom switchoffs when using
35 * libphantom) */ 35 * libphantom) */
36#define PHN_NOT_OH _IO (PH_IOC_MAGIC, 4) 36#define PHN_NOT_OH _IO(PH_IOC_MAGIC, 4)
37#define PH_IOC_MAXNR 4 37#define PHN_GETREG _IOWR(PH_IOC_MAGIC, 5, struct phm_reg)
38#define PHN_SETREG _IOW(PH_IOC_MAGIC, 6, struct phm_reg)
39#define PHN_GETREGS _IOWR(PH_IOC_MAGIC, 7, struct phm_regs)
40#define PHN_SETREGS _IOW(PH_IOC_MAGIC, 8, struct phm_regs)
38 41
39#define PHN_CONTROL 0x6 /* control byte in iaddr space */ 42#define PHN_CONTROL 0x6 /* control byte in iaddr space */
40#define PHN_CTL_AMP 0x1 /* switch after torques change */ 43#define PHN_CTL_AMP 0x1 /* switch after torques change */
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 5e43ae751412..02df20f085fe 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -39,7 +39,8 @@
39 SUPPORTED_1000baseT_Half | \ 39 SUPPORTED_1000baseT_Half | \
40 SUPPORTED_1000baseT_Full) 40 SUPPORTED_1000baseT_Full)
41 41
42/* Set phydev->irq to PHY_POLL if interrupts are not supported, 42/*
43 * Set phydev->irq to PHY_POLL if interrupts are not supported,
43 * or not desired for this PHY. Set to PHY_IGNORE_INTERRUPT if 44 * or not desired for this PHY. Set to PHY_IGNORE_INTERRUPT if
44 * the attached driver handles the interrupt 45 * the attached driver handles the interrupt
45 */ 46 */
@@ -63,8 +64,6 @@ typedef enum {
63 PHY_INTERFACE_MODE_RTBI 64 PHY_INTERFACE_MODE_RTBI
64} phy_interface_t; 65} phy_interface_t;
65 66
66#define MII_BUS_MAX 4
67
68 67
69#define PHY_INIT_TIMEOUT 100000 68#define PHY_INIT_TIMEOUT 100000
70#define PHY_STATE_TIME 1 69#define PHY_STATE_TIME 1
@@ -74,20 +73,30 @@ typedef enum {
74#define PHY_MAX_ADDR 32 73#define PHY_MAX_ADDR 32
75 74
76/* Used when trying to connect to a specific phy (mii bus id:phy device id) */ 75/* Used when trying to connect to a specific phy (mii bus id:phy device id) */
77#define PHY_ID_FMT "%x:%02x" 76#define PHY_ID_FMT "%s:%02x"
77
78/*
79 * Need to be a little smaller than phydev->dev.bus_id to leave room
80 * for the ":%02x"
81 */
82#define MII_BUS_ID_SIZE (BUS_ID_SIZE - 3)
78 83
79/* The Bus class for PHYs. Devices which provide access to 84/*
80 * PHYs should register using this structure */ 85 * The Bus class for PHYs. Devices which provide access to
86 * PHYs should register using this structure
87 */
81struct mii_bus { 88struct mii_bus {
82 const char *name; 89 const char *name;
83 int id; 90 char id[MII_BUS_ID_SIZE];
84 void *priv; 91 void *priv;
85 int (*read)(struct mii_bus *bus, int phy_id, int regnum); 92 int (*read)(struct mii_bus *bus, int phy_id, int regnum);
86 int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val); 93 int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val);
87 int (*reset)(struct mii_bus *bus); 94 int (*reset)(struct mii_bus *bus);
88 95
89 /* A lock to ensure that only one thing can read/write 96 /*
90 * the MDIO bus at a time */ 97 * A lock to ensure that only one thing can read/write
98 * the MDIO bus at a time
99 */
91 struct mutex mdio_lock; 100 struct mutex mdio_lock;
92 101
93 struct device *dev; 102 struct device *dev;
@@ -98,8 +107,10 @@ struct mii_bus {
98 /* Phy addresses to be ignored when probing */ 107 /* Phy addresses to be ignored when probing */
99 u32 phy_mask; 108 u32 phy_mask;
100 109
101 /* Pointer to an array of interrupts, each PHY's 110 /*
102 * interrupt at the index matching its address */ 111 * Pointer to an array of interrupts, each PHY's
112 * interrupt at the index matching its address
113 */
103 int *irq; 114 int *irq;
104}; 115};
105 116
@@ -251,7 +262,8 @@ struct phy_device {
251 /* Bus address of the PHY (0-32) */ 262 /* Bus address of the PHY (0-32) */
252 int addr; 263 int addr;
253 264
254 /* forced speed & duplex (no autoneg) 265 /*
266 * forced speed & duplex (no autoneg)
255 * partner speed & duplex & pause (autoneg) 267 * partner speed & duplex & pause (autoneg)
256 */ 268 */
257 int speed; 269 int speed;
@@ -274,8 +286,10 @@ struct phy_device {
274 286
275 int link_timeout; 287 int link_timeout;
276 288
277 /* Interrupt number for this PHY 289 /*
278 * -1 means no interrupt */ 290 * Interrupt number for this PHY
291 * -1 means no interrupt
292 */
279 int irq; 293 int irq;
280 294
281 /* private data pointer */ 295 /* private data pointer */
@@ -325,22 +339,28 @@ struct phy_driver {
325 u32 features; 339 u32 features;
326 u32 flags; 340 u32 flags;
327 341
328 /* Called to initialize the PHY, 342 /*
329 * including after a reset */ 343 * Called to initialize the PHY,
344 * including after a reset
345 */
330 int (*config_init)(struct phy_device *phydev); 346 int (*config_init)(struct phy_device *phydev);
331 347
332 /* Called during discovery. Used to set 348 /*
333 * up device-specific structures, if any */ 349 * Called during discovery. Used to set
350 * up device-specific structures, if any
351 */
334 int (*probe)(struct phy_device *phydev); 352 int (*probe)(struct phy_device *phydev);
335 353
336 /* PHY Power Management */ 354 /* PHY Power Management */
337 int (*suspend)(struct phy_device *phydev); 355 int (*suspend)(struct phy_device *phydev);
338 int (*resume)(struct phy_device *phydev); 356 int (*resume)(struct phy_device *phydev);
339 357
340 /* Configures the advertisement and resets 358 /*
359 * Configures the advertisement and resets
341 * autonegotiation if phydev->autoneg is on, 360 * autonegotiation if phydev->autoneg is on,
342 * forces the speed to the current settings in phydev 361 * forces the speed to the current settings in phydev
343 * if phydev->autoneg is off */ 362 * if phydev->autoneg is off
363 */
344 int (*config_aneg)(struct phy_device *phydev); 364 int (*config_aneg)(struct phy_device *phydev);
345 365
346 /* Determines the negotiated speed and duplex */ 366 /* Determines the negotiated speed and duplex */
@@ -359,14 +379,27 @@ struct phy_driver {
359}; 379};
360#define to_phy_driver(d) container_of(d, struct phy_driver, driver) 380#define to_phy_driver(d) container_of(d, struct phy_driver, driver)
361 381
382#define PHY_ANY_ID "MATCH ANY PHY"
383#define PHY_ANY_UID 0xffffffff
384
385/* A Structure for boards to register fixups with the PHY Lib */
386struct phy_fixup {
387 struct list_head list;
388 char bus_id[BUS_ID_SIZE];
389 u32 phy_uid;
390 u32 phy_uid_mask;
391 int (*run)(struct phy_device *phydev);
392};
393
362int phy_read(struct phy_device *phydev, u16 regnum); 394int phy_read(struct phy_device *phydev, u16 regnum);
363int phy_write(struct phy_device *phydev, u16 regnum, u16 val); 395int phy_write(struct phy_device *phydev, u16 regnum, u16 val);
396int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id);
364struct phy_device* get_phy_device(struct mii_bus *bus, int addr); 397struct phy_device* get_phy_device(struct mii_bus *bus, int addr);
365int phy_clear_interrupt(struct phy_device *phydev); 398int phy_clear_interrupt(struct phy_device *phydev);
366int phy_config_interrupt(struct phy_device *phydev, u32 interrupts); 399int phy_config_interrupt(struct phy_device *phydev, u32 interrupts);
367struct phy_device * phy_attach(struct net_device *dev, 400struct phy_device * phy_attach(struct net_device *dev,
368 const char *phy_id, u32 flags, phy_interface_t interface); 401 const char *bus_id, u32 flags, phy_interface_t interface);
369struct phy_device * phy_connect(struct net_device *dev, const char *phy_id, 402struct phy_device * phy_connect(struct net_device *dev, const char *bus_id,
370 void (*handler)(struct net_device *), u32 flags, 403 void (*handler)(struct net_device *), u32 flags,
371 phy_interface_t interface); 404 phy_interface_t interface);
372void phy_disconnect(struct phy_device *phydev); 405void phy_disconnect(struct phy_device *phydev);
@@ -406,5 +439,13 @@ void phy_print_status(struct phy_device *phydev);
406struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id); 439struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id);
407void phy_device_free(struct phy_device *phydev); 440void phy_device_free(struct phy_device *phydev);
408 441
442int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
443 int (*run)(struct phy_device *));
444int phy_register_fixup_for_id(const char *bus_id,
445 int (*run)(struct phy_device *));
446int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
447 int (*run)(struct phy_device *));
448int phy_scan_fixups(struct phy_device *phydev);
449
409extern struct bus_type mdio_bus_type; 450extern struct bus_type mdio_bus_type;
410#endif /* __PHY_H */ 451#endif /* __PHY_H */
diff --git a/include/linux/pid.h b/include/linux/pid.h
index c7980810eb09..c21c7e8124a7 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -60,7 +60,7 @@ struct pid
60 /* lists of tasks that use this pid */ 60 /* lists of tasks that use this pid */
61 struct hlist_head tasks[PIDTYPE_MAX]; 61 struct hlist_head tasks[PIDTYPE_MAX];
62 struct rcu_head rcu; 62 struct rcu_head rcu;
63 int level; 63 unsigned int level;
64 struct upid numbers[1]; 64 struct upid numbers[1];
65}; 65};
66 66
@@ -89,9 +89,11 @@ extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
89 * attach_pid() and detach_pid() must be called with the tasklist_lock 89 * attach_pid() and detach_pid() must be called with the tasklist_lock
90 * write-held. 90 * write-held.
91 */ 91 */
92extern int attach_pid(struct task_struct *task, enum pid_type type, 92extern void attach_pid(struct task_struct *task, enum pid_type type,
93 struct pid *pid); 93 struct pid *pid);
94extern void detach_pid(struct task_struct *task, enum pid_type); 94extern void detach_pid(struct task_struct *task, enum pid_type);
95extern void change_pid(struct task_struct *task, enum pid_type,
96 struct pid *pid);
95extern void transfer_pid(struct task_struct *old, struct task_struct *new, 97extern void transfer_pid(struct task_struct *old, struct task_struct *new,
96 enum pid_type); 98 enum pid_type);
97 99
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index fcd61fa2c833..caff5283d15c 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -20,7 +20,7 @@ struct pid_namespace {
20 int last_pid; 20 int last_pid;
21 struct task_struct *child_reaper; 21 struct task_struct *child_reaper;
22 struct kmem_cache *pid_cachep; 22 struct kmem_cache *pid_cachep;
23 int level; 23 unsigned int level;
24 struct pid_namespace *parent; 24 struct pid_namespace *parent;
25#ifdef CONFIG_PROC_FS 25#ifdef CONFIG_PROC_FS
26 struct vfsmount *proc_mnt; 26 struct vfsmount *proc_mnt;
diff --git a/include/linux/pim.h b/include/linux/pim.h
new file mode 100644
index 000000000000..236ffd317394
--- /dev/null
+++ b/include/linux/pim.h
@@ -0,0 +1,45 @@
1#ifndef __LINUX_PIM_H
2#define __LINUX_PIM_H
3
4#include <asm/byteorder.h>
5
6#ifndef __KERNEL__
7struct pim {
8#if defined(__LITTLE_ENDIAN_BITFIELD)
9 __u8 pim_type:4, /* PIM message type */
10 pim_ver:4; /* PIM version */
11#elif defined(__BIG_ENDIAN_BITFIELD)
12 __u8 pim_ver:4; /* PIM version */
13 pim_type:4; /* PIM message type */
14#endif
15 __u8 pim_rsv; /* Reserved */
16 __be16 pim_cksum; /* Checksum */
17};
18
19#define PIM_MINLEN 8
20#endif
21
22/* Message types - V1 */
23#define PIM_V1_VERSION __constant_htonl(0x10000000)
24#define PIM_V1_REGISTER 1
25
26/* Message types - V2 */
27#define PIM_VERSION 2
28#define PIM_REGISTER 1
29
30#if defined(__KERNEL__)
31#define PIM_NULL_REGISTER __constant_htonl(0x40000000)
32
33/* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
34struct pimreghdr
35{
36 __u8 type;
37 __u8 reserved;
38 __be16 csum;
39 __be32 flags;
40};
41
42struct sk_buff;
43extern int pim_rcv_v1(struct sk_buff *);
44#endif
45#endif
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 015b735811b4..39a7ee859b67 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -21,8 +21,6 @@
21#ifndef _LINUX_PM_H 21#ifndef _LINUX_PM_H
22#define _LINUX_PM_H 22#define _LINUX_PM_H
23 23
24#ifdef __KERNEL__
25
26#include <linux/list.h> 24#include <linux/list.h>
27#include <asm/atomic.h> 25#include <asm/atomic.h>
28#include <asm/errno.h> 26#include <asm/errno.h>
@@ -183,8 +181,9 @@ typedef struct pm_message {
183struct dev_pm_info { 181struct dev_pm_info {
184 pm_message_t power_state; 182 pm_message_t power_state;
185 unsigned can_wakeup:1; 183 unsigned can_wakeup:1;
186#ifdef CONFIG_PM_SLEEP
187 unsigned should_wakeup:1; 184 unsigned should_wakeup:1;
185 bool sleeping:1; /* Owned by the PM core */
186#ifdef CONFIG_PM_SLEEP
188 struct list_head entry; 187 struct list_head entry;
189#endif 188#endif
190}; 189};
@@ -197,11 +196,6 @@ extern void device_resume(void);
197extern int device_suspend(pm_message_t state); 196extern int device_suspend(pm_message_t state);
198extern int device_prepare_suspend(pm_message_t state); 197extern int device_prepare_suspend(pm_message_t state);
199 198
200#define device_set_wakeup_enable(dev,val) \
201 ((dev)->power.should_wakeup = !!(val))
202#define device_may_wakeup(dev) \
203 (device_can_wakeup(dev) && (dev)->power.should_wakeup)
204
205extern void __suspend_report_result(const char *function, void *fn, int ret); 199extern void __suspend_report_result(const char *function, void *fn, int ret);
206 200
207#define suspend_report_result(fn, ret) \ 201#define suspend_report_result(fn, ret) \
@@ -209,20 +203,6 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
209 __suspend_report_result(__FUNCTION__, fn, ret); \ 203 __suspend_report_result(__FUNCTION__, fn, ret); \
210 } while (0) 204 } while (0)
211 205
212/*
213 * Platform hook to activate device wakeup capability, if that's not already
214 * handled by enable_irq_wake() etc.
215 * Returns zero on success, else negative errno
216 */
217extern int (*platform_enable_wakeup)(struct device *dev, int is_on);
218
219static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
220{
221 if (platform_enable_wakeup)
222 return (*platform_enable_wakeup)(dev, is_on);
223 return 0;
224}
225
226#else /* !CONFIG_PM_SLEEP */ 206#else /* !CONFIG_PM_SLEEP */
227 207
228static inline int device_suspend(pm_message_t state) 208static inline int device_suspend(pm_message_t state)
@@ -230,29 +210,10 @@ static inline int device_suspend(pm_message_t state)
230 return 0; 210 return 0;
231} 211}
232 212
233#define device_set_wakeup_enable(dev,val) do{}while(0) 213#define suspend_report_result(fn, ret) do {} while (0)
234#define device_may_wakeup(dev) (0)
235
236#define suspend_report_result(fn, ret) do { } while (0)
237
238static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
239{
240 return 0;
241}
242 214
243#endif /* !CONFIG_PM_SLEEP */ 215#endif /* !CONFIG_PM_SLEEP */
244 216
245/* changes to device_may_wakeup take effect on the next pm state change.
246 * by default, devices should wakeup if they can.
247 */
248#define device_can_wakeup(dev) \
249 ((dev)->power.can_wakeup)
250#define device_init_wakeup(dev,val) \
251 do { \
252 device_can_wakeup(dev) = !!(val); \
253 device_set_wakeup_enable(dev,val); \
254 } while(0)
255
256/* 217/*
257 * Global Power Management flags 218 * Global Power Management flags
258 * Used to keep APM and ACPI from both being active 219 * Used to keep APM and ACPI from both being active
@@ -262,6 +223,4 @@ extern unsigned int pm_flags;
262#define PM_APM 1 223#define PM_APM 1
263#define PM_ACPI 2 224#define PM_ACPI 2
264 225
265#endif /* __KERNEL__ */
266
267#endif /* _LINUX_PM_H */ 226#endif /* _LINUX_PM_H */
diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h
new file mode 100644
index 000000000000..f0d0b2cb8d20
--- /dev/null
+++ b/include/linux/pm_wakeup.h
@@ -0,0 +1,90 @@
1/*
2 * pm_wakeup.h - Power management wakeup interface
3 *
4 * Copyright (C) 2008 Alan Stern
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#ifndef _LINUX_PM_WAKEUP_H
22#define _LINUX_PM_WAKEUP_H
23
24#ifndef _DEVICE_H_
25# error "please don't include this file directly"
26#endif
27
28#ifdef CONFIG_PM
29
30/* changes to device_may_wakeup take effect on the next pm state change.
31 * by default, devices should wakeup if they can.
32 */
33static inline void device_init_wakeup(struct device *dev, int val)
34{
35 dev->power.can_wakeup = dev->power.should_wakeup = !!val;
36}
37
38static inline int device_can_wakeup(struct device *dev)
39{
40 return dev->power.can_wakeup;
41}
42
43static inline void device_set_wakeup_enable(struct device *dev, int val)
44{
45 dev->power.should_wakeup = !!val;
46}
47
48static inline int device_may_wakeup(struct device *dev)
49{
50 return dev->power.can_wakeup & dev->power.should_wakeup;
51}
52
53/*
54 * Platform hook to activate device wakeup capability, if that's not already
55 * handled by enable_irq_wake() etc.
56 * Returns zero on success, else negative errno
57 */
58extern int (*platform_enable_wakeup)(struct device *dev, int is_on);
59
60static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
61{
62 if (platform_enable_wakeup)
63 return (*platform_enable_wakeup)(dev, is_on);
64 return 0;
65}
66
67#else /* !CONFIG_PM */
68
69/* For some reason the next two routines work even without CONFIG_PM */
70static inline void device_init_wakeup(struct device *dev, int val)
71{
72 dev->power.can_wakeup = !!val;
73}
74
75static inline int device_can_wakeup(struct device *dev)
76{
77 return dev->power.can_wakeup;
78}
79
80#define device_set_wakeup_enable(dev, val) do {} while (0)
81#define device_may_wakeup(dev) 0
82
83static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
84{
85 return 0;
86}
87
88#endif /* !CONFIG_PM */
89
90#endif /* _LINUX_PM_WAKEUP_H */
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index b2f05c230f4b..63b128d512fb 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -6,66 +6,127 @@
6#ifndef _LINUX_PNP_H 6#ifndef _LINUX_PNP_H
7#define _LINUX_PNP_H 7#define _LINUX_PNP_H
8 8
9#ifdef __KERNEL__
10
11#include <linux/device.h> 9#include <linux/device.h>
12#include <linux/list.h> 10#include <linux/list.h>
13#include <linux/errno.h> 11#include <linux/errno.h>
14#include <linux/mod_devicetable.h> 12#include <linux/mod_devicetable.h>
15 13
16#define PNP_MAX_PORT 40
17#define PNP_MAX_MEM 24
18#define PNP_MAX_IRQ 2
19#define PNP_MAX_DMA 2
20#define PNP_NAME_LEN 50 14#define PNP_NAME_LEN 50
21 15
22struct pnp_protocol; 16struct pnp_protocol;
23struct pnp_dev; 17struct pnp_dev;
18struct pnp_resource_table;
24 19
25/* 20/*
26 * Resource Management 21 * Resource Management
27 */ 22 */
23struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int);
24
25static inline int pnp_resource_valid(struct resource *res)
26{
27 if (res && !(res->flags & IORESOURCE_UNSET))
28 return 1;
29 return 0;
30}
31
32static inline resource_size_t pnp_resource_len(struct resource *res)
33{
34 if (res->start == 0 && res->end == 0)
35 return 0;
36 return res->end - res->start + 1;
37}
38
39
40static inline resource_size_t pnp_port_start(struct pnp_dev *dev,
41 unsigned int bar)
42{
43 return pnp_get_resource(dev, IORESOURCE_IO, bar)->start;
44}
45
46static inline resource_size_t pnp_port_end(struct pnp_dev *dev,
47 unsigned int bar)
48{
49 return pnp_get_resource(dev, IORESOURCE_IO, bar)->end;
50}
51
52static inline unsigned long pnp_port_flags(struct pnp_dev *dev,
53 unsigned int bar)
54{
55 return pnp_get_resource(dev, IORESOURCE_IO, bar)->flags;
56}
57
58static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar)
59{
60 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IO, bar));
61}
62
63static inline resource_size_t pnp_port_len(struct pnp_dev *dev,
64 unsigned int bar)
65{
66 return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_IO, bar));
67}
68
69
70static inline resource_size_t pnp_mem_start(struct pnp_dev *dev,
71 unsigned int bar)
72{
73 return pnp_get_resource(dev, IORESOURCE_MEM, bar)->start;
74}
75
76static inline resource_size_t pnp_mem_end(struct pnp_dev *dev,
77 unsigned int bar)
78{
79 return pnp_get_resource(dev, IORESOURCE_MEM, bar)->end;
80}
81
82static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, unsigned int bar)
83{
84 return pnp_get_resource(dev, IORESOURCE_MEM, bar)->flags;
85}
86
87static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar)
88{
89 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_MEM, bar));
90}
91
92static inline resource_size_t pnp_mem_len(struct pnp_dev *dev,
93 unsigned int bar)
94{
95 return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_MEM, bar));
96}
97
98
99static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
100{
101 return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->start;
102}
103
104static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar)
105{
106 return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->flags;
107}
108
109static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar)
110{
111 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IRQ, bar));
112}
113
114
115static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar)
116{
117 return pnp_get_resource(dev, IORESOURCE_DMA, bar)->start;
118}
119
120static inline unsigned long pnp_dma_flags(struct pnp_dev *dev, unsigned int bar)
121{
122 return pnp_get_resource(dev, IORESOURCE_DMA, bar)->flags;
123}
124
125static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar)
126{
127 return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_DMA, bar));
128}
28 129
29/* Use these instead of directly reading pnp_dev to get resource information */
30#define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start)
31#define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end)
32#define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags)
33#define pnp_port_valid(dev,bar) \
34 ((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \
35 == IORESOURCE_IO)
36#define pnp_port_len(dev,bar) \
37 ((pnp_port_start((dev),(bar)) == 0 && \
38 pnp_port_end((dev),(bar)) == \
39 pnp_port_start((dev),(bar))) ? 0 : \
40 \
41 (pnp_port_end((dev),(bar)) - \
42 pnp_port_start((dev),(bar)) + 1))
43
44#define pnp_mem_start(dev,bar) ((dev)->res.mem_resource[(bar)].start)
45#define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end)
46#define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags)
47#define pnp_mem_valid(dev,bar) \
48 ((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \
49 == IORESOURCE_MEM)
50#define pnp_mem_len(dev,bar) \
51 ((pnp_mem_start((dev),(bar)) == 0 && \
52 pnp_mem_end((dev),(bar)) == \
53 pnp_mem_start((dev),(bar))) ? 0 : \
54 \
55 (pnp_mem_end((dev),(bar)) - \
56 pnp_mem_start((dev),(bar)) + 1))
57
58#define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start)
59#define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags)
60#define pnp_irq_valid(dev,bar) \
61 ((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \
62 == IORESOURCE_IRQ)
63
64#define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start)
65#define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags)
66#define pnp_dma_valid(dev,bar) \
67 ((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \
68 == IORESOURCE_DMA)
69 130
70#define PNP_PORT_FLAG_16BITADDR (1<<0) 131#define PNP_PORT_FLAG_16BITADDR (1<<0)
71#define PNP_PORT_FLAG_FIXED (1<<1) 132#define PNP_PORT_FLAG_FIXED (1<<1)
@@ -118,13 +179,6 @@ struct pnp_option {
118 struct pnp_option *next; /* used to chain dependent resources */ 179 struct pnp_option *next; /* used to chain dependent resources */
119}; 180};
120 181
121struct pnp_resource_table {
122 struct resource port_resource[PNP_MAX_PORT];
123 struct resource mem_resource[PNP_MAX_MEM];
124 struct resource dma_resource[PNP_MAX_DMA];
125 struct resource irq_resource[PNP_MAX_IRQ];
126};
127
128/* 182/*
129 * Device Management 183 * Device Management
130 */ 184 */
@@ -194,10 +248,9 @@ struct pnp_dev {
194 int capabilities; 248 int capabilities;
195 struct pnp_option *independent; 249 struct pnp_option *independent;
196 struct pnp_option *dependent; 250 struct pnp_option *dependent;
197 struct pnp_resource_table res; 251 struct pnp_resource_table *res;
198 252
199 char name[PNP_NAME_LEN]; /* contains a human-readable name */ 253 char name[PNP_NAME_LEN]; /* contains a human-readable name */
200 unsigned short regs; /* ISAPnP: supported registers */
201 int flags; /* used by protocols */ 254 int flags; /* used by protocols */
202 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */ 255 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */
203 void *data; 256 void *data;
@@ -328,8 +381,8 @@ struct pnp_protocol {
328 char *name; 381 char *name;
329 382
330 /* resource control functions */ 383 /* resource control functions */
331 int (*get) (struct pnp_dev *dev, struct pnp_resource_table *res); 384 int (*get) (struct pnp_dev *dev);
332 int (*set) (struct pnp_dev *dev, struct pnp_resource_table *res); 385 int (*set) (struct pnp_dev *dev);
333 int (*disable) (struct pnp_dev *dev); 386 int (*disable) (struct pnp_dev *dev);
334 387
335 /* protocol specific suspend/resume */ 388 /* protocol specific suspend/resume */
@@ -358,20 +411,12 @@ extern struct bus_type pnp_bus_type;
358#if defined(CONFIG_PNP) 411#if defined(CONFIG_PNP)
359 412
360/* device management */ 413/* device management */
361int pnp_register_protocol(struct pnp_protocol *protocol);
362void pnp_unregister_protocol(struct pnp_protocol *protocol);
363int pnp_add_device(struct pnp_dev *dev);
364int pnp_device_attach(struct pnp_dev *pnp_dev); 414int pnp_device_attach(struct pnp_dev *pnp_dev);
365void pnp_device_detach(struct pnp_dev *pnp_dev); 415void pnp_device_detach(struct pnp_dev *pnp_dev);
366extern struct list_head pnp_global; 416extern struct list_head pnp_global;
367extern int pnp_platform_devices; 417extern int pnp_platform_devices;
368 418
369/* multidevice card support */ 419/* multidevice card support */
370int pnp_add_card(struct pnp_card *card);
371void pnp_remove_card(struct pnp_card *card);
372int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
373void pnp_remove_card_device(struct pnp_dev *dev);
374int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card);
375struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, 420struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
376 const char *id, struct pnp_dev *from); 421 const char *id, struct pnp_dev *from);
377void pnp_release_card_device(struct pnp_dev *dev); 422void pnp_release_card_device(struct pnp_dev *dev);
@@ -380,77 +425,42 @@ void pnp_unregister_card_driver(struct pnp_card_driver *drv);
380extern struct list_head pnp_cards; 425extern struct list_head pnp_cards;
381 426
382/* resource management */ 427/* resource management */
383struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
384struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
385 int priority);
386int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data);
387int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data);
388int pnp_register_port_resource(struct pnp_option *option,
389 struct pnp_port *data);
390int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
391void pnp_init_resource_table(struct pnp_resource_table *table);
392int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
393 int mode);
394int pnp_auto_config_dev(struct pnp_dev *dev); 428int pnp_auto_config_dev(struct pnp_dev *dev);
395int pnp_validate_config(struct pnp_dev *dev);
396int pnp_start_dev(struct pnp_dev *dev); 429int pnp_start_dev(struct pnp_dev *dev);
397int pnp_stop_dev(struct pnp_dev *dev); 430int pnp_stop_dev(struct pnp_dev *dev);
398int pnp_activate_dev(struct pnp_dev *dev); 431int pnp_activate_dev(struct pnp_dev *dev);
399int pnp_disable_dev(struct pnp_dev *dev); 432int pnp_disable_dev(struct pnp_dev *dev);
400void pnp_resource_change(struct resource *resource, resource_size_t start,
401 resource_size_t size);
402 433
403/* protocol helpers */ 434/* protocol helpers */
404int pnp_is_active(struct pnp_dev *dev); 435int pnp_is_active(struct pnp_dev *dev);
405int compare_pnp_id(struct pnp_id *pos, const char *id); 436int compare_pnp_id(struct pnp_id *pos, const char *id);
406int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
407int pnp_register_driver(struct pnp_driver *drv); 437int pnp_register_driver(struct pnp_driver *drv);
408void pnp_unregister_driver(struct pnp_driver *drv); 438void pnp_unregister_driver(struct pnp_driver *drv);
409 439
410#else 440#else
411 441
412/* device management */ 442/* device management */
413static inline int pnp_register_protocol(struct pnp_protocol *protocol) { return -ENODEV; }
414static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { }
415static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; }
416static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; }
417static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; } 443static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
418static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { } 444static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }
419 445
420#define pnp_platform_devices 0 446#define pnp_platform_devices 0
421 447
422/* multidevice card support */ 448/* multidevice card support */
423static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; }
424static inline void pnp_remove_card(struct pnp_card *card) { }
425static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; }
426static inline void pnp_remove_card_device(struct pnp_dev *dev) { }
427static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; }
428static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; } 449static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
429static inline void pnp_release_card_device(struct pnp_dev *dev) { } 450static inline void pnp_release_card_device(struct pnp_dev *dev) { }
430static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; } 451static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
431static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { } 452static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
432 453
433/* resource management */ 454/* resource management */
434static inline struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) { return NULL; }
435static inline struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; }
436static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; }
437static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; }
438static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; }
439static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; }
440static inline void pnp_init_resource_table(struct pnp_resource_table *table) { }
441static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; }
442static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; } 455static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
443static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; }
444static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; } 456static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
445static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; } 457static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
446static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } 458static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
447static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } 459static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
448static inline void pnp_resource_change(struct resource *resource, resource_size_t start, resource_size_t size) { }
449 460
450/* protocol helpers */ 461/* protocol helpers */
451static inline int pnp_is_active(struct pnp_dev *dev) { return 0; } 462static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
452static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; } 463static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
453static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
454static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; } 464static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
455static inline void pnp_unregister_driver(struct pnp_driver *drv) { } 465static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
456 466
@@ -466,6 +476,4 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
466#define pnp_dbg(format, arg...) do {} while (0) 476#define pnp_dbg(format, arg...) do {} while (0)
467#endif 477#endif
468 478
469#endif /* __KERNEL__ */
470
471#endif /* _LINUX_PNP_H */ 479#endif /* _LINUX_PNP_H */
diff --git a/include/linux/pnpbios.h b/include/linux/pnpbios.h
deleted file mode 100644
index 329192adc9dd..000000000000
--- a/include/linux/pnpbios.h
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * Include file for the interface to a PnP BIOS
3 *
4 * Original BIOS code (C) 1998 Christian Schmidt (chr.schmidt@tu-bs.de)
5 * PnP handler parts (c) 1998 Tom Lees <tom@lpsg.demon.co.uk>
6 * Minor reorganizations by David Hinds <dahinds@users.sourceforge.net>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * 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. See the GNU
16 * 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#ifndef _LINUX_PNPBIOS_H
24#define _LINUX_PNPBIOS_H
25
26#ifdef __KERNEL__
27
28#include <linux/types.h>
29#include <linux/pnp.h>
30
31/*
32 * Return codes
33 */
34#define PNP_SUCCESS 0x00
35#define PNP_NOT_SET_STATICALLY 0x7f
36#define PNP_UNKNOWN_FUNCTION 0x81
37#define PNP_FUNCTION_NOT_SUPPORTED 0x82
38#define PNP_INVALID_HANDLE 0x83
39#define PNP_BAD_PARAMETER 0x84
40#define PNP_SET_FAILED 0x85
41#define PNP_EVENTS_NOT_PENDING 0x86
42#define PNP_SYSTEM_NOT_DOCKED 0x87
43#define PNP_NO_ISA_PNP_CARDS 0x88
44#define PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES 0x89
45#define PNP_CONFIG_CHANGE_FAILED_NO_BATTERY 0x8a
46#define PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT 0x8b
47#define PNP_BUFFER_TOO_SMALL 0x8c
48#define PNP_USE_ESCD_SUPPORT 0x8d
49#define PNP_MESSAGE_NOT_SUPPORTED 0x8e
50#define PNP_HARDWARE_ERROR 0x8f
51
52#define ESCD_SUCCESS 0x00
53#define ESCD_IO_ERROR_READING 0x55
54#define ESCD_INVALID 0x56
55#define ESCD_BUFFER_TOO_SMALL 0x59
56#define ESCD_NVRAM_TOO_SMALL 0x5a
57#define ESCD_FUNCTION_NOT_SUPPORTED 0x81
58
59/*
60 * Events that can be received by "get event"
61 */
62#define PNPEV_ABOUT_TO_CHANGE_CONFIG 0x0001
63#define PNPEV_DOCK_CHANGED 0x0002
64#define PNPEV_SYSTEM_DEVICE_CHANGED 0x0003
65#define PNPEV_CONFIG_CHANGED_FAILED 0x0004
66#define PNPEV_UNKNOWN_SYSTEM_EVENT 0xffff
67/* 0x8000 through 0xfffe are OEM defined */
68
69/*
70 * Messages that should be sent through "send message"
71 */
72#define PNPMSG_OK 0x00
73#define PNPMSG_ABORT 0x01
74#define PNPMSG_UNDOCK_DEFAULT_ACTION 0x40
75#define PNPMSG_POWER_OFF 0x41
76#define PNPMSG_PNP_OS_ACTIVE 0x42
77#define PNPMSG_PNP_OS_INACTIVE 0x43
78
79/*
80 * Plug and Play BIOS flags
81 */
82#define PNPBIOS_NO_DISABLE 0x0001
83#define PNPBIOS_NO_CONFIG 0x0002
84#define PNPBIOS_OUTPUT 0x0004
85#define PNPBIOS_INPUT 0x0008
86#define PNPBIOS_BOOTABLE 0x0010
87#define PNPBIOS_DOCK 0x0020
88#define PNPBIOS_REMOVABLE 0x0040
89#define pnpbios_is_static(x) (((x)->flags & 0x0100) == 0x0000)
90#define pnpbios_is_dynamic(x) ((x)->flags & 0x0080)
91
92/*
93 * Function Parameters
94 */
95#define PNPMODE_STATIC 1
96#define PNPMODE_DYNAMIC 0
97
98/* 0x8000 through 0xffff are OEM defined */
99
100#pragma pack(1)
101struct pnp_dev_node_info {
102 __u16 no_nodes;
103 __u16 max_node_size;
104};
105struct pnp_docking_station_info {
106 __u32 location_id;
107 __u32 serial;
108 __u16 capabilities;
109};
110struct pnp_isa_config_struc {
111 __u8 revision;
112 __u8 no_csns;
113 __u16 isa_rd_data_port;
114 __u16 reserved;
115};
116struct escd_info_struc {
117 __u16 min_escd_write_size;
118 __u16 escd_size;
119 __u32 nv_storage_base;
120};
121struct pnp_bios_node {
122 __u16 size;
123 __u8 handle;
124 __u32 eisa_id;
125 __u8 type_code[3];
126 __u16 flags;
127 __u8 data[0];
128};
129#pragma pack()
130
131#ifdef CONFIG_PNPBIOS
132
133/* non-exported */
134extern struct pnp_dev_node_info node_info;
135
136extern int pnp_bios_dev_node_info(struct pnp_dev_node_info *data);
137extern int pnp_bios_get_dev_node(u8 *nodenum, char config,
138 struct pnp_bios_node *data);
139extern int pnp_bios_set_dev_node(u8 nodenum, char config,
140 struct pnp_bios_node *data);
141extern int pnp_bios_get_stat_res(char *info);
142extern int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data);
143extern int pnp_bios_escd_info(struct escd_info_struc *data);
144extern int pnp_bios_read_escd(char *data, u32 nvram_base);
145extern int pnp_bios_dock_station_info(struct pnp_docking_station_info *data);
146
147#endif /* CONFIG_PNPBIOS */
148
149#endif /* __KERNEL__ */
150
151#endif /* _LINUX_PNPBIOS_H */
diff --git a/include/linux/poison.h b/include/linux/poison.h
index a9c31be7052c..9f31683728fd 100644
--- a/include/linux/poison.h
+++ b/include/linux/poison.h
@@ -10,6 +10,13 @@
10#define LIST_POISON1 ((void *) 0x00100100) 10#define LIST_POISON1 ((void *) 0x00100100)
11#define LIST_POISON2 ((void *) 0x00200200) 11#define LIST_POISON2 ((void *) 0x00200200)
12 12
13/********** include/linux/timer.h **********/
14/*
15 * Magic number "tsta" to indicate a static timer initializer
16 * for the object debugging code.
17 */
18#define TIMER_ENTRY_STATIC ((void *) 0x74737461)
19
13/********** mm/slab.c **********/ 20/********** mm/slab.c **********/
14/* 21/*
15 * Magic nums for obj red zoning. 22 * Magic nums for obj red zoning.
diff --git a/include/linux/prctl.h b/include/linux/prctl.h
index 3800639775ae..5ad79198d6f9 100644
--- a/include/linux/prctl.h
+++ b/include/linux/prctl.h
@@ -16,7 +16,8 @@
16# define PR_UNALIGN_NOPRINT 1 /* silently fix up unaligned user accesses */ 16# define PR_UNALIGN_NOPRINT 1 /* silently fix up unaligned user accesses */
17# define PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */ 17# define PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */
18 18
19/* Get/set whether or not to drop capabilities on setuid() away from uid 0 */ 19/* Get/set whether or not to drop capabilities on setuid() away from
20 * uid 0 (as per security/commoncap.c) */
20#define PR_GET_KEEPCAPS 7 21#define PR_GET_KEEPCAPS 7
21#define PR_SET_KEEPCAPS 8 22#define PR_SET_KEEPCAPS 8
22 23
@@ -63,8 +64,18 @@
63#define PR_GET_SECCOMP 21 64#define PR_GET_SECCOMP 21
64#define PR_SET_SECCOMP 22 65#define PR_SET_SECCOMP 22
65 66
66/* Get/set the capability bounding set */ 67/* Get/set the capability bounding set (as per security/commoncap.c) */
67#define PR_CAPBSET_READ 23 68#define PR_CAPBSET_READ 23
68#define PR_CAPBSET_DROP 24 69#define PR_CAPBSET_DROP 24
69 70
71/* Get/set the process' ability to use the timestamp counter instruction */
72#define PR_GET_TSC 25
73#define PR_SET_TSC 26
74# define PR_TSC_ENABLE 1 /* allow the use of the timestamp counter */
75# define PR_TSC_SIGSEGV 2 /* throw a SIGSEGV instead of reading the TSC */
76
77/* Get/set securebits (as per security/commoncap.c) */
78#define PR_GET_SECUREBITS 27
79#define PR_SET_SECUREBITS 28
80
70#endif /* _LINUX_PRCTL_H */ 81#endif /* _LINUX_PRCTL_H */
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 9b6c935f69cf..9883bc942262 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -9,7 +9,6 @@
9 9
10struct net; 10struct net;
11struct completion; 11struct completion;
12
13/* 12/*
14 * The proc filesystem constants/structures 13 * The proc filesystem constants/structures
15 */ 14 */
@@ -41,7 +40,7 @@ enum {
41 * /proc file has a parent, but "subdir" is NULL for all 40 * /proc file has a parent, but "subdir" is NULL for all
42 * non-directory entries). 41 * non-directory entries).
43 * 42 *
44 * "get_info" is called at "read", while "owner" is used to protect module 43 * "owner" is used to protect module
45 * from unloading while proc_dir_entry is in use 44 * from unloading while proc_dir_entry is in use
46 */ 45 */
47 46
@@ -49,7 +48,6 @@ typedef int (read_proc_t)(char *page, char **start, off_t off,
49 int count, int *eof, void *data); 48 int count, int *eof, void *data);
50typedef int (write_proc_t)(struct file *file, const char __user *buffer, 49typedef int (write_proc_t)(struct file *file, const char __user *buffer,
51 unsigned long count, void *data); 50 unsigned long count, void *data);
52typedef int (get_info_t)(char *, char **, off_t, int);
53 51
54struct proc_dir_entry { 52struct proc_dir_entry {
55 unsigned int low_ino; 53 unsigned int low_ino;
@@ -70,7 +68,6 @@ struct proc_dir_entry {
70 * somewhere. 68 * somewhere.
71 */ 69 */
72 const struct file_operations *proc_fops; 70 const struct file_operations *proc_fops;
73 get_info_t *get_info;
74 struct module *owner; 71 struct module *owner;
75 struct proc_dir_entry *next, *parent, *subdir; 72 struct proc_dir_entry *next, *parent, *subdir;
76 void *data; 73 void *data;
@@ -97,10 +94,6 @@ struct vmcore {
97 94
98#ifdef CONFIG_PROC_FS 95#ifdef CONFIG_PROC_FS
99 96
100extern struct proc_dir_entry proc_root;
101extern struct proc_dir_entry *proc_root_fs;
102extern struct proc_dir_entry *proc_bus;
103extern struct proc_dir_entry *proc_root_driver;
104extern struct proc_dir_entry *proc_root_kcore; 97extern struct proc_dir_entry *proc_root_kcore;
105 98
106extern spinlock_t proc_subdir_lock; 99extern spinlock_t proc_subdir_lock;
@@ -123,9 +116,10 @@ void de_put(struct proc_dir_entry *de);
123 116
124extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, 117extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
125 struct proc_dir_entry *parent); 118 struct proc_dir_entry *parent);
126struct proc_dir_entry *proc_create(const char *name, mode_t mode, 119struct proc_dir_entry *proc_create_data(const char *name, mode_t mode,
127 struct proc_dir_entry *parent, 120 struct proc_dir_entry *parent,
128 const struct file_operations *proc_fops); 121 const struct file_operations *proc_fops,
122 void *data);
129extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent); 123extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
130 124
131extern struct vfsmount *proc_mnt; 125extern struct vfsmount *proc_mnt;
@@ -180,6 +174,12 @@ extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
180extern struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, 174extern struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
181 struct proc_dir_entry *parent); 175 struct proc_dir_entry *parent);
182 176
177static inline struct proc_dir_entry *proc_create(const char *name, mode_t mode,
178 struct proc_dir_entry *parent, const struct file_operations *proc_fops)
179{
180 return proc_create_data(name, mode, parent, proc_fops, NULL);
181}
182
183static inline struct proc_dir_entry *create_proc_read_entry(const char *name, 183static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
184 mode_t mode, struct proc_dir_entry *base, 184 mode_t mode, struct proc_dir_entry *base,
185 read_proc_t *read_proc, void * data) 185 read_proc_t *read_proc, void * data)
@@ -192,24 +192,19 @@ static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
192 return res; 192 return res;
193} 193}
194 194
195static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
196 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
197{
198 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
199 if (res) res->get_info=get_info;
200 return res;
201}
202
203extern struct proc_dir_entry *proc_net_fops_create(struct net *net, 195extern struct proc_dir_entry *proc_net_fops_create(struct net *net,
204 const char *name, mode_t mode, const struct file_operations *fops); 196 const char *name, mode_t mode, const struct file_operations *fops);
205extern void proc_net_remove(struct net *net, const char *name); 197extern void proc_net_remove(struct net *net, const char *name);
206extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, 198extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
207 struct proc_dir_entry *parent); 199 struct proc_dir_entry *parent);
208 200
209#else 201/* While the {get|set|dup}_mm_exe_file functions are for mm_structs, they are
202 * only needed to implement /proc/<pid>|self/exe so we define them here. */
203extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
204extern struct file *get_mm_exe_file(struct mm_struct *mm);
205extern void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm);
210 206
211#define proc_root_driver NULL 207#else
212#define proc_bus NULL
213 208
214#define proc_net_fops_create(net, name, mode, fops) ({ (void)(mode), NULL; }) 209#define proc_net_fops_create(net, name, mode, fops) ({ (void)(mode), NULL; })
215static inline void proc_net_remove(struct net *net, const char *name) {} 210static inline void proc_net_remove(struct net *net, const char *name) {}
@@ -226,6 +221,12 @@ static inline struct proc_dir_entry *proc_create(const char *name,
226{ 221{
227 return NULL; 222 return NULL;
228} 223}
224static inline struct proc_dir_entry *proc_create_data(const char *name,
225 mode_t mode, struct proc_dir_entry *parent,
226 const struct file_operations *proc_fops, void *data)
227{
228 return NULL;
229}
229#define remove_proc_entry(name, parent) do {} while (0) 230#define remove_proc_entry(name, parent) do {} while (0)
230 231
231static inline struct proc_dir_entry *proc_symlink(const char *name, 232static inline struct proc_dir_entry *proc_symlink(const char *name,
@@ -236,16 +237,11 @@ static inline struct proc_dir_entry *proc_mkdir(const char *name,
236static inline struct proc_dir_entry *create_proc_read_entry(const char *name, 237static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
237 mode_t mode, struct proc_dir_entry *base, 238 mode_t mode, struct proc_dir_entry *base,
238 read_proc_t *read_proc, void * data) { return NULL; } 239 read_proc_t *read_proc, void * data) { return NULL; }
239static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
240 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
241 { return NULL; }
242 240
243struct tty_driver; 241struct tty_driver;
244static inline void proc_tty_register_driver(struct tty_driver *driver) {}; 242static inline void proc_tty_register_driver(struct tty_driver *driver) {};
245static inline void proc_tty_unregister_driver(struct tty_driver *driver) {}; 243static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
246 244
247extern struct proc_dir_entry proc_root;
248
249static inline int pid_ns_prepare_proc(struct pid_namespace *ns) 245static inline int pid_ns_prepare_proc(struct pid_namespace *ns)
250{ 246{
251 return 0; 247 return 0;
@@ -255,6 +251,19 @@ static inline void pid_ns_release_proc(struct pid_namespace *ns)
255{ 251{
256} 252}
257 253
254static inline void set_mm_exe_file(struct mm_struct *mm,
255 struct file *new_exe_file)
256{}
257
258static inline struct file *get_mm_exe_file(struct mm_struct *mm)
259{
260 return NULL;
261}
262
263static inline void dup_mm_exe_file(struct mm_struct *oldmm,
264 struct mm_struct *newmm)
265{}
266
258#endif /* CONFIG_PROC_FS */ 267#endif /* CONFIG_PROC_FS */
259 268
260#if !defined(CONFIG_PROC_KCORE) 269#if !defined(CONFIG_PROC_KCORE)
diff --git a/include/linux/profile.h b/include/linux/profile.h
index ff576d1db67d..05c1cc736937 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -1,8 +1,6 @@
1#ifndef _LINUX_PROFILE_H 1#ifndef _LINUX_PROFILE_H
2#define _LINUX_PROFILE_H 2#define _LINUX_PROFILE_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/kernel.h> 4#include <linux/kernel.h>
7#include <linux/init.h> 5#include <linux/init.h>
8#include <linux/cpumask.h> 6#include <linux/cpumask.h>
@@ -118,6 +116,4 @@ static inline void unregister_timer_hook(int (*hook)(struct pt_regs *))
118 116
119#endif /* CONFIG_PROFILING */ 117#endif /* CONFIG_PROFILING */
120 118
121#endif /* __KERNEL__ */
122
123#endif /* _LINUX_PROFILE_H */ 119#endif /* _LINUX_PROFILE_H */
diff --git a/include/linux/proportions.h b/include/linux/proportions.h
index 2c3b3cad92be..5afc1b23346d 100644
--- a/include/linux/proportions.h
+++ b/include/linux/proportions.h
@@ -78,6 +78,19 @@ void prop_inc_percpu(struct prop_descriptor *pd, struct prop_local_percpu *pl)
78} 78}
79 79
80/* 80/*
81 * Limit the time part in order to ensure there are some bits left for the
82 * cycle counter and fraction multiply.
83 */
84#define PROP_MAX_SHIFT (3*BITS_PER_LONG/4)
85
86#define PROP_FRAC_SHIFT (BITS_PER_LONG - PROP_MAX_SHIFT - 1)
87#define PROP_FRAC_BASE (1UL << PROP_FRAC_SHIFT)
88
89void __prop_inc_percpu_max(struct prop_descriptor *pd,
90 struct prop_local_percpu *pl, long frac);
91
92
93/*
81 * ----- SINGLE ------ 94 * ----- SINGLE ------
82 */ 95 */
83 96
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index ebe0c17039cf..f98501ba557e 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -98,6 +98,10 @@ extern void ptrace_untrace(struct task_struct *child);
98extern int ptrace_may_attach(struct task_struct *task); 98extern int ptrace_may_attach(struct task_struct *task);
99extern int __ptrace_may_attach(struct task_struct *task); 99extern int __ptrace_may_attach(struct task_struct *task);
100 100
101static inline int ptrace_reparented(struct task_struct *child)
102{
103 return child->real_parent != child->parent;
104}
101static inline void ptrace_link(struct task_struct *child, 105static inline void ptrace_link(struct task_struct *child,
102 struct task_struct *new_parent) 106 struct task_struct *new_parent)
103{ 107{
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 6e0393a5b2ea..dcddfb200947 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -160,14 +160,18 @@ enum {
160 160
161 161
162#ifdef __KERNEL__ 162#ifdef __KERNEL__
163#include <linux/spinlock.h> 163#include <linux/list.h>
164#include <linux/rwsem.h>
165#include <linux/mutex.h> 164#include <linux/mutex.h>
165#include <linux/rwsem.h>
166#include <linux/spinlock.h>
167#include <linux/wait.h>
166 168
167#include <linux/dqblk_xfs.h> 169#include <linux/dqblk_xfs.h>
168#include <linux/dqblk_v1.h> 170#include <linux/dqblk_v1.h>
169#include <linux/dqblk_v2.h> 171#include <linux/dqblk_v2.h>
170 172
173#include <asm/atomic.h>
174
171extern spinlock_t dq_data_lock; 175extern spinlock_t dq_data_lock;
172 176
173/* Maximal numbers of writes for quota operation (insert/delete/update) 177/* Maximal numbers of writes for quota operation (insert/delete/update)
@@ -198,10 +202,14 @@ struct quota_format_type;
198 202
199struct mem_dqinfo { 203struct mem_dqinfo {
200 struct quota_format_type *dqi_format; 204 struct quota_format_type *dqi_format;
205 int dqi_fmt_id; /* Id of the dqi_format - used when turning
206 * quotas on after remount RW */
201 struct list_head dqi_dirty_list; /* List of dirty dquots */ 207 struct list_head dqi_dirty_list; /* List of dirty dquots */
202 unsigned long dqi_flags; 208 unsigned long dqi_flags;
203 unsigned int dqi_bgrace; 209 unsigned int dqi_bgrace;
204 unsigned int dqi_igrace; 210 unsigned int dqi_igrace;
211 qsize_t dqi_maxblimit;
212 qsize_t dqi_maxilimit;
205 union { 213 union {
206 struct v1_mem_dqinfo v1_i; 214 struct v1_mem_dqinfo v1_i;
207 struct v2_mem_dqinfo v2_i; 215 struct v2_mem_dqinfo v2_i;
@@ -292,8 +300,8 @@ struct dquot_operations {
292 300
293/* Operations handling requests from userspace */ 301/* Operations handling requests from userspace */
294struct quotactl_ops { 302struct quotactl_ops {
295 int (*quota_on)(struct super_block *, int, int, char *); 303 int (*quota_on)(struct super_block *, int, int, char *, int);
296 int (*quota_off)(struct super_block *, int); 304 int (*quota_off)(struct super_block *, int, int);
297 int (*quota_sync)(struct super_block *, int); 305 int (*quota_sync)(struct super_block *, int);
298 int (*get_info)(struct super_block *, int, struct if_dqinfo *); 306 int (*get_info)(struct super_block *, int, struct if_dqinfo *);
299 int (*set_info)(struct super_block *, int, struct if_dqinfo *); 307 int (*set_info)(struct super_block *, int, struct if_dqinfo *);
@@ -314,6 +322,10 @@ struct quota_format_type {
314 322
315#define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */ 323#define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */
316#define DQUOT_GRP_ENABLED 0x02 /* Group diskquotas enabled */ 324#define DQUOT_GRP_ENABLED 0x02 /* Group diskquotas enabled */
325#define DQUOT_USR_SUSPENDED 0x04 /* User diskquotas are off, but
326 * we have necessary info in
327 * memory to turn them on */
328#define DQUOT_GRP_SUSPENDED 0x08 /* The same for group quotas */
317 329
318struct quota_info { 330struct quota_info {
319 unsigned int flags; /* Flags for diskquotas on this device */ 331 unsigned int flags; /* Flags for diskquotas on this device */
@@ -325,17 +337,19 @@ struct quota_info {
325 struct quota_format_ops *ops[MAXQUOTAS]; /* Operations for each type */ 337 struct quota_format_ops *ops[MAXQUOTAS]; /* Operations for each type */
326}; 338};
327 339
328/* Inline would be better but we need to dereference super_block which is not defined yet */
329int mark_dquot_dirty(struct dquot *dquot);
330
331#define dquot_dirty(dquot) test_bit(DQ_MOD_B, &(dquot)->dq_flags)
332
333#define sb_has_quota_enabled(sb, type) ((type)==USRQUOTA ? \ 340#define sb_has_quota_enabled(sb, type) ((type)==USRQUOTA ? \
334 (sb_dqopt(sb)->flags & DQUOT_USR_ENABLED) : (sb_dqopt(sb)->flags & DQUOT_GRP_ENABLED)) 341 (sb_dqopt(sb)->flags & DQUOT_USR_ENABLED) : (sb_dqopt(sb)->flags & DQUOT_GRP_ENABLED))
335 342
336#define sb_any_quota_enabled(sb) (sb_has_quota_enabled(sb, USRQUOTA) | \ 343#define sb_any_quota_enabled(sb) (sb_has_quota_enabled(sb, USRQUOTA) | \
337 sb_has_quota_enabled(sb, GRPQUOTA)) 344 sb_has_quota_enabled(sb, GRPQUOTA))
338 345
346#define sb_has_quota_suspended(sb, type) \
347 ((type) == USRQUOTA ? (sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED) : \
348 (sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED))
349
350#define sb_any_quota_suspended(sb) (sb_has_quota_suspended(sb, USRQUOTA) | \
351 sb_has_quota_suspended(sb, GRPQUOTA))
352
339int register_quota_format(struct quota_format_type *fmt); 353int register_quota_format(struct quota_format_type *fmt);
340void unregister_quota_format(struct quota_format_type *fmt); 354void unregister_quota_format(struct quota_format_type *fmt);
341 355
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 5110201a4159..f86702053853 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -37,11 +37,11 @@ extern int dquot_release(struct dquot *dquot);
37extern int dquot_commit_info(struct super_block *sb, int type); 37extern int dquot_commit_info(struct super_block *sb, int type);
38extern int dquot_mark_dquot_dirty(struct dquot *dquot); 38extern int dquot_mark_dquot_dirty(struct dquot *dquot);
39 39
40extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path); 40extern int vfs_quota_on(struct super_block *sb, int type, int format_id,
41 char *path, int remount);
41extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name, 42extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
42 int format_id, int type); 43 int format_id, int type);
43extern int vfs_quota_off(struct super_block *sb, int type); 44extern int vfs_quota_off(struct super_block *sb, int type, int remount);
44#define vfs_quota_off_mount(sb, type) vfs_quota_off(sb, type)
45extern int vfs_quota_sync(struct super_block *sb, int type); 45extern int vfs_quota_sync(struct super_block *sb, int type);
46extern int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 46extern int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
47extern int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 47extern int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
@@ -59,7 +59,7 @@ extern struct quotactl_ops vfs_quotactl_ops;
59 59
60/* It is better to call this function outside of any transaction as it might 60/* It is better to call this function outside of any transaction as it might
61 * need a lot of space in journal for dquot structure allocation. */ 61 * need a lot of space in journal for dquot structure allocation. */
62static __inline__ void DQUOT_INIT(struct inode *inode) 62static inline void DQUOT_INIT(struct inode *inode)
63{ 63{
64 BUG_ON(!inode->i_sb); 64 BUG_ON(!inode->i_sb);
65 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) 65 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode))
@@ -67,7 +67,7 @@ static __inline__ void DQUOT_INIT(struct inode *inode)
67} 67}
68 68
69/* The same as with DQUOT_INIT */ 69/* The same as with DQUOT_INIT */
70static __inline__ void DQUOT_DROP(struct inode *inode) 70static inline void DQUOT_DROP(struct inode *inode)
71{ 71{
72 /* Here we can get arbitrary inode from clear_inode() so we have 72 /* Here we can get arbitrary inode from clear_inode() so we have
73 * to be careful. OTOH we don't need locking as quota operations 73 * to be careful. OTOH we don't need locking as quota operations
@@ -90,7 +90,7 @@ static __inline__ void DQUOT_DROP(struct inode *inode)
90 90
91/* The following allocation/freeing/transfer functions *must* be called inside 91/* The following allocation/freeing/transfer functions *must* be called inside
92 * a transaction (deadlocks possible otherwise) */ 92 * a transaction (deadlocks possible otherwise) */
93static __inline__ int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 93static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
94{ 94{
95 if (sb_any_quota_enabled(inode->i_sb)) { 95 if (sb_any_quota_enabled(inode->i_sb)) {
96 /* Used space is updated in alloc_space() */ 96 /* Used space is updated in alloc_space() */
@@ -102,7 +102,7 @@ static __inline__ int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t
102 return 0; 102 return 0;
103} 103}
104 104
105static __inline__ int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr) 105static inline int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr)
106{ 106{
107 int ret; 107 int ret;
108 if (!(ret = DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr))) 108 if (!(ret = DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr)))
@@ -110,7 +110,7 @@ static __inline__ int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr)
110 return ret; 110 return ret;
111} 111}
112 112
113static __inline__ int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 113static inline int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
114{ 114{
115 if (sb_any_quota_enabled(inode->i_sb)) { 115 if (sb_any_quota_enabled(inode->i_sb)) {
116 /* Used space is updated in alloc_space() */ 116 /* Used space is updated in alloc_space() */
@@ -122,7 +122,7 @@ static __inline__ int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
122 return 0; 122 return 0;
123} 123}
124 124
125static __inline__ int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr) 125static inline int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr)
126{ 126{
127 int ret; 127 int ret;
128 if (!(ret = DQUOT_ALLOC_SPACE_NODIRTY(inode, nr))) 128 if (!(ret = DQUOT_ALLOC_SPACE_NODIRTY(inode, nr)))
@@ -130,7 +130,7 @@ static __inline__ int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr)
130 return ret; 130 return ret;
131} 131}
132 132
133static __inline__ int DQUOT_ALLOC_INODE(struct inode *inode) 133static inline int DQUOT_ALLOC_INODE(struct inode *inode)
134{ 134{
135 if (sb_any_quota_enabled(inode->i_sb)) { 135 if (sb_any_quota_enabled(inode->i_sb)) {
136 DQUOT_INIT(inode); 136 DQUOT_INIT(inode);
@@ -140,7 +140,7 @@ static __inline__ int DQUOT_ALLOC_INODE(struct inode *inode)
140 return 0; 140 return 0;
141} 141}
142 142
143static __inline__ void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 143static inline void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
144{ 144{
145 if (sb_any_quota_enabled(inode->i_sb)) 145 if (sb_any_quota_enabled(inode->i_sb))
146 inode->i_sb->dq_op->free_space(inode, nr); 146 inode->i_sb->dq_op->free_space(inode, nr);
@@ -148,19 +148,19 @@ static __inline__ void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
148 inode_sub_bytes(inode, nr); 148 inode_sub_bytes(inode, nr);
149} 149}
150 150
151static __inline__ void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr) 151static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr)
152{ 152{
153 DQUOT_FREE_SPACE_NODIRTY(inode, nr); 153 DQUOT_FREE_SPACE_NODIRTY(inode, nr);
154 mark_inode_dirty(inode); 154 mark_inode_dirty(inode);
155} 155}
156 156
157static __inline__ void DQUOT_FREE_INODE(struct inode *inode) 157static inline void DQUOT_FREE_INODE(struct inode *inode)
158{ 158{
159 if (sb_any_quota_enabled(inode->i_sb)) 159 if (sb_any_quota_enabled(inode->i_sb))
160 inode->i_sb->dq_op->free_inode(inode, 1); 160 inode->i_sb->dq_op->free_inode(inode, 1);
161} 161}
162 162
163static __inline__ int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr) 163static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr)
164{ 164{
165 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) { 165 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) {
166 DQUOT_INIT(inode); 166 DQUOT_INIT(inode);
@@ -171,14 +171,32 @@ static __inline__ int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr)
171} 171}
172 172
173/* The following two functions cannot be called inside a transaction */ 173/* The following two functions cannot be called inside a transaction */
174#define DQUOT_SYNC(sb) sync_dquots(sb, -1) 174static inline void DQUOT_SYNC(struct super_block *sb)
175{
176 sync_dquots(sb, -1);
177}
175 178
176static __inline__ int DQUOT_OFF(struct super_block *sb) 179static inline int DQUOT_OFF(struct super_block *sb, int remount)
177{ 180{
178 int ret = -ENOSYS; 181 int ret = -ENOSYS;
179 182
180 if (sb_any_quota_enabled(sb) && sb->s_qcop && sb->s_qcop->quota_off) 183 if (sb->s_qcop && sb->s_qcop->quota_off)
181 ret = sb->s_qcop->quota_off(sb, -1); 184 ret = sb->s_qcop->quota_off(sb, -1, remount);
185 return ret;
186}
187
188static inline int DQUOT_ON_REMOUNT(struct super_block *sb)
189{
190 int cnt;
191 int ret = 0, err;
192
193 if (!sb->s_qcop || !sb->s_qcop->quota_on)
194 return -ENOSYS;
195 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
196 err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1);
197 if (err < 0 && !ret)
198 ret = err;
199 }
182 return ret; 200 return ret;
183} 201}
184 202
@@ -189,13 +207,43 @@ static __inline__ int DQUOT_OFF(struct super_block *sb)
189 */ 207 */
190#define sb_dquot_ops (NULL) 208#define sb_dquot_ops (NULL)
191#define sb_quotactl_ops (NULL) 209#define sb_quotactl_ops (NULL)
192#define DQUOT_INIT(inode) do { } while(0) 210
193#define DQUOT_DROP(inode) do { } while(0) 211static inline void DQUOT_INIT(struct inode *inode)
194#define DQUOT_ALLOC_INODE(inode) (0) 212{
195#define DQUOT_FREE_INODE(inode) do { } while(0) 213}
196#define DQUOT_SYNC(sb) do { } while(0) 214
197#define DQUOT_OFF(sb) do { } while(0) 215static inline void DQUOT_DROP(struct inode *inode)
198#define DQUOT_TRANSFER(inode, iattr) (0) 216{
217}
218
219static inline int DQUOT_ALLOC_INODE(struct inode *inode)
220{
221 return 0;
222}
223
224static inline void DQUOT_FREE_INODE(struct inode *inode)
225{
226}
227
228static inline void DQUOT_SYNC(struct super_block *sb)
229{
230}
231
232static inline int DQUOT_OFF(struct super_block *sb, int remount)
233{
234 return 0;
235}
236
237static inline int DQUOT_ON_REMOUNT(struct super_block *sb)
238{
239 return 0;
240}
241
242static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr)
243{
244 return 0;
245}
246
199static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 247static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
200{ 248{
201 inode_add_bytes(inode, nr); 249 inode_add_bytes(inode, nr);
@@ -235,11 +283,38 @@ static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr)
235 283
236#endif /* CONFIG_QUOTA */ 284#endif /* CONFIG_QUOTA */
237 285
238#define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_PREALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) 286static inline int DQUOT_PREALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr)
239#define DQUOT_PREALLOC_BLOCK(inode, nr) DQUOT_PREALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) 287{
240#define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_ALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) 288 return DQUOT_PREALLOC_SPACE_NODIRTY(inode,
241#define DQUOT_ALLOC_BLOCK(inode, nr) DQUOT_ALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) 289 nr << inode->i_sb->s_blocksize_bits);
242#define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) DQUOT_FREE_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) 290}
243#define DQUOT_FREE_BLOCK(inode, nr) DQUOT_FREE_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) 291
292static inline int DQUOT_PREALLOC_BLOCK(struct inode *inode, qsize_t nr)
293{
294 return DQUOT_PREALLOC_SPACE(inode,
295 nr << inode->i_sb->s_blocksize_bits);
296}
297
298static inline int DQUOT_ALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr)
299{
300 return DQUOT_ALLOC_SPACE_NODIRTY(inode,
301 nr << inode->i_sb->s_blocksize_bits);
302}
303
304static inline int DQUOT_ALLOC_BLOCK(struct inode *inode, qsize_t nr)
305{
306 return DQUOT_ALLOC_SPACE(inode,
307 nr << inode->i_sb->s_blocksize_bits);
308}
309
310static inline void DQUOT_FREE_BLOCK_NODIRTY(struct inode *inode, qsize_t nr)
311{
312 DQUOT_FREE_SPACE_NODIRTY(inode, nr << inode->i_sb->s_blocksize_bits);
313}
314
315static inline void DQUOT_FREE_BLOCK(struct inode *inode, qsize_t nr)
316{
317 DQUOT_FREE_SPACE(inode, nr << inode->i_sb->s_blocksize_bits);
318}
244 319
245#endif /* _LINUX_QUOTAOPS_ */ 320#endif /* _LINUX_QUOTAOPS_ */
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h
index fbaeda79b2e9..81a1a02d4566 100644
--- a/include/linux/raid/md.h
+++ b/include/linux/raid/md.h
@@ -19,7 +19,6 @@
19#define _MD_H 19#define _MD_H
20 20
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <asm/semaphore.h>
23#include <linux/major.h> 22#include <linux/major.h>
24#include <linux/ioctl.h> 23#include <linux/ioctl.h>
25#include <linux/types.h> 24#include <linux/types.h>
@@ -95,6 +94,7 @@ extern int sync_page_io(struct block_device *bdev, sector_t sector, int size,
95extern void md_do_sync(mddev_t *mddev); 94extern void md_do_sync(mddev_t *mddev);
96extern void md_new_event(mddev_t *mddev); 95extern void md_new_event(mddev_t *mddev);
97extern void md_allow_write(mddev_t *mddev); 96extern void md_allow_write(mddev_t *mddev);
97extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
98 98
99#endif /* CONFIG_MD */ 99#endif /* CONFIG_MD */
100#endif 100#endif
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index 7bb6d1abf71e..812ffa590cff 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -84,6 +84,10 @@ struct mdk_rdev_s
84#define AllReserved 6 /* If whole device is reserved for 84#define AllReserved 6 /* If whole device is reserved for
85 * one array */ 85 * one array */
86#define AutoDetected 7 /* added by auto-detect */ 86#define AutoDetected 7 /* added by auto-detect */
87#define Blocked 8 /* An error occured on an externally
88 * managed array, don't allow writes
89 * until it is cleared */
90 wait_queue_head_t blocked_wait;
87 91
88 int desc_nr; /* descriptor index in the superblock */ 92 int desc_nr; /* descriptor index in the superblock */
89 int raid_disk; /* role of device in array */ 93 int raid_disk; /* role of device in array */
diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h
index 93678f57ccbe..f0827d31ae6f 100644
--- a/include/linux/raid/raid5.h
+++ b/include/linux/raid/raid5.h
@@ -252,6 +252,8 @@ struct r6_state {
252#define STRIPE_EXPANDING 9 252#define STRIPE_EXPANDING 9
253#define STRIPE_EXPAND_SOURCE 10 253#define STRIPE_EXPAND_SOURCE 10
254#define STRIPE_EXPAND_READY 11 254#define STRIPE_EXPAND_READY 11
255#define STRIPE_IO_STARTED 12 /* do not count towards 'bypass_count' */
256#define STRIPE_FULL_WRITE 13 /* all blocks are set to be overwritten */
255/* 257/*
256 * Operations flags (in issue order) 258 * Operations flags (in issue order)
257 */ 259 */
@@ -316,12 +318,17 @@ struct raid5_private_data {
316 int previous_raid_disks; 318 int previous_raid_disks;
317 319
318 struct list_head handle_list; /* stripes needing handling */ 320 struct list_head handle_list; /* stripes needing handling */
321 struct list_head hold_list; /* preread ready stripes */
319 struct list_head delayed_list; /* stripes that have plugged requests */ 322 struct list_head delayed_list; /* stripes that have plugged requests */
320 struct list_head bitmap_list; /* stripes delaying awaiting bitmap update */ 323 struct list_head bitmap_list; /* stripes delaying awaiting bitmap update */
321 struct bio *retry_read_aligned; /* currently retrying aligned bios */ 324 struct bio *retry_read_aligned; /* currently retrying aligned bios */
322 struct bio *retry_read_aligned_list; /* aligned bios retry list */ 325 struct bio *retry_read_aligned_list; /* aligned bios retry list */
323 atomic_t preread_active_stripes; /* stripes with scheduled io */ 326 atomic_t preread_active_stripes; /* stripes with scheduled io */
324 atomic_t active_aligned_reads; 327 atomic_t active_aligned_reads;
328 atomic_t pending_full_writes; /* full write backlog */
329 int bypass_count; /* bypassed prereads */
330 int bypass_threshold; /* preread nice */
331 struct list_head *last_hold; /* detect hold_list promotions */
325 332
326 atomic_t reshape_stripes; /* stripes with pending writes for reshape */ 333 atomic_t reshape_stripes; /* stripes with pending writes for reshape */
327 /* unfortunately we need two cache names as we temporarily have 334 /* unfortunately we need two cache names as we temporarily have
diff --git a/include/linux/raid_class.h b/include/linux/raid_class.h
index d22ad392242a..6b537f1ac96c 100644
--- a/include/linux/raid_class.h
+++ b/include/linux/raid_class.h
@@ -53,20 +53,20 @@ struct raid_data {
53#define DEFINE_RAID_ATTRIBUTE(type, attr) \ 53#define DEFINE_RAID_ATTRIBUTE(type, attr) \
54static inline void \ 54static inline void \
55raid_set_##attr(struct raid_template *r, struct device *dev, type value) { \ 55raid_set_##attr(struct raid_template *r, struct device *dev, type value) { \
56 struct class_device *cdev = \ 56 struct device *device = \
57 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\ 57 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\
58 struct raid_data *rd; \ 58 struct raid_data *rd; \
59 BUG_ON(!cdev); \ 59 BUG_ON(!device); \
60 rd = class_get_devdata(cdev); \ 60 rd = dev_get_drvdata(device); \
61 rd->attr = value; \ 61 rd->attr = value; \
62} \ 62} \
63static inline type \ 63static inline type \
64raid_get_##attr(struct raid_template *r, struct device *dev) { \ 64raid_get_##attr(struct raid_template *r, struct device *dev) { \
65 struct class_device *cdev = \ 65 struct device *device = \
66 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\ 66 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\
67 struct raid_data *rd; \ 67 struct raid_data *rd; \
68 BUG_ON(!cdev); \ 68 BUG_ON(!device); \
69 rd = class_get_devdata(cdev); \ 69 rd = dev_get_drvdata(device); \
70 return rd->attr; \ 70 return rd->attr; \
71} 71}
72 72
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
index b3dccd68629e..b3aa05baab8a 100644
--- a/include/linux/rcuclassic.h
+++ b/include/linux/rcuclassic.h
@@ -33,8 +33,6 @@
33#ifndef __LINUX_RCUCLASSIC_H 33#ifndef __LINUX_RCUCLASSIC_H
34#define __LINUX_RCUCLASSIC_H 34#define __LINUX_RCUCLASSIC_H
35 35
36#ifdef __KERNEL__
37
38#include <linux/cache.h> 36#include <linux/cache.h>
39#include <linux/spinlock.h> 37#include <linux/spinlock.h>
40#include <linux/threads.h> 38#include <linux/threads.h>
@@ -163,5 +161,4 @@ extern long rcu_batches_completed_bh(void);
163#define rcu_enter_nohz() do { } while (0) 161#define rcu_enter_nohz() do { } while (0)
164#define rcu_exit_nohz() do { } while (0) 162#define rcu_exit_nohz() do { } while (0)
165 163
166#endif /* __KERNEL__ */
167#endif /* __LINUX_RCUCLASSIC_H */ 164#endif /* __LINUX_RCUCLASSIC_H */
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 37a642c54871..8082d6587a0f 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -33,8 +33,6 @@
33#ifndef __LINUX_RCUPDATE_H 33#ifndef __LINUX_RCUPDATE_H
34#define __LINUX_RCUPDATE_H 34#define __LINUX_RCUPDATE_H
35 35
36#ifdef __KERNEL__
37
38#include <linux/cache.h> 36#include <linux/cache.h>
39#include <linux/spinlock.h> 37#include <linux/spinlock.h>
40#include <linux/threads.h> 38#include <linux/threads.h>
@@ -245,5 +243,4 @@ extern long rcu_batches_completed_bh(void);
245extern void rcu_init(void); 243extern void rcu_init(void);
246extern int rcu_needs_cpu(int cpu); 244extern int rcu_needs_cpu(int cpu);
247 245
248#endif /* __KERNEL__ */
249#endif /* __LINUX_RCUPDATE_H */ 246#endif /* __LINUX_RCUPDATE_H */
diff --git a/include/linux/rcupreempt.h b/include/linux/rcupreempt.h
index d038aa6e5ee1..8a05c7e20bc4 100644
--- a/include/linux/rcupreempt.h
+++ b/include/linux/rcupreempt.h
@@ -33,8 +33,6 @@
33#ifndef __LINUX_RCUPREEMPT_H 33#ifndef __LINUX_RCUPREEMPT_H
34#define __LINUX_RCUPREEMPT_H 34#define __LINUX_RCUPREEMPT_H
35 35
36#ifdef __KERNEL__
37
38#include <linux/cache.h> 36#include <linux/cache.h>
39#include <linux/spinlock.h> 37#include <linux/spinlock.h>
40#include <linux/threads.h> 38#include <linux/threads.h>
@@ -104,5 +102,4 @@ static inline void rcu_exit_nohz(void)
104#define rcu_exit_nohz() do { } while (0) 102#define rcu_exit_nohz() do { } while (0)
105#endif /* CONFIG_NO_HZ */ 103#endif /* CONFIG_NO_HZ */
106 104
107#endif /* __KERNEL__ */
108#endif /* __LINUX_RCUPREEMPT_H */ 105#endif /* __LINUX_RCUPREEMPT_H */
diff --git a/include/linux/rcupreempt_trace.h b/include/linux/rcupreempt_trace.h
index 21cd6b2a5c42..b99ae073192a 100644
--- a/include/linux/rcupreempt_trace.h
+++ b/include/linux/rcupreempt_trace.h
@@ -32,7 +32,6 @@
32#ifndef __LINUX_RCUPREEMPT_TRACE_H 32#ifndef __LINUX_RCUPREEMPT_TRACE_H
33#define __LINUX_RCUPREEMPT_TRACE_H 33#define __LINUX_RCUPREEMPT_TRACE_H
34 34
35#ifdef __KERNEL__
36#include <linux/types.h> 35#include <linux/types.h>
37#include <linux/kernel.h> 36#include <linux/kernel.h>
38 37
@@ -95,5 +94,4 @@ extern void rcupreempt_trace_done_remove(struct rcupreempt_trace *trace);
95extern void rcupreempt_trace_invoke(struct rcupreempt_trace *trace); 94extern void rcupreempt_trace_invoke(struct rcupreempt_trace *trace);
96extern void rcupreempt_trace_next_add(struct rcupreempt_trace *trace); 95extern void rcupreempt_trace_next_add(struct rcupreempt_trace *trace);
97 96
98#endif /* __KERNEL__ */
99#endif /* __LINUX_RCUPREEMPT_TRACE_H */ 97#endif /* __LINUX_RCUPREEMPT_TRACE_H */
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 8e7eff2cd0ab..4aacaeecb56f 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -2176,6 +2176,7 @@ int reiserfs_ioctl(struct inode *inode, struct file *filp,
2176 unsigned int cmd, unsigned long arg); 2176 unsigned int cmd, unsigned long arg);
2177long reiserfs_compat_ioctl(struct file *filp, 2177long reiserfs_compat_ioctl(struct file *filp,
2178 unsigned int cmd, unsigned long arg); 2178 unsigned int cmd, unsigned long arg);
2179int reiserfs_unpack(struct inode *inode, struct file *filp);
2179 2180
2180/* ioctl's command */ 2181/* ioctl's command */
2181#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long) 2182#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long)
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index db5ef9b83c3f..336ee43ed7d8 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -177,7 +177,6 @@ struct reiserfs_journal {
177 struct reiserfs_journal_cnode *j_last; /* newest journal block */ 177 struct reiserfs_journal_cnode *j_last; /* newest journal block */
178 struct reiserfs_journal_cnode *j_first; /* oldest journal block. start here for traverse */ 178 struct reiserfs_journal_cnode *j_first; /* oldest journal block. start here for traverse */
179 179
180 struct file *j_dev_file;
181 struct block_device *j_dev_bd; 180 struct block_device *j_dev_bd;
182 int j_1st_reserved_block; /* first block on s_dev of reserved area journal */ 181 int j_1st_reserved_block; /* first block on s_dev of reserved area journal */
183 182
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index 61363ce896d5..6d9e1fca098c 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -9,6 +9,8 @@
9 * 9 *
10 * Author: Pavel Emelianov <xemul@openvz.org> 10 * Author: Pavel Emelianov <xemul@openvz.org>
11 * 11 *
12 * See Documentation/controllers/resource_counter.txt for more
13 * info about what this counter is.
12 */ 14 */
13 15
14#include <linux/cgroup.h> 16#include <linux/cgroup.h>
@@ -25,6 +27,10 @@ struct res_counter {
25 */ 27 */
26 unsigned long long usage; 28 unsigned long long usage;
27 /* 29 /*
30 * the maximal value of the usage from the counter creation
31 */
32 unsigned long long max_usage;
33 /*
28 * the limit that usage cannot exceed 34 * the limit that usage cannot exceed
29 */ 35 */
30 unsigned long long limit; 36 unsigned long long limit;
@@ -39,8 +45,9 @@ struct res_counter {
39 spinlock_t lock; 45 spinlock_t lock;
40}; 46};
41 47
42/* 48/**
43 * Helpers to interact with userspace 49 * Helpers to interact with userspace
50 * res_counter_read_u64() - returns the value of the specified member.
44 * res_counter_read/_write - put/get the specified fields from the 51 * res_counter_read/_write - put/get the specified fields from the
45 * res_counter struct to/from the user 52 * res_counter struct to/from the user
46 * 53 *
@@ -51,6 +58,8 @@ struct res_counter {
51 * @pos: and the offset. 58 * @pos: and the offset.
52 */ 59 */
53 60
61u64 res_counter_read_u64(struct res_counter *counter, int member);
62
54ssize_t res_counter_read(struct res_counter *counter, int member, 63ssize_t res_counter_read(struct res_counter *counter, int member,
55 const char __user *buf, size_t nbytes, loff_t *pos, 64 const char __user *buf, size_t nbytes, loff_t *pos,
56 int (*read_strategy)(unsigned long long val, char *s)); 65 int (*read_strategy)(unsigned long long val, char *s));
@@ -64,6 +73,7 @@ ssize_t res_counter_write(struct res_counter *counter, int member,
64 73
65enum { 74enum {
66 RES_USAGE, 75 RES_USAGE,
76 RES_MAX_USAGE,
67 RES_LIMIT, 77 RES_LIMIT,
68 RES_FAILCNT, 78 RES_FAILCNT,
69}; 79};
@@ -124,4 +134,21 @@ static inline bool res_counter_check_under_limit(struct res_counter *cnt)
124 return ret; 134 return ret;
125} 135}
126 136
137static inline void res_counter_reset_max(struct res_counter *cnt)
138{
139 unsigned long flags;
140
141 spin_lock_irqsave(&cnt->lock, flags);
142 cnt->max_usage = cnt->usage;
143 spin_unlock_irqrestore(&cnt->lock, flags);
144}
145
146static inline void res_counter_reset_failcnt(struct res_counter *cnt)
147{
148 unsigned long flags;
149
150 spin_lock_irqsave(&cnt->lock, flags);
151 cnt->failcnt = 0;
152 spin_unlock_irqrestore(&cnt->lock, flags);
153}
127#endif 154#endif
diff --git a/include/linux/resource.h b/include/linux/resource.h
index ae13db714742..aaa423a6f3d9 100644
--- a/include/linux/resource.h
+++ b/include/linux/resource.h
@@ -19,6 +19,7 @@ struct task_struct;
19#define RUSAGE_SELF 0 19#define RUSAGE_SELF 0
20#define RUSAGE_CHILDREN (-1) 20#define RUSAGE_CHILDREN (-1)
21#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ 21#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */
22#define RUSAGE_THREAD 1 /* only the calling thread */
22 23
23struct rusage { 24struct rusage {
24 struct timeval ru_utime; /* user time used */ 25 struct timeval ru_utime; /* user time used */
diff --git a/include/linux/rio.h b/include/linux/rio.h
index 68e3f6853fa6..c1c99c9643d3 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -14,8 +14,6 @@
14#ifndef LINUX_RIO_H 14#ifndef LINUX_RIO_H
15#define LINUX_RIO_H 15#define LINUX_RIO_H
16 16
17#ifdef __KERNEL__
18
19#include <linux/types.h> 17#include <linux/types.h>
20#include <linux/ioport.h> 18#include <linux/ioport.h>
21#include <linux/list.h> 19#include <linux/list.h>
@@ -23,7 +21,6 @@
23#include <linux/device.h> 21#include <linux/device.h>
24#include <linux/rio_regs.h> 22#include <linux/rio_regs.h>
25 23
26#define RIO_ANY_DESTID 0xff
27#define RIO_NO_HOPCOUNT -1 24#define RIO_NO_HOPCOUNT -1
28#define RIO_INVALID_DESTID 0xffff 25#define RIO_INVALID_DESTID 0xffff
29 26
@@ -39,11 +36,8 @@
39 entry is invalid (no route 36 entry is invalid (no route
40 exists for the device ID) */ 37 exists for the device ID) */
41 38
42#ifdef CONFIG_RAPIDIO_8_BIT_TRANSPORT 39#define RIO_MAX_ROUTE_ENTRIES(size) (size ? (1 << 16) : (1 << 8))
43#define RIO_MAX_ROUTE_ENTRIES (1 << 8) 40#define RIO_ANY_DESTID(size) (size ? 0xffff : 0xff)
44#else
45#define RIO_MAX_ROUTE_ENTRIES (1 << 16)
46#endif
47 41
48#define RIO_MAX_MBOX 4 42#define RIO_MAX_MBOX 4
49#define RIO_MAX_MSG_SIZE 0x1000 43#define RIO_MAX_MSG_SIZE 0x1000
@@ -149,6 +143,11 @@ struct rio_dbell {
149 void *dev_id; 143 void *dev_id;
150}; 144};
151 145
146enum rio_phy_type {
147 RIO_PHY_PARALLEL,
148 RIO_PHY_SERIAL,
149};
150
152/** 151/**
153 * struct rio_mport - RIO master port info 152 * struct rio_mport - RIO master port info
154 * @dbells: List of doorbell events 153 * @dbells: List of doorbell events
@@ -163,6 +162,7 @@ struct rio_dbell {
163 * @id: Port ID, unique among all ports 162 * @id: Port ID, unique among all ports
164 * @index: Port index, unique among all port interfaces of the same type 163 * @index: Port index, unique among all port interfaces of the same type
165 * @name: Port name string 164 * @name: Port name string
165 * @priv: Master port private data
166 */ 166 */
167struct rio_mport { 167struct rio_mport {
168 struct list_head dbells; /* list of doorbell events */ 168 struct list_head dbells; /* list of doorbell events */
@@ -177,7 +177,13 @@ struct rio_mport {
177 unsigned char id; /* port ID, unique among all ports */ 177 unsigned char id; /* port ID, unique among all ports */
178 unsigned char index; /* port index, unique among all port 178 unsigned char index; /* port index, unique among all port
179 interfaces of the same type */ 179 interfaces of the same type */
180 unsigned int sys_size; /* RapidIO common transport system size.
181 * 0 - Small size. 256 devices.
182 * 1 - Large size, 65536 devices.
183 */
184 enum rio_phy_type phy_type; /* RapidIO phy type */
180 unsigned char name[40]; 185 unsigned char name[40];
186 void *priv; /* Master port private data */
181}; 187};
182 188
183/** 189/**
@@ -211,7 +217,7 @@ struct rio_switch {
211 u16 switchid; 217 u16 switchid;
212 u16 hopcount; 218 u16 hopcount;
213 u16 destid; 219 u16 destid;
214 u8 route_table[RIO_MAX_ROUTE_ENTRIES]; 220 u8 *route_table;
215 int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount, 221 int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
216 u16 table, u16 route_destid, u8 route_port); 222 u16 table, u16 route_destid, u8 route_port);
217 int (*get_entry) (struct rio_mport * mport, u16 destid, u8 hopcount, 223 int (*get_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
@@ -229,13 +235,15 @@ struct rio_switch {
229 * @dsend: Callback to send a doorbell message. 235 * @dsend: Callback to send a doorbell message.
230 */ 236 */
231struct rio_ops { 237struct rio_ops {
232 int (*lcread) (int index, u32 offset, int len, u32 * data); 238 int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len,
233 int (*lcwrite) (int index, u32 offset, int len, u32 data); 239 u32 *data);
234 int (*cread) (int index, u16 destid, u8 hopcount, u32 offset, int len, 240 int (*lcwrite) (struct rio_mport *mport, int index, u32 offset, int len,
235 u32 * data); 241 u32 data);
236 int (*cwrite) (int index, u16 destid, u8 hopcount, u32 offset, int len, 242 int (*cread) (struct rio_mport *mport, int index, u16 destid,
237 u32 data); 243 u8 hopcount, u32 offset, int len, u32 *data);
238 int (*dsend) (int index, u16 destid, u16 data); 244 int (*cwrite) (struct rio_mport *mport, int index, u16 destid,
245 u8 hopcount, u32 offset, int len, u32 data);
246 int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data);
239}; 247};
240 248
241#define RIO_RESOURCE_MEM 0x00000100 249#define RIO_RESOURCE_MEM 0x00000100
@@ -321,5 +329,4 @@ extern void rio_close_inb_mbox(struct rio_mport *, int);
321extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int); 329extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
322extern void rio_close_outb_mbox(struct rio_mport *, int); 330extern void rio_close_outb_mbox(struct rio_mport *, int);
323 331
324#endif /* __KERNEL__ */
325#endif /* LINUX_RIO_H */ 332#endif /* LINUX_RIO_H */
diff --git a/include/linux/rio_drv.h b/include/linux/rio_drv.h
index 7adb2a1aac92..90987b7bcc1b 100644
--- a/include/linux/rio_drv.h
+++ b/include/linux/rio_drv.h
@@ -13,8 +13,6 @@
13#ifndef LINUX_RIO_DRV_H 13#ifndef LINUX_RIO_DRV_H
14#define LINUX_RIO_DRV_H 14#define LINUX_RIO_DRV_H
15 15
16#ifdef __KERNEL__
17
18#include <linux/types.h> 16#include <linux/types.h>
19#include <linux/ioport.h> 17#include <linux/ioport.h>
20#include <linux/list.h> 18#include <linux/list.h>
@@ -465,5 +463,4 @@ extern struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from);
465extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did, 463extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did,
466 struct rio_dev *from); 464 struct rio_dev *from);
467 465
468#endif /* __KERNEL__ */
469#endif /* LINUX_RIO_DRV_H */ 466#endif /* LINUX_RIO_DRV_H */
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index b9e174079002..44c81c744538 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -740,13 +740,13 @@ extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
740extern void rtnl_lock(void); 740extern void rtnl_lock(void);
741extern void rtnl_unlock(void); 741extern void rtnl_unlock(void);
742extern int rtnl_trylock(void); 742extern int rtnl_trylock(void);
743extern int rtnl_is_locked(void);
743 744
744extern void rtnetlink_init(void); 745extern void rtnetlink_init(void);
745extern void __rtnl_unlock(void); 746extern void __rtnl_unlock(void);
746 747
747#define ASSERT_RTNL() do { \ 748#define ASSERT_RTNL() do { \
748 if (unlikely(rtnl_trylock())) { \ 749 if (unlikely(!rtnl_is_locked())) { \
749 rtnl_unlock(); \
750 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \ 750 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
751 __FILE__, __LINE__); \ 751 __FILE__, __LINE__); \
752 dump_stack(); \ 752 dump_stack(); \
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 7b524b4109a0..efd348fe8ca7 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -9,8 +9,6 @@
9 9
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11 11
12#ifdef __KERNEL__
13
14#include <linux/types.h> 12#include <linux/types.h>
15#include <linux/kernel.h> 13#include <linux/kernel.h>
16#include <asm/system.h> 14#include <asm/system.h>
@@ -90,5 +88,4 @@ extern void up_read_non_owner(struct rw_semaphore *sem);
90# define up_read_non_owner(sem) up_read(sem) 88# define up_read_non_owner(sem) up_read(sem)
91#endif 89#endif
92 90
93#endif /* __KERNEL__ */
94#endif /* _LINUX_RWSEM_H */ 91#endif /* _LINUX_RWSEM_H */
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index a3d567a974e8..71fc81360048 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -213,6 +213,11 @@ int __sg_alloc_table(struct sg_table *, unsigned int, unsigned int, gfp_t,
213 sg_alloc_fn *); 213 sg_alloc_fn *);
214int sg_alloc_table(struct sg_table *, unsigned int, gfp_t); 214int sg_alloc_table(struct sg_table *, unsigned int, gfp_t);
215 215
216size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
217 void *buf, size_t buflen);
218size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
219 void *buf, size_t buflen);
220
216/* 221/*
217 * Maximum number of entries that will be allocated in one piece, if 222 * 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. 223 * a list larger than this is required then chaining will be utilized.
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6a1e7afb099b..03c238088aee 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -61,7 +61,6 @@ struct sched_param {
61#include <linux/mm_types.h> 61#include <linux/mm_types.h>
62 62
63#include <asm/system.h> 63#include <asm/system.h>
64#include <asm/semaphore.h>
65#include <asm/page.h> 64#include <asm/page.h>
66#include <asm/ptrace.h> 65#include <asm/ptrace.h>
67#include <asm/cputime.h> 66#include <asm/cputime.h>
@@ -69,7 +68,6 @@ struct sched_param {
69#include <linux/smp.h> 68#include <linux/smp.h>
70#include <linux/sem.h> 69#include <linux/sem.h>
71#include <linux/signal.h> 70#include <linux/signal.h>
72#include <linux/securebits.h>
73#include <linux/fs_struct.h> 71#include <linux/fs_struct.h>
74#include <linux/compiler.h> 72#include <linux/compiler.h>
75#include <linux/completion.h> 73#include <linux/completion.h>
@@ -556,6 +554,14 @@ struct signal_struct {
556#define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */ 554#define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */
557#define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */ 555#define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */
558#define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress */ 556#define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress */
557/*
558 * Pending notifications to parent.
559 */
560#define SIGNAL_CLD_STOPPED 0x00000010
561#define SIGNAL_CLD_CONTINUED 0x00000020
562#define SIGNAL_CLD_MASK (SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
563
564#define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */
559 565
560/* If true, all threads except ->group_exit_task have pending SIGKILL */ 566/* If true, all threads except ->group_exit_task have pending SIGKILL */
561static inline int signal_group_exit(const struct signal_struct *sig) 567static inline int signal_group_exit(const struct signal_struct *sig)
@@ -704,6 +710,7 @@ enum cpu_idle_type {
704#define SD_POWERSAVINGS_BALANCE 256 /* Balance for power savings */ 710#define SD_POWERSAVINGS_BALANCE 256 /* Balance for power savings */
705#define SD_SHARE_PKG_RESOURCES 512 /* Domain members share cpu pkg resources */ 711#define SD_SHARE_PKG_RESOURCES 512 /* Domain members share cpu pkg resources */
706#define SD_SERIALIZE 1024 /* Only a single load balancing instance */ 712#define SD_SERIALIZE 1024 /* Only a single load balancing instance */
713#define SD_WAKE_IDLE_FAR 2048 /* Gain latency sacrificing cache hit */
707 714
708#define BALANCE_FOR_MC_POWER \ 715#define BALANCE_FOR_MC_POWER \
709 (sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0) 716 (sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0)
@@ -733,12 +740,31 @@ struct sched_group {
733 u32 reciprocal_cpu_power; 740 u32 reciprocal_cpu_power;
734}; 741};
735 742
743enum sched_domain_level {
744 SD_LV_NONE = 0,
745 SD_LV_SIBLING,
746 SD_LV_MC,
747 SD_LV_CPU,
748 SD_LV_NODE,
749 SD_LV_ALLNODES,
750 SD_LV_MAX
751};
752
753struct sched_domain_attr {
754 int relax_domain_level;
755};
756
757#define SD_ATTR_INIT (struct sched_domain_attr) { \
758 .relax_domain_level = -1, \
759}
760
736struct sched_domain { 761struct sched_domain {
737 /* These fields must be setup */ 762 /* These fields must be setup */
738 struct sched_domain *parent; /* top domain must be null terminated */ 763 struct sched_domain *parent; /* top domain must be null terminated */
739 struct sched_domain *child; /* bottom domain must be null terminated */ 764 struct sched_domain *child; /* bottom domain must be null terminated */
740 struct sched_group *groups; /* the balancing groups of the domain */ 765 struct sched_group *groups; /* the balancing groups of the domain */
741 cpumask_t span; /* span of all CPUs in this domain */ 766 cpumask_t span; /* span of all CPUs in this domain */
767 int first_cpu; /* cache of the first cpu in this domain */
742 unsigned long min_interval; /* Minimum balance interval ms */ 768 unsigned long min_interval; /* Minimum balance interval ms */
743 unsigned long max_interval; /* Maximum balance interval ms */ 769 unsigned long max_interval; /* Maximum balance interval ms */
744 unsigned int busy_factor; /* less balancing by factor if busy */ 770 unsigned int busy_factor; /* less balancing by factor if busy */
@@ -750,6 +776,7 @@ struct sched_domain {
750 unsigned int wake_idx; 776 unsigned int wake_idx;
751 unsigned int forkexec_idx; 777 unsigned int forkexec_idx;
752 int flags; /* See SD_* */ 778 int flags; /* See SD_* */
779 enum sched_domain_level level;
753 780
754 /* Runtime fields. */ 781 /* Runtime fields. */
755 unsigned long last_balance; /* init to jiffies. units in jiffies */ 782 unsigned long last_balance; /* init to jiffies. units in jiffies */
@@ -789,7 +816,8 @@ struct sched_domain {
789#endif 816#endif
790}; 817};
791 818
792extern void partition_sched_domains(int ndoms_new, cpumask_t *doms_new); 819extern void partition_sched_domains(int ndoms_new, cpumask_t *doms_new,
820 struct sched_domain_attr *dattr_new);
793extern int arch_reinit_sched_domains(void); 821extern int arch_reinit_sched_domains(void);
794 822
795#endif /* CONFIG_SMP */ 823#endif /* CONFIG_SMP */
@@ -889,7 +917,8 @@ struct sched_class {
889 void (*set_curr_task) (struct rq *rq); 917 void (*set_curr_task) (struct rq *rq);
890 void (*task_tick) (struct rq *rq, struct task_struct *p, int queued); 918 void (*task_tick) (struct rq *rq, struct task_struct *p, int queued);
891 void (*task_new) (struct rq *rq, struct task_struct *p); 919 void (*task_new) (struct rq *rq, struct task_struct *p);
892 void (*set_cpus_allowed)(struct task_struct *p, cpumask_t *newmask); 920 void (*set_cpus_allowed)(struct task_struct *p,
921 const cpumask_t *newmask);
893 922
894 void (*join_domain)(struct rq *rq); 923 void (*join_domain)(struct rq *rq);
895 void (*leave_domain)(struct rq *rq); 924 void (*leave_domain)(struct rq *rq);
@@ -923,6 +952,7 @@ struct load_weight {
923struct sched_entity { 952struct sched_entity {
924 struct load_weight load; /* for load-balancing */ 953 struct load_weight load; /* for load-balancing */
925 struct rb_node run_node; 954 struct rb_node run_node;
955 struct list_head group_node;
926 unsigned int on_rq; 956 unsigned int on_rq;
927 957
928 u64 exec_start; 958 u64 exec_start;
@@ -982,6 +1012,7 @@ struct sched_rt_entity {
982 unsigned long timeout; 1012 unsigned long timeout;
983 int nr_cpus_allowed; 1013 int nr_cpus_allowed;
984 1014
1015 struct sched_rt_entity *back;
985#ifdef CONFIG_RT_GROUP_SCHED 1016#ifdef CONFIG_RT_GROUP_SCHED
986 struct sched_rt_entity *parent; 1017 struct sched_rt_entity *parent;
987 /* rq on which this entity is (to be) queued: */ 1018 /* rq on which this entity is (to be) queued: */
@@ -1109,7 +1140,7 @@ struct task_struct {
1109 gid_t gid,egid,sgid,fsgid; 1140 gid_t gid,egid,sgid,fsgid;
1110 struct group_info *group_info; 1141 struct group_info *group_info;
1111 kernel_cap_t cap_effective, cap_inheritable, cap_permitted, cap_bset; 1142 kernel_cap_t cap_effective, cap_inheritable, cap_permitted, cap_bset;
1112 unsigned keep_capabilities:1; 1143 unsigned securebits;
1113 struct user_struct *user; 1144 struct user_struct *user;
1114#ifdef CONFIG_KEYS 1145#ifdef CONFIG_KEYS
1115 struct key *request_key_auth; /* assumed request_key authority */ 1146 struct key *request_key_auth; /* assumed request_key authority */
@@ -1144,7 +1175,7 @@ struct task_struct {
1144 struct sighand_struct *sighand; 1175 struct sighand_struct *sighand;
1145 1176
1146 sigset_t blocked, real_blocked; 1177 sigset_t blocked, real_blocked;
1147 sigset_t saved_sigmask; /* To be restored with TIF_RESTORE_SIGMASK */ 1178 sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */
1148 struct sigpending pending; 1179 struct sigpending pending;
1149 1180
1150 unsigned long sas_ss_sp; 1181 unsigned long sas_ss_sp;
@@ -1502,15 +1533,21 @@ static inline void put_task_struct(struct task_struct *t)
1502#define used_math() tsk_used_math(current) 1533#define used_math() tsk_used_math(current)
1503 1534
1504#ifdef CONFIG_SMP 1535#ifdef CONFIG_SMP
1505extern int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask); 1536extern int set_cpus_allowed_ptr(struct task_struct *p,
1537 const cpumask_t *new_mask);
1506#else 1538#else
1507static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask) 1539static inline int set_cpus_allowed_ptr(struct task_struct *p,
1540 const cpumask_t *new_mask)
1508{ 1541{
1509 if (!cpu_isset(0, new_mask)) 1542 if (!cpu_isset(0, *new_mask))
1510 return -EINVAL; 1543 return -EINVAL;
1511 return 0; 1544 return 0;
1512} 1545}
1513#endif 1546#endif
1547static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
1548{
1549 return set_cpus_allowed_ptr(p, &new_mask);
1550}
1514 1551
1515extern unsigned long long sched_clock(void); 1552extern unsigned long long sched_clock(void);
1516 1553
@@ -1551,7 +1588,6 @@ static inline void wake_up_idle_cpu(int cpu) { }
1551extern unsigned int sysctl_sched_latency; 1588extern unsigned int sysctl_sched_latency;
1552extern unsigned int sysctl_sched_min_granularity; 1589extern unsigned int sysctl_sched_min_granularity;
1553extern unsigned int sysctl_sched_wakeup_granularity; 1590extern unsigned int sysctl_sched_wakeup_granularity;
1554extern unsigned int sysctl_sched_batch_wakeup_granularity;
1555extern unsigned int sysctl_sched_child_runs_first; 1591extern unsigned int sysctl_sched_child_runs_first;
1556extern unsigned int sysctl_sched_features; 1592extern unsigned int sysctl_sched_features;
1557extern unsigned int sysctl_sched_migration_cost; 1593extern unsigned int sysctl_sched_migration_cost;
@@ -1564,6 +1600,10 @@ int sched_nr_latency_handler(struct ctl_table *table, int write,
1564extern unsigned int sysctl_sched_rt_period; 1600extern unsigned int sysctl_sched_rt_period;
1565extern int sysctl_sched_rt_runtime; 1601extern int sysctl_sched_rt_runtime;
1566 1602
1603int sched_rt_handler(struct ctl_table *table, int write,
1604 struct file *filp, void __user *buffer, size_t *lenp,
1605 loff_t *ppos);
1606
1567extern unsigned int sysctl_sched_compat_yield; 1607extern unsigned int sysctl_sched_compat_yield;
1568 1608
1569#ifdef CONFIG_RT_MUTEXES 1609#ifdef CONFIG_RT_MUTEXES
@@ -1637,7 +1677,10 @@ extern struct pid_namespace init_pid_ns;
1637extern struct task_struct *find_task_by_pid_type_ns(int type, int pid, 1677extern struct task_struct *find_task_by_pid_type_ns(int type, int pid,
1638 struct pid_namespace *ns); 1678 struct pid_namespace *ns);
1639 1679
1640extern struct task_struct *find_task_by_pid(pid_t nr); 1680static inline struct task_struct *__deprecated find_task_by_pid(pid_t nr)
1681{
1682 return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns);
1683}
1641extern struct task_struct *find_task_by_vpid(pid_t nr); 1684extern struct task_struct *find_task_by_vpid(pid_t nr);
1642extern struct task_struct *find_task_by_pid_ns(pid_t nr, 1685extern struct task_struct *find_task_by_pid_ns(pid_t nr,
1643 struct pid_namespace *ns); 1686 struct pid_namespace *ns);
@@ -1713,8 +1756,7 @@ extern void zap_other_threads(struct task_struct *p);
1713extern int kill_proc(pid_t, int, int); 1756extern int kill_proc(pid_t, int, int);
1714extern struct sigqueue *sigqueue_alloc(void); 1757extern struct sigqueue *sigqueue_alloc(void);
1715extern void sigqueue_free(struct sigqueue *); 1758extern void sigqueue_free(struct sigqueue *);
1716extern int send_sigqueue(int, struct sigqueue *, struct task_struct *); 1759extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group);
1717extern int send_group_sigqueue(int, struct sigqueue *, struct task_struct *);
1718extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *); 1760extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *);
1719extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long); 1761extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
1720 1762
@@ -1765,6 +1807,8 @@ extern void mmput(struct mm_struct *);
1765extern struct mm_struct *get_task_mm(struct task_struct *task); 1807extern struct mm_struct *get_task_mm(struct task_struct *task);
1766/* Remove the current tasks stale references to the old mm_struct */ 1808/* Remove the current tasks stale references to the old mm_struct */
1767extern void mm_release(struct task_struct *, struct mm_struct *); 1809extern void mm_release(struct task_struct *, struct mm_struct *);
1810/* Allocate a new mm structure and copy contents from tsk->mm */
1811extern struct mm_struct *dup_mm(struct task_struct *tsk);
1768 1812
1769extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); 1813extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *);
1770extern void flush_thread(void); 1814extern void flush_thread(void);
@@ -1893,6 +1937,8 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
1893 1937
1894#endif 1938#endif
1895 1939
1940extern void thread_info_cache_init(void);
1941
1896/* set thread flags in other task's structures 1942/* set thread flags in other task's structures
1897 * - see asm/thread_info.h for TIF_xxxx flags available 1943 * - see asm/thread_info.h for TIF_xxxx flags available
1898 */ 1944 */
@@ -2031,7 +2077,7 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm)
2031} 2077}
2032#endif 2078#endif
2033 2079
2034extern long sched_setaffinity(pid_t pid, cpumask_t new_mask); 2080extern long sched_setaffinity(pid_t pid, const cpumask_t *new_mask);
2035extern long sched_getaffinity(pid_t pid, cpumask_t *mask); 2081extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
2036 2082
2037extern int sched_mc_power_savings, sched_smt_power_savings; 2083extern int sched_mc_power_savings, sched_smt_power_savings;
@@ -2041,8 +2087,11 @@ extern void normalize_rt_tasks(void);
2041#ifdef CONFIG_GROUP_SCHED 2087#ifdef CONFIG_GROUP_SCHED
2042 2088
2043extern struct task_group init_task_group; 2089extern struct task_group init_task_group;
2090#ifdef CONFIG_USER_SCHED
2091extern struct task_group root_task_group;
2092#endif
2044 2093
2045extern struct task_group *sched_create_group(void); 2094extern struct task_group *sched_create_group(struct task_group *parent);
2046extern void sched_destroy_group(struct task_group *tg); 2095extern void sched_destroy_group(struct task_group *tg);
2047extern void sched_move_task(struct task_struct *tsk); 2096extern void sched_move_task(struct task_struct *tsk);
2048#ifdef CONFIG_FAIR_GROUP_SCHED 2097#ifdef CONFIG_FAIR_GROUP_SCHED
@@ -2053,6 +2102,9 @@ extern unsigned long sched_group_shares(struct task_group *tg);
2053extern int sched_group_set_rt_runtime(struct task_group *tg, 2102extern int sched_group_set_rt_runtime(struct task_group *tg,
2054 long rt_runtime_us); 2103 long rt_runtime_us);
2055extern long sched_group_rt_runtime(struct task_group *tg); 2104extern long sched_group_rt_runtime(struct task_group *tg);
2105extern int sched_group_set_rt_period(struct task_group *tg,
2106 long rt_period_us);
2107extern long sched_group_rt_period(struct task_group *tg);
2056#endif 2108#endif
2057#endif 2109#endif
2058 2110
@@ -2106,6 +2158,19 @@ static inline void migration_init(void)
2106#define TASK_SIZE_OF(tsk) TASK_SIZE 2158#define TASK_SIZE_OF(tsk) TASK_SIZE
2107#endif 2159#endif
2108 2160
2161#ifdef CONFIG_MM_OWNER
2162extern void mm_update_next_owner(struct mm_struct *mm);
2163extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p);
2164#else
2165static inline void mm_update_next_owner(struct mm_struct *mm)
2166{
2167}
2168
2169static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
2170{
2171}
2172#endif /* CONFIG_MM_OWNER */
2173
2109#endif /* __KERNEL__ */ 2174#endif /* __KERNEL__ */
2110 2175
2111#endif 2176#endif
diff --git a/include/linux/securebits.h b/include/linux/securebits.h
index 5b0617840fa4..c1f19dbceb05 100644
--- a/include/linux/securebits.h
+++ b/include/linux/securebits.h
@@ -3,28 +3,39 @@
3 3
4#define SECUREBITS_DEFAULT 0x00000000 4#define SECUREBITS_DEFAULT 0x00000000
5 5
6extern unsigned securebits;
7
8/* When set UID 0 has no special privileges. When unset, we support 6/* When set UID 0 has no special privileges. When unset, we support
9 inheritance of root-permissions and suid-root executable under 7 inheritance of root-permissions and suid-root executable under
10 compatibility mode. We raise the effective and inheritable bitmasks 8 compatibility mode. We raise the effective and inheritable bitmasks
11 *of the executable file* if the effective uid of the new process is 9 *of the executable file* if the effective uid of the new process is
12 0. If the real uid is 0, we raise the inheritable bitmask of the 10 0. If the real uid is 0, we raise the inheritable bitmask of the
13 executable file. */ 11 executable file. */
14#define SECURE_NOROOT 0 12#define SECURE_NOROOT 0
13#define SECURE_NOROOT_LOCKED 1 /* make bit-0 immutable */
15 14
16/* When set, setuid to/from uid 0 does not trigger capability-"fixes" 15/* When set, setuid to/from uid 0 does not trigger capability-"fixes"
17 to be compatible with old programs relying on set*uid to loose 16 to be compatible with old programs relying on set*uid to loose
18 privileges. When unset, setuid doesn't change privileges. */ 17 privileges. When unset, setuid doesn't change privileges. */
19#define SECURE_NO_SETUID_FIXUP 2 18#define SECURE_NO_SETUID_FIXUP 2
19#define SECURE_NO_SETUID_FIXUP_LOCKED 3 /* make bit-2 immutable */
20
21/* When set, a process can retain its capabilities even after
22 transitioning to a non-root user (the set-uid fixup suppressed by
23 bit 2). Bit-4 is cleared when a process calls exec(); setting both
24 bit 4 and 5 will create a barrier through exec that no exec()'d
25 child can use this feature again. */
26#define SECURE_KEEP_CAPS 4
27#define SECURE_KEEP_CAPS_LOCKED 5 /* make bit-4 immutable */
20 28
21/* Each securesetting is implemented using two bits. One bit specify 29/* Each securesetting is implemented using two bits. One bit specify
22 whether the setting is on or off. The other bit specify whether the 30 whether the setting is on or off. The other bit specify whether the
23 setting is fixed or not. A setting which is fixed cannot be changed 31 setting is fixed or not. A setting which is fixed cannot be changed
24 from user-level. */ 32 from user-level. */
33#define issecure_mask(X) (1 << (X))
34#define issecure(X) (issecure_mask(X) & current->securebits)
25 35
26#define issecure(X) ( (1 << (X+1)) & SECUREBITS_DEFAULT ? \ 36#define SECURE_ALL_BITS (issecure_mask(SECURE_NOROOT) | \
27 (1 << (X)) & SECUREBITS_DEFAULT : \ 37 issecure_mask(SECURE_NO_SETUID_FIXUP) | \
28 (1 << (X)) & securebits ) 38 issecure_mask(SECURE_KEEP_CAPS))
39#define SECURE_ALL_LOCKS (SECURE_ALL_BITS << 1)
29 40
30#endif /* !_LINUX_SECUREBITS_H */ 41#endif /* !_LINUX_SECUREBITS_H */
diff --git a/include/linux/security.h b/include/linux/security.h
index c673dfd4dffc..50737c70e78e 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -34,33 +34,38 @@
34#include <linux/xfrm.h> 34#include <linux/xfrm.h>
35#include <net/flow.h> 35#include <net/flow.h>
36 36
37extern unsigned securebits; 37/* Maximum number of letters for an LSM name string */
38#define SECURITY_NAME_MAX 10
38 39
39struct ctl_table; 40struct ctl_table;
41struct audit_krule;
40 42
41/* 43/*
42 * These functions are in security/capability.c and are used 44 * These functions are in security/capability.c and are used
43 * as the default capabilities functions 45 * as the default capabilities functions
44 */ 46 */
45extern int cap_capable (struct task_struct *tsk, int cap); 47extern int cap_capable(struct task_struct *tsk, int cap);
46extern int cap_settime (struct timespec *ts, struct timezone *tz); 48extern int cap_settime(struct timespec *ts, struct timezone *tz);
47extern int cap_ptrace (struct task_struct *parent, struct task_struct *child); 49extern int cap_ptrace(struct task_struct *parent, struct task_struct *child);
48extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 50extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
49extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 51extern int cap_capset_check(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
50extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 52extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
51extern int cap_bprm_set_security (struct linux_binprm *bprm); 53extern int cap_bprm_set_security(struct linux_binprm *bprm);
52extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe); 54extern void cap_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
53extern int cap_bprm_secureexec(struct linux_binprm *bprm); 55extern int cap_bprm_secureexec(struct linux_binprm *bprm);
54extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags); 56extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
55extern int cap_inode_removexattr(struct dentry *dentry, char *name); 57 const void *value, size_t size, int flags);
58extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
56extern int cap_inode_need_killpriv(struct dentry *dentry); 59extern int cap_inode_need_killpriv(struct dentry *dentry);
57extern int cap_inode_killpriv(struct dentry *dentry); 60extern int cap_inode_killpriv(struct dentry *dentry);
58extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags); 61extern int cap_task_post_setuid(uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
59extern void cap_task_reparent_to_init (struct task_struct *p); 62extern void cap_task_reparent_to_init(struct task_struct *p);
60extern int cap_task_setscheduler (struct task_struct *p, int policy, struct sched_param *lp); 63extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
61extern int cap_task_setioprio (struct task_struct *p, int ioprio); 64 unsigned long arg4, unsigned long arg5, long *rc_p);
62extern int cap_task_setnice (struct task_struct *p, int nice); 65extern int cap_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp);
63extern int cap_syslog (int type); 66extern int cap_task_setioprio(struct task_struct *p, int ioprio);
67extern int cap_task_setnice(struct task_struct *p, int nice);
68extern int cap_syslog(int type);
64extern int cap_vm_enough_memory(struct mm_struct *mm, long pages); 69extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
65 70
66struct msghdr; 71struct msghdr;
@@ -124,7 +129,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
124{ 129{
125 int i; 130 int i;
126 if (opts->mnt_opts) 131 if (opts->mnt_opts)
127 for(i = 0; i < opts->num_mnt_opts; i++) 132 for (i = 0; i < opts->num_mnt_opts; i++)
128 kfree(opts->mnt_opts[i]); 133 kfree(opts->mnt_opts[i]);
129 kfree(opts->mnt_opts); 134 kfree(opts->mnt_opts);
130 opts->mnt_opts = NULL; 135 opts->mnt_opts = NULL;
@@ -136,6 +141,12 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
136/** 141/**
137 * struct security_operations - main security structure 142 * struct security_operations - main security structure
138 * 143 *
144 * Security module identifier.
145 *
146 * @name:
147 * A string that acts as a unique identifeir for the LSM with max number
148 * of characters = SECURITY_NAME_MAX.
149 *
139 * Security hooks for program execution operations. 150 * Security hooks for program execution operations.
140 * 151 *
141 * @bprm_alloc_security: 152 * @bprm_alloc_security:
@@ -180,21 +191,21 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
180 * @bprm contains the linux_binprm structure. 191 * @bprm contains the linux_binprm structure.
181 * Return 0 if the hook is successful and permission is granted. 192 * Return 0 if the hook is successful and permission is granted.
182 * @bprm_check_security: 193 * @bprm_check_security:
183 * This hook mediates the point when a search for a binary handler will 194 * This hook mediates the point when a search for a binary handler will
184 * begin. It allows a check the @bprm->security value which is set in 195 * begin. It allows a check the @bprm->security value which is set in
185 * the preceding set_security call. The primary difference from 196 * the preceding set_security call. The primary difference from
186 * set_security is that the argv list and envp list are reliably 197 * set_security is that the argv list and envp list are reliably
187 * available in @bprm. This hook may be called multiple times 198 * available in @bprm. This hook may be called multiple times
188 * during a single execve; and in each pass set_security is called 199 * during a single execve; and in each pass set_security is called
189 * first. 200 * first.
190 * @bprm contains the linux_binprm structure. 201 * @bprm contains the linux_binprm structure.
191 * Return 0 if the hook is successful and permission is granted. 202 * Return 0 if the hook is successful and permission is granted.
192 * @bprm_secureexec: 203 * @bprm_secureexec:
193 * Return a boolean value (0 or 1) indicating whether a "secure exec" 204 * Return a boolean value (0 or 1) indicating whether a "secure exec"
194 * is required. The flag is passed in the auxiliary table 205 * is required. The flag is passed in the auxiliary table
195 * on the initial stack to the ELF interpreter to indicate whether libc 206 * on the initial stack to the ELF interpreter to indicate whether libc
196 * should enable secure mode. 207 * should enable secure mode.
197 * @bprm contains the linux_binprm structure. 208 * @bprm contains the linux_binprm structure.
198 * 209 *
199 * Security hooks for filesystem operations. 210 * Security hooks for filesystem operations.
200 * 211 *
@@ -211,7 +222,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
211 * Check permission before obtaining filesystem statistics for the @mnt 222 * Check permission before obtaining filesystem statistics for the @mnt
212 * mountpoint. 223 * mountpoint.
213 * @dentry is a handle on the superblock for the filesystem. 224 * @dentry is a handle on the superblock for the filesystem.
214 * Return 0 if permission is granted. 225 * Return 0 if permission is granted.
215 * @sb_mount: 226 * @sb_mount:
216 * Check permission before an object specified by @dev_name is mounted on 227 * Check permission before an object specified by @dev_name is mounted on
217 * the mount point named by @nd. For an ordinary mount, @dev_name 228 * the mount point named by @nd. For an ordinary mount, @dev_name
@@ -220,7 +231,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
220 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the 231 * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
221 * pathname of the object being mounted. 232 * pathname of the object being mounted.
222 * @dev_name contains the name for object being mounted. 233 * @dev_name contains the name for object being mounted.
223 * @nd contains the nameidata structure for mount point object. 234 * @path contains the path for mount point object.
224 * @type contains the filesystem type. 235 * @type contains the filesystem type.
225 * @flags contains the mount flags. 236 * @flags contains the mount flags.
226 * @data contains the filesystem-specific data. 237 * @data contains the filesystem-specific data.
@@ -239,7 +250,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
239 * Check permission before the device with superblock @mnt->sb is mounted 250 * Check permission before the device with superblock @mnt->sb is mounted
240 * on the mount point named by @nd. 251 * on the mount point named by @nd.
241 * @mnt contains the vfsmount for device being mounted. 252 * @mnt contains the vfsmount for device being mounted.
242 * @nd contains the nameidata object for the mount point. 253 * @path contains the path for the mount point.
243 * Return 0 if permission is granted. 254 * Return 0 if permission is granted.
244 * @sb_umount: 255 * @sb_umount:
245 * Check permission before the @mnt file system is unmounted. 256 * Check permission before the @mnt file system is unmounted.
@@ -268,16 +279,16 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
268 * This hook is called any time a mount is successfully grafetd to 279 * This hook is called any time a mount is successfully grafetd to
269 * the tree. 280 * the tree.
270 * @mnt contains the mounted filesystem. 281 * @mnt contains the mounted filesystem.
271 * @mountpoint_nd contains the nameidata structure for the mount point. 282 * @mountpoint contains the path for the mount point.
272 * @sb_pivotroot: 283 * @sb_pivotroot:
273 * Check permission before pivoting the root filesystem. 284 * Check permission before pivoting the root filesystem.
274 * @old_nd contains the nameidata structure for the new location of the current root (put_old). 285 * @old_path contains the path for the new location of the current root (put_old).
275 * @new_nd contains the nameidata structure for the new root (new_root). 286 * @new_path contains the path for the new root (new_root).
276 * Return 0 if permission is granted. 287 * Return 0 if permission is granted.
277 * @sb_post_pivotroot: 288 * @sb_post_pivotroot:
278 * Update module state after a successful pivot. 289 * Update module state after a successful pivot.
279 * @old_nd contains the nameidata structure for the old root. 290 * @old_path contains the path for the old root.
280 * @new_nd contains the nameidata structure for the new root. 291 * @new_path contains the path for the new root.
281 * @sb_get_mnt_opts: 292 * @sb_get_mnt_opts:
282 * Get the security relevant mount options used for a superblock 293 * Get the security relevant mount options used for a superblock
283 * @sb the superblock to get security mount options from 294 * @sb the superblock to get security mount options from
@@ -306,9 +317,9 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
306 * @inode_free_security: 317 * @inode_free_security:
307 * @inode contains the inode structure. 318 * @inode contains the inode structure.
308 * Deallocate the inode security structure and set @inode->i_security to 319 * Deallocate the inode security structure and set @inode->i_security to
309 * NULL. 320 * NULL.
310 * @inode_init_security: 321 * @inode_init_security:
311 * Obtain the security attribute name suffix and value to set on a newly 322 * Obtain the security attribute name suffix and value to set on a newly
312 * created inode and set up the incore security field for the new inode. 323 * created inode and set up the incore security field for the new inode.
313 * This hook is called by the fs code as part of the inode creation 324 * This hook is called by the fs code as part of the inode creation
314 * transaction and provides for atomic labeling of the inode, unlike 325 * transaction and provides for atomic labeling of the inode, unlike
@@ -339,7 +350,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
339 * @new_dentry contains the dentry structure for the new link. 350 * @new_dentry contains the dentry structure for the new link.
340 * Return 0 if permission is granted. 351 * Return 0 if permission is granted.
341 * @inode_unlink: 352 * @inode_unlink:
342 * Check the permission to remove a hard link to a file. 353 * Check the permission to remove a hard link to a file.
343 * @dir contains the inode structure of parent directory of the file. 354 * @dir contains the inode structure of parent directory of the file.
344 * @dentry contains the dentry structure for file to be unlinked. 355 * @dentry contains the dentry structure for file to be unlinked.
345 * Return 0 if permission is granted. 356 * Return 0 if permission is granted.
@@ -351,7 +362,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
351 * Return 0 if permission is granted. 362 * Return 0 if permission is granted.
352 * @inode_mkdir: 363 * @inode_mkdir:
353 * Check permissions to create a new directory in the existing directory 364 * Check permissions to create a new directory in the existing directory
354 * associated with inode strcture @dir. 365 * associated with inode strcture @dir.
355 * @dir containst the inode structure of parent of the directory to be created. 366 * @dir containst the inode structure of parent of the directory to be created.
356 * @dentry contains the dentry structure of new directory. 367 * @dentry contains the dentry structure of new directory.
357 * @mode contains the mode of new directory. 368 * @mode contains the mode of new directory.
@@ -396,7 +407,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
396 * called when the actual read/write operations are performed. 407 * called when the actual read/write operations are performed.
397 * @inode contains the inode structure to check. 408 * @inode contains the inode structure to check.
398 * @mask contains the permission mask. 409 * @mask contains the permission mask.
399 * @nd contains the nameidata (may be NULL). 410 * @nd contains the nameidata (may be NULL).
400 * Return 0 if permission is granted. 411 * Return 0 if permission is granted.
401 * @inode_setattr: 412 * @inode_setattr:
402 * Check permission before setting file attributes. Note that the kernel 413 * Check permission before setting file attributes. Note that the kernel
@@ -418,24 +429,24 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
418 * can use this hook to release any persistent label associated with the 429 * can use this hook to release any persistent label associated with the
419 * inode. 430 * inode.
420 * @inode_setxattr: 431 * @inode_setxattr:
421 * Check permission before setting the extended attributes 432 * Check permission before setting the extended attributes
422 * @value identified by @name for @dentry. 433 * @value identified by @name for @dentry.
423 * Return 0 if permission is granted. 434 * Return 0 if permission is granted.
424 * @inode_post_setxattr: 435 * @inode_post_setxattr:
425 * Update inode security field after successful setxattr operation. 436 * Update inode security field after successful setxattr operation.
426 * @value identified by @name for @dentry. 437 * @value identified by @name for @dentry.
427 * @inode_getxattr: 438 * @inode_getxattr:
428 * Check permission before obtaining the extended attributes 439 * Check permission before obtaining the extended attributes
429 * identified by @name for @dentry. 440 * identified by @name for @dentry.
430 * Return 0 if permission is granted. 441 * Return 0 if permission is granted.
431 * @inode_listxattr: 442 * @inode_listxattr:
432 * Check permission before obtaining the list of extended attribute 443 * Check permission before obtaining the list of extended attribute
433 * names for @dentry. 444 * names for @dentry.
434 * Return 0 if permission is granted. 445 * Return 0 if permission is granted.
435 * @inode_removexattr: 446 * @inode_removexattr:
436 * Check permission before removing the extended attribute 447 * Check permission before removing the extended attribute
437 * identified by @name for @dentry. 448 * identified by @name for @dentry.
438 * Return 0 if permission is granted. 449 * Return 0 if permission is granted.
439 * @inode_getsecurity: 450 * @inode_getsecurity:
440 * Retrieve a copy of the extended attribute representation of the 451 * Retrieve a copy of the extended attribute representation of the
441 * security label associated with @name for @inode via @buffer. Note that 452 * security label associated with @name for @inode via @buffer. Note that
@@ -447,7 +458,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
447 * Set the security label associated with @name for @inode from the 458 * Set the security label associated with @name for @inode from the
448 * extended attribute value @value. @size indicates the size of the 459 * extended attribute value @value. @size indicates the size of the
449 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0. 460 * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
450 * Note that @name is the remainder of the attribute name after the 461 * Note that @name is the remainder of the attribute name after the
451 * security. prefix has been removed. 462 * security. prefix has been removed.
452 * Return 0 on success. 463 * Return 0 on success.
453 * @inode_listsecurity: 464 * @inode_listsecurity:
@@ -468,6 +479,11 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
468 * @dentry is the dentry being changed. 479 * @dentry is the dentry being changed.
469 * Return 0 on success. If error is returned, then the operation 480 * Return 0 on success. If error is returned, then the operation
470 * causing setuid bit removal is failed. 481 * causing setuid bit removal is failed.
482 * @inode_getsecid:
483 * Get the secid associated with the node.
484 * @inode contains a pointer to the inode.
485 * @secid contains a pointer to the location where result will be saved.
486 * In case of failure, @secid will be set to zero.
471 * 487 *
472 * Security hooks for file operations 488 * Security hooks for file operations
473 * 489 *
@@ -549,7 +565,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
549 * struct file, so the file structure (and associated security information) 565 * struct file, so the file structure (and associated security information)
550 * can always be obtained: 566 * can always be obtained:
551 * container_of(fown, struct file, f_owner) 567 * container_of(fown, struct file, f_owner)
552 * @tsk contains the structure of task receiving signal. 568 * @tsk contains the structure of task receiving signal.
553 * @fown contains the file owner information. 569 * @fown contains the file owner information.
554 * @sig is the signal that will be sent. When 0, kernel sends SIGIO. 570 * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
555 * Return 0 if permission is granted. 571 * Return 0 if permission is granted.
@@ -636,6 +652,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
636 * @task_getsecid: 652 * @task_getsecid:
637 * Retrieve the security identifier of the process @p. 653 * Retrieve the security identifier of the process @p.
638 * @p contains the task_struct for the process and place is into @secid. 654 * @p contains the task_struct for the process and place is into @secid.
655 * In case of failure, @secid will be set to zero.
656 *
639 * @task_setgroups: 657 * @task_setgroups:
640 * Check permission before setting the supplementary group set of the 658 * Check permission before setting the supplementary group set of the
641 * current process. 659 * current process.
@@ -703,14 +721,16 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
703 * @arg3 contains a argument. 721 * @arg3 contains a argument.
704 * @arg4 contains a argument. 722 * @arg4 contains a argument.
705 * @arg5 contains a argument. 723 * @arg5 contains a argument.
706 * Return 0 if permission is granted. 724 * @rc_p contains a pointer to communicate back the forced return code
725 * Return 0 if permission is granted, and non-zero if the security module
726 * has taken responsibility (setting *rc_p) for the prctl call.
707 * @task_reparent_to_init: 727 * @task_reparent_to_init:
708 * Set the security attributes in @p->security for a kernel thread that 728 * Set the security attributes in @p->security for a kernel thread that
709 * is being reparented to the init task. 729 * is being reparented to the init task.
710 * @p contains the task_struct for the kernel thread. 730 * @p contains the task_struct for the kernel thread.
711 * @task_to_inode: 731 * @task_to_inode:
712 * Set the security attributes for an inode based on an associated task's 732 * Set the security attributes for an inode based on an associated task's
713 * security attributes, e.g. for /proc/pid inodes. 733 * security attributes, e.g. for /proc/pid inodes.
714 * @p contains the task_struct for the task. 734 * @p contains the task_struct for the task.
715 * @inode contains the inode structure for the inode. 735 * @inode contains the inode structure for the inode.
716 * 736 *
@@ -720,7 +740,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
720 * Save security information for a netlink message so that permission 740 * Save security information for a netlink message so that permission
721 * checking can be performed when the message is processed. The security 741 * checking can be performed when the message is processed. The security
722 * information can be saved using the eff_cap field of the 742 * information can be saved using the eff_cap field of the
723 * netlink_skb_parms structure. Also may be used to provide fine 743 * netlink_skb_parms structure. Also may be used to provide fine
724 * grained control over message transmission. 744 * grained control over message transmission.
725 * @sk associated sock of task sending the message., 745 * @sk associated sock of task sending the message.,
726 * @skb contains the sk_buff structure for the netlink message. 746 * @skb contains the sk_buff structure for the netlink message.
@@ -788,14 +808,14 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
788 * @sock contains the socket structure. 808 * @sock contains the socket structure.
789 * @address contains the address to bind to. 809 * @address contains the address to bind to.
790 * @addrlen contains the length of address. 810 * @addrlen contains the length of address.
791 * Return 0 if permission is granted. 811 * Return 0 if permission is granted.
792 * @socket_connect: 812 * @socket_connect:
793 * Check permission before socket protocol layer connect operation 813 * Check permission before socket protocol layer connect operation
794 * attempts to connect socket @sock to a remote address, @address. 814 * attempts to connect socket @sock to a remote address, @address.
795 * @sock contains the socket structure. 815 * @sock contains the socket structure.
796 * @address contains the address of remote endpoint. 816 * @address contains the address of remote endpoint.
797 * @addrlen contains the length of address. 817 * @addrlen contains the length of address.
798 * Return 0 if permission is granted. 818 * Return 0 if permission is granted.
799 * @socket_listen: 819 * @socket_listen:
800 * Check permission before socket protocol layer listen operation. 820 * Check permission before socket protocol layer listen operation.
801 * @sock contains the socket structure. 821 * @sock contains the socket structure.
@@ -825,7 +845,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
825 * @msg contains the message structure. 845 * @msg contains the message structure.
826 * @size contains the size of message structure. 846 * @size contains the size of message structure.
827 * @flags contains the operational flags. 847 * @flags contains the operational flags.
828 * Return 0 if permission is granted. 848 * Return 0 if permission is granted.
829 * @socket_getsockname: 849 * @socket_getsockname:
830 * Check permission before the local address (name) of the socket object 850 * Check permission before the local address (name) of the socket object
831 * @sock is retrieved. 851 * @sock is retrieved.
@@ -849,7 +869,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
849 * @sock contains the socket structure. 869 * @sock contains the socket structure.
850 * @level contains the protocol level to set options for. 870 * @level contains the protocol level to set options for.
851 * @optname contains the name of the option to set. 871 * @optname contains the name of the option to set.
852 * Return 0 if permission is granted. 872 * Return 0 if permission is granted.
853 * @socket_shutdown: 873 * @socket_shutdown:
854 * Checks permission before all or part of a connection on the socket 874 * Checks permission before all or part of a connection on the socket
855 * @sock is shut down. 875 * @sock is shut down.
@@ -876,19 +896,19 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
876 * Return 0 if all is well, otherwise, typical getsockopt return 896 * Return 0 if all is well, otherwise, typical getsockopt return
877 * values. 897 * values.
878 * @socket_getpeersec_dgram: 898 * @socket_getpeersec_dgram:
879 * This hook allows the security module to provide peer socket security 899 * This hook allows the security module to provide peer socket security
880 * state for udp sockets on a per-packet basis to userspace via 900 * state for udp sockets on a per-packet basis to userspace via
881 * getsockopt SO_GETPEERSEC. The application must first have indicated 901 * getsockopt SO_GETPEERSEC. The application must first have indicated
882 * the IP_PASSSEC option via getsockopt. It can then retrieve the 902 * the IP_PASSSEC option via getsockopt. It can then retrieve the
883 * security state returned by this hook for a packet via the SCM_SECURITY 903 * security state returned by this hook for a packet via the SCM_SECURITY
884 * ancillary message type. 904 * ancillary message type.
885 * @skb is the skbuff for the packet being queried 905 * @skb is the skbuff for the packet being queried
886 * @secdata is a pointer to a buffer in which to copy the security data 906 * @secdata is a pointer to a buffer in which to copy the security data
887 * @seclen is the maximum length for @secdata 907 * @seclen is the maximum length for @secdata
888 * Return 0 on success, error on failure. 908 * Return 0 on success, error on failure.
889 * @sk_alloc_security: 909 * @sk_alloc_security:
890 * Allocate and attach a security structure to the sk->sk_security field, 910 * Allocate and attach a security structure to the sk->sk_security field,
891 * which is used to copy security attributes between local stream sockets. 911 * which is used to copy security attributes between local stream sockets.
892 * @sk_free_security: 912 * @sk_free_security:
893 * Deallocate security structure. 913 * Deallocate security structure.
894 * @sk_clone_security: 914 * @sk_clone_security:
@@ -903,31 +923,31 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
903 * @inet_csk_clone: 923 * @inet_csk_clone:
904 * Sets the new child socket's sid to the openreq sid. 924 * Sets the new child socket's sid to the openreq sid.
905 * @inet_conn_established: 925 * @inet_conn_established:
906 * Sets the connection's peersid to the secmark on skb. 926 * Sets the connection's peersid to the secmark on skb.
907 * @req_classify_flow: 927 * @req_classify_flow:
908 * Sets the flow's sid to the openreq sid. 928 * Sets the flow's sid to the openreq sid.
909 * 929 *
910 * Security hooks for XFRM operations. 930 * Security hooks for XFRM operations.
911 * 931 *
912 * @xfrm_policy_alloc_security: 932 * @xfrm_policy_alloc_security:
913 * @xp contains the xfrm_policy being added to Security Policy Database 933 * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
914 * used by the XFRM system. 934 * Database used by the XFRM system.
915 * @sec_ctx contains the security context information being provided by 935 * @sec_ctx contains the security context information being provided by
916 * the user-level policy update program (e.g., setkey). 936 * the user-level policy update program (e.g., setkey).
917 * Allocate a security structure to the xp->security field; the security 937 * Allocate a security structure to the xp->security field; the security
918 * field is initialized to NULL when the xfrm_policy is allocated. 938 * field is initialized to NULL when the xfrm_policy is allocated.
919 * Return 0 if operation was successful (memory to allocate, legal context) 939 * Return 0 if operation was successful (memory to allocate, legal context)
920 * @xfrm_policy_clone_security: 940 * @xfrm_policy_clone_security:
921 * @old contains an existing xfrm_policy in the SPD. 941 * @old_ctx contains an existing xfrm_sec_ctx.
922 * @new contains a new xfrm_policy being cloned from old. 942 * @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
923 * Allocate a security structure to the new->security field 943 * Allocate a security structure in new_ctxp that contains the
924 * that contains the information from the old->security field. 944 * information from the old_ctx structure.
925 * Return 0 if operation was successful (memory to allocate). 945 * Return 0 if operation was successful (memory to allocate).
926 * @xfrm_policy_free_security: 946 * @xfrm_policy_free_security:
927 * @xp contains the xfrm_policy 947 * @ctx contains the xfrm_sec_ctx
928 * Deallocate xp->security. 948 * Deallocate xp->security.
929 * @xfrm_policy_delete_security: 949 * @xfrm_policy_delete_security:
930 * @xp contains the xfrm_policy. 950 * @ctx contains the xfrm_sec_ctx.
931 * Authorize deletion of xp->security. 951 * Authorize deletion of xp->security.
932 * @xfrm_state_alloc_security: 952 * @xfrm_state_alloc_security:
933 * @x contains the xfrm_state being added to the Security Association 953 * @x contains the xfrm_state being added to the Security Association
@@ -947,7 +967,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
947 * @x contains the xfrm_state. 967 * @x contains the xfrm_state.
948 * Authorize deletion of x->security. 968 * Authorize deletion of x->security.
949 * @xfrm_policy_lookup: 969 * @xfrm_policy_lookup:
950 * @xp contains the xfrm_policy for which the access control is being 970 * @ctx contains the xfrm_sec_ctx for which the access control is being
951 * checked. 971 * checked.
952 * @fl_secid contains the flow security label that is used to authorize 972 * @fl_secid contains the flow security label that is used to authorize
953 * access to the policy xp. 973 * access to the policy xp.
@@ -982,13 +1002,24 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
982 * No return value. 1002 * No return value.
983 * @key_permission: 1003 * @key_permission:
984 * See whether a specific operational right is granted to a process on a 1004 * See whether a specific operational right is granted to a process on a
985 * key. 1005 * key.
986 * @key_ref refers to the key (key pointer + possession attribute bit). 1006 * @key_ref refers to the key (key pointer + possession attribute bit).
987 * @context points to the process to provide the context against which to 1007 * @context points to the process to provide the context against which to
988 * evaluate the security data on the key. 1008 * evaluate the security data on the key.
989 * @perm describes the combination of permissions required of this key. 1009 * @perm describes the combination of permissions required of this key.
990 * Return 1 if permission granted, 0 if permission denied and -ve it the 1010 * Return 1 if permission granted, 0 if permission denied and -ve it the
991 * normal permissions model should be effected. 1011 * normal permissions model should be effected.
1012 * @key_getsecurity:
1013 * Get a textual representation of the security context attached to a key
1014 * for the purposes of honouring KEYCTL_GETSECURITY. This function
1015 * allocates the storage for the NUL-terminated string and the caller
1016 * should free it.
1017 * @key points to the key to be queried.
1018 * @_buffer points to a pointer that should be set to point to the
1019 * resulting string (if no label or an error occurs).
1020 * Return the length of the string (including terminating NUL) or -ve if
1021 * an error.
1022 * May also return 0 (and a NULL buffer pointer) if there is no label.
992 * 1023 *
993 * Security hooks affecting all System V IPC operations. 1024 * Security hooks affecting all System V IPC operations.
994 * 1025 *
@@ -997,6 +1028,11 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
997 * @ipcp contains the kernel IPC permission structure 1028 * @ipcp contains the kernel IPC permission structure
998 * @flag contains the desired (requested) permission set 1029 * @flag contains the desired (requested) permission set
999 * Return 0 if permission is granted. 1030 * Return 0 if permission is granted.
1031 * @ipc_getsecid:
1032 * Get the secid associated with the ipc object.
1033 * @ipcp contains the kernel IPC permission structure.
1034 * @secid contains a pointer to the location where result will be saved.
1035 * In case of failure, @secid will be set to zero.
1000 * 1036 *
1001 * Security hooks for individual messages held in System V IPC message queues 1037 * Security hooks for individual messages held in System V IPC message queues
1002 * @msg_msg_alloc_security: 1038 * @msg_msg_alloc_security:
@@ -1034,7 +1070,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1034 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO. 1070 * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1035 * @msq contains the message queue to act upon. May be NULL. 1071 * @msq contains the message queue to act upon. May be NULL.
1036 * @cmd contains the operation to be performed. 1072 * @cmd contains the operation to be performed.
1037 * Return 0 if permission is granted. 1073 * Return 0 if permission is granted.
1038 * @msg_queue_msgsnd: 1074 * @msg_queue_msgsnd:
1039 * Check permission before a message, @msg, is enqueued on the message 1075 * Check permission before a message, @msg, is enqueued on the message
1040 * queue, @msq. 1076 * queue, @msq.
@@ -1044,8 +1080,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1044 * Return 0 if permission is granted. 1080 * Return 0 if permission is granted.
1045 * @msg_queue_msgrcv: 1081 * @msg_queue_msgrcv:
1046 * Check permission before a message, @msg, is removed from the message 1082 * Check permission before a message, @msg, is removed from the message
1047 * queue, @msq. The @target task structure contains a pointer to the 1083 * queue, @msq. The @target task structure contains a pointer to the
1048 * process that will be receiving the message (not equal to the current 1084 * process that will be receiving the message (not equal to the current
1049 * process when inline receives are being performed). 1085 * process when inline receives are being performed).
1050 * @msq contains the message queue to retrieve message from. 1086 * @msq contains the message queue to retrieve message from.
1051 * @msg contains the message destination. 1087 * @msg contains the message destination.
@@ -1110,15 +1146,15 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1110 * Return 0 if permission is granted. 1146 * Return 0 if permission is granted.
1111 * @sem_semctl: 1147 * @sem_semctl:
1112 * Check permission when a semaphore operation specified by @cmd is to be 1148 * Check permission when a semaphore operation specified by @cmd is to be
1113 * performed on the semaphore @sma. The @sma may be NULL, e.g. for 1149 * performed on the semaphore @sma. The @sma may be NULL, e.g. for
1114 * IPC_INFO or SEM_INFO. 1150 * IPC_INFO or SEM_INFO.
1115 * @sma contains the semaphore structure. May be NULL. 1151 * @sma contains the semaphore structure. May be NULL.
1116 * @cmd contains the operation to be performed. 1152 * @cmd contains the operation to be performed.
1117 * Return 0 if permission is granted. 1153 * Return 0 if permission is granted.
1118 * @sem_semop 1154 * @sem_semop
1119 * Check permissions before performing operations on members of the 1155 * Check permissions before performing operations on members of the
1120 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set 1156 * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1121 * may be modified. 1157 * may be modified.
1122 * @sma contains the semaphore structure. 1158 * @sma contains the semaphore structure.
1123 * @sops contains the operations to perform. 1159 * @sops contains the operations to perform.
1124 * @nsops contains the number of operations to perform. 1160 * @nsops contains the number of operations to perform.
@@ -1189,7 +1225,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1189 * @syslog: 1225 * @syslog:
1190 * Check permission before accessing the kernel message ring or changing 1226 * Check permission before accessing the kernel message ring or changing
1191 * logging to the console. 1227 * logging to the console.
1192 * See the syslog(2) manual page for an explanation of the @type values. 1228 * See the syslog(2) manual page for an explanation of the @type values.
1193 * @type contains the type of action. 1229 * @type contains the type of action.
1194 * Return 0 if permission is granted. 1230 * Return 0 if permission is granted.
1195 * @settime: 1231 * @settime:
@@ -1201,79 +1237,112 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1201 * @vm_enough_memory: 1237 * @vm_enough_memory:
1202 * Check permissions for allocating a new virtual mapping. 1238 * Check permissions for allocating a new virtual mapping.
1203 * @mm contains the mm struct it is being added to. 1239 * @mm contains the mm struct it is being added to.
1204 * @pages contains the number of pages. 1240 * @pages contains the number of pages.
1205 * Return 0 if permission is granted. 1241 * Return 0 if permission is granted.
1206 * 1242 *
1207 * @register_security: 1243 * @register_security:
1208 * allow module stacking. 1244 * allow module stacking.
1209 * @name contains the name of the security module being stacked. 1245 * @name contains the name of the security module being stacked.
1210 * @ops contains a pointer to the struct security_operations of the module to stack. 1246 * @ops contains a pointer to the struct security_operations of the module to stack.
1211 * 1247 *
1212 * @secid_to_secctx: 1248 * @secid_to_secctx:
1213 * Convert secid to security context. 1249 * Convert secid to security context.
1214 * @secid contains the security ID. 1250 * @secid contains the security ID.
1215 * @secdata contains the pointer that stores the converted security context. 1251 * @secdata contains the pointer that stores the converted security context.
1216 * @secctx_to_secid: 1252 * @secctx_to_secid:
1217 * Convert security context to secid. 1253 * Convert security context to secid.
1218 * @secid contains the pointer to the generated security ID. 1254 * @secid contains the pointer to the generated security ID.
1219 * @secdata contains the security context. 1255 * @secdata contains the security context.
1220 * 1256 *
1221 * @release_secctx: 1257 * @release_secctx:
1222 * Release the security context. 1258 * Release the security context.
1223 * @secdata contains the security context. 1259 * @secdata contains the security context.
1224 * @seclen contains the length of the security context. 1260 * @seclen contains the length of the security context.
1225 * 1261 *
1262 * Security hooks for Audit
1263 *
1264 * @audit_rule_init:
1265 * Allocate and initialize an LSM audit rule structure.
1266 * @field contains the required Audit action. Fields flags are defined in include/linux/audit.h
1267 * @op contains the operator the rule uses.
1268 * @rulestr contains the context where the rule will be applied to.
1269 * @lsmrule contains a pointer to receive the result.
1270 * Return 0 if @lsmrule has been successfully set,
1271 * -EINVAL in case of an invalid rule.
1272 *
1273 * @audit_rule_known:
1274 * Specifies whether given @rule contains any fields related to current LSM.
1275 * @rule contains the audit rule of interest.
1276 * Return 1 in case of relation found, 0 otherwise.
1277 *
1278 * @audit_rule_match:
1279 * Determine if given @secid matches a rule previously approved
1280 * by @audit_rule_known.
1281 * @secid contains the security id in question.
1282 * @field contains the field which relates to current LSM.
1283 * @op contains the operator that will be used for matching.
1284 * @rule points to the audit rule that will be checked against.
1285 * @actx points to the audit context associated with the check.
1286 * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
1287 *
1288 * @audit_rule_free:
1289 * Deallocate the LSM audit rule structure previously allocated by
1290 * audit_rule_init.
1291 * @rule contains the allocated rule
1292 *
1226 * This is the main security structure. 1293 * This is the main security structure.
1227 */ 1294 */
1228struct security_operations { 1295struct security_operations {
1229 int (*ptrace) (struct task_struct * parent, struct task_struct * child); 1296 char name[SECURITY_NAME_MAX + 1];
1230 int (*capget) (struct task_struct * target, 1297
1231 kernel_cap_t * effective, 1298 int (*ptrace) (struct task_struct *parent, struct task_struct *child);
1232 kernel_cap_t * inheritable, kernel_cap_t * permitted); 1299 int (*capget) (struct task_struct *target,
1233 int (*capset_check) (struct task_struct * target, 1300 kernel_cap_t *effective,
1234 kernel_cap_t * effective, 1301 kernel_cap_t *inheritable, kernel_cap_t *permitted);
1235 kernel_cap_t * inheritable, 1302 int (*capset_check) (struct task_struct *target,
1236 kernel_cap_t * permitted); 1303 kernel_cap_t *effective,
1237 void (*capset_set) (struct task_struct * target, 1304 kernel_cap_t *inheritable,
1238 kernel_cap_t * effective, 1305 kernel_cap_t *permitted);
1239 kernel_cap_t * inheritable, 1306 void (*capset_set) (struct task_struct *target,
1240 kernel_cap_t * permitted); 1307 kernel_cap_t *effective,
1241 int (*capable) (struct task_struct * tsk, int cap); 1308 kernel_cap_t *inheritable,
1242 int (*acct) (struct file * file); 1309 kernel_cap_t *permitted);
1243 int (*sysctl) (struct ctl_table * table, int op); 1310 int (*capable) (struct task_struct *tsk, int cap);
1244 int (*quotactl) (int cmds, int type, int id, struct super_block * sb); 1311 int (*acct) (struct file *file);
1245 int (*quota_on) (struct dentry * dentry); 1312 int (*sysctl) (struct ctl_table *table, int op);
1313 int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1314 int (*quota_on) (struct dentry *dentry);
1246 int (*syslog) (int type); 1315 int (*syslog) (int type);
1247 int (*settime) (struct timespec *ts, struct timezone *tz); 1316 int (*settime) (struct timespec *ts, struct timezone *tz);
1248 int (*vm_enough_memory) (struct mm_struct *mm, long pages); 1317 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1249 1318
1250 int (*bprm_alloc_security) (struct linux_binprm * bprm); 1319 int (*bprm_alloc_security) (struct linux_binprm *bprm);
1251 void (*bprm_free_security) (struct linux_binprm * bprm); 1320 void (*bprm_free_security) (struct linux_binprm *bprm);
1252 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe); 1321 void (*bprm_apply_creds) (struct linux_binprm *bprm, int unsafe);
1253 void (*bprm_post_apply_creds) (struct linux_binprm * bprm); 1322 void (*bprm_post_apply_creds) (struct linux_binprm *bprm);
1254 int (*bprm_set_security) (struct linux_binprm * bprm); 1323 int (*bprm_set_security) (struct linux_binprm *bprm);
1255 int (*bprm_check_security) (struct linux_binprm * bprm); 1324 int (*bprm_check_security) (struct linux_binprm *bprm);
1256 int (*bprm_secureexec) (struct linux_binprm * bprm); 1325 int (*bprm_secureexec) (struct linux_binprm *bprm);
1257 1326
1258 int (*sb_alloc_security) (struct super_block * sb); 1327 int (*sb_alloc_security) (struct super_block *sb);
1259 void (*sb_free_security) (struct super_block * sb); 1328 void (*sb_free_security) (struct super_block *sb);
1260 int (*sb_copy_data)(char *orig, char *copy); 1329 int (*sb_copy_data) (char *orig, char *copy);
1261 int (*sb_kern_mount) (struct super_block *sb, void *data); 1330 int (*sb_kern_mount) (struct super_block *sb, void *data);
1262 int (*sb_statfs) (struct dentry *dentry); 1331 int (*sb_statfs) (struct dentry *dentry);
1263 int (*sb_mount) (char *dev_name, struct nameidata * nd, 1332 int (*sb_mount) (char *dev_name, struct path *path,
1264 char *type, unsigned long flags, void *data); 1333 char *type, unsigned long flags, void *data);
1265 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd); 1334 int (*sb_check_sb) (struct vfsmount *mnt, struct path *path);
1266 int (*sb_umount) (struct vfsmount * mnt, int flags); 1335 int (*sb_umount) (struct vfsmount *mnt, int flags);
1267 void (*sb_umount_close) (struct vfsmount * mnt); 1336 void (*sb_umount_close) (struct vfsmount *mnt);
1268 void (*sb_umount_busy) (struct vfsmount * mnt); 1337 void (*sb_umount_busy) (struct vfsmount *mnt);
1269 void (*sb_post_remount) (struct vfsmount * mnt, 1338 void (*sb_post_remount) (struct vfsmount *mnt,
1270 unsigned long flags, void *data); 1339 unsigned long flags, void *data);
1271 void (*sb_post_addmount) (struct vfsmount * mnt, 1340 void (*sb_post_addmount) (struct vfsmount *mnt,
1272 struct nameidata * mountpoint_nd); 1341 struct path *mountpoint);
1273 int (*sb_pivotroot) (struct nameidata * old_nd, 1342 int (*sb_pivotroot) (struct path *old_path,
1274 struct nameidata * new_nd); 1343 struct path *new_path);
1275 void (*sb_post_pivotroot) (struct nameidata * old_nd, 1344 void (*sb_post_pivotroot) (struct path *old_path,
1276 struct nameidata * new_nd); 1345 struct path *new_path);
1277 int (*sb_get_mnt_opts) (const struct super_block *sb, 1346 int (*sb_get_mnt_opts) (const struct super_block *sb,
1278 struct security_mnt_opts *opts); 1347 struct security_mnt_opts *opts);
1279 int (*sb_set_mnt_opts) (struct super_block *sb, 1348 int (*sb_set_mnt_opts) (struct super_block *sb,
@@ -1282,231 +1351,241 @@ struct security_operations {
1282 struct super_block *newsb); 1351 struct super_block *newsb);
1283 int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts); 1352 int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts);
1284 1353
1285 int (*inode_alloc_security) (struct inode *inode); 1354 int (*inode_alloc_security) (struct inode *inode);
1286 void (*inode_free_security) (struct inode *inode); 1355 void (*inode_free_security) (struct inode *inode);
1287 int (*inode_init_security) (struct inode *inode, struct inode *dir, 1356 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1288 char **name, void **value, size_t *len); 1357 char **name, void **value, size_t *len);
1289 int (*inode_create) (struct inode *dir, 1358 int (*inode_create) (struct inode *dir,
1290 struct dentry *dentry, int mode); 1359 struct dentry *dentry, int mode);
1291 int (*inode_link) (struct dentry *old_dentry, 1360 int (*inode_link) (struct dentry *old_dentry,
1292 struct inode *dir, struct dentry *new_dentry); 1361 struct inode *dir, struct dentry *new_dentry);
1293 int (*inode_unlink) (struct inode *dir, struct dentry *dentry); 1362 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1294 int (*inode_symlink) (struct inode *dir, 1363 int (*inode_symlink) (struct inode *dir,
1295 struct dentry *dentry, const char *old_name); 1364 struct dentry *dentry, const char *old_name);
1296 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode); 1365 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1297 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry); 1366 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1298 int (*inode_mknod) (struct inode *dir, struct dentry *dentry, 1367 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1299 int mode, dev_t dev); 1368 int mode, dev_t dev);
1300 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry, 1369 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1301 struct inode *new_dir, struct dentry *new_dentry); 1370 struct inode *new_dir, struct dentry *new_dentry);
1302 int (*inode_readlink) (struct dentry *dentry); 1371 int (*inode_readlink) (struct dentry *dentry);
1303 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); 1372 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1304 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd); 1373 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1305 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr); 1374 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1306 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry); 1375 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1307 void (*inode_delete) (struct inode *inode); 1376 void (*inode_delete) (struct inode *inode);
1308 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value, 1377 int (*inode_setxattr) (struct dentry *dentry, const char *name,
1309 size_t size, int flags); 1378 const void *value, size_t size, int flags);
1310 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value, 1379 void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
1311 size_t size, int flags); 1380 const void *value, size_t size, int flags);
1312 int (*inode_getxattr) (struct dentry *dentry, char *name); 1381 int (*inode_getxattr) (struct dentry *dentry, const char *name);
1313 int (*inode_listxattr) (struct dentry *dentry); 1382 int (*inode_listxattr) (struct dentry *dentry);
1314 int (*inode_removexattr) (struct dentry *dentry, char *name); 1383 int (*inode_removexattr) (struct dentry *dentry, const char *name);
1315 int (*inode_need_killpriv) (struct dentry *dentry); 1384 int (*inode_need_killpriv) (struct dentry *dentry);
1316 int (*inode_killpriv) (struct dentry *dentry); 1385 int (*inode_killpriv) (struct dentry *dentry);
1317 int (*inode_getsecurity)(const struct inode *inode, const char *name, void **buffer, bool alloc); 1386 int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc);
1318 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags); 1387 int (*inode_setsecurity) (struct inode *inode, const char *name, const void *value, size_t size, int flags);
1319 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size); 1388 int (*inode_listsecurity) (struct inode *inode, char *buffer, size_t buffer_size);
1320 1389 void (*inode_getsecid) (const struct inode *inode, u32 *secid);
1321 int (*file_permission) (struct file * file, int mask); 1390
1322 int (*file_alloc_security) (struct file * file); 1391 int (*file_permission) (struct file *file, int mask);
1323 void (*file_free_security) (struct file * file); 1392 int (*file_alloc_security) (struct file *file);
1324 int (*file_ioctl) (struct file * file, unsigned int cmd, 1393 void (*file_free_security) (struct file *file);
1394 int (*file_ioctl) (struct file *file, unsigned int cmd,
1325 unsigned long arg); 1395 unsigned long arg);
1326 int (*file_mmap) (struct file * file, 1396 int (*file_mmap) (struct file *file,
1327 unsigned long reqprot, unsigned long prot, 1397 unsigned long reqprot, unsigned long prot,
1328 unsigned long flags, unsigned long addr, 1398 unsigned long flags, unsigned long addr,
1329 unsigned long addr_only); 1399 unsigned long addr_only);
1330 int (*file_mprotect) (struct vm_area_struct * vma, 1400 int (*file_mprotect) (struct vm_area_struct *vma,
1331 unsigned long reqprot, 1401 unsigned long reqprot,
1332 unsigned long prot); 1402 unsigned long prot);
1333 int (*file_lock) (struct file * file, unsigned int cmd); 1403 int (*file_lock) (struct file *file, unsigned int cmd);
1334 int (*file_fcntl) (struct file * file, unsigned int cmd, 1404 int (*file_fcntl) (struct file *file, unsigned int cmd,
1335 unsigned long arg); 1405 unsigned long arg);
1336 int (*file_set_fowner) (struct file * file); 1406 int (*file_set_fowner) (struct file *file);
1337 int (*file_send_sigiotask) (struct task_struct * tsk, 1407 int (*file_send_sigiotask) (struct task_struct *tsk,
1338 struct fown_struct * fown, int sig); 1408 struct fown_struct *fown, int sig);
1339 int (*file_receive) (struct file * file); 1409 int (*file_receive) (struct file *file);
1340 int (*dentry_open) (struct file *file); 1410 int (*dentry_open) (struct file *file);
1341 1411
1342 int (*task_create) (unsigned long clone_flags); 1412 int (*task_create) (unsigned long clone_flags);
1343 int (*task_alloc_security) (struct task_struct * p); 1413 int (*task_alloc_security) (struct task_struct *p);
1344 void (*task_free_security) (struct task_struct * p); 1414 void (*task_free_security) (struct task_struct *p);
1345 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags); 1415 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1346 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ , 1416 int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
1347 uid_t old_euid, uid_t old_suid, int flags); 1417 uid_t old_euid, uid_t old_suid, int flags);
1348 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags); 1418 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1349 int (*task_setpgid) (struct task_struct * p, pid_t pgid); 1419 int (*task_setpgid) (struct task_struct *p, pid_t pgid);
1350 int (*task_getpgid) (struct task_struct * p); 1420 int (*task_getpgid) (struct task_struct *p);
1351 int (*task_getsid) (struct task_struct * p); 1421 int (*task_getsid) (struct task_struct *p);
1352 void (*task_getsecid) (struct task_struct * p, u32 * secid); 1422 void (*task_getsecid) (struct task_struct *p, u32 *secid);
1353 int (*task_setgroups) (struct group_info *group_info); 1423 int (*task_setgroups) (struct group_info *group_info);
1354 int (*task_setnice) (struct task_struct * p, int nice); 1424 int (*task_setnice) (struct task_struct *p, int nice);
1355 int (*task_setioprio) (struct task_struct * p, int ioprio); 1425 int (*task_setioprio) (struct task_struct *p, int ioprio);
1356 int (*task_getioprio) (struct task_struct * p); 1426 int (*task_getioprio) (struct task_struct *p);
1357 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim); 1427 int (*task_setrlimit) (unsigned int resource, struct rlimit *new_rlim);
1358 int (*task_setscheduler) (struct task_struct * p, int policy, 1428 int (*task_setscheduler) (struct task_struct *p, int policy,
1359 struct sched_param * lp); 1429 struct sched_param *lp);
1360 int (*task_getscheduler) (struct task_struct * p); 1430 int (*task_getscheduler) (struct task_struct *p);
1361 int (*task_movememory) (struct task_struct * p); 1431 int (*task_movememory) (struct task_struct *p);
1362 int (*task_kill) (struct task_struct * p, 1432 int (*task_kill) (struct task_struct *p,
1363 struct siginfo * info, int sig, u32 secid); 1433 struct siginfo *info, int sig, u32 secid);
1364 int (*task_wait) (struct task_struct * p); 1434 int (*task_wait) (struct task_struct *p);
1365 int (*task_prctl) (int option, unsigned long arg2, 1435 int (*task_prctl) (int option, unsigned long arg2,
1366 unsigned long arg3, unsigned long arg4, 1436 unsigned long arg3, unsigned long arg4,
1367 unsigned long arg5); 1437 unsigned long arg5, long *rc_p);
1368 void (*task_reparent_to_init) (struct task_struct * p); 1438 void (*task_reparent_to_init) (struct task_struct *p);
1369 void (*task_to_inode)(struct task_struct *p, struct inode *inode); 1439 void (*task_to_inode) (struct task_struct *p, struct inode *inode);
1370 1440
1371 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag); 1441 int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag);
1372 1442 void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
1373 int (*msg_msg_alloc_security) (struct msg_msg * msg); 1443
1374 void (*msg_msg_free_security) (struct msg_msg * msg); 1444 int (*msg_msg_alloc_security) (struct msg_msg *msg);
1375 1445 void (*msg_msg_free_security) (struct msg_msg *msg);
1376 int (*msg_queue_alloc_security) (struct msg_queue * msq); 1446
1377 void (*msg_queue_free_security) (struct msg_queue * msq); 1447 int (*msg_queue_alloc_security) (struct msg_queue *msq);
1378 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg); 1448 void (*msg_queue_free_security) (struct msg_queue *msq);
1379 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd); 1449 int (*msg_queue_associate) (struct msg_queue *msq, int msqflg);
1380 int (*msg_queue_msgsnd) (struct msg_queue * msq, 1450 int (*msg_queue_msgctl) (struct msg_queue *msq, int cmd);
1381 struct msg_msg * msg, int msqflg); 1451 int (*msg_queue_msgsnd) (struct msg_queue *msq,
1382 int (*msg_queue_msgrcv) (struct msg_queue * msq, 1452 struct msg_msg *msg, int msqflg);
1383 struct msg_msg * msg, 1453 int (*msg_queue_msgrcv) (struct msg_queue *msq,
1384 struct task_struct * target, 1454 struct msg_msg *msg,
1455 struct task_struct *target,
1385 long type, int mode); 1456 long type, int mode);
1386 1457
1387 int (*shm_alloc_security) (struct shmid_kernel * shp); 1458 int (*shm_alloc_security) (struct shmid_kernel *shp);
1388 void (*shm_free_security) (struct shmid_kernel * shp); 1459 void (*shm_free_security) (struct shmid_kernel *shp);
1389 int (*shm_associate) (struct shmid_kernel * shp, int shmflg); 1460 int (*shm_associate) (struct shmid_kernel *shp, int shmflg);
1390 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd); 1461 int (*shm_shmctl) (struct shmid_kernel *shp, int cmd);
1391 int (*shm_shmat) (struct shmid_kernel * shp, 1462 int (*shm_shmat) (struct shmid_kernel *shp,
1392 char __user *shmaddr, int shmflg); 1463 char __user *shmaddr, int shmflg);
1393 1464
1394 int (*sem_alloc_security) (struct sem_array * sma); 1465 int (*sem_alloc_security) (struct sem_array *sma);
1395 void (*sem_free_security) (struct sem_array * sma); 1466 void (*sem_free_security) (struct sem_array *sma);
1396 int (*sem_associate) (struct sem_array * sma, int semflg); 1467 int (*sem_associate) (struct sem_array *sma, int semflg);
1397 int (*sem_semctl) (struct sem_array * sma, int cmd); 1468 int (*sem_semctl) (struct sem_array *sma, int cmd);
1398 int (*sem_semop) (struct sem_array * sma, 1469 int (*sem_semop) (struct sem_array *sma,
1399 struct sembuf * sops, unsigned nsops, int alter); 1470 struct sembuf *sops, unsigned nsops, int alter);
1400 1471
1401 int (*netlink_send) (struct sock * sk, struct sk_buff * skb); 1472 int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
1402 int (*netlink_recv) (struct sk_buff * skb, int cap); 1473 int (*netlink_recv) (struct sk_buff *skb, int cap);
1403 1474
1404 /* allow module stacking */ 1475 /* allow module stacking */
1405 int (*register_security) (const char *name, 1476 int (*register_security) (const char *name,
1406 struct security_operations *ops); 1477 struct security_operations *ops);
1407 1478
1408 void (*d_instantiate) (struct dentry *dentry, struct inode *inode); 1479 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1409 1480
1410 int (*getprocattr)(struct task_struct *p, char *name, char **value); 1481 int (*getprocattr) (struct task_struct *p, char *name, char **value);
1411 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size); 1482 int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size);
1412 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen); 1483 int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen);
1413 int (*secctx_to_secid)(char *secdata, u32 seclen, u32 *secid); 1484 int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid);
1414 void (*release_secctx)(char *secdata, u32 seclen); 1485 void (*release_secctx) (char *secdata, u32 seclen);
1415 1486
1416#ifdef CONFIG_SECURITY_NETWORK 1487#ifdef CONFIG_SECURITY_NETWORK
1417 int (*unix_stream_connect) (struct socket * sock, 1488 int (*unix_stream_connect) (struct socket *sock,
1418 struct socket * other, struct sock * newsk); 1489 struct socket *other, struct sock *newsk);
1419 int (*unix_may_send) (struct socket * sock, struct socket * other); 1490 int (*unix_may_send) (struct socket *sock, struct socket *other);
1420 1491
1421 int (*socket_create) (int family, int type, int protocol, int kern); 1492 int (*socket_create) (int family, int type, int protocol, int kern);
1422 int (*socket_post_create) (struct socket * sock, int family, 1493 int (*socket_post_create) (struct socket *sock, int family,
1423 int type, int protocol, int kern); 1494 int type, int protocol, int kern);
1424 int (*socket_bind) (struct socket * sock, 1495 int (*socket_bind) (struct socket *sock,
1425 struct sockaddr * address, int addrlen); 1496 struct sockaddr *address, int addrlen);
1426 int (*socket_connect) (struct socket * sock, 1497 int (*socket_connect) (struct socket *sock,
1427 struct sockaddr * address, int addrlen); 1498 struct sockaddr *address, int addrlen);
1428 int (*socket_listen) (struct socket * sock, int backlog); 1499 int (*socket_listen) (struct socket *sock, int backlog);
1429 int (*socket_accept) (struct socket * sock, struct socket * newsock); 1500 int (*socket_accept) (struct socket *sock, struct socket *newsock);
1430 void (*socket_post_accept) (struct socket * sock, 1501 void (*socket_post_accept) (struct socket *sock,
1431 struct socket * newsock); 1502 struct socket *newsock);
1432 int (*socket_sendmsg) (struct socket * sock, 1503 int (*socket_sendmsg) (struct socket *sock,
1433 struct msghdr * msg, int size); 1504 struct msghdr *msg, int size);
1434 int (*socket_recvmsg) (struct socket * sock, 1505 int (*socket_recvmsg) (struct socket *sock,
1435 struct msghdr * msg, int size, int flags); 1506 struct msghdr *msg, int size, int flags);
1436 int (*socket_getsockname) (struct socket * sock); 1507 int (*socket_getsockname) (struct socket *sock);
1437 int (*socket_getpeername) (struct socket * sock); 1508 int (*socket_getpeername) (struct socket *sock);
1438 int (*socket_getsockopt) (struct socket * sock, int level, int optname); 1509 int (*socket_getsockopt) (struct socket *sock, int level, int optname);
1439 int (*socket_setsockopt) (struct socket * sock, int level, int optname); 1510 int (*socket_setsockopt) (struct socket *sock, int level, int optname);
1440 int (*socket_shutdown) (struct socket * sock, int how); 1511 int (*socket_shutdown) (struct socket *sock, int how);
1441 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb); 1512 int (*socket_sock_rcv_skb) (struct sock *sk, struct sk_buff *skb);
1442 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len); 1513 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1443 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid); 1514 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1444 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority); 1515 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1445 void (*sk_free_security) (struct sock *sk); 1516 void (*sk_free_security) (struct sock *sk);
1446 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk); 1517 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1447 void (*sk_getsecid) (struct sock *sk, u32 *secid); 1518 void (*sk_getsecid) (struct sock *sk, u32 *secid);
1448 void (*sock_graft)(struct sock* sk, struct socket *parent); 1519 void (*sock_graft) (struct sock *sk, struct socket *parent);
1449 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb, 1520 int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
1450 struct request_sock *req); 1521 struct request_sock *req);
1451 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req); 1522 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1452 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb); 1523 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1453 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl); 1524 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
1454#endif /* CONFIG_SECURITY_NETWORK */ 1525#endif /* CONFIG_SECURITY_NETWORK */
1455 1526
1456#ifdef CONFIG_SECURITY_NETWORK_XFRM 1527#ifdef CONFIG_SECURITY_NETWORK_XFRM
1457 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, 1528 int (*xfrm_policy_alloc_security) (struct xfrm_sec_ctx **ctxp,
1458 struct xfrm_user_sec_ctx *sec_ctx); 1529 struct xfrm_user_sec_ctx *sec_ctx);
1459 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new); 1530 int (*xfrm_policy_clone_security) (struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctx);
1460 void (*xfrm_policy_free_security) (struct xfrm_policy *xp); 1531 void (*xfrm_policy_free_security) (struct xfrm_sec_ctx *ctx);
1461 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp); 1532 int (*xfrm_policy_delete_security) (struct xfrm_sec_ctx *ctx);
1462 int (*xfrm_state_alloc_security) (struct xfrm_state *x, 1533 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1463 struct xfrm_user_sec_ctx *sec_ctx, 1534 struct xfrm_user_sec_ctx *sec_ctx,
1464 u32 secid); 1535 u32 secid);
1465 void (*xfrm_state_free_security) (struct xfrm_state *x); 1536 void (*xfrm_state_free_security) (struct xfrm_state *x);
1466 int (*xfrm_state_delete_security) (struct xfrm_state *x); 1537 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1467 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir); 1538 int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
1468 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x, 1539 int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
1469 struct xfrm_policy *xp, struct flowi *fl); 1540 struct xfrm_policy *xp,
1470 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall); 1541 struct flowi *fl);
1542 int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
1471#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1543#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1472 1544
1473 /* key management security hooks */ 1545 /* key management security hooks */
1474#ifdef CONFIG_KEYS 1546#ifdef CONFIG_KEYS
1475 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags); 1547 int (*key_alloc) (struct key *key, struct task_struct *tsk, unsigned long flags);
1476 void (*key_free)(struct key *key); 1548 void (*key_free) (struct key *key);
1477 int (*key_permission)(key_ref_t key_ref, 1549 int (*key_permission) (key_ref_t key_ref,
1478 struct task_struct *context, 1550 struct task_struct *context,
1479 key_perm_t perm); 1551 key_perm_t perm);
1480 1552 int (*key_getsecurity)(struct key *key, char **_buffer);
1481#endif /* CONFIG_KEYS */ 1553#endif /* CONFIG_KEYS */
1482 1554
1555#ifdef CONFIG_AUDIT
1556 int (*audit_rule_init) (u32 field, u32 op, char *rulestr, void **lsmrule);
1557 int (*audit_rule_known) (struct audit_krule *krule);
1558 int (*audit_rule_match) (u32 secid, u32 field, u32 op, void *lsmrule,
1559 struct audit_context *actx);
1560 void (*audit_rule_free) (void *lsmrule);
1561#endif /* CONFIG_AUDIT */
1483}; 1562};
1484 1563
1485/* prototypes */ 1564/* prototypes */
1486extern int security_init (void); 1565extern int security_init(void);
1487extern int register_security (struct security_operations *ops); 1566extern int security_module_enable(struct security_operations *ops);
1488extern int mod_reg_security (const char *name, struct security_operations *ops); 1567extern int register_security(struct security_operations *ops);
1568extern int mod_reg_security(const char *name, struct security_operations *ops);
1489extern struct dentry *securityfs_create_file(const char *name, mode_t mode, 1569extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1490 struct dentry *parent, void *data, 1570 struct dentry *parent, void *data,
1491 const struct file_operations *fops); 1571 const struct file_operations *fops);
1492extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent); 1572extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1493extern void securityfs_remove(struct dentry *dentry); 1573extern void securityfs_remove(struct dentry *dentry);
1494 1574
1495
1496/* Security operations */ 1575/* Security operations */
1497int security_ptrace(struct task_struct *parent, struct task_struct *child); 1576int security_ptrace(struct task_struct *parent, struct task_struct *child);
1498int security_capget(struct task_struct *target, 1577int security_capget(struct task_struct *target,
1499 kernel_cap_t *effective, 1578 kernel_cap_t *effective,
1500 kernel_cap_t *inheritable, 1579 kernel_cap_t *inheritable,
1501 kernel_cap_t *permitted); 1580 kernel_cap_t *permitted);
1502int security_capset_check(struct task_struct *target, 1581int security_capset_check(struct task_struct *target,
1503 kernel_cap_t *effective,
1504 kernel_cap_t *inheritable,
1505 kernel_cap_t *permitted);
1506void security_capset_set(struct task_struct *target,
1507 kernel_cap_t *effective, 1582 kernel_cap_t *effective,
1508 kernel_cap_t *inheritable, 1583 kernel_cap_t *inheritable,
1509 kernel_cap_t *permitted); 1584 kernel_cap_t *permitted);
1585void security_capset_set(struct task_struct *target,
1586 kernel_cap_t *effective,
1587 kernel_cap_t *inheritable,
1588 kernel_cap_t *permitted);
1510int security_capable(struct task_struct *tsk, int cap); 1589int security_capable(struct task_struct *tsk, int cap);
1511int security_acct(struct file *file); 1590int security_acct(struct file *file);
1512int security_sysctl(struct ctl_table *table, int op); 1591int security_sysctl(struct ctl_table *table, int op);
@@ -1528,16 +1607,16 @@ void security_sb_free(struct super_block *sb);
1528int security_sb_copy_data(char *orig, char *copy); 1607int security_sb_copy_data(char *orig, char *copy);
1529int security_sb_kern_mount(struct super_block *sb, void *data); 1608int security_sb_kern_mount(struct super_block *sb, void *data);
1530int security_sb_statfs(struct dentry *dentry); 1609int security_sb_statfs(struct dentry *dentry);
1531int security_sb_mount(char *dev_name, struct nameidata *nd, 1610int security_sb_mount(char *dev_name, struct path *path,
1532 char *type, unsigned long flags, void *data); 1611 char *type, unsigned long flags, void *data);
1533int security_sb_check_sb(struct vfsmount *mnt, struct nameidata *nd); 1612int security_sb_check_sb(struct vfsmount *mnt, struct path *path);
1534int security_sb_umount(struct vfsmount *mnt, int flags); 1613int security_sb_umount(struct vfsmount *mnt, int flags);
1535void security_sb_umount_close(struct vfsmount *mnt); 1614void security_sb_umount_close(struct vfsmount *mnt);
1536void security_sb_umount_busy(struct vfsmount *mnt); 1615void security_sb_umount_busy(struct vfsmount *mnt);
1537void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data); 1616void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
1538void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd); 1617void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint);
1539int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd); 1618int security_sb_pivotroot(struct path *old_path, struct path *new_path);
1540void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd); 1619void security_sb_post_pivotroot(struct path *old_path, struct path *new_path);
1541int security_sb_get_mnt_opts(const struct super_block *sb, 1620int security_sb_get_mnt_opts(const struct super_block *sb,
1542 struct security_mnt_opts *opts); 1621 struct security_mnt_opts *opts);
1543int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts); 1622int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts);
@@ -1554,30 +1633,31 @@ int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1554 struct dentry *new_dentry); 1633 struct dentry *new_dentry);
1555int security_inode_unlink(struct inode *dir, struct dentry *dentry); 1634int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1556int security_inode_symlink(struct inode *dir, struct dentry *dentry, 1635int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1557 const char *old_name); 1636 const char *old_name);
1558int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode); 1637int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1559int security_inode_rmdir(struct inode *dir, struct dentry *dentry); 1638int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1560int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev); 1639int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1561int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry, 1640int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1562 struct inode *new_dir, struct dentry *new_dentry); 1641 struct inode *new_dir, struct dentry *new_dentry);
1563int security_inode_readlink(struct dentry *dentry); 1642int security_inode_readlink(struct dentry *dentry);
1564int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd); 1643int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1565int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd); 1644int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
1566int security_inode_setattr(struct dentry *dentry, struct iattr *attr); 1645int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1567int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry); 1646int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1568void security_inode_delete(struct inode *inode); 1647void security_inode_delete(struct inode *inode);
1569int security_inode_setxattr(struct dentry *dentry, char *name, 1648int security_inode_setxattr(struct dentry *dentry, const char *name,
1570 void *value, size_t size, int flags); 1649 const void *value, size_t size, int flags);
1571void security_inode_post_setxattr(struct dentry *dentry, char *name, 1650void security_inode_post_setxattr(struct dentry *dentry, const char *name,
1572 void *value, size_t size, int flags); 1651 const void *value, size_t size, int flags);
1573int security_inode_getxattr(struct dentry *dentry, char *name); 1652int security_inode_getxattr(struct dentry *dentry, const char *name);
1574int security_inode_listxattr(struct dentry *dentry); 1653int security_inode_listxattr(struct dentry *dentry);
1575int security_inode_removexattr(struct dentry *dentry, char *name); 1654int security_inode_removexattr(struct dentry *dentry, const char *name);
1576int security_inode_need_killpriv(struct dentry *dentry); 1655int security_inode_need_killpriv(struct dentry *dentry);
1577int security_inode_killpriv(struct dentry *dentry); 1656int security_inode_killpriv(struct dentry *dentry);
1578int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc); 1657int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
1579int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags); 1658int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1580int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size); 1659int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1660void security_inode_getsecid(const struct inode *inode, u32 *secid);
1581int security_file_permission(struct file *file, int mask); 1661int security_file_permission(struct file *file, int mask);
1582int security_file_alloc(struct file *file); 1662int security_file_alloc(struct file *file);
1583void security_file_free(struct file *file); 1663void security_file_free(struct file *file);
@@ -1586,12 +1666,12 @@ int security_file_mmap(struct file *file, unsigned long reqprot,
1586 unsigned long prot, unsigned long flags, 1666 unsigned long prot, unsigned long flags,
1587 unsigned long addr, unsigned long addr_only); 1667 unsigned long addr, unsigned long addr_only);
1588int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, 1668int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1589 unsigned long prot); 1669 unsigned long prot);
1590int security_file_lock(struct file *file, unsigned int cmd); 1670int security_file_lock(struct file *file, unsigned int cmd);
1591int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg); 1671int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1592int security_file_set_fowner(struct file *file); 1672int security_file_set_fowner(struct file *file);
1593int security_file_send_sigiotask(struct task_struct *tsk, 1673int security_file_send_sigiotask(struct task_struct *tsk,
1594 struct fown_struct *fown, int sig); 1674 struct fown_struct *fown, int sig);
1595int security_file_receive(struct file *file); 1675int security_file_receive(struct file *file);
1596int security_dentry_open(struct file *file); 1676int security_dentry_open(struct file *file);
1597int security_task_create(unsigned long clone_flags); 1677int security_task_create(unsigned long clone_flags);
@@ -1599,7 +1679,7 @@ int security_task_alloc(struct task_struct *p);
1599void security_task_free(struct task_struct *p); 1679void security_task_free(struct task_struct *p);
1600int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags); 1680int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
1601int security_task_post_setuid(uid_t old_ruid, uid_t old_euid, 1681int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
1602 uid_t old_suid, int flags); 1682 uid_t old_suid, int flags);
1603int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags); 1683int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1604int security_task_setpgid(struct task_struct *p, pid_t pgid); 1684int security_task_setpgid(struct task_struct *p, pid_t pgid);
1605int security_task_getpgid(struct task_struct *p); 1685int security_task_getpgid(struct task_struct *p);
@@ -1618,10 +1698,11 @@ int security_task_kill(struct task_struct *p, struct siginfo *info,
1618 int sig, u32 secid); 1698 int sig, u32 secid);
1619int security_task_wait(struct task_struct *p); 1699int security_task_wait(struct task_struct *p);
1620int security_task_prctl(int option, unsigned long arg2, unsigned long arg3, 1700int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1621 unsigned long arg4, unsigned long arg5); 1701 unsigned long arg4, unsigned long arg5, long *rc_p);
1622void security_task_reparent_to_init(struct task_struct *p); 1702void security_task_reparent_to_init(struct task_struct *p);
1623void security_task_to_inode(struct task_struct *p, struct inode *inode); 1703void security_task_to_inode(struct task_struct *p, struct inode *inode);
1624int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag); 1704int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1705void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
1625int security_msg_msg_alloc(struct msg_msg *msg); 1706int security_msg_msg_alloc(struct msg_msg *msg);
1626void security_msg_msg_free(struct msg_msg *msg); 1707void security_msg_msg_free(struct msg_msg *msg);
1627int security_msg_queue_alloc(struct msg_queue *msq); 1708int security_msg_queue_alloc(struct msg_queue *msq);
@@ -1629,9 +1710,9 @@ void security_msg_queue_free(struct msg_queue *msq);
1629int security_msg_queue_associate(struct msg_queue *msq, int msqflg); 1710int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1630int security_msg_queue_msgctl(struct msg_queue *msq, int cmd); 1711int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1631int security_msg_queue_msgsnd(struct msg_queue *msq, 1712int security_msg_queue_msgsnd(struct msg_queue *msq,
1632 struct msg_msg *msg, int msqflg); 1713 struct msg_msg *msg, int msqflg);
1633int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg, 1714int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1634 struct task_struct *target, long type, int mode); 1715 struct task_struct *target, long type, int mode);
1635int security_shm_alloc(struct shmid_kernel *shp); 1716int security_shm_alloc(struct shmid_kernel *shp);
1636void security_shm_free(struct shmid_kernel *shp); 1717void security_shm_free(struct shmid_kernel *shp);
1637int security_shm_associate(struct shmid_kernel *shp, int shmflg); 1718int security_shm_associate(struct shmid_kernel *shp, int shmflg);
@@ -1643,13 +1724,13 @@ int security_sem_associate(struct sem_array *sma, int semflg);
1643int security_sem_semctl(struct sem_array *sma, int cmd); 1724int security_sem_semctl(struct sem_array *sma, int cmd);
1644int security_sem_semop(struct sem_array *sma, struct sembuf *sops, 1725int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1645 unsigned nsops, int alter); 1726 unsigned nsops, int alter);
1646void security_d_instantiate (struct dentry *dentry, struct inode *inode); 1727void security_d_instantiate(struct dentry *dentry, struct inode *inode);
1647int security_getprocattr(struct task_struct *p, char *name, char **value); 1728int security_getprocattr(struct task_struct *p, char *name, char **value);
1648int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size); 1729int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1649int security_netlink_send(struct sock *sk, struct sk_buff *skb); 1730int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1650int security_netlink_recv(struct sk_buff *skb, int cap); 1731int security_netlink_recv(struct sk_buff *skb, int cap);
1651int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen); 1732int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
1652int security_secctx_to_secid(char *secdata, u32 seclen, u32 *secid); 1733int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
1653void security_release_secctx(char *secdata, u32 seclen); 1734void security_release_secctx(char *secdata, u32 seclen);
1654 1735
1655#else /* CONFIG_SECURITY */ 1736#else /* CONFIG_SECURITY */
@@ -1674,33 +1755,33 @@ static inline int security_init(void)
1674 return 0; 1755 return 0;
1675} 1756}
1676 1757
1677static inline int security_ptrace (struct task_struct *parent, struct task_struct * child) 1758static inline int security_ptrace(struct task_struct *parent, struct task_struct *child)
1678{ 1759{
1679 return cap_ptrace (parent, child); 1760 return cap_ptrace(parent, child);
1680} 1761}
1681 1762
1682static inline int security_capget (struct task_struct *target, 1763static inline int security_capget(struct task_struct *target,
1683 kernel_cap_t *effective, 1764 kernel_cap_t *effective,
1684 kernel_cap_t *inheritable, 1765 kernel_cap_t *inheritable,
1685 kernel_cap_t *permitted) 1766 kernel_cap_t *permitted)
1686{ 1767{
1687 return cap_capget (target, effective, inheritable, permitted); 1768 return cap_capget(target, effective, inheritable, permitted);
1688} 1769}
1689 1770
1690static inline int security_capset_check (struct task_struct *target, 1771static inline int security_capset_check(struct task_struct *target,
1691 kernel_cap_t *effective, 1772 kernel_cap_t *effective,
1692 kernel_cap_t *inheritable, 1773 kernel_cap_t *inheritable,
1693 kernel_cap_t *permitted) 1774 kernel_cap_t *permitted)
1694{ 1775{
1695 return cap_capset_check (target, effective, inheritable, permitted); 1776 return cap_capset_check(target, effective, inheritable, permitted);
1696} 1777}
1697 1778
1698static inline void security_capset_set (struct task_struct *target, 1779static inline void security_capset_set(struct task_struct *target,
1699 kernel_cap_t *effective, 1780 kernel_cap_t *effective,
1700 kernel_cap_t *inheritable, 1781 kernel_cap_t *inheritable,
1701 kernel_cap_t *permitted) 1782 kernel_cap_t *permitted)
1702{ 1783{
1703 cap_capset_set (target, effective, inheritable, permitted); 1784 cap_capset_set(target, effective, inheritable, permitted);
1704} 1785}
1705 1786
1706static inline int security_capable(struct task_struct *tsk, int cap) 1787static inline int security_capable(struct task_struct *tsk, int cap)
@@ -1708,7 +1789,7 @@ static inline int security_capable(struct task_struct *tsk, int cap)
1708 return cap_capable(tsk, cap); 1789 return cap_capable(tsk, cap);
1709} 1790}
1710 1791
1711static inline int security_acct (struct file *file) 1792static inline int security_acct(struct file *file)
1712{ 1793{
1713 return 0; 1794 return 0;
1714} 1795}
@@ -1718,13 +1799,13 @@ static inline int security_sysctl(struct ctl_table *table, int op)
1718 return 0; 1799 return 0;
1719} 1800}
1720 1801
1721static inline int security_quotactl (int cmds, int type, int id, 1802static inline int security_quotactl(int cmds, int type, int id,
1722 struct super_block * sb) 1803 struct super_block *sb)
1723{ 1804{
1724 return 0; 1805 return 0;
1725} 1806}
1726 1807
1727static inline int security_quota_on (struct dentry * dentry) 1808static inline int security_quota_on(struct dentry *dentry)
1728{ 1809{
1729 return 0; 1810 return 0;
1730} 1811}
@@ -1749,102 +1830,102 @@ static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1749 return cap_vm_enough_memory(mm, pages); 1830 return cap_vm_enough_memory(mm, pages);
1750} 1831}
1751 1832
1752static inline int security_bprm_alloc (struct linux_binprm *bprm) 1833static inline int security_bprm_alloc(struct linux_binprm *bprm)
1753{ 1834{
1754 return 0; 1835 return 0;
1755} 1836}
1756 1837
1757static inline void security_bprm_free (struct linux_binprm *bprm) 1838static inline void security_bprm_free(struct linux_binprm *bprm)
1758{ } 1839{ }
1759 1840
1760static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe) 1841static inline void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe)
1761{ 1842{
1762 cap_bprm_apply_creds (bprm, unsafe); 1843 cap_bprm_apply_creds(bprm, unsafe);
1763} 1844}
1764 1845
1765static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm) 1846static inline void security_bprm_post_apply_creds(struct linux_binprm *bprm)
1766{ 1847{
1767 return; 1848 return;
1768} 1849}
1769 1850
1770static inline int security_bprm_set (struct linux_binprm *bprm) 1851static inline int security_bprm_set(struct linux_binprm *bprm)
1771{ 1852{
1772 return cap_bprm_set_security (bprm); 1853 return cap_bprm_set_security(bprm);
1773} 1854}
1774 1855
1775static inline int security_bprm_check (struct linux_binprm *bprm) 1856static inline int security_bprm_check(struct linux_binprm *bprm)
1776{ 1857{
1777 return 0; 1858 return 0;
1778} 1859}
1779 1860
1780static inline int security_bprm_secureexec (struct linux_binprm *bprm) 1861static inline int security_bprm_secureexec(struct linux_binprm *bprm)
1781{ 1862{
1782 return cap_bprm_secureexec(bprm); 1863 return cap_bprm_secureexec(bprm);
1783} 1864}
1784 1865
1785static inline int security_sb_alloc (struct super_block *sb) 1866static inline int security_sb_alloc(struct super_block *sb)
1786{ 1867{
1787 return 0; 1868 return 0;
1788} 1869}
1789 1870
1790static inline void security_sb_free (struct super_block *sb) 1871static inline void security_sb_free(struct super_block *sb)
1791{ } 1872{ }
1792 1873
1793static inline int security_sb_copy_data (char *orig, char *copy) 1874static inline int security_sb_copy_data(char *orig, char *copy)
1794{ 1875{
1795 return 0; 1876 return 0;
1796} 1877}
1797 1878
1798static inline int security_sb_kern_mount (struct super_block *sb, void *data) 1879static inline int security_sb_kern_mount(struct super_block *sb, void *data)
1799{ 1880{
1800 return 0; 1881 return 0;
1801} 1882}
1802 1883
1803static inline int security_sb_statfs (struct dentry *dentry) 1884static inline int security_sb_statfs(struct dentry *dentry)
1804{ 1885{
1805 return 0; 1886 return 0;
1806} 1887}
1807 1888
1808static inline int security_sb_mount (char *dev_name, struct nameidata *nd, 1889static inline int security_sb_mount(char *dev_name, struct path *path,
1809 char *type, unsigned long flags, 1890 char *type, unsigned long flags,
1810 void *data) 1891 void *data)
1811{ 1892{
1812 return 0; 1893 return 0;
1813} 1894}
1814 1895
1815static inline int security_sb_check_sb (struct vfsmount *mnt, 1896static inline int security_sb_check_sb(struct vfsmount *mnt,
1816 struct nameidata *nd) 1897 struct path *path)
1817{ 1898{
1818 return 0; 1899 return 0;
1819} 1900}
1820 1901
1821static inline int security_sb_umount (struct vfsmount *mnt, int flags) 1902static inline int security_sb_umount(struct vfsmount *mnt, int flags)
1822{ 1903{
1823 return 0; 1904 return 0;
1824} 1905}
1825 1906
1826static inline void security_sb_umount_close (struct vfsmount *mnt) 1907static inline void security_sb_umount_close(struct vfsmount *mnt)
1827{ } 1908{ }
1828 1909
1829static inline void security_sb_umount_busy (struct vfsmount *mnt) 1910static inline void security_sb_umount_busy(struct vfsmount *mnt)
1830{ } 1911{ }
1831 1912
1832static inline void security_sb_post_remount (struct vfsmount *mnt, 1913static inline void security_sb_post_remount(struct vfsmount *mnt,
1833 unsigned long flags, void *data) 1914 unsigned long flags, void *data)
1834{ } 1915{ }
1835 1916
1836static inline void security_sb_post_addmount (struct vfsmount *mnt, 1917static inline void security_sb_post_addmount(struct vfsmount *mnt,
1837 struct nameidata *mountpoint_nd) 1918 struct path *mountpoint)
1838{ } 1919{ }
1839 1920
1840static inline int security_sb_pivotroot (struct nameidata *old_nd, 1921static inline int security_sb_pivotroot(struct path *old_path,
1841 struct nameidata *new_nd) 1922 struct path *new_path)
1842{ 1923{
1843 return 0; 1924 return 0;
1844} 1925}
1845 1926
1846static inline void security_sb_post_pivotroot (struct nameidata *old_nd, 1927static inline void security_sb_post_pivotroot(struct path *old_path,
1847 struct nameidata *new_nd) 1928 struct path *new_path)
1848{ } 1929{ }
1849static inline int security_sb_get_mnt_opts(const struct super_block *sb, 1930static inline int security_sb_get_mnt_opts(const struct super_block *sb,
1850 struct security_mnt_opts *opts) 1931 struct security_mnt_opts *opts)
@@ -1868,15 +1949,15 @@ static inline int security_sb_parse_opts_str(char *options, struct security_mnt_
1868 return 0; 1949 return 0;
1869} 1950}
1870 1951
1871static inline int security_inode_alloc (struct inode *inode) 1952static inline int security_inode_alloc(struct inode *inode)
1872{ 1953{
1873 return 0; 1954 return 0;
1874} 1955}
1875 1956
1876static inline void security_inode_free (struct inode *inode) 1957static inline void security_inode_free(struct inode *inode)
1877{ } 1958{ }
1878 1959
1879static inline int security_inode_init_security (struct inode *inode, 1960static inline int security_inode_init_security(struct inode *inode,
1880 struct inode *dir, 1961 struct inode *dir,
1881 char **name, 1962 char **name,
1882 void **value, 1963 void **value,
@@ -1884,55 +1965,55 @@ static inline int security_inode_init_security (struct inode *inode,
1884{ 1965{
1885 return -EOPNOTSUPP; 1966 return -EOPNOTSUPP;
1886} 1967}
1887 1968
1888static inline int security_inode_create (struct inode *dir, 1969static inline int security_inode_create(struct inode *dir,
1889 struct dentry *dentry, 1970 struct dentry *dentry,
1890 int mode) 1971 int mode)
1891{ 1972{
1892 return 0; 1973 return 0;
1893} 1974}
1894 1975
1895static inline int security_inode_link (struct dentry *old_dentry, 1976static inline int security_inode_link(struct dentry *old_dentry,
1896 struct inode *dir, 1977 struct inode *dir,
1897 struct dentry *new_dentry) 1978 struct dentry *new_dentry)
1898{ 1979{
1899 return 0; 1980 return 0;
1900} 1981}
1901 1982
1902static inline int security_inode_unlink (struct inode *dir, 1983static inline int security_inode_unlink(struct inode *dir,
1903 struct dentry *dentry) 1984 struct dentry *dentry)
1904{ 1985{
1905 return 0; 1986 return 0;
1906} 1987}
1907 1988
1908static inline int security_inode_symlink (struct inode *dir, 1989static inline int security_inode_symlink(struct inode *dir,
1909 struct dentry *dentry, 1990 struct dentry *dentry,
1910 const char *old_name) 1991 const char *old_name)
1911{ 1992{
1912 return 0; 1993 return 0;
1913} 1994}
1914 1995
1915static inline int security_inode_mkdir (struct inode *dir, 1996static inline int security_inode_mkdir(struct inode *dir,
1916 struct dentry *dentry, 1997 struct dentry *dentry,
1917 int mode) 1998 int mode)
1918{ 1999{
1919 return 0; 2000 return 0;
1920} 2001}
1921 2002
1922static inline int security_inode_rmdir (struct inode *dir, 2003static inline int security_inode_rmdir(struct inode *dir,
1923 struct dentry *dentry) 2004 struct dentry *dentry)
1924{ 2005{
1925 return 0; 2006 return 0;
1926} 2007}
1927 2008
1928static inline int security_inode_mknod (struct inode *dir, 2009static inline int security_inode_mknod(struct inode *dir,
1929 struct dentry *dentry, 2010 struct dentry *dentry,
1930 int mode, dev_t dev) 2011 int mode, dev_t dev)
1931{ 2012{
1932 return 0; 2013 return 0;
1933} 2014}
1934 2015
1935static inline int security_inode_rename (struct inode *old_dir, 2016static inline int security_inode_rename(struct inode *old_dir,
1936 struct dentry *old_dentry, 2017 struct dentry *old_dentry,
1937 struct inode *new_dir, 2018 struct inode *new_dir,
1938 struct dentry *new_dentry) 2019 struct dentry *new_dentry)
@@ -1940,59 +2021,61 @@ static inline int security_inode_rename (struct inode *old_dir,
1940 return 0; 2021 return 0;
1941} 2022}
1942 2023
1943static inline int security_inode_readlink (struct dentry *dentry) 2024static inline int security_inode_readlink(struct dentry *dentry)
1944{ 2025{
1945 return 0; 2026 return 0;
1946} 2027}
1947 2028
1948static inline int security_inode_follow_link (struct dentry *dentry, 2029static inline int security_inode_follow_link(struct dentry *dentry,
1949 struct nameidata *nd) 2030 struct nameidata *nd)
1950{ 2031{
1951 return 0; 2032 return 0;
1952} 2033}
1953 2034
1954static inline int security_inode_permission (struct inode *inode, int mask, 2035static inline int security_inode_permission(struct inode *inode, int mask,
1955 struct nameidata *nd) 2036 struct nameidata *nd)
1956{ 2037{
1957 return 0; 2038 return 0;
1958} 2039}
1959 2040
1960static inline int security_inode_setattr (struct dentry *dentry, 2041static inline int security_inode_setattr(struct dentry *dentry,
1961 struct iattr *attr) 2042 struct iattr *attr)
1962{ 2043{
1963 return 0; 2044 return 0;
1964} 2045}
1965 2046
1966static inline int security_inode_getattr (struct vfsmount *mnt, 2047static inline int security_inode_getattr(struct vfsmount *mnt,
1967 struct dentry *dentry) 2048 struct dentry *dentry)
1968{ 2049{
1969 return 0; 2050 return 0;
1970} 2051}
1971 2052
1972static inline void security_inode_delete (struct inode *inode) 2053static inline void security_inode_delete(struct inode *inode)
1973{ } 2054{ }
1974 2055
1975static inline int security_inode_setxattr (struct dentry *dentry, char *name, 2056static inline int security_inode_setxattr(struct dentry *dentry,
1976 void *value, size_t size, int flags) 2057 const char *name, const void *value, size_t size, int flags)
1977{ 2058{
1978 return cap_inode_setxattr(dentry, name, value, size, flags); 2059 return cap_inode_setxattr(dentry, name, value, size, flags);
1979} 2060}
1980 2061
1981static inline void security_inode_post_setxattr (struct dentry *dentry, char *name, 2062static inline void security_inode_post_setxattr(struct dentry *dentry,
1982 void *value, size_t size, int flags) 2063 const char *name, const void *value, size_t size, int flags)
1983{ } 2064{ }
1984 2065
1985static inline int security_inode_getxattr (struct dentry *dentry, char *name) 2066static inline int security_inode_getxattr(struct dentry *dentry,
2067 const char *name)
1986{ 2068{
1987 return 0; 2069 return 0;
1988} 2070}
1989 2071
1990static inline int security_inode_listxattr (struct dentry *dentry) 2072static inline int security_inode_listxattr(struct dentry *dentry)
1991{ 2073{
1992 return 0; 2074 return 0;
1993} 2075}
1994 2076
1995static inline int security_inode_removexattr (struct dentry *dentry, char *name) 2077static inline int security_inode_removexattr(struct dentry *dentry,
2078 const char *name)
1996{ 2079{
1997 return cap_inode_removexattr(dentry, name); 2080 return cap_inode_removexattr(dentry, name);
1998} 2081}
@@ -2022,292 +2105,304 @@ static inline int security_inode_listsecurity(struct inode *inode, char *buffer,
2022 return 0; 2105 return 0;
2023} 2106}
2024 2107
2025static inline int security_file_permission (struct file *file, int mask) 2108static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
2109{
2110 *secid = 0;
2111}
2112
2113static inline int security_file_permission(struct file *file, int mask)
2026{ 2114{
2027 return 0; 2115 return 0;
2028} 2116}
2029 2117
2030static inline int security_file_alloc (struct file *file) 2118static inline int security_file_alloc(struct file *file)
2031{ 2119{
2032 return 0; 2120 return 0;
2033} 2121}
2034 2122
2035static inline void security_file_free (struct file *file) 2123static inline void security_file_free(struct file *file)
2036{ } 2124{ }
2037 2125
2038static inline int security_file_ioctl (struct file *file, unsigned int cmd, 2126static inline int security_file_ioctl(struct file *file, unsigned int cmd,
2039 unsigned long arg) 2127 unsigned long arg)
2040{ 2128{
2041 return 0; 2129 return 0;
2042} 2130}
2043 2131
2044static inline int security_file_mmap (struct file *file, unsigned long reqprot, 2132static inline int security_file_mmap(struct file *file, unsigned long reqprot,
2045 unsigned long prot, 2133 unsigned long prot,
2046 unsigned long flags, 2134 unsigned long flags,
2047 unsigned long addr, 2135 unsigned long addr,
2048 unsigned long addr_only) 2136 unsigned long addr_only)
2049{ 2137{
2050 return 0; 2138 return 0;
2051} 2139}
2052 2140
2053static inline int security_file_mprotect (struct vm_area_struct *vma, 2141static inline int security_file_mprotect(struct vm_area_struct *vma,
2054 unsigned long reqprot, 2142 unsigned long reqprot,
2055 unsigned long prot) 2143 unsigned long prot)
2056{ 2144{
2057 return 0; 2145 return 0;
2058} 2146}
2059 2147
2060static inline int security_file_lock (struct file *file, unsigned int cmd) 2148static inline int security_file_lock(struct file *file, unsigned int cmd)
2061{ 2149{
2062 return 0; 2150 return 0;
2063} 2151}
2064 2152
2065static inline int security_file_fcntl (struct file *file, unsigned int cmd, 2153static inline int security_file_fcntl(struct file *file, unsigned int cmd,
2066 unsigned long arg) 2154 unsigned long arg)
2067{ 2155{
2068 return 0; 2156 return 0;
2069} 2157}
2070 2158
2071static inline int security_file_set_fowner (struct file *file) 2159static inline int security_file_set_fowner(struct file *file)
2072{ 2160{
2073 return 0; 2161 return 0;
2074} 2162}
2075 2163
2076static inline int security_file_send_sigiotask (struct task_struct *tsk, 2164static inline int security_file_send_sigiotask(struct task_struct *tsk,
2077 struct fown_struct *fown, 2165 struct fown_struct *fown,
2078 int sig) 2166 int sig)
2079{ 2167{
2080 return 0; 2168 return 0;
2081} 2169}
2082 2170
2083static inline int security_file_receive (struct file *file) 2171static inline int security_file_receive(struct file *file)
2084{ 2172{
2085 return 0; 2173 return 0;
2086} 2174}
2087 2175
2088static inline int security_dentry_open (struct file *file) 2176static inline int security_dentry_open(struct file *file)
2089{ 2177{
2090 return 0; 2178 return 0;
2091} 2179}
2092 2180
2093static inline int security_task_create (unsigned long clone_flags) 2181static inline int security_task_create(unsigned long clone_flags)
2094{ 2182{
2095 return 0; 2183 return 0;
2096} 2184}
2097 2185
2098static inline int security_task_alloc (struct task_struct *p) 2186static inline int security_task_alloc(struct task_struct *p)
2099{ 2187{
2100 return 0; 2188 return 0;
2101} 2189}
2102 2190
2103static inline void security_task_free (struct task_struct *p) 2191static inline void security_task_free(struct task_struct *p)
2104{ } 2192{ }
2105 2193
2106static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2, 2194static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2,
2107 int flags) 2195 int flags)
2108{ 2196{
2109 return 0; 2197 return 0;
2110} 2198}
2111 2199
2112static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid, 2200static inline int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
2113 uid_t old_suid, int flags) 2201 uid_t old_suid, int flags)
2114{ 2202{
2115 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags); 2203 return cap_task_post_setuid(old_ruid, old_euid, old_suid, flags);
2116} 2204}
2117 2205
2118static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2, 2206static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2,
2119 int flags) 2207 int flags)
2120{ 2208{
2121 return 0; 2209 return 0;
2122} 2210}
2123 2211
2124static inline int security_task_setpgid (struct task_struct *p, pid_t pgid) 2212static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
2125{ 2213{
2126 return 0; 2214 return 0;
2127} 2215}
2128 2216
2129static inline int security_task_getpgid (struct task_struct *p) 2217static inline int security_task_getpgid(struct task_struct *p)
2130{ 2218{
2131 return 0; 2219 return 0;
2132} 2220}
2133 2221
2134static inline int security_task_getsid (struct task_struct *p) 2222static inline int security_task_getsid(struct task_struct *p)
2135{ 2223{
2136 return 0; 2224 return 0;
2137} 2225}
2138 2226
2139static inline void security_task_getsecid (struct task_struct *p, u32 *secid) 2227static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
2140{ } 2228{
2229 *secid = 0;
2230}
2141 2231
2142static inline int security_task_setgroups (struct group_info *group_info) 2232static inline int security_task_setgroups(struct group_info *group_info)
2143{ 2233{
2144 return 0; 2234 return 0;
2145} 2235}
2146 2236
2147static inline int security_task_setnice (struct task_struct *p, int nice) 2237static inline int security_task_setnice(struct task_struct *p, int nice)
2148{ 2238{
2149 return cap_task_setnice(p, nice); 2239 return cap_task_setnice(p, nice);
2150} 2240}
2151 2241
2152static inline int security_task_setioprio (struct task_struct *p, int ioprio) 2242static inline int security_task_setioprio(struct task_struct *p, int ioprio)
2153{ 2243{
2154 return cap_task_setioprio(p, ioprio); 2244 return cap_task_setioprio(p, ioprio);
2155} 2245}
2156 2246
2157static inline int security_task_getioprio (struct task_struct *p) 2247static inline int security_task_getioprio(struct task_struct *p)
2158{ 2248{
2159 return 0; 2249 return 0;
2160} 2250}
2161 2251
2162static inline int security_task_setrlimit (unsigned int resource, 2252static inline int security_task_setrlimit(unsigned int resource,
2163 struct rlimit *new_rlim) 2253 struct rlimit *new_rlim)
2164{ 2254{
2165 return 0; 2255 return 0;
2166} 2256}
2167 2257
2168static inline int security_task_setscheduler (struct task_struct *p, 2258static inline int security_task_setscheduler(struct task_struct *p,
2169 int policy, 2259 int policy,
2170 struct sched_param *lp) 2260 struct sched_param *lp)
2171{ 2261{
2172 return cap_task_setscheduler(p, policy, lp); 2262 return cap_task_setscheduler(p, policy, lp);
2173} 2263}
2174 2264
2175static inline int security_task_getscheduler (struct task_struct *p) 2265static inline int security_task_getscheduler(struct task_struct *p)
2176{ 2266{
2177 return 0; 2267 return 0;
2178} 2268}
2179 2269
2180static inline int security_task_movememory (struct task_struct *p) 2270static inline int security_task_movememory(struct task_struct *p)
2181{ 2271{
2182 return 0; 2272 return 0;
2183} 2273}
2184 2274
2185static inline int security_task_kill (struct task_struct *p, 2275static inline int security_task_kill(struct task_struct *p,
2186 struct siginfo *info, int sig, 2276 struct siginfo *info, int sig,
2187 u32 secid) 2277 u32 secid)
2188{ 2278{
2189 return 0; 2279 return 0;
2190} 2280}
2191 2281
2192static inline int security_task_wait (struct task_struct *p) 2282static inline int security_task_wait(struct task_struct *p)
2193{ 2283{
2194 return 0; 2284 return 0;
2195} 2285}
2196 2286
2197static inline int security_task_prctl (int option, unsigned long arg2, 2287static inline int security_task_prctl(int option, unsigned long arg2,
2198 unsigned long arg3, 2288 unsigned long arg3,
2199 unsigned long arg4, 2289 unsigned long arg4,
2200 unsigned long arg5) 2290 unsigned long arg5, long *rc_p)
2201{ 2291{
2202 return 0; 2292 return cap_task_prctl(option, arg2, arg3, arg3, arg5, rc_p);
2203} 2293}
2204 2294
2205static inline void security_task_reparent_to_init (struct task_struct *p) 2295static inline void security_task_reparent_to_init(struct task_struct *p)
2206{ 2296{
2207 cap_task_reparent_to_init (p); 2297 cap_task_reparent_to_init(p);
2208} 2298}
2209 2299
2210static inline void security_task_to_inode(struct task_struct *p, struct inode *inode) 2300static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2211{ } 2301{ }
2212 2302
2213static inline int security_ipc_permission (struct kern_ipc_perm *ipcp, 2303static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
2214 short flag) 2304 short flag)
2215{ 2305{
2216 return 0; 2306 return 0;
2217} 2307}
2218 2308
2219static inline int security_msg_msg_alloc (struct msg_msg * msg) 2309static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
2310{
2311 *secid = 0;
2312}
2313
2314static inline int security_msg_msg_alloc(struct msg_msg *msg)
2220{ 2315{
2221 return 0; 2316 return 0;
2222} 2317}
2223 2318
2224static inline void security_msg_msg_free (struct msg_msg * msg) 2319static inline void security_msg_msg_free(struct msg_msg *msg)
2225{ } 2320{ }
2226 2321
2227static inline int security_msg_queue_alloc (struct msg_queue *msq) 2322static inline int security_msg_queue_alloc(struct msg_queue *msq)
2228{ 2323{
2229 return 0; 2324 return 0;
2230} 2325}
2231 2326
2232static inline void security_msg_queue_free (struct msg_queue *msq) 2327static inline void security_msg_queue_free(struct msg_queue *msq)
2233{ } 2328{ }
2234 2329
2235static inline int security_msg_queue_associate (struct msg_queue * msq, 2330static inline int security_msg_queue_associate(struct msg_queue *msq,
2236 int msqflg) 2331 int msqflg)
2237{ 2332{
2238 return 0; 2333 return 0;
2239} 2334}
2240 2335
2241static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd) 2336static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
2242{ 2337{
2243 return 0; 2338 return 0;
2244} 2339}
2245 2340
2246static inline int security_msg_queue_msgsnd (struct msg_queue * msq, 2341static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
2247 struct msg_msg * msg, int msqflg) 2342 struct msg_msg *msg, int msqflg)
2248{ 2343{
2249 return 0; 2344 return 0;
2250} 2345}
2251 2346
2252static inline int security_msg_queue_msgrcv (struct msg_queue * msq, 2347static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
2253 struct msg_msg * msg, 2348 struct msg_msg *msg,
2254 struct task_struct * target, 2349 struct task_struct *target,
2255 long type, int mode) 2350 long type, int mode)
2256{ 2351{
2257 return 0; 2352 return 0;
2258} 2353}
2259 2354
2260static inline int security_shm_alloc (struct shmid_kernel *shp) 2355static inline int security_shm_alloc(struct shmid_kernel *shp)
2261{ 2356{
2262 return 0; 2357 return 0;
2263} 2358}
2264 2359
2265static inline void security_shm_free (struct shmid_kernel *shp) 2360static inline void security_shm_free(struct shmid_kernel *shp)
2266{ } 2361{ }
2267 2362
2268static inline int security_shm_associate (struct shmid_kernel * shp, 2363static inline int security_shm_associate(struct shmid_kernel *shp,
2269 int shmflg) 2364 int shmflg)
2270{ 2365{
2271 return 0; 2366 return 0;
2272} 2367}
2273 2368
2274static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd) 2369static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
2275{ 2370{
2276 return 0; 2371 return 0;
2277} 2372}
2278 2373
2279static inline int security_shm_shmat (struct shmid_kernel * shp, 2374static inline int security_shm_shmat(struct shmid_kernel *shp,
2280 char __user *shmaddr, int shmflg) 2375 char __user *shmaddr, int shmflg)
2281{ 2376{
2282 return 0; 2377 return 0;
2283} 2378}
2284 2379
2285static inline int security_sem_alloc (struct sem_array *sma) 2380static inline int security_sem_alloc(struct sem_array *sma)
2286{ 2381{
2287 return 0; 2382 return 0;
2288} 2383}
2289 2384
2290static inline void security_sem_free (struct sem_array *sma) 2385static inline void security_sem_free(struct sem_array *sma)
2291{ } 2386{ }
2292 2387
2293static inline int security_sem_associate (struct sem_array * sma, int semflg) 2388static inline int security_sem_associate(struct sem_array *sma, int semflg)
2294{ 2389{
2295 return 0; 2390 return 0;
2296} 2391}
2297 2392
2298static inline int security_sem_semctl (struct sem_array * sma, int cmd) 2393static inline int security_sem_semctl(struct sem_array *sma, int cmd)
2299{ 2394{
2300 return 0; 2395 return 0;
2301} 2396}
2302 2397
2303static inline int security_sem_semop (struct sem_array * sma, 2398static inline int security_sem_semop(struct sem_array *sma,
2304 struct sembuf * sops, unsigned nsops, 2399 struct sembuf *sops, unsigned nsops,
2305 int alter) 2400 int alter)
2306{ 2401{
2307 return 0; 2402 return 0;
2308} 2403}
2309 2404
2310static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode) 2405static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
2311{ } 2406{ }
2312 2407
2313static inline int security_getprocattr(struct task_struct *p, char *name, char **value) 2408static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
@@ -2320,14 +2415,14 @@ static inline int security_setprocattr(struct task_struct *p, char *name, void *
2320 return -EINVAL; 2415 return -EINVAL;
2321} 2416}
2322 2417
2323static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb) 2418static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
2324{ 2419{
2325 return cap_netlink_send (sk, skb); 2420 return cap_netlink_send(sk, skb);
2326} 2421}
2327 2422
2328static inline int security_netlink_recv (struct sk_buff *skb, int cap) 2423static inline int security_netlink_recv(struct sk_buff *skb, int cap)
2329{ 2424{
2330 return cap_netlink_recv (skb, cap); 2425 return cap_netlink_recv(skb, cap);
2331} 2426}
2332 2427
2333static inline struct dentry *securityfs_create_dir(const char *name, 2428static inline struct dentry *securityfs_create_dir(const char *name,
@@ -2354,7 +2449,7 @@ static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *secle
2354 return -EOPNOTSUPP; 2449 return -EOPNOTSUPP;
2355} 2450}
2356 2451
2357static inline int security_secctx_to_secid(char *secdata, 2452static inline int security_secctx_to_secid(const char *secdata,
2358 u32 seclen, 2453 u32 seclen,
2359 u32 *secid) 2454 u32 *secid)
2360{ 2455{
@@ -2405,26 +2500,26 @@ void security_inet_conn_established(struct sock *sk,
2405 struct sk_buff *skb); 2500 struct sk_buff *skb);
2406 2501
2407#else /* CONFIG_SECURITY_NETWORK */ 2502#else /* CONFIG_SECURITY_NETWORK */
2408static inline int security_unix_stream_connect(struct socket * sock, 2503static inline int security_unix_stream_connect(struct socket *sock,
2409 struct socket * other, 2504 struct socket *other,
2410 struct sock * newsk) 2505 struct sock *newsk)
2411{ 2506{
2412 return 0; 2507 return 0;
2413} 2508}
2414 2509
2415static inline int security_unix_may_send(struct socket * sock, 2510static inline int security_unix_may_send(struct socket *sock,
2416 struct socket * other) 2511 struct socket *other)
2417{ 2512{
2418 return 0; 2513 return 0;
2419} 2514}
2420 2515
2421static inline int security_socket_create (int family, int type, 2516static inline int security_socket_create(int family, int type,
2422 int protocol, int kern) 2517 int protocol, int kern)
2423{ 2518{
2424 return 0; 2519 return 0;
2425} 2520}
2426 2521
2427static inline int security_socket_post_create(struct socket * sock, 2522static inline int security_socket_post_create(struct socket *sock,
2428 int family, 2523 int family,
2429 int type, 2524 int type,
2430 int protocol, int kern) 2525 int protocol, int kern)
@@ -2432,77 +2527,77 @@ static inline int security_socket_post_create(struct socket * sock,
2432 return 0; 2527 return 0;
2433} 2528}
2434 2529
2435static inline int security_socket_bind(struct socket * sock, 2530static inline int security_socket_bind(struct socket *sock,
2436 struct sockaddr * address, 2531 struct sockaddr *address,
2437 int addrlen) 2532 int addrlen)
2438{ 2533{
2439 return 0; 2534 return 0;
2440} 2535}
2441 2536
2442static inline int security_socket_connect(struct socket * sock, 2537static inline int security_socket_connect(struct socket *sock,
2443 struct sockaddr * address, 2538 struct sockaddr *address,
2444 int addrlen) 2539 int addrlen)
2445{ 2540{
2446 return 0; 2541 return 0;
2447} 2542}
2448 2543
2449static inline int security_socket_listen(struct socket * sock, int backlog) 2544static inline int security_socket_listen(struct socket *sock, int backlog)
2450{ 2545{
2451 return 0; 2546 return 0;
2452} 2547}
2453 2548
2454static inline int security_socket_accept(struct socket * sock, 2549static inline int security_socket_accept(struct socket *sock,
2455 struct socket * newsock) 2550 struct socket *newsock)
2456{ 2551{
2457 return 0; 2552 return 0;
2458} 2553}
2459 2554
2460static inline void security_socket_post_accept(struct socket * sock, 2555static inline void security_socket_post_accept(struct socket *sock,
2461 struct socket * newsock) 2556 struct socket *newsock)
2462{ 2557{
2463} 2558}
2464 2559
2465static inline int security_socket_sendmsg(struct socket * sock, 2560static inline int security_socket_sendmsg(struct socket *sock,
2466 struct msghdr * msg, int size) 2561 struct msghdr *msg, int size)
2467{ 2562{
2468 return 0; 2563 return 0;
2469} 2564}
2470 2565
2471static inline int security_socket_recvmsg(struct socket * sock, 2566static inline int security_socket_recvmsg(struct socket *sock,
2472 struct msghdr * msg, int size, 2567 struct msghdr *msg, int size,
2473 int flags) 2568 int flags)
2474{ 2569{
2475 return 0; 2570 return 0;
2476} 2571}
2477 2572
2478static inline int security_socket_getsockname(struct socket * sock) 2573static inline int security_socket_getsockname(struct socket *sock)
2479{ 2574{
2480 return 0; 2575 return 0;
2481} 2576}
2482 2577
2483static inline int security_socket_getpeername(struct socket * sock) 2578static inline int security_socket_getpeername(struct socket *sock)
2484{ 2579{
2485 return 0; 2580 return 0;
2486} 2581}
2487 2582
2488static inline int security_socket_getsockopt(struct socket * sock, 2583static inline int security_socket_getsockopt(struct socket *sock,
2489 int level, int optname) 2584 int level, int optname)
2490{ 2585{
2491 return 0; 2586 return 0;
2492} 2587}
2493 2588
2494static inline int security_socket_setsockopt(struct socket * sock, 2589static inline int security_socket_setsockopt(struct socket *sock,
2495 int level, int optname) 2590 int level, int optname)
2496{ 2591{
2497 return 0; 2592 return 0;
2498} 2593}
2499 2594
2500static inline int security_socket_shutdown(struct socket * sock, int how) 2595static inline int security_socket_shutdown(struct socket *sock, int how)
2501{ 2596{
2502 return 0; 2597 return 0;
2503} 2598}
2504static inline int security_sock_rcv_skb (struct sock * sk, 2599static inline int security_sock_rcv_skb(struct sock *sk,
2505 struct sk_buff * skb) 2600 struct sk_buff *skb)
2506{ 2601{
2507 return 0; 2602 return 0;
2508} 2603}
@@ -2539,7 +2634,7 @@ static inline void security_req_classify_flow(const struct request_sock *req, st
2539{ 2634{
2540} 2635}
2541 2636
2542static inline void security_sock_graft(struct sock* sk, struct socket *parent) 2637static inline void security_sock_graft(struct sock *sk, struct socket *parent)
2543{ 2638{
2544} 2639}
2545 2640
@@ -2562,16 +2657,16 @@ static inline void security_inet_conn_established(struct sock *sk,
2562 2657
2563#ifdef CONFIG_SECURITY_NETWORK_XFRM 2658#ifdef CONFIG_SECURITY_NETWORK_XFRM
2564 2659
2565int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx); 2660int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx);
2566int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new); 2661int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
2567void security_xfrm_policy_free(struct xfrm_policy *xp); 2662void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
2568int security_xfrm_policy_delete(struct xfrm_policy *xp); 2663int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
2569int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); 2664int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2570int security_xfrm_state_alloc_acquire(struct xfrm_state *x, 2665int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2571 struct xfrm_sec_ctx *polsec, u32 secid); 2666 struct xfrm_sec_ctx *polsec, u32 secid);
2572int security_xfrm_state_delete(struct xfrm_state *x); 2667int security_xfrm_state_delete(struct xfrm_state *x);
2573void security_xfrm_state_free(struct xfrm_state *x); 2668void security_xfrm_state_free(struct xfrm_state *x);
2574int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir); 2669int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
2575int security_xfrm_state_pol_flow_match(struct xfrm_state *x, 2670int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2576 struct xfrm_policy *xp, struct flowi *fl); 2671 struct xfrm_policy *xp, struct flowi *fl);
2577int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid); 2672int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
@@ -2579,21 +2674,21 @@ void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
2579 2674
2580#else /* CONFIG_SECURITY_NETWORK_XFRM */ 2675#else /* CONFIG_SECURITY_NETWORK_XFRM */
2581 2676
2582static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) 2677static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx)
2583{ 2678{
2584 return 0; 2679 return 0;
2585} 2680}
2586 2681
2587static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) 2682static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
2588{ 2683{
2589 return 0; 2684 return 0;
2590} 2685}
2591 2686
2592static inline void security_xfrm_policy_free(struct xfrm_policy *xp) 2687static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
2593{ 2688{
2594} 2689}
2595 2690
2596static inline int security_xfrm_policy_delete(struct xfrm_policy *xp) 2691static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
2597{ 2692{
2598 return 0; 2693 return 0;
2599} 2694}
@@ -2619,7 +2714,7 @@ static inline int security_xfrm_state_delete(struct xfrm_state *x)
2619 return 0; 2714 return 0;
2620} 2715}
2621 2716
2622static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir) 2717static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
2623{ 2718{
2624 return 0; 2719 return 0;
2625} 2720}
@@ -2648,6 +2743,7 @@ int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long f
2648void security_key_free(struct key *key); 2743void security_key_free(struct key *key);
2649int security_key_permission(key_ref_t key_ref, 2744int security_key_permission(key_ref_t key_ref,
2650 struct task_struct *context, key_perm_t perm); 2745 struct task_struct *context, key_perm_t perm);
2746int security_key_getsecurity(struct key *key, char **_buffer);
2651 2747
2652#else 2748#else
2653 2749
@@ -2669,8 +2765,47 @@ static inline int security_key_permission(key_ref_t key_ref,
2669 return 0; 2765 return 0;
2670} 2766}
2671 2767
2768static inline int security_key_getsecurity(struct key *key, char **_buffer)
2769{
2770 *_buffer = NULL;
2771 return 0;
2772}
2773
2672#endif 2774#endif
2673#endif /* CONFIG_KEYS */ 2775#endif /* CONFIG_KEYS */
2674 2776
2777#ifdef CONFIG_AUDIT
2778#ifdef CONFIG_SECURITY
2779int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
2780int security_audit_rule_known(struct audit_krule *krule);
2781int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
2782 struct audit_context *actx);
2783void security_audit_rule_free(void *lsmrule);
2784
2785#else
2786
2787static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
2788 void **lsmrule)
2789{
2790 return 0;
2791}
2792
2793static inline int security_audit_rule_known(struct audit_krule *krule)
2794{
2795 return 0;
2796}
2797
2798static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
2799 void *lsmrule, struct audit_context *actx)
2800{
2801 return 0;
2802}
2803
2804static inline void security_audit_rule_free(void *lsmrule)
2805{ }
2806
2807#endif /* CONFIG_SECURITY */
2808#endif /* CONFIG_AUDIT */
2809
2675#endif /* ! __LINUX_SECURITY_H */ 2810#endif /* ! __LINUX_SECURITY_H */
2676 2811
diff --git a/include/linux/selinux.h b/include/linux/selinux.h
index 8c2cc4c02526..20f965d4b041 100644
--- a/include/linux/selinux.h
+++ b/include/linux/selinux.h
@@ -16,99 +16,11 @@
16 16
17struct selinux_audit_rule; 17struct selinux_audit_rule;
18struct audit_context; 18struct audit_context;
19struct inode;
20struct kern_ipc_perm; 19struct kern_ipc_perm;
21 20
22#ifdef CONFIG_SECURITY_SELINUX 21#ifdef CONFIG_SECURITY_SELINUX
23 22
24/** 23/**
25 * selinux_audit_rule_init - alloc/init an selinux audit rule structure.
26 * @field: the field this rule refers to
27 * @op: the operater the rule uses
28 * @rulestr: the text "target" of the rule
29 * @rule: pointer to the new rule structure returned via this
30 *
31 * Returns 0 if successful, -errno if not. On success, the rule structure
32 * will be allocated internally. The caller must free this structure with
33 * selinux_audit_rule_free() after use.
34 */
35int selinux_audit_rule_init(u32 field, u32 op, char *rulestr,
36 struct selinux_audit_rule **rule);
37
38/**
39 * selinux_audit_rule_free - free an selinux audit rule structure.
40 * @rule: pointer to the audit rule to be freed
41 *
42 * This will free all memory associated with the given rule.
43 * If @rule is NULL, no operation is performed.
44 */
45void selinux_audit_rule_free(struct selinux_audit_rule *rule);
46
47/**
48 * selinux_audit_rule_match - determine if a context ID matches a rule.
49 * @sid: the context ID to check
50 * @field: the field this rule refers to
51 * @op: the operater the rule uses
52 * @rule: pointer to the audit rule to check against
53 * @actx: the audit context (can be NULL) associated with the check
54 *
55 * Returns 1 if the context id matches the rule, 0 if it does not, and
56 * -errno on failure.
57 */
58int selinux_audit_rule_match(u32 sid, u32 field, u32 op,
59 struct selinux_audit_rule *rule,
60 struct audit_context *actx);
61
62/**
63 * selinux_audit_set_callback - set the callback for policy reloads.
64 * @callback: the function to call when the policy is reloaded
65 *
66 * This sets the function callback function that will update the rules
67 * upon policy reloads. This callback should rebuild all existing rules
68 * using selinux_audit_rule_init().
69 */
70void selinux_audit_set_callback(int (*callback)(void));
71
72/**
73 * selinux_sid_to_string - map a security context ID to a string
74 * @sid: security context ID to be converted.
75 * @ctx: address of context string to be returned
76 * @ctxlen: length of returned context string.
77 *
78 * Returns 0 if successful, -errno if not. On success, the context
79 * string will be allocated internally, and the caller must call
80 * kfree() on it after use.
81 */
82int selinux_sid_to_string(u32 sid, char **ctx, u32 *ctxlen);
83
84/**
85 * selinux_get_inode_sid - get the inode's security context ID
86 * @inode: inode structure to get the sid from.
87 * @sid: pointer to security context ID to be filled in.
88 *
89 * Returns nothing
90 */
91void selinux_get_inode_sid(const struct inode *inode, u32 *sid);
92
93/**
94 * selinux_get_ipc_sid - get the ipc security context ID
95 * @ipcp: ipc structure to get the sid from.
96 * @sid: pointer to security context ID to be filled in.
97 *
98 * Returns nothing
99 */
100void selinux_get_ipc_sid(const struct kern_ipc_perm *ipcp, u32 *sid);
101
102/**
103 * selinux_get_task_sid - return the SID of task
104 * @tsk: the task whose SID will be returned
105 * @sid: pointer to security context ID to be filled in.
106 *
107 * Returns nothing
108 */
109void selinux_get_task_sid(struct task_struct *tsk, u32 *sid);
110
111/**
112 * selinux_string_to_sid - map a security context string to a security ID 24 * selinux_string_to_sid - map a security context string to a security ID
113 * @str: the security context string to be mapped 25 * @str: the security context string to be mapped
114 * @sid: ID value returned via this. 26 * @sid: ID value returned via this.
@@ -151,52 +63,6 @@ void selinux_secmark_refcount_inc(void);
151void selinux_secmark_refcount_dec(void); 63void selinux_secmark_refcount_dec(void);
152#else 64#else
153 65
154static inline int selinux_audit_rule_init(u32 field, u32 op,
155 char *rulestr,
156 struct selinux_audit_rule **rule)
157{
158 return -EOPNOTSUPP;
159}
160
161static inline void selinux_audit_rule_free(struct selinux_audit_rule *rule)
162{
163 return;
164}
165
166static inline int selinux_audit_rule_match(u32 sid, u32 field, u32 op,
167 struct selinux_audit_rule *rule,
168 struct audit_context *actx)
169{
170 return 0;
171}
172
173static inline void selinux_audit_set_callback(int (*callback)(void))
174{
175 return;
176}
177
178static inline int selinux_sid_to_string(u32 sid, char **ctx, u32 *ctxlen)
179{
180 *ctx = NULL;
181 *ctxlen = 0;
182 return 0;
183}
184
185static inline void selinux_get_inode_sid(const struct inode *inode, u32 *sid)
186{
187 *sid = 0;
188}
189
190static inline void selinux_get_ipc_sid(const struct kern_ipc_perm *ipcp, u32 *sid)
191{
192 *sid = 0;
193}
194
195static inline void selinux_get_task_sid(struct task_struct *tsk, u32 *sid)
196{
197 *sid = 0;
198}
199
200static inline int selinux_string_to_sid(const char *str, u32 *sid) 66static inline int selinux_string_to_sid(const char *str, u32 *sid)
201{ 67{
202 *sid = 0; 68 *sid = 0;
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
new file mode 100644
index 000000000000..9cae64b00d6b
--- /dev/null
+++ b/include/linux/semaphore.h
@@ -0,0 +1,51 @@
1/*
2 * Copyright (c) 2008 Intel Corporation
3 * Author: Matthew Wilcox <willy@linux.intel.com>
4 *
5 * Distributed under the terms of the GNU GPL, version 2
6 *
7 * Please see kernel/semaphore.c for documentation of these functions
8 */
9#ifndef __LINUX_SEMAPHORE_H
10#define __LINUX_SEMAPHORE_H
11
12#include <linux/list.h>
13#include <linux/spinlock.h>
14
15/* Please don't access any members of this structure directly */
16struct semaphore {
17 spinlock_t lock;
18 unsigned int count;
19 struct list_head wait_list;
20};
21
22#define __SEMAPHORE_INITIALIZER(name, n) \
23{ \
24 .lock = __SPIN_LOCK_UNLOCKED((name).lock), \
25 .count = n, \
26 .wait_list = LIST_HEAD_INIT((name).wait_list), \
27}
28
29#define __DECLARE_SEMAPHORE_GENERIC(name, count) \
30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, count)
31
32#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
33
34static inline void sema_init(struct semaphore *sem, int val)
35{
36 static struct lock_class_key __key;
37 *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
38 lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
39}
40
41#define init_MUTEX(sem) sema_init(sem, 1)
42#define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
43
44extern void down(struct semaphore *sem);
45extern int __must_check down_interruptible(struct semaphore *sem);
46extern int __must_check down_killable(struct semaphore *sem);
47extern int __must_check down_trylock(struct semaphore *sem);
48extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
49extern void up(struct semaphore *sem);
50
51#endif /* __LINUX_SEMAPHORE_H */
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 67c2563961f3..a66304a09955 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -1,6 +1,5 @@
1#ifndef _LINUX_SEQ_FILE_H 1#ifndef _LINUX_SEQ_FILE_H
2#define _LINUX_SEQ_FILE_H 2#define _LINUX_SEQ_FILE_H
3#ifdef __KERNEL__
4 3
5#include <linux/types.h> 4#include <linux/types.h>
6#include <linux/string.h> 5#include <linux/string.h>
@@ -10,6 +9,7 @@ struct seq_operations;
10struct file; 9struct file;
11struct path; 10struct path;
12struct inode; 11struct inode;
12struct dentry;
13 13
14struct seq_file { 14struct seq_file {
15 char *buf; 15 char *buf;
@@ -30,6 +30,8 @@ struct seq_operations {
30 int (*show) (struct seq_file *m, void *v); 30 int (*show) (struct seq_file *m, void *v);
31}; 31};
32 32
33#define SEQ_SKIP 1
34
33int seq_open(struct file *, const struct seq_operations *); 35int seq_open(struct file *, const struct seq_operations *);
34ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); 36ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
35loff_t seq_lseek(struct file *, loff_t, int); 37loff_t seq_lseek(struct file *, loff_t, int);
@@ -42,6 +44,9 @@ int seq_printf(struct seq_file *, const char *, ...)
42 __attribute__ ((format (printf,2,3))); 44 __attribute__ ((format (printf,2,3)));
43 45
44int seq_path(struct seq_file *, struct path *, char *); 46int seq_path(struct seq_file *, struct path *, char *);
47int seq_dentry(struct seq_file *, struct dentry *, char *);
48int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
49 char *esc);
45 50
46int single_open(struct file *, int (*)(struct seq_file *, void *), void *); 51int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
47int single_release(struct inode *, struct file *); 52int single_release(struct inode *, struct file *);
@@ -62,18 +67,4 @@ extern struct list_head *seq_list_start_head(struct list_head *head,
62extern struct list_head *seq_list_next(void *v, struct list_head *head, 67extern struct list_head *seq_list_next(void *v, struct list_head *head,
63 loff_t *ppos); 68 loff_t *ppos);
64 69
65struct net;
66struct seq_net_private {
67 struct net *net;
68};
69
70int seq_open_net(struct inode *, struct file *,
71 const struct seq_operations *, int);
72int seq_release_net(struct inode *, struct file *);
73static inline struct net *seq_file_net(struct seq_file *seq)
74{
75 return ((struct seq_net_private *)seq->private)->net;
76}
77
78#endif
79#endif 70#endif
diff --git a/include/linux/seq_file_net.h b/include/linux/seq_file_net.h
new file mode 100644
index 000000000000..4ac52542a563
--- /dev/null
+++ b/include/linux/seq_file_net.h
@@ -0,0 +1,27 @@
1#ifndef __SEQ_FILE_NET_H__
2#define __SEQ_FILE_NET_H__
3
4#include <linux/seq_file.h>
5
6struct net;
7extern struct net init_net;
8
9struct seq_net_private {
10#ifdef CONFIG_NET_NS
11 struct net *net;
12#endif
13};
14
15int seq_open_net(struct inode *, struct file *,
16 const struct seq_operations *, int);
17int seq_release_net(struct inode *, struct file *);
18static inline struct net *seq_file_net(struct seq_file *seq)
19{
20#ifdef CONFIG_NET_NS
21 return ((struct seq_net_private *)seq->private)->net;
22#else
23 return &init_net;
24#endif
25}
26
27#endif
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 26e4925bc35b..632205ccc25d 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -85,23 +85,29 @@ static inline int write_tryseqlock(seqlock_t *sl)
85/* Start of read calculation -- fetch last complete writer token */ 85/* Start of read calculation -- fetch last complete writer token */
86static __always_inline unsigned read_seqbegin(const seqlock_t *sl) 86static __always_inline unsigned read_seqbegin(const seqlock_t *sl)
87{ 87{
88 unsigned ret = sl->sequence; 88 unsigned ret;
89
90repeat:
91 ret = sl->sequence;
89 smp_rmb(); 92 smp_rmb();
93 if (unlikely(ret & 1)) {
94 cpu_relax();
95 goto repeat;
96 }
97
90 return ret; 98 return ret;
91} 99}
92 100
93/* Test if reader processed invalid data. 101/*
94 * If initial values is odd, 102 * Test if reader processed invalid data.
95 * then writer had already started when section was entered 103 *
96 * If sequence value changed 104 * If sequence value changed then writer changed data while in section.
97 * then writer changed data while in section
98 *
99 * Using xor saves one conditional branch.
100 */ 105 */
101static __always_inline int read_seqretry(const seqlock_t *sl, unsigned iv) 106static __always_inline int read_seqretry(const seqlock_t *sl, unsigned start)
102{ 107{
103 smp_rmb(); 108 smp_rmb();
104 return (iv & 1) | (sl->sequence ^ iv); 109
110 return (sl->sequence != start);
105} 111}
106 112
107 113
@@ -122,20 +128,26 @@ typedef struct seqcount {
122/* Start of read using pointer to a sequence counter only. */ 128/* Start of read using pointer to a sequence counter only. */
123static inline unsigned read_seqcount_begin(const seqcount_t *s) 129static inline unsigned read_seqcount_begin(const seqcount_t *s)
124{ 130{
125 unsigned ret = s->sequence; 131 unsigned ret;
132
133repeat:
134 ret = s->sequence;
126 smp_rmb(); 135 smp_rmb();
136 if (unlikely(ret & 1)) {
137 cpu_relax();
138 goto repeat;
139 }
127 return ret; 140 return ret;
128} 141}
129 142
130/* Test if reader processed invalid data. 143/*
131 * Equivalent to: iv is odd or sequence number has changed. 144 * Test if reader processed invalid data because sequence number has changed.
132 * (iv & 1) || (*s != iv)
133 * Using xor saves one conditional branch.
134 */ 145 */
135static inline int read_seqcount_retry(const seqcount_t *s, unsigned iv) 146static inline int read_seqcount_retry(const seqcount_t *s, unsigned start)
136{ 147{
137 smp_rmb(); 148 smp_rmb();
138 return (iv & 1) | (s->sequence ^ iv); 149
150 return s->sequence != start;
139} 151}
140 152
141 153
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 00b65c0a82ca..3d37c94abbc8 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -46,6 +46,7 @@ enum {
46 PLAT8250_DEV_HUB6, 46 PLAT8250_DEV_HUB6,
47 PLAT8250_DEV_MCA, 47 PLAT8250_DEV_MCA,
48 PLAT8250_DEV_AU1X00, 48 PLAT8250_DEV_AU1X00,
49 PLAT8250_DEV_SM501,
49}; 50};
50 51
51/* 52/*
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 289942fc6655..d32123ae08ad 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -149,13 +149,15 @@
149/* Freescale ColdFire */ 149/* Freescale ColdFire */
150#define PORT_MCF 78 150#define PORT_MCF 78
151 151
152#define PORT_SC26XX 79 152/* Blackfin SPORT */
153 153#define PORT_BFIN_SPORT 79
154 154
155/* MN10300 on-chip UART numbers */ 155/* MN10300 on-chip UART numbers */
156#define PORT_MN10300 80 156#define PORT_MN10300 80
157#define PORT_MN10300_CTS 81 157#define PORT_MN10300_CTS 81
158 158
159#define PORT_SC26XX 82
160
159#ifdef __KERNEL__ 161#ifdef __KERNEL__
160 162
161#include <linux/compiler.h> 163#include <linux/compiler.h>
@@ -213,6 +215,10 @@ struct uart_ops {
213 void (*config_port)(struct uart_port *, int); 215 void (*config_port)(struct uart_port *, int);
214 int (*verify_port)(struct uart_port *, struct serial_struct *); 216 int (*verify_port)(struct uart_port *, struct serial_struct *);
215 int (*ioctl)(struct uart_port *, unsigned int, unsigned long); 217 int (*ioctl)(struct uart_port *, unsigned int, unsigned long);
218#ifdef CONFIG_CONSOLE_POLL
219 void (*poll_put_char)(struct uart_port *, unsigned char);
220 int (*poll_get_char)(struct uart_port *);
221#endif
216}; 222};
217 223
218#define UART_CONFIG_TYPE (1 << 0) 224#define UART_CONFIG_TYPE (1 << 0)
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 9f3825014674..95674d97dabd 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -211,5 +211,6 @@ static inline void serio_unpin_driver(struct serio *serio)
211#define SERIO_TOUCHWIN 0x33 211#define SERIO_TOUCHWIN 0x33
212#define SERIO_TAOSEVM 0x34 212#define SERIO_TAOSEVM 0x34
213#define SERIO_FUJITSU 0x35 213#define SERIO_FUJITSU 0x35
214#define SERIO_ZHENHUA 0x36
214 215
215#endif 216#endif
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 8d5fb36ea047..f2d12d5a21b8 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -34,8 +34,7 @@ struct shmem_sb_info {
34 uid_t uid; /* Mount uid for root directory */ 34 uid_t uid; /* Mount uid for root directory */
35 gid_t gid; /* Mount gid for root directory */ 35 gid_t gid; /* Mount gid for root directory */
36 mode_t mode; /* Mount mode for root directory */ 36 mode_t mode; /* Mount mode for root directory */
37 int policy; /* Default NUMA memory alloc policy */ 37 struct mempolicy *mpol; /* default memory policy for mappings */
38 nodemask_t policy_nodes; /* nodemask for preferred and bind */
39}; 38};
40 39
41static inline struct shmem_inode_info *SHMEM_I(struct inode *inode) 40static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
diff --git a/include/linux/signal.h b/include/linux/signal.h
index 42d2e0a948f4..84f997f8aa53 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -362,8 +362,6 @@ int unhandled_signal(struct task_struct *tsk, int sig);
362#define sig_kernel_stop(sig) \ 362#define sig_kernel_stop(sig) \
363 (((sig) < SIGRTMIN) && siginmask(sig, SIG_KERNEL_STOP_MASK)) 363 (((sig) < SIGRTMIN) && siginmask(sig, SIG_KERNEL_STOP_MASK))
364 364
365#define sig_needs_tasklist(sig) ((sig) == SIGCONT)
366
367#define sig_user_defined(t, signr) \ 365#define sig_user_defined(t, signr) \
368 (((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_DFL) && \ 366 (((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_DFL) && \
369 ((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_IGN)) 367 ((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_IGN))
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index bbd8d0027e2f..299ec4b31412 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -242,6 +242,7 @@ typedef unsigned char *sk_buff_data_t;
242 * @queue_mapping: Queue mapping for multiqueue devices 242 * @queue_mapping: Queue mapping for multiqueue devices
243 * @tc_index: Traffic control index 243 * @tc_index: Traffic control index
244 * @tc_verd: traffic control verdict 244 * @tc_verd: traffic control verdict
245 * @ndisc_nodetype: router type (from link layer)
245 * @dma_cookie: a cookie to one of several possible DMA operations 246 * @dma_cookie: a cookie to one of several possible DMA operations
246 * done by skb DMA functions 247 * done by skb DMA functions
247 * @secmark: security marking 248 * @secmark: security marking
@@ -256,7 +257,10 @@ struct sk_buff {
256 ktime_t tstamp; 257 ktime_t tstamp;
257 struct net_device *dev; 258 struct net_device *dev;
258 259
259 struct dst_entry *dst; 260 union {
261 struct dst_entry *dst;
262 struct rtable *rtable;
263 };
260 struct sec_path *sp; 264 struct sec_path *sp;
261 265
262 /* 266 /*
@@ -310,7 +314,10 @@ struct sk_buff {
310 __u16 tc_verd; /* traffic control verdict */ 314 __u16 tc_verd; /* traffic control verdict */
311#endif 315#endif
312#endif 316#endif
313 /* 2 byte hole */ 317#ifdef CONFIG_IPV6_NDISC_NODETYPE
318 __u8 ndisc_nodetype:2;
319#endif
320 /* 14 bit hole */
314 321
315#ifdef CONFIG_NET_DMA 322#ifdef CONFIG_NET_DMA
316 dma_cookie_t dma_cookie; 323 dma_cookie_t dma_cookie;
@@ -657,11 +664,21 @@ static inline void skb_queue_head_init_class(struct sk_buff_head *list,
657} 664}
658 665
659/* 666/*
660 * Insert an sk_buff at the start of a list. 667 * Insert an sk_buff on a list.
661 * 668 *
662 * The "__skb_xxxx()" functions are the non-atomic ones that 669 * The "__skb_xxxx()" functions are the non-atomic ones that
663 * can only be called with interrupts disabled. 670 * can only be called with interrupts disabled.
664 */ 671 */
672extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list);
673static inline void __skb_insert(struct sk_buff *newsk,
674 struct sk_buff *prev, struct sk_buff *next,
675 struct sk_buff_head *list)
676{
677 newsk->next = next;
678 newsk->prev = prev;
679 next->prev = prev->next = newsk;
680 list->qlen++;
681}
665 682
666/** 683/**
667 * __skb_queue_after - queue a buffer at the list head 684 * __skb_queue_after - queue a buffer at the list head
@@ -678,13 +695,17 @@ static inline void __skb_queue_after(struct sk_buff_head *list,
678 struct sk_buff *prev, 695 struct sk_buff *prev,
679 struct sk_buff *newsk) 696 struct sk_buff *newsk)
680{ 697{
681 struct sk_buff *next; 698 __skb_insert(newsk, prev, prev->next, list);
682 list->qlen++; 699}
683 700
684 next = prev->next; 701extern void skb_append(struct sk_buff *old, struct sk_buff *newsk,
685 newsk->next = next; 702 struct sk_buff_head *list);
686 newsk->prev = prev; 703
687 next->prev = prev->next = newsk; 704static inline void __skb_queue_before(struct sk_buff_head *list,
705 struct sk_buff *next,
706 struct sk_buff *newsk)
707{
708 __skb_insert(newsk, next->prev, next, list);
688} 709}
689 710
690/** 711/**
@@ -718,66 +739,7 @@ extern void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
718static inline void __skb_queue_tail(struct sk_buff_head *list, 739static inline void __skb_queue_tail(struct sk_buff_head *list,
719 struct sk_buff *newsk) 740 struct sk_buff *newsk)
720{ 741{
721 struct sk_buff *prev, *next; 742 __skb_queue_before(list, (struct sk_buff *)list, newsk);
722
723 list->qlen++;
724 next = (struct sk_buff *)list;
725 prev = next->prev;
726 newsk->next = next;
727 newsk->prev = prev;
728 next->prev = prev->next = newsk;
729}
730
731
732/**
733 * __skb_dequeue - remove from the head of the queue
734 * @list: list to dequeue from
735 *
736 * Remove the head of the list. This function does not take any locks
737 * so must be used with appropriate locks held only. The head item is
738 * returned or %NULL if the list is empty.
739 */
740extern struct sk_buff *skb_dequeue(struct sk_buff_head *list);
741static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
742{
743 struct sk_buff *next, *prev, *result;
744
745 prev = (struct sk_buff *) list;
746 next = prev->next;
747 result = NULL;
748 if (next != prev) {
749 result = next;
750 next = next->next;
751 list->qlen--;
752 next->prev = prev;
753 prev->next = next;
754 result->next = result->prev = NULL;
755 }
756 return result;
757}
758
759
760/*
761 * Insert a packet on a list.
762 */
763extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list);
764static inline void __skb_insert(struct sk_buff *newsk,
765 struct sk_buff *prev, struct sk_buff *next,
766 struct sk_buff_head *list)
767{
768 newsk->next = next;
769 newsk->prev = prev;
770 next->prev = prev->next = newsk;
771 list->qlen++;
772}
773
774/*
775 * Place a packet after a given packet in a list.
776 */
777extern void skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list);
778static inline void __skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list)
779{
780 __skb_insert(newsk, old, old->next, list);
781} 743}
782 744
783/* 745/*
@@ -797,8 +759,22 @@ static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
797 prev->next = next; 759 prev->next = next;
798} 760}
799 761
800 762/**
801/* XXX: more streamlined implementation */ 763 * __skb_dequeue - remove from the head of the queue
764 * @list: list to dequeue from
765 *
766 * Remove the head of the list. This function does not take any locks
767 * so must be used with appropriate locks held only. The head item is
768 * returned or %NULL if the list is empty.
769 */
770extern struct sk_buff *skb_dequeue(struct sk_buff_head *list);
771static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
772{
773 struct sk_buff *skb = skb_peek(list);
774 if (skb)
775 __skb_unlink(skb, list);
776 return skb;
777}
802 778
803/** 779/**
804 * __skb_dequeue_tail - remove from the tail of the queue 780 * __skb_dequeue_tail - remove from the tail of the queue
@@ -889,6 +865,7 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
889/* 865/*
890 * Add data to an sk_buff 866 * Add data to an sk_buff
891 */ 867 */
868extern unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
892static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) 869static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
893{ 870{
894 unsigned char *tmp = skb_tail_pointer(skb); 871 unsigned char *tmp = skb_tail_pointer(skb);
@@ -898,26 +875,7 @@ static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
898 return tmp; 875 return tmp;
899} 876}
900 877
901/** 878extern unsigned char *skb_push(struct sk_buff *skb, unsigned int len);
902 * skb_put - add data to a buffer
903 * @skb: buffer to use
904 * @len: amount of data to add
905 *
906 * This function extends the used data area of the buffer. If this would
907 * exceed the total buffer size the kernel will panic. A pointer to the
908 * first byte of the extra data is returned.
909 */
910static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
911{
912 unsigned char *tmp = skb_tail_pointer(skb);
913 SKB_LINEAR_ASSERT(skb);
914 skb->tail += len;
915 skb->len += len;
916 if (unlikely(skb->tail > skb->end))
917 skb_over_panic(skb, len, current_text_addr());
918 return tmp;
919}
920
921static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len) 879static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
922{ 880{
923 skb->data -= len; 881 skb->data -= len;
@@ -925,24 +883,7 @@ static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len)
925 return skb->data; 883 return skb->data;
926} 884}
927 885
928/** 886extern unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
929 * skb_push - add data to the start of a buffer
930 * @skb: buffer to use
931 * @len: amount of data to add
932 *
933 * This function extends the used data area of the buffer at the buffer
934 * start. If this would exceed the total buffer headroom the kernel will
935 * panic. A pointer to the first byte of the extra data is returned.
936 */
937static inline unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
938{
939 skb->data -= len;
940 skb->len += len;
941 if (unlikely(skb->data<skb->head))
942 skb_under_panic(skb, len, current_text_addr());
943 return skb->data;
944}
945
946static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len) 887static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len)
947{ 888{
948 skb->len -= len; 889 skb->len -= len;
@@ -950,21 +891,6 @@ static inline unsigned char *__skb_pull(struct sk_buff *skb, unsigned int len)
950 return skb->data += len; 891 return skb->data += len;
951} 892}
952 893
953/**
954 * skb_pull - remove data from the start of a buffer
955 * @skb: buffer to use
956 * @len: amount of data to remove
957 *
958 * This function removes data from the start of a buffer, returning
959 * the memory to the headroom. A pointer to the next data in the buffer
960 * is returned. Once the data has been pulled future pushes will overwrite
961 * the old data.
962 */
963static inline unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)
964{
965 return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len);
966}
967
968extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta); 894extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta);
969 895
970static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len) 896static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len)
@@ -1205,21 +1131,7 @@ static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
1205 skb_set_tail_pointer(skb, len); 1131 skb_set_tail_pointer(skb, len);
1206} 1132}
1207 1133
1208/** 1134extern void skb_trim(struct sk_buff *skb, unsigned int len);
1209 * skb_trim - remove end from a buffer
1210 * @skb: buffer to alter
1211 * @len: new length
1212 *
1213 * Cut the length of a buffer down by removing data from the tail. If
1214 * the buffer is already under the length specified it is not modified.
1215 * The skb must be linear.
1216 */
1217static inline void skb_trim(struct sk_buff *skb, unsigned int len)
1218{
1219 if (skb->len > len)
1220 __skb_trim(skb, len);
1221}
1222
1223 1135
1224static inline int __pskb_trim(struct sk_buff *skb, unsigned int len) 1136static inline int __pskb_trim(struct sk_buff *skb, unsigned int len)
1225{ 1137{
@@ -1302,22 +1214,7 @@ static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
1302 return skb; 1214 return skb;
1303} 1215}
1304 1216
1305/** 1217extern struct sk_buff *dev_alloc_skb(unsigned int length);
1306 * dev_alloc_skb - allocate an skbuff for receiving
1307 * @length: length to allocate
1308 *
1309 * Allocate a new &sk_buff and assign it a usage count of one. The
1310 * buffer has unspecified headroom built in. Users should allocate
1311 * the headroom they think they need without accounting for the
1312 * built in space. The built in space is used for optimisations.
1313 *
1314 * %NULL is returned if there is no free memory. Although this function
1315 * allocates memory it can be called from an interrupt.
1316 */
1317static inline struct sk_buff *dev_alloc_skb(unsigned int length)
1318{
1319 return __dev_alloc_skb(length, GFP_ATOMIC);
1320}
1321 1218
1322extern struct sk_buff *__netdev_alloc_skb(struct net_device *dev, 1219extern struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
1323 unsigned int length, gfp_t gfp_mask); 1220 unsigned int length, gfp_t gfp_mask);
diff --git a/include/linux/slab.h b/include/linux/slab.h
index f62caaad94e0..805ed4b92f9a 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -9,8 +9,6 @@
9#ifndef _LINUX_SLAB_H 9#ifndef _LINUX_SLAB_H
10#define _LINUX_SLAB_H 10#define _LINUX_SLAB_H
11 11
12#ifdef __KERNEL__
13
14#include <linux/gfp.h> 12#include <linux/gfp.h>
15#include <linux/types.h> 13#include <linux/types.h>
16 14
@@ -29,6 +27,13 @@
29#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ 27#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
30#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ 28#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */
31 29
30/* Flag to prevent checks on free */
31#ifdef CONFIG_DEBUG_OBJECTS
32# define SLAB_DEBUG_OBJECTS 0x00400000UL
33#else
34# define SLAB_DEBUG_OBJECTS 0x00000000UL
35#endif
36
32/* The following flags affect the page allocator grouping pages by mobility */ 37/* The following flags affect the page allocator grouping pages by mobility */
33#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ 38#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */
34#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ 39#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */
@@ -276,5 +281,4 @@ extern const struct seq_operations slabinfo_op;
276ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *); 281ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
277#endif 282#endif
278 283
279#endif /* __KERNEL__ */
280#endif /* _LINUX_SLAB_H */ 284#endif /* _LINUX_SLAB_H */
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index b00c1c73eb0a..71e43a12ebbb 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -29,6 +29,7 @@ enum stat_item {
29 DEACTIVATE_TO_HEAD, /* Cpu slab was moved to the head of partials */ 29 DEACTIVATE_TO_HEAD, /* Cpu slab was moved to the head of partials */
30 DEACTIVATE_TO_TAIL, /* Cpu slab was moved to the tail of partials */ 30 DEACTIVATE_TO_TAIL, /* Cpu slab was moved to the tail of partials */
31 DEACTIVATE_REMOTE_FREES,/* Slab contained remotely freed objects */ 31 DEACTIVATE_REMOTE_FREES,/* Slab contained remotely freed objects */
32 ORDER_FALLBACK, /* Number of times fallback was necessary */
32 NR_SLUB_STAT_ITEMS }; 33 NR_SLUB_STAT_ITEMS };
33 34
34struct kmem_cache_cpu { 35struct kmem_cache_cpu {
@@ -45,14 +46,24 @@ struct kmem_cache_cpu {
45struct kmem_cache_node { 46struct kmem_cache_node {
46 spinlock_t list_lock; /* Protect partial list and nr_partial */ 47 spinlock_t list_lock; /* Protect partial list and nr_partial */
47 unsigned long nr_partial; 48 unsigned long nr_partial;
48 atomic_long_t nr_slabs;
49 struct list_head partial; 49 struct list_head partial;
50#ifdef CONFIG_SLUB_DEBUG 50#ifdef CONFIG_SLUB_DEBUG
51 atomic_long_t nr_slabs;
52 atomic_long_t total_objects;
51 struct list_head full; 53 struct list_head full;
52#endif 54#endif
53}; 55};
54 56
55/* 57/*
58 * Word size structure that can be atomically updated or read and that
59 * contains both the order and the number of objects that a slab of the
60 * given order would contain.
61 */
62struct kmem_cache_order_objects {
63 unsigned long x;
64};
65
66/*
56 * Slab cache management. 67 * Slab cache management.
57 */ 68 */
58struct kmem_cache { 69struct kmem_cache {
@@ -61,7 +72,7 @@ struct kmem_cache {
61 int size; /* The size of an object including meta data */ 72 int size; /* The size of an object including meta data */
62 int objsize; /* The size of an object without meta data */ 73 int objsize; /* The size of an object without meta data */
63 int offset; /* Free pointer offset. */ 74 int offset; /* Free pointer offset. */
64 int order; /* Current preferred allocation order */ 75 struct kmem_cache_order_objects oo;
65 76
66 /* 77 /*
67 * Avoid an extra cache line for UP, SMP and for the node local to 78 * Avoid an extra cache line for UP, SMP and for the node local to
@@ -70,7 +81,8 @@ struct kmem_cache {
70 struct kmem_cache_node local_node; 81 struct kmem_cache_node local_node;
71 82
72 /* Allocation and freeing of slabs */ 83 /* Allocation and freeing of slabs */
73 int objects; /* Number of objects in slab */ 84 struct kmem_cache_order_objects max;
85 struct kmem_cache_order_objects min;
74 gfp_t allocflags; /* gfp flags to use on each alloc */ 86 gfp_t allocflags; /* gfp flags to use on each alloc */
75 int refcount; /* Refcount for slab cache destroy */ 87 int refcount; /* Refcount for slab cache destroy */
76 void (*ctor)(struct kmem_cache *, void *); 88 void (*ctor)(struct kmem_cache *, void *);
diff --git a/include/linux/smb.h b/include/linux/smb.h
index f098dff93f6b..caa43b2370cb 100644
--- a/include/linux/smb.h
+++ b/include/linux/smb.h
@@ -11,6 +11,7 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/magic.h> 13#include <linux/magic.h>
14#include <linux/time.h>
14 15
15enum smb_protocol { 16enum smb_protocol {
16 SMB_PROTOCOL_NONE, 17 SMB_PROTOCOL_NONE,
diff --git a/include/linux/smb_fs_i.h b/include/linux/smb_fs_i.h
index 8516954a5141..8ccf4eca2c3d 100644
--- a/include/linux/smb_fs_i.h
+++ b/include/linux/smb_fs_i.h
@@ -9,7 +9,6 @@
9#ifndef _LINUX_SMB_FS_I 9#ifndef _LINUX_SMB_FS_I
10#define _LINUX_SMB_FS_I 10#define _LINUX_SMB_FS_I
11 11
12#ifdef __KERNEL__
13#include <linux/types.h> 12#include <linux/types.h>
14#include <linux/fs.h> 13#include <linux/fs.h>
15 14
@@ -36,4 +35,3 @@ struct smb_inode_info {
36}; 35};
37 36
38#endif 37#endif
39#endif
diff --git a/include/linux/smb_fs_sb.h b/include/linux/smb_fs_sb.h
index 3aa97aa4277f..8a060a7040d8 100644
--- a/include/linux/smb_fs_sb.h
+++ b/include/linux/smb_fs_sb.h
@@ -9,8 +9,6 @@
9#ifndef _SMB_FS_SB 9#ifndef _SMB_FS_SB
10#define _SMB_FS_SB 10#define _SMB_FS_SB
11 11
12#ifdef __KERNEL__
13
14#include <linux/types.h> 12#include <linux/types.h>
15#include <linux/smb.h> 13#include <linux/smb.h>
16 14
@@ -96,6 +94,4 @@ smb_unlock_server(struct smb_sb_info *server)
96 up(&(server->sem)); 94 up(&(server->sem));
97} 95}
98 96
99#endif /* __KERNEL__ */
100
101#endif 97#endif
diff --git a/include/linux/smc91x.h b/include/linux/smc91x.h
new file mode 100644
index 000000000000..8e0556b8781c
--- /dev/null
+++ b/include/linux/smc91x.h
@@ -0,0 +1,13 @@
1#ifndef __SMC91X_H__
2#define __SMC91X_H__
3
4#define SMC91X_USE_8BIT (1 << 0)
5#define SMC91X_USE_16BIT (1 << 1)
6#define SMC91X_USE_32BIT (1 << 2)
7
8struct smc91x_platdata {
9 unsigned long flags;
10 unsigned long irq_flags; /* IRQF_... */
11};
12
13#endif /* __SMC91X_H__ */
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index 334d31411629..daf744017a31 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -14,7 +14,8 @@ enum ads7846_filter {
14struct ads7846_platform_data { 14struct ads7846_platform_data {
15 u16 model; /* 7843, 7845, 7846. */ 15 u16 model; /* 7843, 7845, 7846. */
16 u16 vref_delay_usecs; /* 0 for external vref; etc */ 16 u16 vref_delay_usecs; /* 0 for external vref; etc */
17 int keep_vref_on:1; /* set to keep vref on for differential 17 u16 vref_mv; /* external vref value, milliVolts */
18 bool keep_vref_on; /* set to keep vref on for differential
18 * measurements as well */ 19 * measurements as well */
19 20
20 /* Settling time of the analog signals; a function of Vcc and the 21 /* Settling time of the analog signals; a function of Vcc and the
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 1129ee0a7180..d311a090fae7 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -296,43 +296,6 @@ do { \
296}) 296})
297 297
298/* 298/*
299 * Locks two spinlocks l1 and l2.
300 * l1_first indicates if spinlock l1 should be taken first.
301 */
302static inline void double_spin_lock(spinlock_t *l1, spinlock_t *l2,
303 bool l1_first)
304 __acquires(l1)
305 __acquires(l2)
306{
307 if (l1_first) {
308 spin_lock(l1);
309 spin_lock(l2);
310 } else {
311 spin_lock(l2);
312 spin_lock(l1);
313 }
314}
315
316/*
317 * Unlocks two spinlocks l1 and l2.
318 * l1_taken_first indicates if spinlock l1 was taken first and therefore
319 * should be released after spinlock l2.
320 */
321static inline void double_spin_unlock(spinlock_t *l1, spinlock_t *l2,
322 bool l1_taken_first)
323 __releases(l1)
324 __releases(l2)
325{
326 if (l1_taken_first) {
327 spin_unlock(l2);
328 spin_unlock(l1);
329 } else {
330 spin_unlock(l1);
331 spin_unlock(l2);
332 }
333}
334
335/*
336 * Pull the atomic_t declaration: 299 * Pull the atomic_t declaration:
337 * (asm-mips/atomic.h needs above definitions) 300 * (asm-mips/atomic.h needs above definitions)
338 */ 301 */
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index db53defde5ee..50dfd0dc4093 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -72,10 +72,18 @@ struct ssb_device;
72/* Lowlevel read/write operations on the device MMIO. 72/* Lowlevel read/write operations on the device MMIO.
73 * Internal, don't use that outside of ssb. */ 73 * Internal, don't use that outside of ssb. */
74struct ssb_bus_ops { 74struct ssb_bus_ops {
75 u8 (*read8)(struct ssb_device *dev, u16 offset);
75 u16 (*read16)(struct ssb_device *dev, u16 offset); 76 u16 (*read16)(struct ssb_device *dev, u16 offset);
76 u32 (*read32)(struct ssb_device *dev, u16 offset); 77 u32 (*read32)(struct ssb_device *dev, u16 offset);
78 void (*write8)(struct ssb_device *dev, u16 offset, u8 value);
77 void (*write16)(struct ssb_device *dev, u16 offset, u16 value); 79 void (*write16)(struct ssb_device *dev, u16 offset, u16 value);
78 void (*write32)(struct ssb_device *dev, u16 offset, u32 value); 80 void (*write32)(struct ssb_device *dev, u16 offset, u32 value);
81#ifdef CONFIG_SSB_BLOCKIO
82 void (*block_read)(struct ssb_device *dev, void *buffer,
83 size_t count, u16 offset, u8 reg_width);
84 void (*block_write)(struct ssb_device *dev, const void *buffer,
85 size_t count, u16 offset, u8 reg_width);
86#endif
79}; 87};
80 88
81 89
@@ -247,9 +255,9 @@ struct ssb_bus {
247 /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */ 255 /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
248 struct pcmcia_device *host_pcmcia; 256 struct pcmcia_device *host_pcmcia;
249 257
250#ifdef CONFIG_SSB_PCIHOST 258#ifdef CONFIG_SSB_SPROM
251 /* Mutex to protect the SPROM writing. */ 259 /* Mutex to protect the SPROM writing. */
252 struct mutex pci_sprom_mutex; 260 struct mutex sprom_mutex;
253#endif 261#endif
254 262
255 /* ID information about the Chip. */ 263 /* ID information about the Chip. */
@@ -262,9 +270,6 @@ struct ssb_bus {
262 struct ssb_device devices[SSB_MAX_NR_CORES]; 270 struct ssb_device devices[SSB_MAX_NR_CORES];
263 u8 nr_devices; 271 u8 nr_devices;
264 272
265 /* Reference count. Number of suspended devices. */
266 u8 suspend_cnt;
267
268 /* Software ID number for this bus. */ 273 /* Software ID number for this bus. */
269 unsigned int busnumber; 274 unsigned int busnumber;
270 275
@@ -336,6 +341,13 @@ extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
336 341
337extern void ssb_bus_unregister(struct ssb_bus *bus); 342extern void ssb_bus_unregister(struct ssb_bus *bus);
338 343
344/* Suspend a SSB bus.
345 * Call this from the parent bus suspend routine. */
346extern int ssb_bus_suspend(struct ssb_bus *bus);
347/* Resume a SSB bus.
348 * Call this from the parent bus resume routine. */
349extern int ssb_bus_resume(struct ssb_bus *bus);
350
339extern u32 ssb_clockspeed(struct ssb_bus *bus); 351extern u32 ssb_clockspeed(struct ssb_bus *bus);
340 352
341/* Is the device enabled in hardware? */ 353/* Is the device enabled in hardware? */
@@ -348,6 +360,10 @@ void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags);
348 360
349 361
350/* Device MMIO register read/write functions. */ 362/* Device MMIO register read/write functions. */
363static inline u8 ssb_read8(struct ssb_device *dev, u16 offset)
364{
365 return dev->ops->read8(dev, offset);
366}
351static inline u16 ssb_read16(struct ssb_device *dev, u16 offset) 367static inline u16 ssb_read16(struct ssb_device *dev, u16 offset)
352{ 368{
353 return dev->ops->read16(dev, offset); 369 return dev->ops->read16(dev, offset);
@@ -356,6 +372,10 @@ static inline u32 ssb_read32(struct ssb_device *dev, u16 offset)
356{ 372{
357 return dev->ops->read32(dev, offset); 373 return dev->ops->read32(dev, offset);
358} 374}
375static inline void ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
376{
377 dev->ops->write8(dev, offset, value);
378}
359static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value) 379static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
360{ 380{
361 dev->ops->write16(dev, offset, value); 381 dev->ops->write16(dev, offset, value);
@@ -364,6 +384,19 @@ static inline void ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
364{ 384{
365 dev->ops->write32(dev, offset, value); 385 dev->ops->write32(dev, offset, value);
366} 386}
387#ifdef CONFIG_SSB_BLOCKIO
388static inline void ssb_block_read(struct ssb_device *dev, void *buffer,
389 size_t count, u16 offset, u8 reg_width)
390{
391 dev->ops->block_read(dev, buffer, count, offset, reg_width);
392}
393
394static inline void ssb_block_write(struct ssb_device *dev, const void *buffer,
395 size_t count, u16 offset, u8 reg_width)
396{
397 dev->ops->block_write(dev, buffer, count, offset, reg_width);
398}
399#endif /* CONFIG_SSB_BLOCKIO */
367 400
368 401
369/* Translation (routing) bits that need to be ORed to DMA 402/* Translation (routing) bits that need to be ORed to DMA
@@ -416,5 +449,12 @@ extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
416extern u32 ssb_admatch_base(u32 adm); 449extern u32 ssb_admatch_base(u32 adm);
417extern u32 ssb_admatch_size(u32 adm); 450extern u32 ssb_admatch_size(u32 adm);
418 451
452/* PCI device mapping and fixup routines.
453 * Called from the architecture pcibios init code.
454 * These are only available on SSB_EMBEDDED configurations. */
455#ifdef CONFIG_SSB_EMBEDDED
456int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
457int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
458#endif /* CONFIG_SSB_EMBEDDED */
419 459
420#endif /* LINUX_SSB_H_ */ 460#endif /* LINUX_SSB_H_ */
diff --git a/include/linux/ssb/ssb_driver_chipcommon.h b/include/linux/ssb/ssb_driver_chipcommon.h
index 536851b946f6..7d7e03dcf77c 100644
--- a/include/linux/ssb/ssb_driver_chipcommon.h
+++ b/include/linux/ssb/ssb_driver_chipcommon.h
@@ -367,8 +367,7 @@ static inline bool ssb_chipco_available(struct ssb_chipcommon *cc)
367 367
368extern void ssb_chipcommon_init(struct ssb_chipcommon *cc); 368extern void ssb_chipcommon_init(struct ssb_chipcommon *cc);
369 369
370#include <linux/pm.h> 370extern void ssb_chipco_suspend(struct ssb_chipcommon *cc);
371extern void ssb_chipco_suspend(struct ssb_chipcommon *cc, pm_message_t state);
372extern void ssb_chipco_resume(struct ssb_chipcommon *cc); 371extern void ssb_chipco_resume(struct ssb_chipcommon *cc);
373 372
374extern void ssb_chipco_get_clockcpu(struct ssb_chipcommon *cc, 373extern void ssb_chipco_get_clockcpu(struct ssb_chipcommon *cc,
@@ -390,6 +389,10 @@ extern void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc,
390extern void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, 389extern void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc,
391 u32 ticks); 390 u32 ticks);
392 391
392void ssb_chipco_irq_mask(struct ssb_chipcommon *cc, u32 mask, u32 value);
393
394u32 ssb_chipco_irq_status(struct ssb_chipcommon *cc, u32 mask);
395
393/* Chipcommon GPIO pin access. */ 396/* Chipcommon GPIO pin access. */
394u32 ssb_chipco_gpio_in(struct ssb_chipcommon *cc, u32 mask); 397u32 ssb_chipco_gpio_in(struct ssb_chipcommon *cc, u32 mask);
395u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value); 398u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value);
diff --git a/include/linux/ssb/ssb_driver_gige.h b/include/linux/ssb/ssb_driver_gige.h
new file mode 100644
index 000000000000..01fbdf5fef22
--- /dev/null
+++ b/include/linux/ssb/ssb_driver_gige.h
@@ -0,0 +1,174 @@
1#ifndef LINUX_SSB_DRIVER_GIGE_H_
2#define LINUX_SSB_DRIVER_GIGE_H_
3
4#include <linux/ssb/ssb.h>
5#include <linux/pci.h>
6#include <linux/spinlock.h>
7
8
9#ifdef CONFIG_SSB_DRIVER_GIGE
10
11
12#define SSB_GIGE_PCIIO 0x0000 /* PCI I/O Registers (1024 bytes) */
13#define SSB_GIGE_RESERVED 0x0400 /* Reserved (1024 bytes) */
14#define SSB_GIGE_PCICFG 0x0800 /* PCI config space (256 bytes) */
15#define SSB_GIGE_SHIM_FLUSHSTAT 0x0C00 /* PCI to OCP: Flush status control (32bit) */
16#define SSB_GIGE_SHIM_FLUSHRDA 0x0C04 /* PCI to OCP: Flush read address (32bit) */
17#define SSB_GIGE_SHIM_FLUSHTO 0x0C08 /* PCI to OCP: Flush timeout counter (32bit) */
18#define SSB_GIGE_SHIM_BARRIER 0x0C0C /* PCI to OCP: Barrier register (32bit) */
19#define SSB_GIGE_SHIM_MAOCPSI 0x0C10 /* PCI to OCP: MaocpSI Control (32bit) */
20#define SSB_GIGE_SHIM_SIOCPMA 0x0C14 /* PCI to OCP: SiocpMa Control (32bit) */
21
22/* TM Status High flags */
23#define SSB_GIGE_TMSHIGH_RGMII 0x00010000 /* Have an RGMII PHY-bus */
24/* TM Status Low flags */
25#define SSB_GIGE_TMSLOW_TXBYPASS 0x00080000 /* TX bypass (no delay) */
26#define SSB_GIGE_TMSLOW_RXBYPASS 0x00100000 /* RX bypass (no delay) */
27#define SSB_GIGE_TMSLOW_DLLEN 0x01000000 /* Enable DLL controls */
28
29/* Boardflags (low) */
30#define SSB_GIGE_BFL_ROBOSWITCH 0x0010
31
32
33#define SSB_GIGE_MEM_RES_NAME "SSB Broadcom 47xx GigE memory"
34#define SSB_GIGE_IO_RES_NAME "SSB Broadcom 47xx GigE I/O"
35
36struct ssb_gige {
37 struct ssb_device *dev;
38
39 spinlock_t lock;
40
41 /* True, if the device has an RGMII bus.
42 * False, if the device has a GMII bus. */
43 bool has_rgmii;
44
45 /* The PCI controller device. */
46 struct pci_controller pci_controller;
47 struct pci_ops pci_ops;
48 struct resource mem_resource;
49 struct resource io_resource;
50};
51
52/* Check whether a PCI device is a SSB Gigabit Ethernet core. */
53extern bool pdev_is_ssb_gige_core(struct pci_dev *pdev);
54
55/* Convert a pci_dev pointer to a ssb_gige pointer. */
56static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
57{
58 if (!pdev_is_ssb_gige_core(pdev))
59 return NULL;
60 return container_of(pdev->bus->ops, struct ssb_gige, pci_ops);
61}
62
63/* Returns whether the PHY is connected by an RGMII bus. */
64static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
65{
66 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
67 return (dev ? dev->has_rgmii : 0);
68}
69
70/* Returns whether we have a Roboswitch. */
71static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
72{
73 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
74 if (dev)
75 return !!(dev->dev->bus->sprom.boardflags_lo &
76 SSB_GIGE_BFL_ROBOSWITCH);
77 return 0;
78}
79
80/* Returns whether we can only do one DMA at once. */
81static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
82{
83 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
84 if (dev)
85 return ((dev->dev->bus->chip_id == 0x4785) &&
86 (dev->dev->bus->chip_rev < 2));
87 return 0;
88}
89
90/* Returns whether we must flush posted writes. */
91static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
92{
93 struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
94 if (dev)
95 return (dev->dev->bus->chip_id == 0x4785);
96 return 0;
97}
98
99extern char * nvram_get(const char *name);
100/* Get the device MAC address */
101static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
102{
103#ifdef CONFIG_BCM947XX
104 char *res = nvram_get("et0macaddr");
105 if (res)
106 memcpy(macaddr, res, 6);
107#endif
108}
109
110extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
111 struct pci_dev *pdev);
112extern int ssb_gige_map_irq(struct ssb_device *sdev,
113 const struct pci_dev *pdev);
114
115/* The GigE driver is not a standalone module, because we don't have support
116 * for unregistering the driver. So we could not unload the module anyway. */
117extern int ssb_gige_init(void);
118static inline void ssb_gige_exit(void)
119{
120 /* Currently we can not unregister the GigE driver,
121 * because we can not unregister the PCI bridge. */
122 BUG();
123}
124
125
126#else /* CONFIG_SSB_DRIVER_GIGE */
127/* Gigabit Ethernet driver disabled */
128
129
130static inline int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
131 struct pci_dev *pdev)
132{
133 return -ENOSYS;
134}
135static inline int ssb_gige_map_irq(struct ssb_device *sdev,
136 const struct pci_dev *pdev)
137{
138 return -ENOSYS;
139}
140static inline int ssb_gige_init(void)
141{
142 return 0;
143}
144static inline void ssb_gige_exit(void)
145{
146}
147
148static inline bool pdev_is_ssb_gige_core(struct pci_dev *pdev)
149{
150 return 0;
151}
152static inline struct ssb_gige * pdev_to_ssb_gige(struct pci_dev *pdev)
153{
154 return NULL;
155}
156static inline bool ssb_gige_is_rgmii(struct pci_dev *pdev)
157{
158 return 0;
159}
160static inline bool ssb_gige_have_roboswitch(struct pci_dev *pdev)
161{
162 return 0;
163}
164static inline bool ssb_gige_one_dma_at_once(struct pci_dev *pdev)
165{
166 return 0;
167}
168static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
169{
170 return 0;
171}
172
173#endif /* CONFIG_SSB_DRIVER_GIGE */
174#endif /* LINUX_SSB_DRIVER_GIGE_H_ */
diff --git a/include/linux/ssb/ssb_driver_pci.h b/include/linux/ssb/ssb_driver_pci.h
index 5e25bac4ed31..41e330e51c2a 100644
--- a/include/linux/ssb/ssb_driver_pci.h
+++ b/include/linux/ssb/ssb_driver_pci.h
@@ -1,6 +1,11 @@
1#ifndef LINUX_SSB_PCICORE_H_ 1#ifndef LINUX_SSB_PCICORE_H_
2#define LINUX_SSB_PCICORE_H_ 2#define LINUX_SSB_PCICORE_H_
3 3
4#include <linux/types.h>
5
6struct pci_dev;
7
8
4#ifdef CONFIG_SSB_DRIVER_PCICORE 9#ifdef CONFIG_SSB_DRIVER_PCICORE
5 10
6/* PCI core registers. */ 11/* PCI core registers. */
@@ -88,6 +93,9 @@ extern void ssb_pcicore_init(struct ssb_pcicore *pc);
88extern int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc, 93extern int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
89 struct ssb_device *dev); 94 struct ssb_device *dev);
90 95
96int ssb_pcicore_plat_dev_init(struct pci_dev *d);
97int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
98
91 99
92#else /* CONFIG_SSB_DRIVER_PCICORE */ 100#else /* CONFIG_SSB_DRIVER_PCICORE */
93 101
@@ -107,5 +115,16 @@ int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
107 return 0; 115 return 0;
108} 116}
109 117
118static inline
119int ssb_pcicore_plat_dev_init(struct pci_dev *d)
120{
121 return -ENODEV;
122}
123static inline
124int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
125{
126 return -ENODEV;
127}
128
110#endif /* CONFIG_SSB_DRIVER_PCICORE */ 129#endif /* CONFIG_SSB_DRIVER_PCICORE */
111#endif /* LINUX_SSB_PCICORE_H_ */ 130#endif /* LINUX_SSB_PCICORE_H_ */
diff --git a/include/linux/string.h b/include/linux/string.h
index c5d3fcad7b57..efdc44593b52 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -109,5 +109,7 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp);
109extern char **argv_split(gfp_t gfp, const char *str, int *argcp); 109extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
110extern void argv_free(char **argv); 110extern void argv_free(char **argv);
111 111
112extern bool sysfs_streq(const char *s1, const char *s2);
113
112#endif 114#endif
113#endif /* _LINUX_STRING_H_ */ 115#endif /* _LINUX_STRING_H_ */
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
index 7a69ca3bebaf..3f632182d8eb 100644
--- a/include/linux/sunrpc/auth.h
+++ b/include/linux/sunrpc/auth.h
@@ -26,6 +26,7 @@ struct auth_cred {
26 uid_t uid; 26 uid_t uid;
27 gid_t gid; 27 gid_t gid;
28 struct group_info *group_info; 28 struct group_info *group_info;
29 unsigned char machine_cred : 1;
29}; 30};
30 31
31/* 32/*
@@ -59,8 +60,8 @@ struct rpc_cred {
59/* 60/*
60 * Client authentication handle 61 * Client authentication handle
61 */ 62 */
62#define RPC_CREDCACHE_NR 8 63#define RPC_CREDCACHE_HASHBITS 4
63#define RPC_CREDCACHE_MASK (RPC_CREDCACHE_NR - 1) 64#define RPC_CREDCACHE_NR (1 << RPC_CREDCACHE_HASHBITS)
64struct rpc_cred_cache { 65struct rpc_cred_cache {
65 struct hlist_head hashtable[RPC_CREDCACHE_NR]; 66 struct hlist_head hashtable[RPC_CREDCACHE_NR];
66 spinlock_t lock; 67 spinlock_t lock;
@@ -89,7 +90,6 @@ struct rpc_auth {
89 90
90/* Flags for rpcauth_lookupcred() */ 91/* Flags for rpcauth_lookupcred() */
91#define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */ 92#define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */
92#define RPCAUTH_LOOKUP_ROOTCREDS 0x02 /* This really ought to go! */
93 93
94/* 94/*
95 * Client authentication ops 95 * Client authentication ops
@@ -97,9 +97,7 @@ struct rpc_auth {
97struct rpc_authops { 97struct rpc_authops {
98 struct module *owner; 98 struct module *owner;
99 rpc_authflavor_t au_flavor; /* flavor (RPC_AUTH_*) */ 99 rpc_authflavor_t au_flavor; /* flavor (RPC_AUTH_*) */
100#ifdef RPC_DEBUG
101 char * au_name; 100 char * au_name;
102#endif
103 struct rpc_auth * (*create)(struct rpc_clnt *, rpc_authflavor_t); 101 struct rpc_auth * (*create)(struct rpc_clnt *, rpc_authflavor_t);
104 void (*destroy)(struct rpc_auth *); 102 void (*destroy)(struct rpc_auth *);
105 103
@@ -113,6 +111,7 @@ struct rpc_credops {
113 void (*crdestroy)(struct rpc_cred *); 111 void (*crdestroy)(struct rpc_cred *);
114 112
115 int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); 113 int (*crmatch)(struct auth_cred *, struct rpc_cred *, int);
114 void (*crbind)(struct rpc_task *, struct rpc_cred *);
116 __be32 * (*crmarshal)(struct rpc_task *, __be32 *); 115 __be32 * (*crmarshal)(struct rpc_task *, __be32 *);
117 int (*crrefresh)(struct rpc_task *); 116 int (*crrefresh)(struct rpc_task *);
118 __be32 * (*crvalidate)(struct rpc_task *, __be32 *); 117 __be32 * (*crvalidate)(struct rpc_task *, __be32 *);
@@ -126,9 +125,13 @@ extern const struct rpc_authops authunix_ops;
126extern const struct rpc_authops authnull_ops; 125extern const struct rpc_authops authnull_ops;
127 126
128void __init rpc_init_authunix(void); 127void __init rpc_init_authunix(void);
128void __init rpc_init_generic_auth(void);
129void __init rpcauth_init_module(void); 129void __init rpcauth_init_module(void);
130void __exit rpcauth_remove_module(void); 130void __exit rpcauth_remove_module(void);
131void __exit rpc_destroy_generic_auth(void);
131 132
133struct rpc_cred * rpc_lookup_cred(void);
134struct rpc_cred * rpc_lookup_machine_cred(void);
132int rpcauth_register(const struct rpc_authops *); 135int rpcauth_register(const struct rpc_authops *);
133int rpcauth_unregister(const struct rpc_authops *); 136int rpcauth_unregister(const struct rpc_authops *);
134struct rpc_auth * rpcauth_create(rpc_authflavor_t, struct rpc_clnt *); 137struct rpc_auth * rpcauth_create(rpc_authflavor_t, struct rpc_clnt *);
@@ -136,8 +139,8 @@ void rpcauth_release(struct rpc_auth *);
136struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int); 139struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int);
137void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); 140void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *);
138struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); 141struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int);
139struct rpc_cred * rpcauth_bindcred(struct rpc_task *); 142void rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int);
140void rpcauth_holdcred(struct rpc_task *); 143void rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *);
141void put_rpccred(struct rpc_cred *); 144void put_rpccred(struct rpc_cred *);
142void rpcauth_unbindcred(struct rpc_task *); 145void rpcauth_unbindcred(struct rpc_task *);
143__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); 146__be32 * rpcauth_marshcred(struct rpc_task *, __be32 *);
diff --git a/include/linux/sunrpc/auth_gss.h b/include/linux/sunrpc/auth_gss.h
index 67658e17a375..fec6899bf355 100644
--- a/include/linux/sunrpc/auth_gss.h
+++ b/include/linux/sunrpc/auth_gss.h
@@ -84,6 +84,7 @@ struct gss_cred {
84 enum rpc_gss_svc gc_service; 84 enum rpc_gss_svc gc_service;
85 struct gss_cl_ctx *gc_ctx; 85 struct gss_cl_ctx *gc_ctx;
86 struct gss_upcall_msg *gc_upcall; 86 struct gss_upcall_msg *gc_upcall;
87 unsigned char gc_machine_cred : 1;
87}; 88};
88 89
89#endif /* __KERNEL__ */ 90#endif /* __KERNEL__ */
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index 03547d6abee5..2d8b211b9324 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -120,7 +120,6 @@ struct cache_deferred_req {
120 struct list_head hash; /* on hash chain */ 120 struct list_head hash; /* on hash chain */
121 struct list_head recent; /* on fifo */ 121 struct list_head recent; /* on fifo */
122 struct cache_head *item; /* cache item we wait on */ 122 struct cache_head *item; /* cache item we wait on */
123 time_t recv_time;
124 void *owner; /* we might need to discard all defered requests 123 void *owner; /* we might need to discard all defered requests
125 * owned by someone */ 124 * owned by someone */
126 void (*revisit)(struct cache_deferred_req *req, 125 void (*revisit)(struct cache_deferred_req *req,
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 129a86e25d29..6fff7f82ef12 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -127,11 +127,12 @@ int 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_start(struct rpc_task *); 129void rpc_call_start(struct rpc_task *);
130int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, 130int rpc_call_async(struct rpc_clnt *clnt,
131 int flags, const struct rpc_call_ops *tk_ops, 131 const struct rpc_message *msg, int flags,
132 const struct rpc_call_ops *tk_ops,
132 void *calldata); 133 void *calldata);
133int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, 134int rpc_call_sync(struct rpc_clnt *clnt,
134 int flags); 135 const struct rpc_message *msg, int flags);
135struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, 136struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
136 int flags); 137 int flags);
137void rpc_restart_call(struct rpc_task *); 138void rpc_restart_call(struct rpc_task *);
diff --git a/include/linux/sunrpc/gss_krb5.h b/include/linux/sunrpc/gss_krb5.h
index 5a4b1e0206e3..a10f1fb0bf7c 100644
--- a/include/linux/sunrpc/gss_krb5.h
+++ b/include/linux/sunrpc/gss_krb5.h
@@ -70,8 +70,6 @@ enum seal_alg {
70 SEAL_ALG_DES3KD = 0x0002 70 SEAL_ALG_DES3KD = 0x0002
71}; 71};
72 72
73#define KRB5_CKSUM_LENGTH 8
74
75#define CKSUMTYPE_CRC32 0x0001 73#define CKSUMTYPE_CRC32 0x0001
76#define CKSUMTYPE_RSA_MD4 0x0002 74#define CKSUMTYPE_RSA_MD4 0x0002
77#define CKSUMTYPE_RSA_MD4_DES 0x0003 75#define CKSUMTYPE_RSA_MD4_DES 0x0003
@@ -150,9 +148,9 @@ gss_decrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *inbuf,
150s32 148s32
151krb5_make_seq_num(struct crypto_blkcipher *key, 149krb5_make_seq_num(struct crypto_blkcipher *key,
152 int direction, 150 int direction,
153 s32 seqnum, unsigned char *cksum, unsigned char *buf); 151 u32 seqnum, unsigned char *cksum, unsigned char *buf);
154 152
155s32 153s32
156krb5_get_seq_num(struct crypto_blkcipher *key, 154krb5_get_seq_num(struct crypto_blkcipher *key,
157 unsigned char *cksum, 155 unsigned char *cksum,
158 unsigned char *buf, int *direction, s32 * seqnum); 156 unsigned char *buf, int *direction, u32 *seqnum);
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index f689f02e6793..d1a5c8c1a0f1 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -11,7 +11,6 @@
11 11
12#include <linux/timer.h> 12#include <linux/timer.h>
13#include <linux/sunrpc/types.h> 13#include <linux/sunrpc/types.h>
14#include <linux/rcupdate.h>
15#include <linux/spinlock.h> 14#include <linux/spinlock.h>
16#include <linux/wait.h> 15#include <linux/wait.h>
17#include <linux/workqueue.h> 16#include <linux/workqueue.h>
@@ -33,7 +32,8 @@ struct rpc_wait_queue;
33struct rpc_wait { 32struct rpc_wait {
34 struct list_head list; /* wait queue links */ 33 struct list_head list; /* wait queue links */
35 struct list_head links; /* Links to related tasks */ 34 struct list_head links; /* Links to related tasks */
36 struct rpc_wait_queue * rpc_waitq; /* RPC wait queue we're on */ 35 struct list_head timer_list; /* Timer list */
36 unsigned long expires;
37}; 37};
38 38
39/* 39/*
@@ -57,33 +57,25 @@ struct rpc_task {
57 __u8 tk_cred_retry; 57 __u8 tk_cred_retry;
58 58
59 /* 59 /*
60 * timeout_fn to be executed by timer bottom half
61 * callback to be executed after waking up 60 * callback to be executed after waking up
62 * action next procedure for async tasks 61 * action next procedure for async tasks
63 * tk_ops caller callbacks 62 * tk_ops caller callbacks
64 */ 63 */
65 void (*tk_timeout_fn)(struct rpc_task *);
66 void (*tk_callback)(struct rpc_task *); 64 void (*tk_callback)(struct rpc_task *);
67 void (*tk_action)(struct rpc_task *); 65 void (*tk_action)(struct rpc_task *);
68 const struct rpc_call_ops *tk_ops; 66 const struct rpc_call_ops *tk_ops;
69 void * tk_calldata; 67 void * tk_calldata;
70 68
71 /*
72 * tk_timer is used for async processing by the RPC scheduling
73 * primitives. You should not access this directly unless
74 * you have a pathological interest in kernel oopses.
75 */
76 struct timer_list tk_timer; /* kernel timer */
77 unsigned long tk_timeout; /* timeout for rpc_sleep() */ 69 unsigned long tk_timeout; /* timeout for rpc_sleep() */
78 unsigned short tk_flags; /* misc flags */ 70 unsigned short tk_flags; /* misc flags */
79 unsigned long tk_runstate; /* Task run status */ 71 unsigned long tk_runstate; /* Task run status */
80 struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could 72 struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could
81 * be any workqueue 73 * be any workqueue
82 */ 74 */
75 struct rpc_wait_queue *tk_waitqueue; /* RPC wait queue we're on */
83 union { 76 union {
84 struct work_struct tk_work; /* Async task work queue */ 77 struct work_struct tk_work; /* Async task work queue */
85 struct rpc_wait tk_wait; /* RPC wait */ 78 struct rpc_wait tk_wait; /* RPC wait */
86 struct rcu_head tk_rcu; /* for task deletion */
87 } u; 79 } u;
88 80
89 unsigned short tk_timeouts; /* maj timeouts */ 81 unsigned short tk_timeouts; /* maj timeouts */
@@ -123,6 +115,7 @@ struct rpc_task_setup {
123 const struct rpc_message *rpc_message; 115 const struct rpc_message *rpc_message;
124 const struct rpc_call_ops *callback_ops; 116 const struct rpc_call_ops *callback_ops;
125 void *callback_data; 117 void *callback_data;
118 struct workqueue_struct *workqueue;
126 unsigned short flags; 119 unsigned short flags;
127 signed char priority; 120 signed char priority;
128}; 121};
@@ -147,9 +140,7 @@ struct rpc_task_setup {
147 140
148#define RPC_TASK_RUNNING 0 141#define RPC_TASK_RUNNING 0
149#define RPC_TASK_QUEUED 1 142#define RPC_TASK_QUEUED 1
150#define RPC_TASK_WAKEUP 2 143#define RPC_TASK_ACTIVE 2
151#define RPC_TASK_HAS_TIMER 3
152#define RPC_TASK_ACTIVE 4
153 144
154#define RPC_IS_RUNNING(t) test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) 145#define RPC_IS_RUNNING(t) test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate)
155#define rpc_set_running(t) set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) 146#define rpc_set_running(t) set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate)
@@ -171,15 +162,6 @@ struct rpc_task_setup {
171 smp_mb__after_clear_bit(); \ 162 smp_mb__after_clear_bit(); \
172 } while (0) 163 } while (0)
173 164
174#define rpc_start_wakeup(t) \
175 (test_and_set_bit(RPC_TASK_WAKEUP, &(t)->tk_runstate) == 0)
176#define rpc_finish_wakeup(t) \
177 do { \
178 smp_mb__before_clear_bit(); \
179 clear_bit(RPC_TASK_WAKEUP, &(t)->tk_runstate); \
180 smp_mb__after_clear_bit(); \
181 } while (0)
182
183#define RPC_IS_ACTIVATED(t) test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate) 165#define RPC_IS_ACTIVATED(t) test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate)
184 166
185/* 167/*
@@ -192,6 +174,12 @@ struct rpc_task_setup {
192#define RPC_PRIORITY_HIGH (1) 174#define RPC_PRIORITY_HIGH (1)
193#define RPC_NR_PRIORITY (1 + RPC_PRIORITY_HIGH - RPC_PRIORITY_LOW) 175#define RPC_NR_PRIORITY (1 + RPC_PRIORITY_HIGH - RPC_PRIORITY_LOW)
194 176
177struct rpc_timer {
178 struct timer_list timer;
179 struct list_head list;
180 unsigned long expires;
181};
182
195/* 183/*
196 * RPC synchronization objects 184 * RPC synchronization objects
197 */ 185 */
@@ -204,6 +192,7 @@ struct rpc_wait_queue {
204 unsigned char count; /* # task groups remaining serviced so far */ 192 unsigned char count; /* # task groups remaining serviced so far */
205 unsigned char nr; /* # tasks remaining for cookie */ 193 unsigned char nr; /* # tasks remaining for cookie */
206 unsigned short qlen; /* total # tasks waiting in queue */ 194 unsigned short qlen; /* total # tasks waiting in queue */
195 struct rpc_timer timer_list;
207#ifdef RPC_DEBUG 196#ifdef RPC_DEBUG
208 const char * name; 197 const char * name;
209#endif 198#endif
@@ -229,9 +218,11 @@ void rpc_killall_tasks(struct rpc_clnt *);
229void rpc_execute(struct rpc_task *); 218void rpc_execute(struct rpc_task *);
230void rpc_init_priority_wait_queue(struct rpc_wait_queue *, const char *); 219void rpc_init_priority_wait_queue(struct rpc_wait_queue *, const char *);
231void rpc_init_wait_queue(struct rpc_wait_queue *, const char *); 220void rpc_init_wait_queue(struct rpc_wait_queue *, const char *);
221void rpc_destroy_wait_queue(struct rpc_wait_queue *);
232void rpc_sleep_on(struct rpc_wait_queue *, struct rpc_task *, 222void rpc_sleep_on(struct rpc_wait_queue *, struct rpc_task *,
233 rpc_action action, rpc_action timer); 223 rpc_action action);
234void rpc_wake_up_task(struct rpc_task *); 224void rpc_wake_up_queued_task(struct rpc_wait_queue *,
225 struct rpc_task *);
235void rpc_wake_up(struct rpc_wait_queue *); 226void rpc_wake_up(struct rpc_wait_queue *);
236struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *); 227struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *);
237void rpc_wake_up_status(struct rpc_wait_queue *, int); 228void rpc_wake_up_status(struct rpc_wait_queue *, int);
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 64c97552964a..4b54c5fdcfd9 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -386,7 +386,6 @@ struct svc_serv * svc_create(struct svc_program *, unsigned int,
386 void (*shutdown)(struct svc_serv*)); 386 void (*shutdown)(struct svc_serv*));
387struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, 387struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
388 struct svc_pool *pool); 388 struct svc_pool *pool);
389int svc_create_thread(svc_thread_fn, struct svc_serv *);
390void svc_exit_thread(struct svc_rqst *); 389void svc_exit_thread(struct svc_rqst *);
391struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, 390struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
392 void (*shutdown)(struct svc_serv*), 391 void (*shutdown)(struct svc_serv*),
diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
index 22e1ef8e200e..d39dbdc7b10f 100644
--- a/include/linux/sunrpc/svcauth.h
+++ b/include/linux/sunrpc/svcauth.h
@@ -24,6 +24,7 @@ struct svc_cred {
24}; 24};
25 25
26struct svc_rqst; /* forward decl */ 26struct svc_rqst; /* forward decl */
27struct in6_addr;
27 28
28/* Authentication is done in the context of a domain. 29/* Authentication is done in the context of a domain.
29 * 30 *
@@ -120,10 +121,10 @@ extern void svc_auth_unregister(rpc_authflavor_t flavor);
120 121
121extern struct auth_domain *unix_domain_find(char *name); 122extern struct auth_domain *unix_domain_find(char *name);
122extern void auth_domain_put(struct auth_domain *item); 123extern void auth_domain_put(struct auth_domain *item);
123extern int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom); 124extern int auth_unix_add_addr(struct in6_addr *addr, struct auth_domain *dom);
124extern struct auth_domain *auth_domain_lookup(char *name, struct auth_domain *new); 125extern struct auth_domain *auth_domain_lookup(char *name, struct auth_domain *new);
125extern struct auth_domain *auth_domain_find(char *name); 126extern struct auth_domain *auth_domain_find(char *name);
126extern struct auth_domain *auth_unix_lookup(struct in_addr addr); 127extern struct auth_domain *auth_unix_lookup(struct in6_addr *addr);
127extern int auth_unix_forget_old(struct auth_domain *dom); 128extern int auth_unix_forget_old(struct auth_domain *dom);
128extern void svcauth_unix_purge(void); 129extern void svcauth_unix_purge(void);
129extern void svcauth_unix_info_release(void *); 130extern void svcauth_unix_info_release(void *);
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 206f092ad4c7..8cff696dedf5 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -26,8 +26,8 @@ struct svc_sock {
26 void (*sk_owspace)(struct sock *); 26 void (*sk_owspace)(struct sock *);
27 27
28 /* private TCP part */ 28 /* private TCP part */
29 int sk_reclen; /* length of record */ 29 u32 sk_reclen; /* length of record */
30 int sk_tcplen; /* current read length */ 30 u32 sk_tcplen; /* current read length */
31}; 31};
32 32
33/* 33/*
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index b3ff9a815e6f..4d80a118d538 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -86,6 +86,10 @@ struct rpc_rqst {
86 unsigned long rq_majortimeo; /* major timeout alarm */ 86 unsigned long rq_majortimeo; /* major timeout alarm */
87 unsigned long rq_timeout; /* Current timeout value */ 87 unsigned long rq_timeout; /* Current timeout value */
88 unsigned int rq_retries; /* # of retries */ 88 unsigned int rq_retries; /* # of retries */
89 unsigned int rq_connect_cookie;
90 /* A cookie used to track the
91 state of the transport
92 connection */
89 93
90 /* 94 /*
91 * Partial send handling 95 * Partial send handling
@@ -152,6 +156,9 @@ struct rpc_xprt {
152 unsigned long connect_timeout, 156 unsigned long connect_timeout,
153 bind_timeout, 157 bind_timeout,
154 reestablish_timeout; 158 reestablish_timeout;
159 unsigned int connect_cookie; /* A cookie that gets bumped
160 every time the transport
161 is reconnected */
155 162
156 /* 163 /*
157 * Disconnection of idle transports 164 * Disconnection of idle transports
@@ -232,7 +239,7 @@ int xprt_unregister_transport(struct xprt_class *type);
232void xprt_set_retrans_timeout_def(struct rpc_task *task); 239void xprt_set_retrans_timeout_def(struct rpc_task *task);
233void xprt_set_retrans_timeout_rtt(struct rpc_task *task); 240void xprt_set_retrans_timeout_rtt(struct rpc_task *task);
234void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status); 241void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status);
235void xprt_wait_for_buffer_space(struct rpc_task *task); 242void xprt_wait_for_buffer_space(struct rpc_task *task, rpc_action action);
236void xprt_write_space(struct rpc_xprt *xprt); 243void xprt_write_space(struct rpc_xprt *xprt);
237void xprt_update_rtt(struct rpc_task *task); 244void xprt_update_rtt(struct rpc_task *task);
238void xprt_adjust_cwnd(struct rpc_task *task, int result); 245void xprt_adjust_cwnd(struct rpc_task *task, int result);
@@ -241,6 +248,7 @@ void xprt_complete_rqst(struct rpc_task *task, int copied);
241void xprt_release_rqst_cong(struct rpc_task *task); 248void xprt_release_rqst_cong(struct rpc_task *task);
242void xprt_disconnect_done(struct rpc_xprt *xprt); 249void xprt_disconnect_done(struct rpc_xprt *xprt);
243void xprt_force_disconnect(struct rpc_xprt *xprt); 250void xprt_force_disconnect(struct rpc_xprt *xprt);
251void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie);
244 252
245/* 253/*
246 * Reserved bit positions in xprt->state 254 * Reserved bit positions in xprt->state
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 1d7d4c5797ee..a6977423baf7 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -12,11 +12,22 @@
12#include <asm/errno.h> 12#include <asm/errno.h>
13 13
14#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE) 14#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
15extern void pm_set_vt_switch(int);
15extern int pm_prepare_console(void); 16extern int pm_prepare_console(void);
16extern void pm_restore_console(void); 17extern void pm_restore_console(void);
17#else 18#else
18static inline int pm_prepare_console(void) { return 0; } 19static inline void pm_set_vt_switch(int do_switch)
19static inline void pm_restore_console(void) {} 20{
21}
22
23static inline int pm_prepare_console(void)
24{
25 return 0;
26}
27
28static inline void pm_restore_console(void)
29{
30}
20#endif 31#endif
21 32
22typedef int __bitwise suspend_state_t; 33typedef int __bitwise suspend_state_t;
diff --git a/include/linux/svga.h b/include/linux/svga.h
index 13ad0b82ac28..c59a51a2b0e7 100644
--- a/include/linux/svga.h
+++ b/include/linux/svga.h
@@ -1,8 +1,6 @@
1#ifndef _LINUX_SVGA_H 1#ifndef _LINUX_SVGA_H
2#define _LINUX_SVGA_H 2#define _LINUX_SVGA_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/pci.h> 4#include <linux/pci.h>
7#include <video/vga.h> 5#include <video/vga.h>
8 6
@@ -122,6 +120,5 @@ void svga_set_timings(const struct svga_timing_regs *tm, struct fb_var_screeninf
122 120
123int svga_match_format(const struct svga_fb_format *frm, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix); 121int svga_match_format(const struct svga_fb_format *frm, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix);
124 122
125#endif /* __KERNEL__ */
126#endif /* _LINUX_SVGA_H */ 123#endif /* _LINUX_SVGA_H */
127 124
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 878459ae0454..0b3377650c85 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -177,11 +177,11 @@ extern void activate_page(struct page *);
177extern void mark_page_accessed(struct page *); 177extern void mark_page_accessed(struct page *);
178extern void lru_add_drain(void); 178extern void lru_add_drain(void);
179extern int lru_add_drain_all(void); 179extern int lru_add_drain_all(void);
180extern int rotate_reclaimable_page(struct page *page); 180extern void rotate_reclaimable_page(struct page *page);
181extern void swap_setup(void); 181extern void swap_setup(void);
182 182
183/* linux/mm/vmscan.c */ 183/* linux/mm/vmscan.c */
184extern unsigned long try_to_free_pages(struct zone **zones, int order, 184extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
185 gfp_t gfp_mask); 185 gfp_t gfp_mask);
186extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, 186extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
187 gfp_t gfp_mask); 187 gfp_t gfp_mask);
diff --git a/include/linux/synclink.h b/include/linux/synclink.h
index 5562fbf72095..45f6bc82d317 100644
--- a/include/linux/synclink.h
+++ b/include/linux/synclink.h
@@ -13,10 +13,6 @@
13#define _SYNCLINK_H_ 13#define _SYNCLINK_H_
14#define SYNCLINK_H_VERSION 3.6 14#define SYNCLINK_H_VERSION 3.6
15 15
16#define BOOLEAN int
17#define TRUE 1
18#define FALSE 0
19
20#define BIT0 0x0001 16#define BIT0 0x0001
21#define BIT1 0x0002 17#define BIT1 0x0002
22#define BIT2 0x0004 18#define BIT2 0x0004
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 4c2577bd1c85..0522f368f9d7 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -60,7 +60,6 @@ struct getcpu_cache;
60#include <linux/capability.h> 60#include <linux/capability.h>
61#include <linux/list.h> 61#include <linux/list.h>
62#include <linux/sem.h> 62#include <linux/sem.h>
63#include <asm/semaphore.h>
64#include <asm/siginfo.h> 63#include <asm/siginfo.h>
65#include <asm/signal.h> 64#include <asm/signal.h>
66#include <linux/quota.h> 65#include <linux/quota.h>
@@ -241,26 +240,28 @@ asmlinkage long sys_truncate64(const char __user *path, loff_t length);
241asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length); 240asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length);
242#endif 241#endif
243 242
244asmlinkage long sys_setxattr(char __user *path, char __user *name, 243asmlinkage long sys_setxattr(const char __user *path, const char __user *name,
245 void __user *value, size_t size, int flags); 244 const void __user *value, size_t size, int flags);
246asmlinkage long sys_lsetxattr(char __user *path, char __user *name, 245asmlinkage long sys_lsetxattr(const char __user *path, const char __user *name,
247 void __user *value, size_t size, int flags); 246 const void __user *value, size_t size, int flags);
248asmlinkage long sys_fsetxattr(int fd, char __user *name, void __user *value, 247asmlinkage long sys_fsetxattr(int fd, const char __user *name,
249 size_t size, int flags); 248 const void __user *value, size_t size, int flags);
250asmlinkage ssize_t sys_getxattr(char __user *path, char __user *name, 249asmlinkage ssize_t sys_getxattr(const char __user *path, const char __user *name,
251 void __user *value, size_t size); 250 void __user *value, size_t size);
252asmlinkage ssize_t sys_lgetxattr(char __user *path, char __user *name, 251asmlinkage ssize_t sys_lgetxattr(const char __user *path, const char __user *name,
253 void __user *value, size_t size); 252 void __user *value, size_t size);
254asmlinkage ssize_t sys_fgetxattr(int fd, char __user *name, 253asmlinkage ssize_t sys_fgetxattr(int fd, const char __user *name,
255 void __user *value, size_t size); 254 void __user *value, size_t size);
256asmlinkage ssize_t sys_listxattr(char __user *path, char __user *list, 255asmlinkage ssize_t sys_listxattr(const char __user *path, char __user *list,
257 size_t size); 256 size_t size);
258asmlinkage ssize_t sys_llistxattr(char __user *path, char __user *list, 257asmlinkage ssize_t sys_llistxattr(const char __user *path, char __user *list,
259 size_t size); 258 size_t size);
260asmlinkage ssize_t sys_flistxattr(int fd, char __user *list, size_t size); 259asmlinkage ssize_t sys_flistxattr(int fd, char __user *list, size_t size);
261asmlinkage long sys_removexattr(char __user *path, char __user *name); 260asmlinkage long sys_removexattr(const char __user *path,
262asmlinkage long sys_lremovexattr(char __user *path, char __user *name); 261 const char __user *name);
263asmlinkage long sys_fremovexattr(int fd, char __user *name); 262asmlinkage long sys_lremovexattr(const char __user *path,
263 const char __user *name);
264asmlinkage long sys_fremovexattr(int fd, const char __user *name);
264 265
265asmlinkage unsigned long sys_brk(unsigned long brk); 266asmlinkage unsigned long sys_brk(unsigned long brk);
266asmlinkage long sys_mprotect(unsigned long start, size_t len, 267asmlinkage long sys_mprotect(unsigned long start, size_t len,
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 571f01d20a86..24141b4d1a11 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -945,11 +945,14 @@ enum
945/* For the /proc/sys support */ 945/* For the /proc/sys support */
946struct ctl_table; 946struct ctl_table;
947struct nsproxy; 947struct nsproxy;
948struct ctl_table_root;
949
948extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev); 950extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
949extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 951extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
950 struct ctl_table_header *prev); 952 struct ctl_table_header *prev);
951extern void sysctl_head_finish(struct ctl_table_header *prev); 953extern void sysctl_head_finish(struct ctl_table_header *prev);
952extern int sysctl_perm(struct ctl_table *table, int op); 954extern int sysctl_perm(struct ctl_table_root *root,
955 struct ctl_table *table, int op);
953 956
954typedef struct ctl_table ctl_table; 957typedef struct ctl_table ctl_table;
955 958
@@ -981,11 +984,6 @@ extern int do_sysctl (int __user *name, int nlen,
981 void __user *oldval, size_t __user *oldlenp, 984 void __user *oldval, size_t __user *oldlenp,
982 void __user *newval, size_t newlen); 985 void __user *newval, size_t newlen);
983 986
984extern int do_sysctl_strategy (struct ctl_table *table,
985 int __user *name, int nlen,
986 void __user *oldval, size_t __user *oldlenp,
987 void __user *newval, size_t newlen);
988
989extern ctl_handler sysctl_data; 987extern ctl_handler sysctl_data;
990extern ctl_handler sysctl_string; 988extern ctl_handler sysctl_string;
991extern ctl_handler sysctl_intvec; 989extern ctl_handler sysctl_intvec;
@@ -1054,6 +1052,8 @@ struct ctl_table_root {
1054 struct list_head header_list; 1052 struct list_head header_list;
1055 struct list_head *(*lookup)(struct ctl_table_root *root, 1053 struct list_head *(*lookup)(struct ctl_table_root *root,
1056 struct nsproxy *namespaces); 1054 struct nsproxy *namespaces);
1055 int (*permissions)(struct ctl_table_root *root,
1056 struct nsproxy *namespaces, struct ctl_table *table);
1057}; 1057};
1058 1058
1059/* struct ctl_table_header is used to maintain dynamic lists of 1059/* struct ctl_table_header is used to maintain dynamic lists of
@@ -1085,8 +1085,6 @@ struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1085void unregister_sysctl_table(struct ctl_table_header * table); 1085void unregister_sysctl_table(struct ctl_table_header * table);
1086int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table); 1086int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table);
1087 1087
1088#else /* __KERNEL__ */
1089
1090#endif /* __KERNEL__ */ 1088#endif /* __KERNEL__ */
1091 1089
1092#endif /* _LINUX_SYSCTL_H */ 1090#endif /* _LINUX_SYSCTL_H */
diff --git a/include/linux/sysdev.h b/include/linux/sysdev.h
index f752e73bf977..f2767bc6b735 100644
--- a/include/linux/sysdev.h
+++ b/include/linux/sysdev.h
@@ -45,12 +45,16 @@ struct sysdev_class_attribute {
45 ssize_t (*store)(struct sysdev_class *, const char *, size_t); 45 ssize_t (*store)(struct sysdev_class *, const char *, size_t);
46}; 46};
47 47
48#define SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \ 48#define _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \
49struct sysdev_class_attribute attr_##_name = { \ 49{ \
50 .attr = {.name = __stringify(_name), .mode = _mode }, \ 50 .attr = {.name = __stringify(_name), .mode = _mode }, \
51 .show = _show, \ 51 .show = _show, \
52 .store = _store, \ 52 .store = _store, \
53}; 53}
54
55#define SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \
56 struct sysdev_class_attribute attr_##_name = \
57 _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store)
54 58
55 59
56extern int sysdev_class_register(struct sysdev_class *); 60extern int sysdev_class_register(struct sysdev_class *);
@@ -100,15 +104,16 @@ struct sysdev_attribute {
100}; 104};
101 105
102 106
103#define _SYSDEV_ATTR(_name,_mode,_show,_store) \ 107#define _SYSDEV_ATTR(_name, _mode, _show, _store) \
104{ \ 108{ \
105 .attr = { .name = __stringify(_name), .mode = _mode }, \ 109 .attr = { .name = __stringify(_name), .mode = _mode }, \
106 .show = _show, \ 110 .show = _show, \
107 .store = _store, \ 111 .store = _store, \
108} 112}
109 113
110#define SYSDEV_ATTR(_name,_mode,_show,_store) \ 114#define SYSDEV_ATTR(_name, _mode, _show, _store) \
111struct sysdev_attribute attr_##_name = _SYSDEV_ATTR(_name,_mode,_show,_store); 115 struct sysdev_attribute attr_##_name = \
116 _SYSDEV_ATTR(_name, _mode, _show, _store);
112 117
113extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *); 118extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
114extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *); 119extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 802710438a9e..27bad59dae79 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -32,7 +32,7 @@ struct attribute {
32 32
33struct attribute_group { 33struct attribute_group {
34 const char *name; 34 const char *name;
35 int (*is_visible)(struct kobject *, 35 mode_t (*is_visible)(struct kobject *,
36 struct attribute *, int); 36 struct attribute *, int);
37 struct attribute **attrs; 37 struct attribute **attrs;
38}; 38};
@@ -105,6 +105,8 @@ void sysfs_remove_link(struct kobject *kobj, const char *name);
105 105
106int __must_check sysfs_create_group(struct kobject *kobj, 106int __must_check sysfs_create_group(struct kobject *kobj,
107 const struct attribute_group *grp); 107 const struct attribute_group *grp);
108int sysfs_update_group(struct kobject *kobj,
109 const struct attribute_group *grp);
108void sysfs_remove_group(struct kobject *kobj, 110void sysfs_remove_group(struct kobject *kobj,
109 const struct attribute_group *grp); 111 const struct attribute_group *grp);
110int sysfs_add_file_to_group(struct kobject *kobj, 112int sysfs_add_file_to_group(struct kobject *kobj,
@@ -131,7 +133,6 @@ static inline int sysfs_create_dir(struct kobject *kobj)
131 133
132static inline void sysfs_remove_dir(struct kobject *kobj) 134static inline void sysfs_remove_dir(struct kobject *kobj)
133{ 135{
134 ;
135} 136}
136 137
137static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name) 138static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
@@ -160,7 +161,6 @@ static inline int sysfs_chmod_file(struct kobject *kobj,
160static inline void sysfs_remove_file(struct kobject *kobj, 161static inline void sysfs_remove_file(struct kobject *kobj,
161 const struct attribute *attr) 162 const struct attribute *attr)
162{ 163{
163 ;
164} 164}
165 165
166static inline int sysfs_create_bin_file(struct kobject *kobj, 166static inline int sysfs_create_bin_file(struct kobject *kobj,
@@ -169,10 +169,9 @@ static inline int sysfs_create_bin_file(struct kobject *kobj,
169 return 0; 169 return 0;
170} 170}
171 171
172static inline int sysfs_remove_bin_file(struct kobject *kobj, 172static inline void sysfs_remove_bin_file(struct kobject *kobj,
173 struct bin_attribute *attr) 173 struct bin_attribute *attr)
174{ 174{
175 return 0;
176} 175}
177 176
178static inline int sysfs_create_link(struct kobject *kobj, 177static inline int sysfs_create_link(struct kobject *kobj,
@@ -183,7 +182,6 @@ static inline int sysfs_create_link(struct kobject *kobj,
183 182
184static inline void sysfs_remove_link(struct kobject *kobj, const char *name) 183static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
185{ 184{
186 ;
187} 185}
188 186
189static inline int sysfs_create_group(struct kobject *kobj, 187static inline int sysfs_create_group(struct kobject *kobj,
@@ -192,10 +190,21 @@ static inline int sysfs_create_group(struct kobject *kobj,
192 return 0; 190 return 0;
193} 191}
194 192
193static inline int sysfs_update_group(struct kobject *kobj,
194 const struct attribute_group *grp)
195{
196 return 0;
197}
198
199static inline int sysfs_update_group(struct kobject *kobj,
200 const struct attribute_group *grp)
201{
202 return 0;
203}
204
195static inline void sysfs_remove_group(struct kobject *kobj, 205static inline void sysfs_remove_group(struct kobject *kobj,
196 const struct attribute_group *grp) 206 const struct attribute_group *grp)
197{ 207{
198 ;
199} 208}
200 209
201static inline int sysfs_add_file_to_group(struct kobject *kobj, 210static inline int sysfs_add_file_to_group(struct kobject *kobj,
diff --git a/include/linux/sysv_fs.h b/include/linux/sysv_fs.h
index e0248631e461..96411306eec6 100644
--- a/include/linux/sysv_fs.h
+++ b/include/linux/sysv_fs.h
@@ -1,11 +1,7 @@
1#ifndef _LINUX_SYSV_FS_H 1#ifndef _LINUX_SYSV_FS_H
2#define _LINUX_SYSV_FS_H 2#define _LINUX_SYSV_FS_H
3 3
4#if defined(__GNUC__) 4#define __packed2__ __attribute__((packed, aligned(2)))
5# define __packed2__ __attribute__((packed, aligned(2)))
6#else
7>> I want to scream! <<
8#endif
9 5
10 6
11#ifndef __KERNEL__ 7#ifndef __KERNEL__
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 08027f1d7f31..d96d9b122304 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -239,6 +239,11 @@ static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)
239 return (struct tcp_request_sock *)req; 239 return (struct tcp_request_sock *)req;
240} 240}
241 241
242struct tcp_deferred_accept_info {
243 struct sock *listen_sk;
244 struct request_sock *request;
245};
246
242struct tcp_sock { 247struct tcp_sock {
243 /* inet_connection_sock has to be the first member of tcp_sock */ 248 /* inet_connection_sock has to be the first member of tcp_sock */
244 struct inet_connection_sock inet_conn; 249 struct inet_connection_sock inet_conn;
@@ -374,6 +379,8 @@ struct tcp_sock {
374 unsigned int keepalive_intvl; /* time interval between keep alive probes */ 379 unsigned int keepalive_intvl; /* time interval between keep alive probes */
375 int linger2; 380 int linger2;
376 381
382 struct tcp_deferred_accept_info defer_tcp_accept;
383
377 unsigned long last_synq_overflow; 384 unsigned long last_synq_overflow;
378 385
379 u32 tso_deferred; 386 u32 tso_deferred;
diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h
index 004808a6df1d..6f371f24160b 100644
--- a/include/linux/textsearch.h
+++ b/include/linux/textsearch.h
@@ -1,8 +1,6 @@
1#ifndef __LINUX_TEXTSEARCH_H 1#ifndef __LINUX_TEXTSEARCH_H
2#define __LINUX_TEXTSEARCH_H 2#define __LINUX_TEXTSEARCH_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/types.h> 4#include <linux/types.h>
7#include <linux/list.h> 5#include <linux/list.h>
8#include <linux/kernel.h> 6#include <linux/kernel.h>
@@ -177,6 +175,4 @@ static inline void *ts_config_priv(struct ts_config *conf)
177 return ((u8 *) conf + TS_PRIV_ALIGN(sizeof(struct ts_config))); 175 return ((u8 *) conf + TS_PRIV_ALIGN(sizeof(struct ts_config)));
178} 176}
179 177
180#endif /* __KERNEL__ */
181
182#endif 178#endif
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 90c1c191ea69..06d3e6eb9ca8 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -41,6 +41,7 @@ struct thermal_zone_device_ops {
41 int (*set_mode) (struct thermal_zone_device *, const char *); 41 int (*set_mode) (struct thermal_zone_device *, const char *);
42 int (*get_trip_type) (struct thermal_zone_device *, int, char *); 42 int (*get_trip_type) (struct thermal_zone_device *, int, char *);
43 int (*get_trip_temp) (struct thermal_zone_device *, int, char *); 43 int (*get_trip_temp) (struct thermal_zone_device *, int, char *);
44 int (*get_crit_temp) (struct thermal_zone_device *, unsigned long *);
44}; 45};
45 46
46struct thermal_cooling_device_ops { 47struct thermal_cooling_device_ops {
@@ -65,6 +66,23 @@ struct thermal_cooling_device {
65 ((long)t-2732+5)/10 : ((long)t-2732-5)/10) 66 ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
66#define CELSIUS_TO_KELVIN(t) ((t)*10+2732) 67#define CELSIUS_TO_KELVIN(t) ((t)*10+2732)
67 68
69#if defined(CONFIG_HWMON) || \
70 (defined(CONFIG_HWMON_MODULE) && defined(CONFIG_THERMAL_MODULE))
71/* thermal zone devices with the same type share one hwmon device */
72struct thermal_hwmon_device {
73 char type[THERMAL_NAME_LENGTH];
74 struct device *device;
75 int count;
76 struct list_head tz_list;
77 struct list_head node;
78};
79
80struct thermal_hwmon_attr {
81 struct device_attribute attr;
82 char name[16];
83};
84#endif
85
68struct thermal_zone_device { 86struct thermal_zone_device {
69 int id; 87 int id;
70 char type[THERMAL_NAME_LENGTH]; 88 char type[THERMAL_NAME_LENGTH];
@@ -76,6 +94,13 @@ struct thermal_zone_device {
76 struct idr idr; 94 struct idr idr;
77 struct mutex lock; /* protect cooling devices list */ 95 struct mutex lock; /* protect cooling devices list */
78 struct list_head node; 96 struct list_head node;
97#if defined(CONFIG_HWMON) || \
98 (defined(CONFIG_HWMON_MODULE) && defined(CONFIG_THERMAL_MODULE))
99 struct list_head hwmon_node;
100 struct thermal_hwmon_device *hwmon;
101 struct thermal_hwmon_attr temp_input; /* hwmon sys attr */
102 struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */
103#endif
79}; 104};
80 105
81struct thermal_zone_device *thermal_zone_device_register(char *, int, void *, 106struct thermal_zone_device *thermal_zone_device_register(char *, int, void *,
@@ -88,24 +113,10 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
88 struct thermal_cooling_device *); 113 struct thermal_cooling_device *);
89int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int, 114int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
90 struct thermal_cooling_device *); 115 struct thermal_cooling_device *);
91
92#ifdef CONFIG_THERMAL
93struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, 116struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
94 struct 117 struct
95 thermal_cooling_device_ops 118 thermal_cooling_device_ops
96 *); 119 *);
97void thermal_cooling_device_unregister(struct thermal_cooling_device *); 120void thermal_cooling_device_unregister(struct thermal_cooling_device *);
98#else
99static inline struct thermal_cooling_device
100*thermal_cooling_device_register(char *c, void *v,
101 struct thermal_cooling_device_ops *t)
102{
103 return NULL;
104}
105static inline
106 void thermal_cooling_device_unregister(struct thermal_cooling_device *t)
107{
108};
109#endif
110 121
111#endif /* __THERMAL_H__ */ 122#endif /* __THERMAL_H__ */
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 421323e5a2d6..38a56477f27a 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -9,6 +9,9 @@
9 9
10#include <linux/types.h> 10#include <linux/types.h>
11 11
12struct timespec;
13struct compat_timespec;
14
12/* 15/*
13 * System call restart block. 16 * System call restart block.
14 */ 17 */
@@ -26,6 +29,15 @@ struct restart_block {
26 u32 bitset; 29 u32 bitset;
27 u64 time; 30 u64 time;
28 } futex; 31 } futex;
32 /* For nanosleep */
33 struct {
34 clockid_t index;
35 struct timespec __user *rmtp;
36#ifdef CONFIG_COMPAT
37 struct compat_timespec __user *compat_rmtp;
38#endif
39 u64 expires;
40 } nanosleep;
29 }; 41 };
30}; 42};
31 43
@@ -80,6 +92,31 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
80#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED) 92#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
81#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED) 93#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
82 94
83#endif 95#if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK
96/*
97 * An arch can define its own version of set_restore_sigmask() to get the
98 * job done however works, with or without TIF_RESTORE_SIGMASK.
99 */
100#define HAVE_SET_RESTORE_SIGMASK 1
101
102/**
103 * set_restore_sigmask() - make sure saved_sigmask processing gets done
104 *
105 * This sets TIF_RESTORE_SIGMASK and ensures that the arch signal code
106 * will run before returning to user mode, to process the flag. For
107 * all callers, TIF_SIGPENDING is already set or it's no harm to set
108 * it. TIF_RESTORE_SIGMASK need not be in the set of bits that the
109 * arch code will notice on return to user mode, in case those bits
110 * are scarce. We set TIF_SIGPENDING here to ensure that the arch
111 * signal code always gets run when TIF_RESTORE_SIGMASK is set.
112 */
113static inline void set_restore_sigmask(void)
114{
115 set_thread_flag(TIF_RESTORE_SIGMASK);
116 set_thread_flag(TIF_SIGPENDING);
117}
118#endif /* TIF_RESTORE_SIGMASK && !HAVE_SET_RESTORE_SIGMASK */
119
120#endif /* __KERNEL__ */
84 121
85#endif /* _LINUX_THREAD_INFO_H */ 122#endif /* _LINUX_THREAD_INFO_H */
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 979fefdeb862..d4ba79248a27 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -4,6 +4,7 @@
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/ktime.h> 5#include <linux/ktime.h>
6#include <linux/stddef.h> 6#include <linux/stddef.h>
7#include <linux/debugobjects.h>
7 8
8struct tvec_base; 9struct tvec_base;
9 10
@@ -25,6 +26,7 @@ struct timer_list {
25extern struct tvec_base boot_tvec_bases; 26extern struct tvec_base boot_tvec_bases;
26 27
27#define TIMER_INITIALIZER(_function, _expires, _data) { \ 28#define TIMER_INITIALIZER(_function, _expires, _data) { \
29 .entry = { .prev = TIMER_ENTRY_STATIC }, \
28 .function = (_function), \ 30 .function = (_function), \
29 .expires = (_expires), \ 31 .expires = (_expires), \
30 .data = (_data), \ 32 .data = (_data), \
@@ -38,6 +40,17 @@ extern struct tvec_base boot_tvec_bases;
38void init_timer(struct timer_list *timer); 40void init_timer(struct timer_list *timer);
39void init_timer_deferrable(struct timer_list *timer); 41void init_timer_deferrable(struct timer_list *timer);
40 42
43#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
44extern void init_timer_on_stack(struct timer_list *timer);
45extern void destroy_timer_on_stack(struct timer_list *timer);
46#else
47static inline void destroy_timer_on_stack(struct timer_list *timer) { }
48static inline void init_timer_on_stack(struct timer_list *timer)
49{
50 init_timer(timer);
51}
52#endif
53
41static inline void setup_timer(struct timer_list * timer, 54static inline void setup_timer(struct timer_list * timer,
42 void (*function)(unsigned long), 55 void (*function)(unsigned long),
43 unsigned long data) 56 unsigned long data)
@@ -47,6 +60,15 @@ static inline void setup_timer(struct timer_list * timer,
47 init_timer(timer); 60 init_timer(timer);
48} 61}
49 62
63static inline void setup_timer_on_stack(struct timer_list *timer,
64 void (*function)(unsigned long),
65 unsigned long data)
66{
67 timer->function = function;
68 timer->data = data;
69 init_timer_on_stack(timer);
70}
71
50/** 72/**
51 * timer_pending - is a timer pending? 73 * timer_pending - is a timer pending?
52 * @timer: the timer in question 74 * @timer: the timer in question
@@ -164,5 +186,4 @@ unsigned long __round_jiffies_relative(unsigned long j, int cpu);
164unsigned long round_jiffies(unsigned long j); 186unsigned long round_jiffies(unsigned long j);
165unsigned long round_jiffies_relative(unsigned long j); 187unsigned long round_jiffies_relative(unsigned long j);
166 188
167
168#endif 189#endif
diff --git a/include/linux/timex.h b/include/linux/timex.h
index 8ea3e71ba7fa..fc6035d29d56 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -58,6 +58,8 @@
58 58
59#include <asm/param.h> 59#include <asm/param.h>
60 60
61#define NTP_API 4 /* NTP API version */
62
61/* 63/*
62 * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen 64 * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
63 * for a slightly underdamped convergence characteristic. SHIFT_KH 65 * for a slightly underdamped convergence characteristic. SHIFT_KH
@@ -74,24 +76,22 @@
74#define MAXTC 10 /* maximum time constant (shift) */ 76#define MAXTC 10 /* maximum time constant (shift) */
75 77
76/* 78/*
77 * The SHIFT_UPDATE define establishes the decimal point of the
78 * time_offset variable which represents the current offset with
79 * respect to standard time.
80 *
81 * SHIFT_USEC defines the scaling (shift) of the time_freq and 79 * SHIFT_USEC defines the scaling (shift) of the time_freq and
82 * time_tolerance variables, which represent the current frequency 80 * time_tolerance variables, which represent the current frequency
83 * offset and maximum frequency tolerance. 81 * offset and maximum frequency tolerance.
84 */ 82 */
85#define SHIFT_UPDATE (SHIFT_HZ + 1) /* time offset scale (shift) */
86#define SHIFT_USEC 16 /* frequency offset scale (shift) */ 83#define SHIFT_USEC 16 /* frequency offset scale (shift) */
87#define SHIFT_NSEC 12 /* kernel frequency offset scale */ 84#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
88 85#define PPM_SCALE_INV_SHIFT 20
89#define MAXPHASE 512000L /* max phase error (us) */ 86#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
90#define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */ 87 PPM_SCALE + 1)
91#define MAXFREQ_NSEC (512000L << SHIFT_NSEC) /* max frequency error (ppb) */ 88
89#define MAXPHASE 500000000l /* max phase error (ns) */
90#define MAXFREQ 500000 /* max frequency error (ns/s) */
91#define MAXFREQ_SCALED ((s64)MAXFREQ << NTP_SCALE_SHIFT)
92#define MINSEC 256 /* min interval between updates (s) */ 92#define MINSEC 256 /* min interval between updates (s) */
93#define MAXSEC 2048 /* max interval between updates (s) */ 93#define MAXSEC 2048 /* max interval between updates (s) */
94#define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */ 94#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) << 5) /* beyond max. dispersion */
95 95
96/* 96/*
97 * syscall interface - used (mainly by NTP daemon) 97 * syscall interface - used (mainly by NTP daemon)
@@ -121,9 +121,11 @@ struct timex {
121 long errcnt; /* calibration errors (ro) */ 121 long errcnt; /* calibration errors (ro) */
122 long stbcnt; /* stability limit exceeded (ro) */ 122 long stbcnt; /* stability limit exceeded (ro) */
123 123
124 int tai; /* TAI offset (ro) */
125
124 int :32; int :32; int :32; int :32; 126 int :32; int :32; int :32; int :32;
125 int :32; int :32; int :32; int :32; 127 int :32; int :32; int :32; int :32;
126 int :32; int :32; int :32; int :32; 128 int :32; int :32; int :32;
127}; 129};
128 130
129/* 131/*
@@ -135,6 +137,9 @@ struct timex {
135#define ADJ_ESTERROR 0x0008 /* estimated time error */ 137#define ADJ_ESTERROR 0x0008 /* estimated time error */
136#define ADJ_STATUS 0x0010 /* clock status */ 138#define ADJ_STATUS 0x0010 /* clock status */
137#define ADJ_TIMECONST 0x0020 /* pll time constant */ 139#define ADJ_TIMECONST 0x0020 /* pll time constant */
140#define ADJ_TAI 0x0080 /* set TAI offset */
141#define ADJ_MICRO 0x1000 /* select microsecond resolution */
142#define ADJ_NANO 0x2000 /* select nanosecond resolution */
138#define ADJ_TICK 0x4000 /* tick value */ 143#define ADJ_TICK 0x4000 /* tick value */
139#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ 144#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
140#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ 145#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
@@ -146,8 +151,6 @@ struct timex {
146#define MOD_ESTERROR ADJ_ESTERROR 151#define MOD_ESTERROR ADJ_ESTERROR
147#define MOD_STATUS ADJ_STATUS 152#define MOD_STATUS ADJ_STATUS
148#define MOD_TIMECONST ADJ_TIMECONST 153#define MOD_TIMECONST ADJ_TIMECONST
149#define MOD_CLKB ADJ_TICK
150#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
151 154
152 155
153/* 156/*
@@ -169,9 +172,13 @@ struct timex {
169#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ 172#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
170 173
171#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ 174#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
175#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
176#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
177#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
172 178
179/* read-only bits */
173#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ 180#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
174 STA_PPSERROR | STA_CLOCKERR) /* read-only bits */ 181 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
175 182
176/* 183/*
177 * Clock states (time_state) 184 * Clock states (time_state)
@@ -203,10 +210,9 @@ extern int time_status; /* clock synchronization status bits */
203extern long time_maxerror; /* maximum error */ 210extern long time_maxerror; /* maximum error */
204extern long time_esterror; /* estimated error */ 211extern long time_esterror; /* estimated error */
205 212
206extern long time_freq; /* frequency offset (scaled ppm) */
207
208extern long time_adjust; /* The amount of adjtime left */ 213extern long time_adjust; /* The amount of adjtime left */
209 214
215extern void ntp_init(void);
210extern void ntp_clear(void); 216extern void ntp_clear(void);
211 217
212/** 218/**
@@ -225,7 +231,7 @@ static inline int ntp_synced(void)
225 __x < 0 ? -(-__x >> __s) : __x >> __s; \ 231 __x < 0 ? -(-__x >> __s) : __x >> __s; \
226}) 232})
227 233
228#define TICK_LENGTH_SHIFT 32 234#define NTP_SCALE_SHIFT 32
229 235
230#ifdef CONFIG_NO_HZ 236#ifdef CONFIG_NO_HZ
231#define NTP_INTERVAL_FREQ (2) 237#define NTP_INTERVAL_FREQ (2)
@@ -234,8 +240,8 @@ static inline int ntp_synced(void)
234#endif 240#endif
235#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) 241#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ)
236 242
237/* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */ 243/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
238extern u64 current_tick_length(void); 244extern u64 tick_length;
239 245
240extern void second_overflow(void); 246extern void second_overflow(void);
241extern void update_ntp_one_tick(void); 247extern void update_ntp_one_tick(void);
diff --git a/include/linux/topology.h b/include/linux/topology.h
index bd14f8b30f09..4bb7074a2c3a 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -38,16 +38,15 @@
38#endif 38#endif
39 39
40#ifndef nr_cpus_node 40#ifndef nr_cpus_node
41#define nr_cpus_node(node) \ 41#define nr_cpus_node(node) \
42 ({ \ 42 ({ \
43 cpumask_t __tmp__; \ 43 node_to_cpumask_ptr(__tmp__, node); \
44 __tmp__ = node_to_cpumask(node); \ 44 cpus_weight(*__tmp__); \
45 cpus_weight(__tmp__); \
46 }) 45 })
47#endif 46#endif
48 47
49#define for_each_node_with_cpus(node) \ 48#define for_each_node_with_cpus(node) \
50 for_each_online_node(node) \ 49 for_each_online_node(node) \
51 if (nr_cpus_node(node)) 50 if (nr_cpus_node(node))
52 51
53void arch_update_cpu_topology(void); 52void arch_update_cpu_topology(void);
@@ -80,7 +79,9 @@ void arch_update_cpu_topology(void);
80 * by defining their own arch-specific initializer in include/asm/topology.h. 79 * by defining their own arch-specific initializer in include/asm/topology.h.
81 * A definition there will automagically override these default initializers 80 * A definition there will automagically override these default initializers
82 * and allow arch-specific performance tuning of sched_domains. 81 * and allow arch-specific performance tuning of sched_domains.
82 * (Only non-zero and non-null fields need be specified.)
83 */ 83 */
84
84#ifdef CONFIG_SCHED_SMT 85#ifdef CONFIG_SCHED_SMT
85/* MCD - Do we really need this? It is always on if CONFIG_SCHED_SMT is, 86/* MCD - Do we really need this? It is always on if CONFIG_SCHED_SMT is,
86 * so can't we drop this in favor of CONFIG_SCHED_SMT? 87 * so can't we drop this in favor of CONFIG_SCHED_SMT?
@@ -89,20 +90,10 @@ void arch_update_cpu_topology(void);
89/* Common values for SMT siblings */ 90/* Common values for SMT siblings */
90#ifndef SD_SIBLING_INIT 91#ifndef SD_SIBLING_INIT
91#define SD_SIBLING_INIT (struct sched_domain) { \ 92#define SD_SIBLING_INIT (struct sched_domain) { \
92 .span = CPU_MASK_NONE, \
93 .parent = NULL, \
94 .child = NULL, \
95 .groups = NULL, \
96 .min_interval = 1, \ 93 .min_interval = 1, \
97 .max_interval = 2, \ 94 .max_interval = 2, \
98 .busy_factor = 64, \ 95 .busy_factor = 64, \
99 .imbalance_pct = 110, \ 96 .imbalance_pct = 110, \
100 .cache_nice_tries = 0, \
101 .busy_idx = 0, \
102 .idle_idx = 0, \
103 .newidle_idx = 0, \
104 .wake_idx = 0, \
105 .forkexec_idx = 0, \
106 .flags = SD_LOAD_BALANCE \ 97 .flags = SD_LOAD_BALANCE \
107 | SD_BALANCE_NEWIDLE \ 98 | SD_BALANCE_NEWIDLE \
108 | SD_BALANCE_FORK \ 99 | SD_BALANCE_FORK \
@@ -112,7 +103,6 @@ void arch_update_cpu_topology(void);
112 | SD_SHARE_CPUPOWER, \ 103 | SD_SHARE_CPUPOWER, \
113 .last_balance = jiffies, \ 104 .last_balance = jiffies, \
114 .balance_interval = 1, \ 105 .balance_interval = 1, \
115 .nr_balance_failed = 0, \
116} 106}
117#endif 107#endif
118#endif /* CONFIG_SCHED_SMT */ 108#endif /* CONFIG_SCHED_SMT */
@@ -121,18 +111,12 @@ void arch_update_cpu_topology(void);
121/* Common values for MC siblings. for now mostly derived from SD_CPU_INIT */ 111/* Common values for MC siblings. for now mostly derived from SD_CPU_INIT */
122#ifndef SD_MC_INIT 112#ifndef SD_MC_INIT
123#define SD_MC_INIT (struct sched_domain) { \ 113#define SD_MC_INIT (struct sched_domain) { \
124 .span = CPU_MASK_NONE, \
125 .parent = NULL, \
126 .child = NULL, \
127 .groups = NULL, \
128 .min_interval = 1, \ 114 .min_interval = 1, \
129 .max_interval = 4, \ 115 .max_interval = 4, \
130 .busy_factor = 64, \ 116 .busy_factor = 64, \
131 .imbalance_pct = 125, \ 117 .imbalance_pct = 125, \
132 .cache_nice_tries = 1, \ 118 .cache_nice_tries = 1, \
133 .busy_idx = 2, \ 119 .busy_idx = 2, \
134 .idle_idx = 0, \
135 .newidle_idx = 0, \
136 .wake_idx = 1, \ 120 .wake_idx = 1, \
137 .forkexec_idx = 1, \ 121 .forkexec_idx = 1, \
138 .flags = SD_LOAD_BALANCE \ 122 .flags = SD_LOAD_BALANCE \
@@ -144,7 +128,6 @@ void arch_update_cpu_topology(void);
144 | BALANCE_FOR_MC_POWER, \ 128 | BALANCE_FOR_MC_POWER, \
145 .last_balance = jiffies, \ 129 .last_balance = jiffies, \
146 .balance_interval = 1, \ 130 .balance_interval = 1, \
147 .nr_balance_failed = 0, \
148} 131}
149#endif 132#endif
150#endif /* CONFIG_SCHED_MC */ 133#endif /* CONFIG_SCHED_MC */
@@ -152,10 +135,6 @@ void arch_update_cpu_topology(void);
152/* Common values for CPUs */ 135/* Common values for CPUs */
153#ifndef SD_CPU_INIT 136#ifndef SD_CPU_INIT
154#define SD_CPU_INIT (struct sched_domain) { \ 137#define SD_CPU_INIT (struct sched_domain) { \
155 .span = CPU_MASK_NONE, \
156 .parent = NULL, \
157 .child = NULL, \
158 .groups = NULL, \
159 .min_interval = 1, \ 138 .min_interval = 1, \
160 .max_interval = 4, \ 139 .max_interval = 4, \
161 .busy_factor = 64, \ 140 .busy_factor = 64, \
@@ -174,16 +153,11 @@ void arch_update_cpu_topology(void);
174 | BALANCE_FOR_PKG_POWER,\ 153 | BALANCE_FOR_PKG_POWER,\
175 .last_balance = jiffies, \ 154 .last_balance = jiffies, \
176 .balance_interval = 1, \ 155 .balance_interval = 1, \
177 .nr_balance_failed = 0, \
178} 156}
179#endif 157#endif
180 158
181/* sched_domains SD_ALLNODES_INIT for NUMA machines */ 159/* sched_domains SD_ALLNODES_INIT for NUMA machines */
182#define SD_ALLNODES_INIT (struct sched_domain) { \ 160#define SD_ALLNODES_INIT (struct sched_domain) { \
183 .span = CPU_MASK_NONE, \
184 .parent = NULL, \
185 .child = NULL, \
186 .groups = NULL, \
187 .min_interval = 64, \ 161 .min_interval = 64, \
188 .max_interval = 64*num_online_cpus(), \ 162 .max_interval = 64*num_online_cpus(), \
189 .busy_factor = 128, \ 163 .busy_factor = 128, \
@@ -191,14 +165,10 @@ void arch_update_cpu_topology(void);
191 .cache_nice_tries = 1, \ 165 .cache_nice_tries = 1, \
192 .busy_idx = 3, \ 166 .busy_idx = 3, \
193 .idle_idx = 3, \ 167 .idle_idx = 3, \
194 .newidle_idx = 0, /* unused */ \
195 .wake_idx = 0, /* unused */ \
196 .forkexec_idx = 0, /* unused */ \
197 .flags = SD_LOAD_BALANCE \ 168 .flags = SD_LOAD_BALANCE \
198 | SD_SERIALIZE, \ 169 | SD_SERIALIZE, \
199 .last_balance = jiffies, \ 170 .last_balance = jiffies, \
200 .balance_interval = 64, \ 171 .balance_interval = 64, \
201 .nr_balance_failed = 0, \
202} 172}
203 173
204#ifdef CONFIG_NUMA 174#ifdef CONFIG_NUMA
diff --git a/include/linux/transport_class.h b/include/linux/transport_class.h
index 1d6cc22e5f42..eaec1ea9558e 100644
--- a/include/linux/transport_class.h
+++ b/include/linux/transport_class.h
@@ -17,11 +17,11 @@ struct transport_container;
17struct transport_class { 17struct transport_class {
18 struct class class; 18 struct class class;
19 int (*setup)(struct transport_container *, struct device *, 19 int (*setup)(struct transport_container *, struct device *,
20 struct class_device *); 20 struct device *);
21 int (*configure)(struct transport_container *, struct device *, 21 int (*configure)(struct transport_container *, struct device *,
22 struct class_device *); 22 struct device *);
23 int (*remove)(struct transport_container *, struct device *, 23 int (*remove)(struct transport_container *, struct device *,
24 struct class_device *); 24 struct device *);
25}; 25};
26 26
27#define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg) \ 27#define DECLARE_TRANSPORT_CLASS(cls, nm, su, rm, cfg) \
@@ -86,9 +86,10 @@ static inline int transport_container_register(struct transport_container *tc)
86 return attribute_container_register(&tc->ac); 86 return attribute_container_register(&tc->ac);
87} 87}
88 88
89static inline int transport_container_unregister(struct transport_container *tc) 89static inline void transport_container_unregister(struct transport_container *tc)
90{ 90{
91 return attribute_container_unregister(&tc->ac); 91 if (unlikely(attribute_container_unregister(&tc->ac)))
92 BUG();
92} 93}
93 94
94int transport_class_register(struct transport_class *); 95int transport_class_register(struct transport_class *);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index dd8e08fe8855..7f7121f9c968 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -177,27 +177,33 @@ struct signal_struct;
177 * size each time the window is created or resized anyway. 177 * size each time the window is created or resized anyway.
178 * - TYT, 9/14/92 178 * - TYT, 9/14/92
179 */ 179 */
180
181struct tty_operations;
182
180struct tty_struct { 183struct tty_struct {
181 int magic; 184 int magic;
182 struct tty_driver *driver; 185 struct tty_driver *driver;
186 const struct tty_operations *ops;
183 int index; 187 int index;
184 struct tty_ldisc ldisc; 188 struct tty_ldisc ldisc;
185 struct mutex termios_mutex; 189 struct mutex termios_mutex;
190 spinlock_t ctrl_lock;
191 /* Termios values are protected by the termios mutex */
186 struct ktermios *termios, *termios_locked; 192 struct ktermios *termios, *termios_locked;
187 char name[64]; 193 char name[64];
188 struct pid *pgrp; 194 struct pid *pgrp; /* Protected by ctrl lock */
189 struct pid *session; 195 struct pid *session;
190 unsigned long flags; 196 unsigned long flags;
191 int count; 197 int count;
192 struct winsize winsize; 198 struct winsize winsize; /* termios mutex */
193 unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; 199 unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1;
194 unsigned char low_latency:1, warned:1; 200 unsigned char low_latency:1, warned:1;
195 unsigned char ctrl_status; 201 unsigned char ctrl_status; /* ctrl_lock */
196 unsigned int receive_room; /* Bytes free for queue */ 202 unsigned int receive_room; /* Bytes free for queue */
197 203
198 struct tty_struct *link; 204 struct tty_struct *link;
199 struct fasync_struct *fasync; 205 struct fasync_struct *fasync;
200 struct tty_bufhead buf; 206 struct tty_bufhead buf; /* Locked internally */
201 int alt_speed; /* For magic substitution of 38400 bps */ 207 int alt_speed; /* For magic substitution of 38400 bps */
202 wait_queue_head_t write_wait; 208 wait_queue_head_t write_wait;
203 wait_queue_head_t read_wait; 209 wait_queue_head_t read_wait;
@@ -211,6 +217,7 @@ struct tty_struct {
211 /* 217 /*
212 * The following is data for the N_TTY line discipline. For 218 * The following is data for the N_TTY line discipline. For
213 * historical reasons, this is included in the tty structure. 219 * historical reasons, this is included in the tty structure.
220 * Mostly locked by the BKL.
214 */ 221 */
215 unsigned int column; 222 unsigned int column;
216 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; 223 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
@@ -292,15 +299,21 @@ extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
292extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, 299extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
293 int buflen); 300 int buflen);
294extern void tty_write_message(struct tty_struct *tty, char *msg); 301extern void tty_write_message(struct tty_struct *tty, char *msg);
302extern int tty_put_char(struct tty_struct *tty, unsigned char c);
303extern int tty_chars_in_buffer(struct tty_struct *tty);
304extern int tty_write_room(struct tty_struct *tty);
305extern void tty_driver_flush_buffer(struct tty_struct *tty);
306extern void tty_throttle(struct tty_struct *tty);
307extern void tty_unthrottle(struct tty_struct *tty);
295 308
296extern int is_current_pgrp_orphaned(void); 309extern int is_current_pgrp_orphaned(void);
310extern struct pid *tty_get_pgrp(struct tty_struct *tty);
297extern int is_ignored(int sig); 311extern int is_ignored(int sig);
298extern int tty_signal(int sig, struct tty_struct *tty); 312extern int tty_signal(int sig, struct tty_struct *tty);
299extern void tty_hangup(struct tty_struct * tty); 313extern void tty_hangup(struct tty_struct * tty);
300extern void tty_vhangup(struct tty_struct * tty); 314extern void tty_vhangup(struct tty_struct * tty);
301extern void tty_unhangup(struct file *filp); 315extern void tty_unhangup(struct file *filp);
302extern int tty_hung_up_p(struct file * filp); 316extern int tty_hung_up_p(struct file * filp);
303extern int is_tty(struct file *filp);
304extern void do_SAK(struct tty_struct *tty); 317extern void do_SAK(struct tty_struct *tty);
305extern void __do_SAK(struct tty_struct *tty); 318extern void __do_SAK(struct tty_struct *tty);
306extern void disassociate_ctty(int priv); 319extern void disassociate_ctty(int priv);
@@ -324,8 +337,7 @@ extern void tty_ldisc_put(int);
324extern void tty_wakeup(struct tty_struct *tty); 337extern void tty_wakeup(struct tty_struct *tty);
325extern void tty_ldisc_flush(struct tty_struct *tty); 338extern void tty_ldisc_flush(struct tty_struct *tty);
326 339
327extern int tty_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 340extern long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
328 unsigned long arg);
329extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file, 341extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
330 unsigned int cmd, unsigned long arg); 342 unsigned int cmd, unsigned long arg);
331extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg); 343extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
@@ -351,8 +363,7 @@ extern void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
351extern void tty_audit_exit(void); 363extern void tty_audit_exit(void);
352extern void tty_audit_fork(struct signal_struct *sig); 364extern void tty_audit_fork(struct signal_struct *sig);
353extern void tty_audit_push(struct tty_struct *tty); 365extern void tty_audit_push(struct tty_struct *tty);
354extern void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid); 366extern void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid);
355extern void tty_audit_opening(void);
356#else 367#else
357static inline void tty_audit_add_data(struct tty_struct *tty, 368static inline void tty_audit_add_data(struct tty_struct *tty,
358 unsigned char *data, size_t size) 369 unsigned char *data, size_t size)
@@ -367,10 +378,7 @@ static inline void tty_audit_fork(struct signal_struct *sig)
367static inline void tty_audit_push(struct tty_struct *tty) 378static inline void tty_audit_push(struct tty_struct *tty)
368{ 379{
369} 380}
370static inline void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid) 381static inline void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid)
371{
372}
373static inline void tty_audit_opening(void)
374{ 382{
375} 383}
376#endif 384#endif
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 85c95cd39bc3..59f1c0bd8f9c 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -12,11 +12,15 @@
12 * This routine is called when a particular tty device is opened. 12 * This routine is called when a particular tty device is opened.
13 * This routine is mandatory; if this routine is not filled in, 13 * This routine is mandatory; if this routine is not filled in,
14 * the attempted open will fail with ENODEV. 14 * the attempted open will fail with ENODEV.
15 *
16 * Required method.
15 * 17 *
16 * void (*close)(struct tty_struct * tty, struct file * filp); 18 * void (*close)(struct tty_struct * tty, struct file * filp);
17 * 19 *
18 * This routine is called when a particular tty device is closed. 20 * This routine is called when a particular tty device is closed.
19 * 21 *
22 * Required method.
23 *
20 * int (*write)(struct tty_struct * tty, 24 * int (*write)(struct tty_struct * tty,
21 * const unsigned char *buf, int count); 25 * const unsigned char *buf, int count);
22 * 26 *
@@ -26,7 +30,9 @@
26 * number of characters actually accepted for writing. This 30 * number of characters actually accepted for writing. This
27 * routine is mandatory. 31 * routine is mandatory.
28 * 32 *
29 * void (*put_char)(struct tty_struct *tty, unsigned char ch); 33 * Optional: Required for writable devices.
34 *
35 * int (*put_char)(struct tty_struct *tty, unsigned char ch);
30 * 36 *
31 * This routine is called by the kernel to write a single 37 * This routine is called by the kernel to write a single
32 * character to the tty device. If the kernel uses this routine, 38 * character to the tty device. If the kernel uses this routine,
@@ -34,10 +40,18 @@
34 * done stuffing characters into the driver. If there is no room 40 * done stuffing characters into the driver. If there is no room
35 * in the queue, the character is ignored. 41 * in the queue, the character is ignored.
36 * 42 *
43 * Optional: Kernel will use the write method if not provided.
44 *
45 * Note: Do not call this function directly, call tty_put_char
46 *
37 * void (*flush_chars)(struct tty_struct *tty); 47 * void (*flush_chars)(struct tty_struct *tty);
38 * 48 *
39 * This routine is called by the kernel after it has written a 49 * This routine is called by the kernel after it has written a
40 * series of characters to the tty device using put_char(). 50 * series of characters to the tty device using put_char().
51 *
52 * Optional:
53 *
54 * Note: Do not call this function directly, call tty_driver_flush_chars
41 * 55 *
42 * int (*write_room)(struct tty_struct *tty); 56 * int (*write_room)(struct tty_struct *tty);
43 * 57 *
@@ -45,6 +59,10 @@
45 * will accept for queuing to be written. This number is subject 59 * will accept for queuing to be written. This number is subject
46 * to change as output buffers get emptied, or if the output flow 60 * to change as output buffers get emptied, or if the output flow
47 * control is acted. 61 * control is acted.
62 *
63 * Required if write method is provided else not needed.
64 *
65 * Note: Do not call this function directly, call tty_write_room
48 * 66 *
49 * int (*ioctl)(struct tty_struct *tty, struct file * file, 67 * int (*ioctl)(struct tty_struct *tty, struct file * file,
50 * unsigned int cmd, unsigned long arg); 68 * unsigned int cmd, unsigned long arg);
@@ -53,28 +71,37 @@
53 * device-specific ioctl's. If the ioctl number passed in cmd 71 * device-specific ioctl's. If the ioctl number passed in cmd
54 * is not recognized by the driver, it should return ENOIOCTLCMD. 72 * is not recognized by the driver, it should return ENOIOCTLCMD.
55 * 73 *
74 * Optional
75 *
56 * long (*compat_ioctl)(struct tty_struct *tty, struct file * file, 76 * long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
57 * unsigned int cmd, unsigned long arg); 77 * unsigned int cmd, unsigned long arg);
58 * 78 *
59 * implement ioctl processing for 32 bit process on 64 bit system 79 * implement ioctl processing for 32 bit process on 64 bit system
80 *
81 * Optional
60 * 82 *
61 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 83 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
62 * 84 *
63 * This routine allows the tty driver to be notified when 85 * This routine allows the tty driver to be notified when
64 * device's termios settings have changed. Note that a 86 * device's termios settings have changed.
65 * well-designed tty driver should be prepared to accept the case 87 *
66 * where old == NULL, and try to do something rational. 88 * Optional: Called under the termios lock
89 *
67 * 90 *
68 * void (*set_ldisc)(struct tty_struct *tty); 91 * void (*set_ldisc)(struct tty_struct *tty);
69 * 92 *
70 * This routine allows the tty driver to be notified when the 93 * This routine allows the tty driver to be notified when the
71 * device's termios settings have changed. 94 * device's termios settings have changed.
95 *
96 * Optional: Called under BKL (currently)
72 * 97 *
73 * void (*throttle)(struct tty_struct * tty); 98 * void (*throttle)(struct tty_struct * tty);
74 * 99 *
75 * This routine notifies the tty driver that input buffers for 100 * This routine notifies the tty driver that input buffers for
76 * the line discipline are close to full, and it should somehow 101 * the line discipline are close to full, and it should somehow
77 * signal that no more characters should be sent to the tty. 102 * signal that no more characters should be sent to the tty.
103 *
104 * Optional: Always invoke via tty_throttle();
78 * 105 *
79 * void (*unthrottle)(struct tty_struct * tty); 106 * void (*unthrottle)(struct tty_struct * tty);
80 * 107 *
@@ -82,21 +109,33 @@
82 * that characters can now be sent to the tty without fear of 109 * that characters can now be sent to the tty without fear of
83 * overrunning the input buffers of the line disciplines. 110 * overrunning the input buffers of the line disciplines.
84 * 111 *
112 * Optional: Always invoke via tty_unthrottle();
113 *
85 * void (*stop)(struct tty_struct *tty); 114 * void (*stop)(struct tty_struct *tty);
86 * 115 *
87 * This routine notifies the tty driver that it should stop 116 * This routine notifies the tty driver that it should stop
88 * outputting characters to the tty device. 117 * outputting characters to the tty device.
118 *
119 * Optional:
120 *
121 * Note: Call stop_tty not this method.
89 * 122 *
90 * void (*start)(struct tty_struct *tty); 123 * void (*start)(struct tty_struct *tty);
91 * 124 *
92 * This routine notifies the tty driver that it resume sending 125 * This routine notifies the tty driver that it resume sending
93 * characters to the tty device. 126 * characters to the tty device.
127 *
128 * Optional:
129 *
130 * Note: Call start_tty not this method.
94 * 131 *
95 * void (*hangup)(struct tty_struct *tty); 132 * void (*hangup)(struct tty_struct *tty);
96 * 133 *
97 * This routine notifies the tty driver that it should hangup the 134 * This routine notifies the tty driver that it should hangup the
98 * tty device. 135 * tty device.
99 * 136 *
137 * Required:
138 *
100 * void (*break_ctl)(struct tty_stuct *tty, int state); 139 * void (*break_ctl)(struct tty_stuct *tty, int state);
101 * 140 *
102 * This optional routine requests the tty driver to turn on or 141 * This optional routine requests the tty driver to turn on or
@@ -106,18 +145,26 @@
106 * 145 *
107 * If this routine is implemented, the high-level tty driver will 146 * If this routine is implemented, the high-level tty driver will
108 * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK, 147 * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK,
109 * TIOCCBRK. Otherwise, these ioctls will be passed down to the 148 * TIOCCBRK.
110 * driver to handle. 149 *
150 * Optional: Required for TCSBRK/BRKP/etc handling.
111 * 151 *
112 * void (*wait_until_sent)(struct tty_struct *tty, int timeout); 152 * void (*wait_until_sent)(struct tty_struct *tty, int timeout);
113 * 153 *
114 * This routine waits until the device has written out all of the 154 * This routine waits until the device has written out all of the
115 * characters in its transmitter FIFO. 155 * characters in its transmitter FIFO.
116 * 156 *
157 * Optional: If not provided the device is assumed to have no FIFO
158 *
159 * Note: Usually correct to call tty_wait_until_sent
160 *
117 * void (*send_xchar)(struct tty_struct *tty, char ch); 161 * void (*send_xchar)(struct tty_struct *tty, char ch);
118 * 162 *
119 * This routine is used to send a high-priority XON/XOFF 163 * This routine is used to send a high-priority XON/XOFF
120 * character to the device. 164 * character to the device.
165 *
166 * Optional: If not provided then the write method is called under
167 * the atomic write lock to keep it serialized with the ldisc.
121 */ 168 */
122 169
123#include <linux/fs.h> 170#include <linux/fs.h>
@@ -125,13 +172,14 @@
125#include <linux/cdev.h> 172#include <linux/cdev.h>
126 173
127struct tty_struct; 174struct tty_struct;
175struct tty_driver;
128 176
129struct tty_operations { 177struct tty_operations {
130 int (*open)(struct tty_struct * tty, struct file * filp); 178 int (*open)(struct tty_struct * tty, struct file * filp);
131 void (*close)(struct tty_struct * tty, struct file * filp); 179 void (*close)(struct tty_struct * tty, struct file * filp);
132 int (*write)(struct tty_struct * tty, 180 int (*write)(struct tty_struct * tty,
133 const unsigned char *buf, int count); 181 const unsigned char *buf, int count);
134 void (*put_char)(struct tty_struct *tty, unsigned char ch); 182 int (*put_char)(struct tty_struct *tty, unsigned char ch);
135 void (*flush_chars)(struct tty_struct *tty); 183 void (*flush_chars)(struct tty_struct *tty);
136 int (*write_room)(struct tty_struct *tty); 184 int (*write_room)(struct tty_struct *tty);
137 int (*chars_in_buffer)(struct tty_struct *tty); 185 int (*chars_in_buffer)(struct tty_struct *tty);
@@ -152,11 +200,14 @@ struct tty_operations {
152 void (*send_xchar)(struct tty_struct *tty, char ch); 200 void (*send_xchar)(struct tty_struct *tty, char ch);
153 int (*read_proc)(char *page, char **start, off_t off, 201 int (*read_proc)(char *page, char **start, off_t off,
154 int count, int *eof, void *data); 202 int count, int *eof, void *data);
155 int (*write_proc)(struct file *file, const char __user *buffer,
156 unsigned long count, void *data);
157 int (*tiocmget)(struct tty_struct *tty, struct file *file); 203 int (*tiocmget)(struct tty_struct *tty, struct file *file);
158 int (*tiocmset)(struct tty_struct *tty, struct file *file, 204 int (*tiocmset)(struct tty_struct *tty, struct file *file,
159 unsigned int set, unsigned int clear); 205 unsigned int set, unsigned int clear);
206#ifdef CONFIG_CONSOLE_POLL
207 int (*poll_init)(struct tty_driver *driver, int line, char *options);
208 int (*poll_get_char)(struct tty_driver *driver, int line);
209 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
210#endif
160}; 211};
161 212
162struct tty_driver { 213struct tty_driver {
@@ -184,43 +235,13 @@ struct tty_driver {
184 struct tty_struct **ttys; 235 struct tty_struct **ttys;
185 struct ktermios **termios; 236 struct ktermios **termios;
186 struct ktermios **termios_locked; 237 struct ktermios **termios_locked;
187 void *driver_state; /* only used for the PTY driver */ 238 void *driver_state;
188 239
189 /* 240 /*
190 * Interface routines from the upper tty layer to the tty 241 * Driver methods
191 * driver. Will be replaced with struct tty_operations.
192 */ 242 */
193 int (*open)(struct tty_struct * tty, struct file * filp);
194 void (*close)(struct tty_struct * tty, struct file * filp);
195 int (*write)(struct tty_struct * tty,
196 const unsigned char *buf, int count);
197 void (*put_char)(struct tty_struct *tty, unsigned char ch);
198 void (*flush_chars)(struct tty_struct *tty);
199 int (*write_room)(struct tty_struct *tty);
200 int (*chars_in_buffer)(struct tty_struct *tty);
201 int (*ioctl)(struct tty_struct *tty, struct file * file,
202 unsigned int cmd, unsigned long arg);
203 long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
204 unsigned int cmd, unsigned long arg);
205 void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
206 void (*throttle)(struct tty_struct * tty);
207 void (*unthrottle)(struct tty_struct * tty);
208 void (*stop)(struct tty_struct *tty);
209 void (*start)(struct tty_struct *tty);
210 void (*hangup)(struct tty_struct *tty);
211 void (*break_ctl)(struct tty_struct *tty, int state);
212 void (*flush_buffer)(struct tty_struct *tty);
213 void (*set_ldisc)(struct tty_struct *tty);
214 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
215 void (*send_xchar)(struct tty_struct *tty, char ch);
216 int (*read_proc)(char *page, char **start, off_t off,
217 int count, int *eof, void *data);
218 int (*write_proc)(struct file *file, const char __user *buffer,
219 unsigned long count, void *data);
220 int (*tiocmget)(struct tty_struct *tty, struct file *file);
221 int (*tiocmset)(struct tty_struct *tty, struct file *file,
222 unsigned int set, unsigned int clear);
223 243
244 const struct tty_operations *ops;
224 struct list_head tty_drivers; 245 struct list_head tty_drivers;
225}; 246};
226 247
@@ -230,6 +251,7 @@ struct tty_driver *alloc_tty_driver(int lines);
230void put_tty_driver(struct tty_driver *driver); 251void put_tty_driver(struct tty_driver *driver);
231void tty_set_operations(struct tty_driver *driver, 252void tty_set_operations(struct tty_driver *driver,
232 const struct tty_operations *op); 253 const struct tty_operations *op);
254extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
233 255
234/* tty driver magic number */ 256/* tty driver magic number */
235#define TTY_DRIVER_MAGIC 0x5402 257#define TTY_DRIVER_MAGIC 0x5402
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 975c963e5789..fec6decfb983 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -84,4 +84,26 @@ static inline unsigned long __copy_from_user_nocache(void *to,
84 ret; \ 84 ret; \
85 }) 85 })
86 86
87/*
88 * probe_kernel_read(): safely attempt to read from a location
89 * @dst: pointer to the buffer that shall take the data
90 * @src: address to read from
91 * @size: size of the data chunk
92 *
93 * Safely read from address @src to the buffer at @dst. If a kernel fault
94 * happens, handle that and return -EFAULT.
95 */
96extern long probe_kernel_read(void *dst, void *src, size_t size);
97
98/*
99 * probe_kernel_write(): safely attempt to write to a location
100 * @dst: address to write to
101 * @src: pointer to the data that shall be written
102 * @size: size of the data chunk
103 *
104 * Safely write to address @dst from the buffer at @src. If a kernel fault
105 * happens, handle that and return -EFAULT.
106 */
107extern long probe_kernel_write(void *dst, void *src, size_t size);
108
87#endif /* __LINUX_UACCESS_H__ */ 109#endif /* __LINUX_UACCESS_H__ */
diff --git a/include/linux/udf_fs.h b/include/linux/udf_fs.h
deleted file mode 100644
index aa88654eb76b..000000000000
--- a/include/linux/udf_fs.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * udf_fs.h
3 *
4 * PURPOSE
5 * Included by fs/filesystems.c
6 *
7 * DESCRIPTION
8 * OSTA-UDF(tm) = Optical Storage Technology Association
9 * Universal Disk Format.
10 *
11 * This code is based on version 2.50 of the UDF specification,
12 * and revision 3 of the ECMA 167 standard [equivalent to ISO 13346].
13 * http://www.osta.org/ * http://www.ecma.ch/
14 * http://www.iso.org/
15 *
16 * COPYRIGHT
17 * This file is distributed under the terms of the GNU General Public
18 * License (GPL). Copies of the GPL can be obtained from:
19 * ftp://prep.ai.mit.edu/pub/gnu/GPL
20 * Each contributing author retains all rights to their own work.
21 *
22 * (C) 1999-2004 Ben Fennema
23 * (C) 1999-2000 Stelias Computing Inc
24 *
25 * HISTORY
26 *
27 */
28
29#ifndef _UDF_FS_H
30#define _UDF_FS_H 1
31
32#define UDF_PREALLOCATE
33#define UDF_DEFAULT_PREALLOC_BLOCKS 8
34
35#undef UDFFS_DEBUG
36
37#ifdef UDFFS_DEBUG
38#define udf_debug(f, a...) \
39 do { \
40 printk (KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \
41 __FILE__, __LINE__, __FUNCTION__); \
42 printk (f, ##a); \
43 } while (0)
44#else
45#define udf_debug(f, a...) /**/
46#endif
47
48#define udf_info(f, a...) \
49 printk (KERN_INFO "UDF-fs INFO " f, ##a);
50
51#endif /* _UDF_FS_H */
diff --git a/include/linux/udf_fs_i.h b/include/linux/udf_fs_i.h
index ffaf05679ffb..3536965913b0 100644
--- a/include/linux/udf_fs_i.h
+++ b/include/linux/udf_fs_i.h
@@ -9,41 +9,10 @@
9 * ftp://prep.ai.mit.edu/pub/gnu/GPL 9 * ftp://prep.ai.mit.edu/pub/gnu/GPL
10 * Each contributing author retains all rights to their own work. 10 * Each contributing author retains all rights to their own work.
11 */ 11 */
12
13#ifndef _UDF_FS_I_H 12#ifndef _UDF_FS_I_H
14#define _UDF_FS_I_H 1 13#define _UDF_FS_I_H 1
15 14
16#ifdef __KERNEL__
17
18struct udf_inode_info
19{
20 struct timespec i_crtime;
21 /* Physical address of inode */
22 kernel_lb_addr i_location;
23 __u64 i_unique;
24 __u32 i_lenEAttr;
25 __u32 i_lenAlloc;
26 __u64 i_lenExtents;
27 __u32 i_next_alloc_block;
28 __u32 i_next_alloc_goal;
29 unsigned i_alloc_type : 3;
30 unsigned i_efe : 1;
31 unsigned i_use : 1;
32 unsigned i_strat4096 : 1;
33 unsigned reserved : 26;
34 union
35 {
36 short_ad *i_sad;
37 long_ad *i_lad;
38 __u8 *i_data;
39 } i_ext;
40 struct inode vfs_inode;
41};
42
43#endif
44
45/* exported IOCTLs, we have 'l', 0x40-0x7f */ 15/* exported IOCTLs, we have 'l', 0x40-0x7f */
46
47#define UDF_GETEASIZE _IOR('l', 0x40, int) 16#define UDF_GETEASIZE _IOR('l', 0x40, int)
48#define UDF_GETEABLOCK _IOR('l', 0x41, void *) 17#define UDF_GETEABLOCK _IOR('l', 0x41, void *)
49#define UDF_GETVOLIDENT _IOR('l', 0x42, void *) 18#define UDF_GETVOLIDENT _IOR('l', 0x42, void *)
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
deleted file mode 100644
index 9bc47352b6b4..000000000000
--- a/include/linux/udf_fs_sb.h
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 * udf_fs_sb.h
3 *
4 * This include file is for the Linux kernel/module.
5 *
6 * COPYRIGHT
7 * This file is distributed under the terms of the GNU General Public
8 * License (GPL). Copies of the GPL can be obtained from:
9 * ftp://prep.ai.mit.edu/pub/gnu/GPL
10 * Each contributing author retains all rights to their own work.
11 */
12
13#ifndef _UDF_FS_SB_H
14#define _UDF_FS_SB_H 1
15
16#include <linux/mutex.h>
17
18#pragma pack(1)
19
20#define UDF_MAX_BLOCK_LOADED 8
21
22#define UDF_TYPE1_MAP15 0x1511U
23#define UDF_VIRTUAL_MAP15 0x1512U
24#define UDF_VIRTUAL_MAP20 0x2012U
25#define UDF_SPARABLE_MAP15 0x1522U
26
27struct udf_sparing_data
28{
29 __u16 s_packet_len;
30 struct buffer_head *s_spar_map[4];
31};
32
33struct udf_virtual_data
34{
35 __u32 s_num_entries;
36 __u16 s_start_offset;
37};
38
39struct udf_bitmap
40{
41 __u32 s_extLength;
42 __u32 s_extPosition;
43 __u16 s_nr_groups;
44 struct buffer_head **s_block_bitmap;
45};
46
47struct udf_part_map
48{
49 union
50 {
51 struct udf_bitmap *s_bitmap;
52 struct inode *s_table;
53 } s_uspace;
54 union
55 {
56 struct udf_bitmap *s_bitmap;
57 struct inode *s_table;
58 } s_fspace;
59 __u32 s_partition_root;
60 __u32 s_partition_len;
61 __u16 s_partition_type;
62 __u16 s_partition_num;
63 union
64 {
65 struct udf_sparing_data s_sparing;
66 struct udf_virtual_data s_virtual;
67 } s_type_specific;
68 __u32 (*s_partition_func)(struct super_block *, __u32, __u16, __u32);
69 __u16 s_volumeseqnum;
70 __u16 s_partition_flags;
71};
72
73#pragma pack()
74
75struct udf_sb_info
76{
77 struct udf_part_map *s_partmaps;
78 __u8 s_volume_ident[32];
79
80 /* Overall info */
81 __u16 s_partitions;
82 __u16 s_partition;
83
84 /* Sector headers */
85 __s32 s_session;
86 __u32 s_anchor[4];
87 __u32 s_last_block;
88
89 struct buffer_head *s_lvid_bh;
90
91 /* Default permissions */
92 mode_t s_umask;
93 gid_t s_gid;
94 uid_t s_uid;
95
96 /* Root Info */
97 struct timespec s_record_time;
98
99 /* Fileset Info */
100 __u16 s_serial_number;
101
102 /* highest UDF revision we have recorded to this media */
103 __u16 s_udfrev;
104
105 /* Miscellaneous flags */
106 __u32 s_flags;
107
108 /* Encoding info */
109 struct nls_table *s_nls_map;
110
111 /* VAT inode */
112 struct inode *s_vat_inode;
113
114 struct mutex s_alloc_mutex;
115};
116
117#endif /* _UDF_FS_SB_H */
diff --git a/include/linux/udp.h b/include/linux/udp.h
index 8ec703f462da..581ca2c14c52 100644
--- a/include/linux/udp.h
+++ b/include/linux/udp.h
@@ -26,15 +26,6 @@ struct udphdr {
26 __sum16 check; 26 __sum16 check;
27}; 27};
28 28
29#ifdef __KERNEL__
30#include <linux/skbuff.h>
31
32static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
33{
34 return (struct udphdr *)skb_transport_header(skb);
35}
36#endif
37
38/* UDP socket options */ 29/* UDP socket options */
39#define UDP_CORK 1 /* Never send partially complete segments */ 30#define UDP_CORK 1 /* Never send partially complete segments */
40#define UDP_ENCAP 100 /* Set the socket to accept encapsulated packets */ 31#define UDP_ENCAP 100 /* Set the socket to accept encapsulated packets */
@@ -45,9 +36,14 @@ static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
45#define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */ 36#define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */
46 37
47#ifdef __KERNEL__ 38#ifdef __KERNEL__
48#include <linux/types.h>
49
50#include <net/inet_sock.h> 39#include <net/inet_sock.h>
40#include <linux/skbuff.h>
41
42static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
43{
44 return (struct udphdr *)skb_transport_header(skb);
45}
46
51#define UDP_HTABLE_SIZE 128 47#define UDP_HTABLE_SIZE 128
52 48
53struct udp_sock { 49struct udp_sock {
@@ -82,6 +78,7 @@ static inline struct udp_sock *udp_sk(const struct sock *sk)
82{ 78{
83 return (struct udp_sock *)sk; 79 return (struct udp_sock *)sk;
84} 80}
81
85#define IS_UDPLITE(__sk) (udp_sk(__sk)->pcflag) 82#define IS_UDPLITE(__sk) (udp_sk(__sk)->pcflag)
86 83
87#endif 84#endif
diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
new file mode 100644
index 000000000000..99c1b4d20b0f
--- /dev/null
+++ b/include/linux/unaligned/access_ok.h
@@ -0,0 +1,67 @@
1#ifndef _LINUX_UNALIGNED_ACCESS_OK_H
2#define _LINUX_UNALIGNED_ACCESS_OK_H
3
4#include <linux/kernel.h>
5#include <asm/byteorder.h>
6
7static inline u16 get_unaligned_le16(const void *p)
8{
9 return le16_to_cpup((__le16 *)p);
10}
11
12static inline u32 get_unaligned_le32(const void *p)
13{
14 return le32_to_cpup((__le32 *)p);
15}
16
17static inline u64 get_unaligned_le64(const void *p)
18{
19 return le64_to_cpup((__le64 *)p);
20}
21
22static inline u16 get_unaligned_be16(const void *p)
23{
24 return be16_to_cpup((__be16 *)p);
25}
26
27static inline u32 get_unaligned_be32(const void *p)
28{
29 return be32_to_cpup((__be32 *)p);
30}
31
32static inline u64 get_unaligned_be64(const void *p)
33{
34 return be64_to_cpup((__be64 *)p);
35}
36
37static inline void put_unaligned_le16(u16 val, void *p)
38{
39 *((__le16 *)p) = cpu_to_le16(val);
40}
41
42static inline void put_unaligned_le32(u32 val, void *p)
43{
44 *((__le32 *)p) = cpu_to_le32(val);
45}
46
47static inline void put_unaligned_le64(u64 val, void *p)
48{
49 *((__le64 *)p) = cpu_to_le64(val);
50}
51
52static inline void put_unaligned_be16(u16 val, void *p)
53{
54 *((__be16 *)p) = cpu_to_be16(val);
55}
56
57static inline void put_unaligned_be32(u32 val, void *p)
58{
59 *((__be32 *)p) = cpu_to_be32(val);
60}
61
62static inline void put_unaligned_be64(u64 val, void *p)
63{
64 *((__be64 *)p) = cpu_to_be64(val);
65}
66
67#endif /* _LINUX_UNALIGNED_ACCESS_OK_H */
diff --git a/include/linux/unaligned/be_byteshift.h b/include/linux/unaligned/be_byteshift.h
new file mode 100644
index 000000000000..46dd12c5709e
--- /dev/null
+++ b/include/linux/unaligned/be_byteshift.h
@@ -0,0 +1,70 @@
1#ifndef _LINUX_UNALIGNED_BE_BYTESHIFT_H
2#define _LINUX_UNALIGNED_BE_BYTESHIFT_H
3
4#include <linux/kernel.h>
5
6static inline u16 __get_unaligned_be16(const u8 *p)
7{
8 return p[0] << 8 | p[1];
9}
10
11static inline u32 __get_unaligned_be32(const u8 *p)
12{
13 return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
14}
15
16static inline u64 __get_unaligned_be64(const u8 *p)
17{
18 return (u64)__get_unaligned_be32(p) << 32 |
19 __get_unaligned_be32(p + 4);
20}
21
22static inline void __put_unaligned_be16(u16 val, u8 *p)
23{
24 *p++ = val >> 8;
25 *p++ = val;
26}
27
28static inline void __put_unaligned_be32(u32 val, u8 *p)
29{
30 __put_unaligned_be16(val >> 16, p);
31 __put_unaligned_be16(val, p + 2);
32}
33
34static inline void __put_unaligned_be64(u64 val, u8 *p)
35{
36 __put_unaligned_be32(val >> 32, p);
37 __put_unaligned_be32(val, p + 4);
38}
39
40static inline u16 get_unaligned_be16(const void *p)
41{
42 return __get_unaligned_be16((const u8 *)p);
43}
44
45static inline u32 get_unaligned_be32(const void *p)
46{
47 return __get_unaligned_be32((const u8 *)p);
48}
49
50static inline u64 get_unaligned_be64(const void *p)
51{
52 return __get_unaligned_be64((const u8 *)p);
53}
54
55static inline void put_unaligned_be16(u16 val, void *p)
56{
57 __put_unaligned_be16(val, p);
58}
59
60static inline void put_unaligned_be32(u32 val, void *p)
61{
62 __put_unaligned_be32(val, p);
63}
64
65static inline void put_unaligned_be64(u64 val, void *p)
66{
67 __put_unaligned_be64(val, p);
68}
69
70#endif /* _LINUX_UNALIGNED_BE_BYTESHIFT_H */
diff --git a/include/linux/unaligned/be_memmove.h b/include/linux/unaligned/be_memmove.h
new file mode 100644
index 000000000000..c2a76c5c9ed0
--- /dev/null
+++ b/include/linux/unaligned/be_memmove.h
@@ -0,0 +1,36 @@
1#ifndef _LINUX_UNALIGNED_BE_MEMMOVE_H
2#define _LINUX_UNALIGNED_BE_MEMMOVE_H
3
4#include <linux/unaligned/memmove.h>
5
6static inline u16 get_unaligned_be16(const void *p)
7{
8 return __get_unaligned_memmove16((const u8 *)p);
9}
10
11static inline u32 get_unaligned_be32(const void *p)
12{
13 return __get_unaligned_memmove32((const u8 *)p);
14}
15
16static inline u64 get_unaligned_be64(const void *p)
17{
18 return __get_unaligned_memmove64((const u8 *)p);
19}
20
21static inline void put_unaligned_be16(u16 val, void *p)
22{
23 __put_unaligned_memmove16(val, p);
24}
25
26static inline void put_unaligned_be32(u32 val, void *p)
27{
28 __put_unaligned_memmove32(val, p);
29}
30
31static inline void put_unaligned_be64(u64 val, void *p)
32{
33 __put_unaligned_memmove64(val, p);
34}
35
36#endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */
diff --git a/include/linux/unaligned/be_struct.h b/include/linux/unaligned/be_struct.h
new file mode 100644
index 000000000000..132415836c50
--- /dev/null
+++ b/include/linux/unaligned/be_struct.h
@@ -0,0 +1,36 @@
1#ifndef _LINUX_UNALIGNED_BE_STRUCT_H
2#define _LINUX_UNALIGNED_BE_STRUCT_H
3
4#include <linux/unaligned/packed_struct.h>
5
6static inline u16 get_unaligned_be16(const void *p)
7{
8 return __get_unaligned_cpu16((const u8 *)p);
9}
10
11static inline u32 get_unaligned_be32(const void *p)
12{
13 return __get_unaligned_cpu32((const u8 *)p);
14}
15
16static inline u64 get_unaligned_be64(const void *p)
17{
18 return __get_unaligned_cpu64((const u8 *)p);
19}
20
21static inline void put_unaligned_be16(u16 val, void *p)
22{
23 __put_unaligned_cpu16(val, p);
24}
25
26static inline void put_unaligned_be32(u32 val, void *p)
27{
28 __put_unaligned_cpu32(val, p);
29}
30
31static inline void put_unaligned_be64(u64 val, void *p)
32{
33 __put_unaligned_cpu64(val, p);
34}
35
36#endif /* _LINUX_UNALIGNED_BE_STRUCT_H */
diff --git a/include/linux/unaligned/generic.h b/include/linux/unaligned/generic.h
new file mode 100644
index 000000000000..02d97ff3df70
--- /dev/null
+++ b/include/linux/unaligned/generic.h
@@ -0,0 +1,68 @@
1#ifndef _LINUX_UNALIGNED_GENERIC_H
2#define _LINUX_UNALIGNED_GENERIC_H
3
4/*
5 * Cause a link-time error if we try an unaligned access other than
6 * 1,2,4 or 8 bytes long
7 */
8extern void __bad_unaligned_access_size(void);
9
10#define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \
11 __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \
12 __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \
13 __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \
14 __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \
15 __bad_unaligned_access_size())))); \
16 }))
17
18#define __get_unaligned_be(ptr) ((__force typeof(*(ptr)))({ \
19 __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \
20 __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_be16((ptr)), \
21 __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_be32((ptr)), \
22 __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_be64((ptr)), \
23 __bad_unaligned_access_size())))); \
24 }))
25
26#define __put_unaligned_le(val, ptr) ({ \
27 void *__gu_p = (ptr); \
28 switch (sizeof(*(ptr))) { \
29 case 1: \
30 *(u8 *)__gu_p = (__force u8)(val); \
31 break; \
32 case 2: \
33 put_unaligned_le16((__force u16)(val), __gu_p); \
34 break; \
35 case 4: \
36 put_unaligned_le32((__force u32)(val), __gu_p); \
37 break; \
38 case 8: \
39 put_unaligned_le64((__force u64)(val), __gu_p); \
40 break; \
41 default: \
42 __bad_unaligned_access_size(); \
43 break; \
44 } \
45 (void)0; })
46
47#define __put_unaligned_be(val, ptr) ({ \
48 void *__gu_p = (ptr); \
49 switch (sizeof(*(ptr))) { \
50 case 1: \
51 *(u8 *)__gu_p = (__force u8)(val); \
52 break; \
53 case 2: \
54 put_unaligned_be16((__force u16)(val), __gu_p); \
55 break; \
56 case 4: \
57 put_unaligned_be32((__force u32)(val), __gu_p); \
58 break; \
59 case 8: \
60 put_unaligned_be64((__force u64)(val), __gu_p); \
61 break; \
62 default: \
63 __bad_unaligned_access_size(); \
64 break; \
65 } \
66 (void)0; })
67
68#endif /* _LINUX_UNALIGNED_GENERIC_H */
diff --git a/include/linux/unaligned/le_byteshift.h b/include/linux/unaligned/le_byteshift.h
new file mode 100644
index 000000000000..59777e951baf
--- /dev/null
+++ b/include/linux/unaligned/le_byteshift.h
@@ -0,0 +1,70 @@
1#ifndef _LINUX_UNALIGNED_LE_BYTESHIFT_H
2#define _LINUX_UNALIGNED_LE_BYTESHIFT_H
3
4#include <linux/kernel.h>
5
6static inline u16 __get_unaligned_le16(const u8 *p)
7{
8 return p[0] | p[1] << 8;
9}
10
11static inline u32 __get_unaligned_le32(const u8 *p)
12{
13 return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
14}
15
16static inline u64 __get_unaligned_le64(const u8 *p)
17{
18 return (u64)__get_unaligned_le32(p + 4) << 32 |
19 __get_unaligned_le32(p);
20}
21
22static inline void __put_unaligned_le16(u16 val, u8 *p)
23{
24 *p++ = val;
25 *p++ = val >> 8;
26}
27
28static inline void __put_unaligned_le32(u32 val, u8 *p)
29{
30 __put_unaligned_le16(val >> 16, p + 2);
31 __put_unaligned_le16(val, p);
32}
33
34static inline void __put_unaligned_le64(u64 val, u8 *p)
35{
36 __put_unaligned_le32(val >> 32, p + 4);
37 __put_unaligned_le32(val, p);
38}
39
40static inline u16 get_unaligned_le16(const void *p)
41{
42 return __get_unaligned_le16((const u8 *)p);
43}
44
45static inline u32 get_unaligned_le32(const void *p)
46{
47 return __get_unaligned_le32((const u8 *)p);
48}
49
50static inline u64 get_unaligned_le64(const void *p)
51{
52 return __get_unaligned_le64((const u8 *)p);
53}
54
55static inline void put_unaligned_le16(u16 val, void *p)
56{
57 __put_unaligned_le16(val, p);
58}
59
60static inline void put_unaligned_le32(u32 val, void *p)
61{
62 __put_unaligned_le32(val, p);
63}
64
65static inline void put_unaligned_le64(u64 val, void *p)
66{
67 __put_unaligned_le64(val, p);
68}
69
70#endif /* _LINUX_UNALIGNED_LE_BYTESHIFT_H */
diff --git a/include/linux/unaligned/le_memmove.h b/include/linux/unaligned/le_memmove.h
new file mode 100644
index 000000000000..269849bee4ec
--- /dev/null
+++ b/include/linux/unaligned/le_memmove.h
@@ -0,0 +1,36 @@
1#ifndef _LINUX_UNALIGNED_LE_MEMMOVE_H
2#define _LINUX_UNALIGNED_LE_MEMMOVE_H
3
4#include <linux/unaligned/memmove.h>
5
6static inline u16 get_unaligned_le16(const void *p)
7{
8 return __get_unaligned_memmove16((const u8 *)p);
9}
10
11static inline u32 get_unaligned_le32(const void *p)
12{
13 return __get_unaligned_memmove32((const u8 *)p);
14}
15
16static inline u64 get_unaligned_le64(const void *p)
17{
18 return __get_unaligned_memmove64((const u8 *)p);
19}
20
21static inline void put_unaligned_le16(u16 val, void *p)
22{
23 __put_unaligned_memmove16(val, p);
24}
25
26static inline void put_unaligned_le32(u32 val, void *p)
27{
28 __put_unaligned_memmove32(val, p);
29}
30
31static inline void put_unaligned_le64(u64 val, void *p)
32{
33 __put_unaligned_memmove64(val, p);
34}
35
36#endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */
diff --git a/include/linux/unaligned/le_struct.h b/include/linux/unaligned/le_struct.h
new file mode 100644
index 000000000000..088c4572faa8
--- /dev/null
+++ b/include/linux/unaligned/le_struct.h
@@ -0,0 +1,36 @@
1#ifndef _LINUX_UNALIGNED_LE_STRUCT_H
2#define _LINUX_UNALIGNED_LE_STRUCT_H
3
4#include <linux/unaligned/packed_struct.h>
5
6static inline u16 get_unaligned_le16(const void *p)
7{
8 return __get_unaligned_cpu16((const u8 *)p);
9}
10
11static inline u32 get_unaligned_le32(const void *p)
12{
13 return __get_unaligned_cpu32((const u8 *)p);
14}
15
16static inline u64 get_unaligned_le64(const void *p)
17{
18 return __get_unaligned_cpu64((const u8 *)p);
19}
20
21static inline void put_unaligned_le16(u16 val, void *p)
22{
23 __put_unaligned_cpu16(val, p);
24}
25
26static inline void put_unaligned_le32(u32 val, void *p)
27{
28 __put_unaligned_cpu32(val, p);
29}
30
31static inline void put_unaligned_le64(u64 val, void *p)
32{
33 __put_unaligned_cpu64(val, p);
34}
35
36#endif /* _LINUX_UNALIGNED_LE_STRUCT_H */
diff --git a/include/linux/unaligned/memmove.h b/include/linux/unaligned/memmove.h
new file mode 100644
index 000000000000..eeb5a779a4fd
--- /dev/null
+++ b/include/linux/unaligned/memmove.h
@@ -0,0 +1,45 @@
1#ifndef _LINUX_UNALIGNED_MEMMOVE_H
2#define _LINUX_UNALIGNED_MEMMOVE_H
3
4#include <linux/kernel.h>
5#include <linux/string.h>
6
7/* Use memmove here, so gcc does not insert a __builtin_memcpy. */
8
9static inline u16 __get_unaligned_memmove16(const void *p)
10{
11 u16 tmp;
12 memmove(&tmp, p, 2);
13 return tmp;
14}
15
16static inline u32 __get_unaligned_memmove32(const void *p)
17{
18 u32 tmp;
19 memmove(&tmp, p, 4);
20 return tmp;
21}
22
23static inline u64 __get_unaligned_memmove64(const void *p)
24{
25 u64 tmp;
26 memmove(&tmp, p, 8);
27 return tmp;
28}
29
30static inline void __put_unaligned_memmove16(u16 val, void *p)
31{
32 memmove(p, &val, 2);
33}
34
35static inline void __put_unaligned_memmove32(u32 val, void *p)
36{
37 memmove(p, &val, 4);
38}
39
40static inline void __put_unaligned_memmove64(u64 val, void *p)
41{
42 memmove(p, &val, 8);
43}
44
45#endif /* _LINUX_UNALIGNED_MEMMOVE_H */
diff --git a/include/linux/unaligned/packed_struct.h b/include/linux/unaligned/packed_struct.h
new file mode 100644
index 000000000000..2498bb9fe002
--- /dev/null
+++ b/include/linux/unaligned/packed_struct.h
@@ -0,0 +1,46 @@
1#ifndef _LINUX_UNALIGNED_PACKED_STRUCT_H
2#define _LINUX_UNALIGNED_PACKED_STRUCT_H
3
4#include <linux/kernel.h>
5
6struct __una_u16 { u16 x __attribute__((packed)); };
7struct __una_u32 { u32 x __attribute__((packed)); };
8struct __una_u64 { u64 x __attribute__((packed)); };
9
10static inline u16 __get_unaligned_cpu16(const void *p)
11{
12 const struct __una_u16 *ptr = (const struct __una_u16 *)p;
13 return ptr->x;
14}
15
16static inline u32 __get_unaligned_cpu32(const void *p)
17{
18 const struct __una_u32 *ptr = (const struct __una_u32 *)p;
19 return ptr->x;
20}
21
22static inline u64 __get_unaligned_cpu64(const void *p)
23{
24 const struct __una_u64 *ptr = (const struct __una_u64 *)p;
25 return ptr->x;
26}
27
28static inline void __put_unaligned_cpu16(u16 val, void *p)
29{
30 struct __una_u16 *ptr = (struct __una_u16 *)p;
31 ptr->x = val;
32}
33
34static inline void __put_unaligned_cpu32(u32 val, void *p)
35{
36 struct __una_u32 *ptr = (struct __una_u32 *)p;
37 ptr->x = val;
38}
39
40static inline void __put_unaligned_cpu64(u64 val, void *p)
41{
42 struct __una_u64 *ptr = (struct __una_u64 *)p;
43 ptr->x = val;
44}
45
46#endif /* _LINUX_UNALIGNED_PACKED_STRUCT_H */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 583e0481dfa0..c08689ea9b4b 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -23,6 +23,7 @@
23 23
24struct usb_device; 24struct usb_device;
25struct usb_driver; 25struct usb_driver;
26struct wusb_dev;
26 27
27/*-------------------------------------------------------------------------*/ 28/*-------------------------------------------------------------------------*/
28 29
@@ -341,103 +342,146 @@ struct usb_bus {
341 342
342struct usb_tt; 343struct usb_tt;
343 344
344/* 345/**
345 * struct usb_device - kernel's representation of a USB device 346 * struct usb_device - kernel's representation of a USB device
346 * 347 * @devnum: device number; address on a USB bus
347 * FIXME: Write the kerneldoc! 348 * @devpath: device ID string for use in messages (e.g., /port/...)
348 * 349 * @state: device state: configured, not attached, etc.
350 * @speed: device speed: high/full/low (or error)
351 * @tt: Transaction Translator info; used with low/full speed dev, highspeed hub
352 * @ttport: device port on that tt hub
353 * @toggle: one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints
354 * @parent: our hub, unless we're the root
355 * @bus: bus we're part of
356 * @ep0: endpoint 0 data (default control pipe)
357 * @dev: generic device interface
358 * @descriptor: USB device descriptor
359 * @config: all of the device's configs
360 * @actconfig: the active configuration
361 * @ep_in: array of IN endpoints
362 * @ep_out: array of OUT endpoints
363 * @rawdescriptors: raw descriptors for each config
364 * @bus_mA: Current available from the bus
365 * @portnum: parent port number (origin 1)
366 * @level: number of USB hub ancestors
367 * @can_submit: URBs may be submitted
368 * @discon_suspended: disconnected while suspended
369 * @persist_enabled: USB_PERSIST enabled for this device
370 * @have_langid: whether string_langid is valid
371 * @authorized: policy has said we can use it;
372 * (user space) policy determines if we authorize this device to be
373 * used or not. By default, wired USB devices are authorized.
374 * WUSB devices are not, until we authorize them from user space.
375 * FIXME -- complete doc
376 * @authenticated: Crypto authentication passed
377 * @wusb: device is Wireless USB
378 * @string_langid: language ID for strings
379 * @product: iProduct string, if present (static)
380 * @manufacturer: iManufacturer string, if present (static)
381 * @serial: iSerialNumber string, if present (static)
382 * @filelist: usbfs files that are open to this device
383 * @usb_classdev: USB class device that was created for usbfs device
384 * access from userspace
385 * @usbfs_dentry: usbfs dentry entry for the device
386 * @maxchild: number of ports if hub
387 * @children: child devices - USB devices that are attached to this hub
388 * @pm_usage_cnt: usage counter for autosuspend
389 * @quirks: quirks of the whole device
390 * @urbnum: number of URBs submitted for the whole device
391 * @active_duration: total time device is not suspended
392 * @autosuspend: for delayed autosuspends
393 * @pm_mutex: protects PM operations
394 * @last_busy: time of last use
395 * @autosuspend_delay: in jiffies
396 * @connect_time: time device was first connected
397 * @auto_pm: autosuspend/resume in progress
398 * @do_remote_wakeup: remote wakeup should be enabled
399 * @reset_resume: needs reset instead of resume
400 * @autosuspend_disabled: autosuspend disabled by the user
401 * @autoresume_disabled: autoresume disabled by the user
402 * @skip_sys_resume: skip the next system resume
403 *
404 * Notes:
349 * Usbcore drivers should not set usbdev->state directly. Instead use 405 * Usbcore drivers should not set usbdev->state directly. Instead use
350 * usb_set_device_state(). 406 * usb_set_device_state().
351 *
352 * @authorized: (user space) policy determines if we authorize this
353 * device to be used or not. By default, wired USB
354 * devices are authorized. WUSB devices are not, until we
355 * authorize them from user space. FIXME -- complete doc
356 */ 407 */
357struct usb_device { 408struct usb_device {
358 int devnum; /* Address on USB bus */ 409 int devnum;
359 char devpath [16]; /* Use in messages: /port/port/... */ 410 char devpath [16];
360 enum usb_device_state state; /* configured, not attached, etc */ 411 enum usb_device_state state;
361 enum usb_device_speed speed; /* high/full/low (or error) */ 412 enum usb_device_speed speed;
362 413
363 struct usb_tt *tt; /* low/full speed dev, highspeed hub */ 414 struct usb_tt *tt;
364 int ttport; /* device port on that tt hub */ 415 int ttport;
365 416
366 unsigned int toggle[2]; /* one bit for each endpoint 417 unsigned int toggle[2];
367 * ([0] = IN, [1] = OUT) */
368 418
369 struct usb_device *parent; /* our hub, unless we're the root */ 419 struct usb_device *parent;
370 struct usb_bus *bus; /* Bus we're part of */ 420 struct usb_bus *bus;
371 struct usb_host_endpoint ep0; 421 struct usb_host_endpoint ep0;
372 422
373 struct device dev; /* Generic device interface */ 423 struct device dev;
374 424
375 struct usb_device_descriptor descriptor;/* Descriptor */ 425 struct usb_device_descriptor descriptor;
376 struct usb_host_config *config; /* All of the configs */ 426 struct usb_host_config *config;
377 427
378 struct usb_host_config *actconfig;/* the active configuration */ 428 struct usb_host_config *actconfig;
379 struct usb_host_endpoint *ep_in[16]; 429 struct usb_host_endpoint *ep_in[16];
380 struct usb_host_endpoint *ep_out[16]; 430 struct usb_host_endpoint *ep_out[16];
381 431
382 char **rawdescriptors; /* Raw descriptors for each config */ 432 char **rawdescriptors;
383 433
384 unsigned short bus_mA; /* Current available from the bus */ 434 unsigned short bus_mA;
385 u8 portnum; /* Parent port number (origin 1) */ 435 u8 portnum;
386 u8 level; /* Number of USB hub ancestors */ 436 u8 level;
387 437
388 unsigned can_submit:1; /* URBs may be submitted */ 438 unsigned can_submit:1;
389 unsigned discon_suspended:1; /* Disconnected while suspended */ 439 unsigned discon_suspended:1;
390 unsigned have_langid:1; /* whether string_langid is valid */ 440 unsigned persist_enabled:1;
391 unsigned authorized:1; /* Policy has said we can use it */ 441 unsigned have_langid:1;
392 unsigned wusb:1; /* Device is Wireless USB */ 442 unsigned authorized:1;
393 int string_langid; /* language ID for strings */ 443 unsigned authenticated:1;
444 unsigned wusb:1;
445 int string_langid;
394 446
395 /* static strings from the device */ 447 /* static strings from the device */
396 char *product; /* iProduct string, if present */ 448 char *product;
397 char *manufacturer; /* iManufacturer string, if present */ 449 char *manufacturer;
398 char *serial; /* iSerialNumber string, if present */ 450 char *serial;
399 451
400 struct list_head filelist; 452 struct list_head filelist;
401#ifdef CONFIG_USB_DEVICE_CLASS 453#ifdef CONFIG_USB_DEVICE_CLASS
402 struct device *usb_classdev; 454 struct device *usb_classdev;
403#endif 455#endif
404#ifdef CONFIG_USB_DEVICEFS 456#ifdef CONFIG_USB_DEVICEFS
405 struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */ 457 struct dentry *usbfs_dentry;
406#endif 458#endif
407 /*
408 * Child devices - these can be either new devices
409 * (if this is a hub device), or different instances
410 * of this same device.
411 *
412 * Each instance needs its own set of data structures.
413 */
414 459
415 int maxchild; /* Number of ports if hub */ 460 int maxchild;
416 struct usb_device *children[USB_MAXCHILDREN]; 461 struct usb_device *children[USB_MAXCHILDREN];
417 462
418 int pm_usage_cnt; /* usage counter for autosuspend */ 463 int pm_usage_cnt;
419 u32 quirks; /* quirks of the whole device */ 464 u32 quirks;
420 atomic_t urbnum; /* number of URBs submitted for 465 atomic_t urbnum;
421 the whole device */
422 466
423 unsigned long active_duration; /* total time device is not suspended */ 467 unsigned long active_duration;
424 468
425#ifdef CONFIG_PM 469#ifdef CONFIG_PM
426 struct delayed_work autosuspend; /* for delayed autosuspends */ 470 struct delayed_work autosuspend;
427 struct mutex pm_mutex; /* protects PM operations */ 471 struct mutex pm_mutex;
428 472
429 unsigned long last_busy; /* time of last use */ 473 unsigned long last_busy;
430 int autosuspend_delay; /* in jiffies */ 474 int autosuspend_delay;
431 unsigned long connect_time; /* time device was first connected */ 475 unsigned long connect_time;
432 476
433 unsigned auto_pm:1; /* autosuspend/resume in progress */ 477 unsigned auto_pm:1;
434 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ 478 unsigned do_remote_wakeup:1;
435 unsigned reset_resume:1; /* needs reset instead of resume */ 479 unsigned reset_resume:1;
436 unsigned persist_enabled:1; /* USB_PERSIST enabled for this dev */ 480 unsigned autosuspend_disabled:1;
437 unsigned autosuspend_disabled:1; /* autosuspend and autoresume */ 481 unsigned autoresume_disabled:1;
438 unsigned autoresume_disabled:1; /* disabled by the user */ 482 unsigned skip_sys_resume:1;
439 unsigned skip_sys_resume:1; /* skip the next system resume */
440#endif 483#endif
484 struct wusb_dev *wusb_dev;
441}; 485};
442#define to_usb_device(d) container_of(d, struct usb_device, dev) 486#define to_usb_device(d) container_of(d, struct usb_device, dev)
443 487
@@ -898,10 +942,11 @@ struct usbdrv_wrap {
898 * and should normally be the same as the module name. 942 * and should normally be the same as the module name.
899 * @probe: Called to see if the driver is willing to manage a particular 943 * @probe: Called to see if the driver is willing to manage a particular
900 * interface on a device. If it is, probe returns zero and uses 944 * interface on a device. If it is, probe returns zero and uses
901 * dev_set_drvdata() to associate driver-specific data with the 945 * usb_set_intfdata() to associate driver-specific data with the
902 * interface. It may also use usb_set_interface() to specify the 946 * interface. It may also use usb_set_interface() to specify the
903 * appropriate altsetting. If unwilling to manage the interface, 947 * appropriate altsetting. If unwilling to manage the interface,
904 * return a negative errno value. 948 * return -ENODEV, if genuine IO errors occured, an appropriate
949 * negative errno value.
905 * @disconnect: Called when the interface is no longer accessible, usually 950 * @disconnect: Called when the interface is no longer accessible, usually
906 * because its device has been (or is being) disconnected or the 951 * because its device has been (or is being) disconnected or the
907 * driver module is being unloaded. 952 * driver module is being unloaded.
@@ -916,10 +961,7 @@ struct usbdrv_wrap {
916 * @pre_reset: Called by usb_reset_composite_device() when the device 961 * @pre_reset: Called by usb_reset_composite_device() when the device
917 * is about to be reset. 962 * is about to be reset.
918 * @post_reset: Called by usb_reset_composite_device() after the device 963 * @post_reset: Called by usb_reset_composite_device() after the device
919 * has been reset, or in lieu of @resume following a reset-resume 964 * has been reset
920 * (i.e., the device is reset instead of being resumed, as might
921 * happen if power was lost). The second argument tells which is
922 * the reason.
923 * @id_table: USB drivers use ID table to support hotplugging. 965 * @id_table: USB drivers use ID table to support hotplugging.
924 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set 966 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
925 * or your driver's probe function will never get called. 967 * or your driver's probe function will never get called.
@@ -1411,6 +1453,7 @@ extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags);
1411extern int usb_unlink_urb(struct urb *urb); 1453extern int usb_unlink_urb(struct urb *urb);
1412extern void usb_kill_urb(struct urb *urb); 1454extern void usb_kill_urb(struct urb *urb);
1413extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); 1455extern void usb_kill_anchored_urbs(struct usb_anchor *anchor);
1456extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor);
1414extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); 1457extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor);
1415extern void usb_unanchor_urb(struct urb *urb); 1458extern void usb_unanchor_urb(struct urb *urb);
1416extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, 1459extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor,
@@ -1661,13 +1704,12 @@ extern void usb_unregister_notify(struct notifier_block *nb);
1661#define dbg(format, arg...) do {} while (0) 1704#define dbg(format, arg...) do {} while (0)
1662#endif 1705#endif
1663 1706
1664#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ 1707#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
1665 __FILE__ , ## arg) 1708 format "\n" , ## arg)
1666#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \ 1709#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
1667 __FILE__ , ## arg) 1710 format "\n" , ## arg)
1668#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \ 1711#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \
1669 __FILE__ , ## arg) 1712 format "\n" , ## arg)
1670
1671 1713
1672#endif /* __KERNEL__ */ 1714#endif /* __KERNEL__ */
1673 1715
diff --git a/include/linux/usb/atmel_usba_udc.h b/include/linux/usb/atmel_usba_udc.h
new file mode 100644
index 000000000000..6311fa2d9f82
--- /dev/null
+++ b/include/linux/usb/atmel_usba_udc.h
@@ -0,0 +1,22 @@
1/*
2 * Platform data definitions for Atmel USBA gadget driver.
3 */
4#ifndef __LINUX_USB_USBA_H
5#define __LINUX_USB_USBA_H
6
7struct usba_ep_data {
8 char *name;
9 int index;
10 int fifo_size;
11 int nr_banks;
12 int can_dma;
13 int can_isoc;
14};
15
16struct usba_platform_data {
17 int vbus_pin;
18 int num_ep;
19 struct usba_ep_data ep[0];
20};
21
22#endif /* __LINUX_USB_USBA_H */
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index 2dfeef16b221..8cb025fef634 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -50,4 +50,4 @@ struct usb_ac_header_descriptor_##n { \
50 __u8 baInterfaceNr[n]; \ 50 __u8 baInterfaceNr[n]; \
51} __attribute__ ((packed)) 51} __attribute__ ((packed))
52 52
53#endif 53#endif /* __LINUX_USB_AUDIO_H */
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index 94ee4ecf0564..71e52f2f6a38 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -6,6 +6,9 @@
6 * firmware based USB peripherals. 6 * firmware based USB peripherals.
7 */ 7 */
8 8
9#ifndef __LINUX_USB_CDC_H
10#define __LINUX_USB_CDC_H
11
9#define USB_CDC_SUBCLASS_ACM 0x02 12#define USB_CDC_SUBCLASS_ACM 0x02
10#define USB_CDC_SUBCLASS_ETHERNET 0x06 13#define USB_CDC_SUBCLASS_ETHERNET 0x06
11#define USB_CDC_SUBCLASS_WHCM 0x08 14#define USB_CDC_SUBCLASS_WHCM 0x08
@@ -221,3 +224,4 @@ struct usb_cdc_notification {
221 __le16 wLength; 224 __le16 wLength;
222} __attribute__ ((packed)); 225} __attribute__ ((packed));
223 226
227#endif /* __LINUX_USB_CDC_H */
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 6169438ec5a2..7e0d3084f76c 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -66,8 +66,8 @@
66#define USB_RECIP_ENDPOINT 0x02 66#define USB_RECIP_ENDPOINT 0x02
67#define USB_RECIP_OTHER 0x03 67#define USB_RECIP_OTHER 0x03
68/* From Wireless USB 1.0 */ 68/* From Wireless USB 1.0 */
69#define USB_RECIP_PORT 0x04 69#define USB_RECIP_PORT 0x04
70#define USB_RECIP_RPIPE 0x05 70#define USB_RECIP_RPIPE 0x05
71 71
72/* 72/*
73 * Standard requests, for the bRequest field of a SETUP packet. 73 * Standard requests, for the bRequest field of a SETUP packet.
@@ -102,10 +102,16 @@
102#define USB_REQ_LOOPBACK_DATA_READ 0x16 102#define USB_REQ_LOOPBACK_DATA_READ 0x16
103#define USB_REQ_SET_INTERFACE_DS 0x17 103#define USB_REQ_SET_INTERFACE_DS 0x17
104 104
105/* The Link Power Mangement (LPM) ECN defines USB_REQ_TEST_AND_SET command,
106 * used by hubs to put ports into a new L1 suspend state, except that it
107 * forgot to define its number ...
108 */
109
105/* 110/*
106 * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and 111 * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
107 * are read as a bit array returned by USB_REQ_GET_STATUS. (So there 112 * are read as a bit array returned by USB_REQ_GET_STATUS. (So there
108 * are at most sixteen features of each type.) 113 * are at most sixteen features of each type.) Hubs may also support a
114 * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
109 */ 115 */
110#define USB_DEVICE_SELF_POWERED 0 /* (read only) */ 116#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
111#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ 117#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
@@ -180,6 +186,7 @@ struct usb_ctrlrequest {
180#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 186#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
181#define USB_DT_WIRE_ADAPTER 0x21 187#define USB_DT_WIRE_ADAPTER 0x21
182#define USB_DT_RPIPE 0x22 188#define USB_DT_RPIPE 0x22
189#define USB_DT_CS_RADIO_CONTROL 0x23
183 190
184/* Conventional codes for class-specific descriptors. The convention is 191/* Conventional codes for class-specific descriptors. The convention is
185 * defined in the USB "Common Class" Spec (3.11). Individual class specs 192 * defined in the USB "Common Class" Spec (3.11). Individual class specs
@@ -574,7 +581,9 @@ enum usb_device_state {
574 /* NOTE: there are actually four different SUSPENDED 581 /* NOTE: there are actually four different SUSPENDED
575 * states, returning to POWERED, DEFAULT, ADDRESS, or 582 * states, returning to POWERED, DEFAULT, ADDRESS, or
576 * CONFIGURED respectively when SOF tokens flow again. 583 * CONFIGURED respectively when SOF tokens flow again.
584 * At this level there's no difference between L1 and L2
585 * suspend states. (L2 being original USB 1.1 suspend.)
577 */ 586 */
578}; 587};
579 588
580#endif /* __LINUX_USB_CH9_H */ 589#endif /* __LINUX_USB_CH9_H */
diff --git a/include/linux/usb/g_printer.h b/include/linux/usb/g_printer.h
index 0c5ea1e3eb98..6178fde50f74 100644
--- a/include/linux/usb/g_printer.h
+++ b/include/linux/usb/g_printer.h
@@ -18,6 +18,8 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 20
21#ifndef __LINUX_USB_G_PRINTER_H
22#define __LINUX_USB_G_PRINTER_H
21 23
22#define PRINTER_NOT_ERROR 0x08 24#define PRINTER_NOT_ERROR 0x08
23#define PRINTER_SELECTED 0x10 25#define PRINTER_SELECTED 0x10
@@ -29,3 +31,5 @@
29 */ 31 */
30#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char) 32#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char)
31#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char) 33#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char)
34
35#endif /* __LINUX_USB_G_PRINTER_H */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index f3295296b435..d8128f7102c9 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -846,4 +846,4 @@ extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
846 846
847extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit; 847extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit;
848 848
849#endif /* __LINUX_USB_GADGET_H */ 849#endif /* __LINUX_USB_GADGET_H */
diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h
index c291ab1af747..ea45f265ec05 100644
--- a/include/linux/usb/gadgetfs.h
+++ b/include/linux/usb/gadgetfs.h
@@ -1,11 +1,3 @@
1#ifndef __LINUX_USB_GADGETFS_H
2#define __LINUX_USB_GADGETFS_H
3
4#include <asm/types.h>
5#include <asm/ioctl.h>
6
7#include <linux/usb/ch9.h>
8
9/* 1/*
10 * Filesystem based user-mode API to USB Gadget controller hardware 2 * Filesystem based user-mode API to USB Gadget controller hardware
11 * 3 *
@@ -23,6 +15,14 @@
23 * then performing data transfers by reading or writing. 15 * then performing data transfers by reading or writing.
24 */ 16 */
25 17
18#ifndef __LINUX_USB_GADGETFS_H
19#define __LINUX_USB_GADGETFS_H
20
21#include <asm/types.h>
22#include <asm/ioctl.h>
23
24#include <linux/usb/ch9.h>
25
26/* 26/*
27 * Events are delivered on the ep0 file descriptor, when the user mode driver 27 * Events are delivered on the ep0 file descriptor, when the user mode driver
28 * reads from this file descriptor after writing the descriptors. Don't 28 * reads from this file descriptor after writing the descriptors. Don't
diff --git a/include/linux/usb/input.h b/include/linux/usb/input.h
index 716e0cc16043..0e010b220e85 100644
--- a/include/linux/usb/input.h
+++ b/include/linux/usb/input.h
@@ -1,6 +1,3 @@
1#ifndef __USB_INPUT_H
2#define __USB_INPUT_H
3
4/* 1/*
5 * Copyright (C) 2005 Dmitry Torokhov 2 * Copyright (C) 2005 Dmitry Torokhov
6 * 3 *
@@ -9,6 +6,9 @@
9 * the Free Software Foundation. 6 * the Free Software Foundation.
10 */ 7 */
11 8
9#ifndef __LINUX_USB_INPUT_H
10#define __LINUX_USB_INPUT_H
11
12#include <linux/usb.h> 12#include <linux/usb.h>
13#include <linux/input.h> 13#include <linux/input.h>
14#include <asm/byteorder.h> 14#include <asm/byteorder.h>
@@ -22,4 +22,4 @@ usb_to_input_id(const struct usb_device *dev, struct input_id *id)
22 id->version = le16_to_cpu(dev->descriptor.bcdDevice); 22 id->version = le16_to_cpu(dev->descriptor.bcdDevice);
23} 23}
24 24
25#endif 25#endif /* __LINUX_USB_INPUT_H */
diff --git a/include/linux/usb/iowarrior.h b/include/linux/usb/iowarrior.h
index de6f380e17a2..4fd6513d564c 100644
--- a/include/linux/usb/iowarrior.h
+++ b/include/linux/usb/iowarrior.h
@@ -1,5 +1,5 @@
1#ifndef _IOWARRIOR_H_ 1#ifndef __LINUX_USB_IOWARRIOR_H
2#define _IOWARRIOR_H_ 2#define __LINUX_USB_IOWARRIOR_H
3 3
4#define CODEMERCS_MAGIC_NUMBER 0xC0 /* like COde Mercenaries */ 4#define CODEMERCS_MAGIC_NUMBER 0xC0 /* like COde Mercenaries */
5 5
@@ -39,4 +39,4 @@ struct iowarrior_info {
39*/ 39*/
40#define IOW_GETINFO _IOR(CODEMERCS_MAGIC_NUMBER, 3, struct iowarrior_info) 40#define IOW_GETINFO _IOR(CODEMERCS_MAGIC_NUMBER, 3, struct iowarrior_info)
41 41
42#endif /* _IOWARRIOR_H_ */ 42#endif /* __LINUX_USB_IOWARRIOR_H */
diff --git a/include/linux/usb/isp116x.h b/include/linux/usb/isp116x.h
index 67d2826f34fe..96ca114e88d0 100644
--- a/include/linux/usb/isp116x.h
+++ b/include/linux/usb/isp116x.h
@@ -1,9 +1,11 @@
1
2/* 1/*
3 * Board initialization code should put one of these into dev->platform_data 2 * Board initialization code should put one of these into dev->platform_data
4 * and place the isp116x onto platform_bus. 3 * and place the isp116x onto platform_bus.
5 */ 4 */
6 5
6#ifndef __LINUX_USB_ISP116X_H
7#define __LINUX_USB_ISP116X_H
8
7struct isp116x_platform_data { 9struct isp116x_platform_data {
8 /* Enable internal resistors on downstream ports */ 10 /* Enable internal resistors on downstream ports */
9 unsigned sel15Kres:1; 11 unsigned sel15Kres:1;
@@ -27,3 +29,5 @@ struct isp116x_platform_data {
27 */ 29 */
28 void (*delay) (struct device *dev, int delay); 30 void (*delay) (struct device *dev, int delay);
29}; 31};
32
33#endif /* __LINUX_USB_ISP116X_H */
diff --git a/include/linux/usb/midi.h b/include/linux/usb/midi.h
index 80624c562921..1d1040865661 100644
--- a/include/linux/usb/midi.h
+++ b/include/linux/usb/midi.h
@@ -109,4 +109,4 @@ struct usb_ms_endpoint_descriptor_##n { \
109 __u8 baAssocJackID[n]; \ 109 __u8 baAssocJackID[n]; \
110} __attribute__ ((packed)) 110} __attribute__ ((packed))
111 111
112#endif 112#endif /* __LINUX_USB_MIDI_H */
diff --git a/include/linux/usb/net2280.h b/include/linux/usb/net2280.h
index ec897cb844ab..96ca549a778d 100644
--- a/include/linux/usb/net2280.h
+++ b/include/linux/usb/net2280.h
@@ -1,11 +1,7 @@
1/* 1/*
2 * NetChip 2280 high/full speed USB device controller. 2 * NetChip 2280 high/full speed USB device controller.
3 * Unlike many such controllers, this one talks PCI. 3 * Unlike many such controllers, this one talks PCI.
4 */ 4 *
5#ifndef __LINUX_USB_NET2280_H
6#define __LINUX_USB_NET2280_H
7
8/*
9 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com) 5 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
10 * Copyright (C) 2003 David Brownell 6 * Copyright (C) 2003 David Brownell
11 * 7 *
@@ -24,6 +20,9 @@
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 21 */
26 22
23#ifndef __LINUX_USB_NET2280_H
24#define __LINUX_USB_NET2280_H
25
27/*-------------------------------------------------------------------------*/ 26/*-------------------------------------------------------------------------*/
28 27
29/* NET2280 MEMORY MAPPED REGISTERS 28/* NET2280 MEMORY MAPPED REGISTERS
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index e007074ebe41..1db25d152ad8 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -1,11 +1,13 @@
1/* USB OTG (On The Go) defines */ 1/* USB OTG (On The Go) defines */
2
3/* 2/*
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
5 * (for either host or peripheral roles) don't use these calls; they 5 * (for either host or peripheral roles) don't use these calls; they
6 * continue to use just usb_device and usb_gadget. 6 * continue to use just usb_device and usb_gadget.
7 */ 7 */
8 8
9#ifndef __LINUX_USB_OTG_H
10#define __LINUX_USB_OTG_H
9 11
10/* OTG defines lots of enumeration states before device reset */ 12/* OTG defines lots of enumeration states before device reset */
11enum usb_otg_state { 13enum usb_otg_state {
@@ -129,3 +131,5 @@ otg_start_srp(struct otg_transceiver *otg)
129 131
130/* for OTG controller drivers (and maybe other stuff) */ 132/* for OTG controller drivers (and maybe other stuff) */
131extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); 133extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
134
135#endif /* __LINUX_USB_OTG_H */
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index 1f999ec8d08c..7f6c603db654 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -4,6 +4,9 @@
4 * belong here. 4 * belong here.
5 */ 5 */
6 6
7#ifndef __LINUX_USB_QUIRKS_H
8#define __LINUX_USB_QUIRKS_H
9
7/* string descriptors must not be fetched using a 255-byte read */ 10/* string descriptors must not be fetched using a 255-byte read */
8#define USB_QUIRK_STRING_FETCH_255 0x00000001 11#define USB_QUIRK_STRING_FETCH_255 0x00000001
9 12
@@ -12,3 +15,5 @@
12 15
13/* device can't handle Set-Interface requests */ 16/* device can't handle Set-Interface requests */
14#define USB_QUIRK_NO_SET_INTF 0x00000004 17#define USB_QUIRK_NO_SET_INTF 0x00000004
18
19#endif /* __LINUX_USB_QUIRKS_H */
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
index edc1d4a0e272..29d6458ecb8d 100644
--- a/include/linux/usb/rndis_host.h
+++ b/include/linux/usb/rndis_host.h
@@ -17,10 +17,8 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19
20 20#ifndef __LINUX_USB_RNDIS_HOST_H
21#ifndef __RNDIS_HOST_H 21#define __LINUX_USB_RNDIS_HOST_H
22#define __RNDIS_HOST_H
23
24 22
25/* 23/*
26 * CONTROL uses CDC "encapsulated commands" with funky notifications. 24 * CONTROL uses CDC "encapsulated commands" with funky notifications.
@@ -270,5 +268,4 @@ extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
270extern struct sk_buff * 268extern struct sk_buff *
271rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags); 269rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags);
272 270
273#endif /* __RNDIS_HOST_H */ 271#endif /* __LINUX_USB_RNDIS_HOST_H */
274
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 21b4a1c6f585..8f891cbaf9ab 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -10,7 +10,6 @@
10 * 10 *
11 */ 11 */
12 12
13
14#ifndef __LINUX_USB_SERIAL_H 13#ifndef __LINUX_USB_SERIAL_H
15#define __LINUX_USB_SERIAL_H 14#define __LINUX_USB_SERIAL_H
16 15
@@ -146,8 +145,6 @@ struct usb_serial {
146}; 145};
147#define to_usb_serial(d) container_of(d, struct usb_serial, kref) 146#define to_usb_serial(d) container_of(d, struct usb_serial, kref)
148 147
149#define NUM_DONT_CARE 99
150
151/* get and set the serial private data pointer helper functions */ 148/* get and set the serial private data pointer helper functions */
152static inline void *usb_get_serial_data(struct usb_serial *serial) 149static inline void *usb_get_serial_data(struct usb_serial *serial)
153{ 150{
@@ -165,18 +162,6 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
165 * used in the syslog messages when a device is inserted or removed. 162 * used in the syslog messages when a device is inserted or removed.
166 * @id_table: pointer to a list of usb_device_id structures that define all 163 * @id_table: pointer to a list of usb_device_id structures that define all
167 * of the devices this structure can support. 164 * of the devices this structure can support.
168 * @num_interrupt_in: If a device doesn't have this many interrupt-in
169 * endpoints, it won't be sent to the driver's attach() method.
170 * (But it might still be sent to the probe() method.)
171 * @num_interrupt_out: If a device doesn't have this many interrupt-out
172 * endpoints, it won't be sent to the driver's attach() method.
173 * (But it might still be sent to the probe() method.)
174 * @num_bulk_in: If a device doesn't have this many bulk-in
175 * endpoints, it won't be sent to the driver's attach() method.
176 * (But it might still be sent to the probe() method.)
177 * @num_bulk_out: If a device doesn't have this many bulk-out
178 * endpoints, it won't be sent to the driver's attach() method.
179 * (But it might still be sent to the probe() method.)
180 * @num_ports: the number of different ports this device will have. 165 * @num_ports: the number of different ports this device will have.
181 * @calc_num_ports: pointer to a function to determine how many ports this 166 * @calc_num_ports: pointer to a function to determine how many ports this
182 * device has dynamically. It will be called after the probe() 167 * device has dynamically. It will be called after the probe()
@@ -212,10 +197,6 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
212struct usb_serial_driver { 197struct usb_serial_driver {
213 const char *description; 198 const char *description;
214 const struct usb_device_id *id_table; 199 const struct usb_device_id *id_table;
215 char num_interrupt_in;
216 char num_interrupt_out;
217 char num_bulk_in;
218 char num_bulk_out;
219 char num_ports; 200 char num_ports;
220 201
221 struct list_head driver_list; 202 struct list_head driver_list;
@@ -340,5 +321,5 @@ static inline void usb_serial_debug_data(int debug,
340 321
341 322
342 323
343#endif /* ifdef __LINUX_USB_SERIAL_H */ 324#endif /* __LINUX_USB_SERIAL_H */
344 325
diff --git a/include/linux/usb/sl811.h b/include/linux/usb/sl811.h
index 877373da410d..3afe4d16fcef 100644
--- a/include/linux/usb/sl811.h
+++ b/include/linux/usb/sl811.h
@@ -1,9 +1,11 @@
1
2/* 1/*
3 * board initialization should put one of these into dev->platform_data 2 * board initialization should put one of these into dev->platform_data
4 * and place the sl811hs onto platform_bus named "sl811-hcd". 3 * and place the sl811hs onto platform_bus named "sl811-hcd".
5 */ 4 */
6 5
6#ifndef __LINUX_USB_SL811_H
7#define __LINUX_USB_SL811_H
8
7struct sl811_platform_data { 9struct sl811_platform_data {
8 unsigned can_wakeup:1; 10 unsigned can_wakeup:1;
9 11
@@ -24,3 +26,4 @@ struct sl811_platform_data {
24 /* void (*clock_enable)(struct device *dev, int is_on); */ 26 /* void (*clock_enable)(struct device *dev, int is_on); */
25}; 27};
26 28
29#endif /* __LINUX_USB_SL811_H */
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index e0501da3dd11..ba09fe88adda 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -19,10 +19,8 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22 22#ifndef __LINUX_USB_USBNET_H
23#ifndef __USBNET_H 23#define __LINUX_USB_USBNET_H
24#define __USBNET_H
25
26 24
27/* interface from usbnet core to each USB networking link we handle */ 25/* interface from usbnet core to each USB networking link we handle */
28struct usbnet { 26struct usbnet {
@@ -211,4 +209,4 @@ extern int usbnet_nway_reset(struct net_device *net);
211 printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \ 209 printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \
212 210
213 211
214#endif /* __USBNET_H */ 212#endif /* __LINUX_USB_USBNET_H */
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index 0a40dfa44c9f..d9a3bbe38e6b 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -85,6 +85,7 @@ enum { US_DO_ALL_FLAGS };
85#define US_SC_LOCKABLE 0x07 /* Password-protected */ 85#define US_SC_LOCKABLE 0x07 /* Password-protected */
86 86
87#define US_SC_ISD200 0xf0 /* ISD200 ATA */ 87#define US_SC_ISD200 0xf0 /* ISD200 ATA */
88#define US_SC_CYP_ATACB 0xf1 /* Cypress ATACB */
88#define US_SC_DEVICE 0xff /* Use device's value */ 89#define US_SC_DEVICE 0xff /* Use device's value */
89 90
90/* Protocols */ 91/* Protocols */
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 17cb108b7db0..3118ede2c67b 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -77,8 +77,11 @@ struct usbdevfs_connectinfo {
77 unsigned char slow; 77 unsigned char slow;
78}; 78};
79 79
80#define USBDEVFS_URB_SHORT_NOT_OK 1 80#define USBDEVFS_URB_SHORT_NOT_OK 0x01
81#define USBDEVFS_URB_ISO_ASAP 2 81#define USBDEVFS_URB_ISO_ASAP 0x02
82#define USBDEVFS_URB_NO_FSBR 0x20
83#define USBDEVFS_URB_ZERO_PACKET 0x40
84#define USBDEVFS_URB_NO_INTERRUPT 0x80
82 85
83#define USBDEVFS_URB_TYPE_ISO 0 86#define USBDEVFS_URB_TYPE_ISO 0
84#define USBDEVFS_URB_TYPE_INTERRUPT 1 87#define USBDEVFS_URB_TYPE_INTERRUPT 1
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 17a80177a674..c1411189ba6c 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -282,6 +282,7 @@ struct v4l2_pix_format
282#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ 282#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */
283#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ 283#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */
284#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ 284#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */
285#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y','1','6',' ') /* 16 Greyscale */
285#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P','A','L','8') /* 8 8-bit palette */ 286#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P','A','L','8') /* 8 8-bit palette */
286#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ 287#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */
287#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ 288#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */
@@ -308,6 +309,7 @@ struct v4l2_pix_format
308 309
309/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ 310/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
310#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ 311#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */
312#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B','Y','R','2') /* 16 BGBG.. GRGR.. */
311 313
312/* compressed formats */ 314/* compressed formats */
313#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ 315#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */
@@ -793,6 +795,7 @@ struct v4l2_ext_controls
793/* Values for ctrl_class field */ 795/* Values for ctrl_class field */
794#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ 796#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
795#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ 797#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */
798#define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */
796 799
797#define V4L2_CTRL_ID_MASK (0x0fffffff) 800#define V4L2_CTRL_ID_MASK (0x0fffffff)
798#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) 801#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
@@ -849,21 +852,37 @@ struct v4l2_querymenu
849#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) 852#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8)
850#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) 853#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9)
851#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) 854#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10)
852#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) 855#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) /* Deprecated */
853#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) 856#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12)
854#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) 857#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13)
855#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) 858#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14)
856#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) 859#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15)
857#define V4L2_CID_GAMMA (V4L2_CID_BASE+16) 860#define V4L2_CID_GAMMA (V4L2_CID_BASE+16)
858#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */ 861#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* Deprecated */
859#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) 862#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17)
860#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) 863#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18)
861#define V4L2_CID_GAIN (V4L2_CID_BASE+19) 864#define V4L2_CID_GAIN (V4L2_CID_BASE+19)
862#define V4L2_CID_HFLIP (V4L2_CID_BASE+20) 865#define V4L2_CID_HFLIP (V4L2_CID_BASE+20)
863#define V4L2_CID_VFLIP (V4L2_CID_BASE+21) 866#define V4L2_CID_VFLIP (V4L2_CID_BASE+21)
864#define V4L2_CID_HCENTER (V4L2_CID_BASE+22) 867
865#define V4L2_CID_VCENTER (V4L2_CID_BASE+23) 868/* Deprecated, use V4L2_CID_PAN_RESET and V4L2_CID_TILT_RESET */
866#define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */ 869#define V4L2_CID_HCENTER_DEPRECATED (V4L2_CID_BASE+22)
870#define V4L2_CID_VCENTER_DEPRECATED (V4L2_CID_BASE+23)
871
872#define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24)
873enum v4l2_power_line_frequency {
874 V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
875 V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1,
876 V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2,
877};
878#define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25)
879#define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26)
880#define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27)
881#define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28)
882#define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29)
883#define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30)
884/* last CID + 1 */
885#define V4L2_CID_LASTP1 (V4L2_CID_BASE+31)
867 886
868/* MPEG-class control IDs defined by V4L2 */ 887/* MPEG-class control IDs defined by V4L2 */
869#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) 888#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
@@ -1051,6 +1070,32 @@ enum v4l2_mpeg_cx2341x_video_median_filter_type {
1051#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) 1070#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)
1052#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) 1071#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11)
1053 1072
1073/* Camera class control IDs */
1074#define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
1075#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
1076
1077#define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1)
1078enum v4l2_exposure_auto_type {
1079 V4L2_EXPOSURE_AUTO = 0,
1080 V4L2_EXPOSURE_MANUAL = 1,
1081 V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
1082 V4L2_EXPOSURE_APERTURE_PRIORITY = 3
1083};
1084#define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2)
1085#define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3)
1086
1087#define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4)
1088#define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5)
1089#define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6)
1090#define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7)
1091
1092#define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8)
1093#define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9)
1094
1095#define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10)
1096#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11)
1097#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12)
1098
1054/* 1099/*
1055 * T U N I N G 1100 * T U N I N G
1056 */ 1101 */
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index ce8e7da05807..364789aae9f3 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -31,6 +31,7 @@ struct vm_struct {
31 struct page **pages; 31 struct page **pages;
32 unsigned int nr_pages; 32 unsigned int nr_pages;
33 unsigned long phys_addr; 33 unsigned long phys_addr;
34 void *caller;
34}; 35};
35 36
36/* 37/*
@@ -66,6 +67,8 @@ static inline size_t get_vm_area_size(const struct vm_struct *area)
66} 67}
67 68
68extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags); 69extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
70extern struct vm_struct *get_vm_area_caller(unsigned long size,
71 unsigned long flags, void *caller);
69extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags, 72extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
70 unsigned long start, unsigned long end); 73 unsigned long start, unsigned long end);
71extern struct vm_struct *get_vm_area_node(unsigned long size, 74extern struct vm_struct *get_vm_area_node(unsigned long size,
@@ -87,4 +90,6 @@ extern void free_vm_area(struct vm_struct *area);
87extern rwlock_t vmlist_lock; 90extern rwlock_t vmlist_lock;
88extern struct vm_struct *vmlist; 91extern struct vm_struct *vmlist;
89 92
93extern const struct seq_operations vmalloc_op;
94
90#endif /* _LINUX_VMALLOC_H */ 95#endif /* _LINUX_VMALLOC_H */
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 9f1b4b46151e..e83b69346d23 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -25,6 +25,7 @@
25#define HIGHMEM_ZONE(xx) 25#define HIGHMEM_ZONE(xx)
26#endif 26#endif
27 27
28
28#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) , xx##_MOVABLE 29#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) , xx##_MOVABLE
29 30
30enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, 31enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
@@ -37,6 +38,9 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
37 FOR_ALL_ZONES(PGSCAN_DIRECT), 38 FOR_ALL_ZONES(PGSCAN_DIRECT),
38 PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL, 39 PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
39 PAGEOUTRUN, ALLOCSTALL, PGROTATED, 40 PAGEOUTRUN, ALLOCSTALL, PGROTATED,
41#ifdef CONFIG_HUGETLB_PAGE
42 HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL,
43#endif
40 NR_VM_EVENT_ITEMS 44 NR_VM_EVENT_ITEMS
41}; 45};
42 46
@@ -174,7 +178,7 @@ static inline unsigned long node_page_state(int node,
174 zone_page_state(&zones[ZONE_MOVABLE], item); 178 zone_page_state(&zones[ZONE_MOVABLE], item);
175} 179}
176 180
177extern void zone_statistics(struct zonelist *, struct zone *); 181extern void zone_statistics(struct zone *, struct zone *);
178 182
179#else 183#else
180 184
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index 3160dfed73ca..2864b1699ecc 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -455,6 +455,7 @@
455#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */ 455#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
456#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */ 456#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
457#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */ 457#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
458#define IW_MODE_MESH 7 /* Mesh (IEEE 802.11s) network */
458 459
459/* Statistics flags (bitmask in updated) */ 460/* Statistics flags (bitmask in updated) */
460#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */ 461#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
new file mode 100644
index 000000000000..4d13732e9cf0
--- /dev/null
+++ b/include/linux/wm97xx.h
@@ -0,0 +1,314 @@
1
2/*
3 * Register bits and API for Wolfson WM97xx series of codecs
4 */
5
6#ifndef _LINUX_WM97XX_H
7#define _LINUX_WM97XX_H
8
9#include <sound/core.h>
10#include <sound/pcm.h>
11#include <sound/ac97_codec.h>
12#include <sound/initval.h>
13#include <linux/types.h>
14#include <linux/list.h>
15#include <linux/input.h> /* Input device layer */
16#include <linux/platform_device.h>
17
18/*
19 * WM97xx AC97 Touchscreen registers
20 */
21#define AC97_WM97XX_DIGITISER1 0x76
22#define AC97_WM97XX_DIGITISER2 0x78
23#define AC97_WM97XX_DIGITISER_RD 0x7a
24#define AC97_WM9713_DIG1 0x74
25#define AC97_WM9713_DIG2 AC97_WM97XX_DIGITISER1
26#define AC97_WM9713_DIG3 AC97_WM97XX_DIGITISER2
27
28/*
29 * WM97xx register bits
30 */
31#define WM97XX_POLL 0x8000 /* initiate a polling measurement */
32#define WM97XX_ADCSEL_X 0x1000 /* x coord measurement */
33#define WM97XX_ADCSEL_Y 0x2000 /* y coord measurement */
34#define WM97XX_ADCSEL_PRES 0x3000 /* pressure measurement */
35#define WM97XX_ADCSEL_MASK 0x7000
36#define WM97XX_COO 0x0800 /* enable coordinate mode */
37#define WM97XX_CTC 0x0400 /* enable continuous mode */
38#define WM97XX_CM_RATE_93 0x0000 /* 93.75Hz continuous rate */
39#define WM97XX_CM_RATE_187 0x0100 /* 187.5Hz continuous rate */
40#define WM97XX_CM_RATE_375 0x0200 /* 375Hz continuous rate */
41#define WM97XX_CM_RATE_750 0x0300 /* 750Hz continuous rate */
42#define WM97XX_CM_RATE_8K 0x00f0 /* 8kHz continuous rate */
43#define WM97XX_CM_RATE_12K 0x01f0 /* 12kHz continuous rate */
44#define WM97XX_CM_RATE_24K 0x02f0 /* 24kHz continuous rate */
45#define WM97XX_CM_RATE_48K 0x03f0 /* 48kHz continuous rate */
46#define WM97XX_CM_RATE_MASK 0x03f0
47#define WM97XX_RATE(i) (((i & 3) << 8) | ((i & 4) ? 0xf0 : 0))
48#define WM97XX_DELAY(i) ((i << 4) & 0x00f0) /* sample delay times */
49#define WM97XX_DELAY_MASK 0x00f0
50#define WM97XX_SLEN 0x0008 /* slot read back enable */
51#define WM97XX_SLT(i) ((i - 5) & 0x7) /* panel slot (5-11) */
52#define WM97XX_SLT_MASK 0x0007
53#define WM97XX_PRP_DETW 0x4000 /* detect on, digitise off, wake */
54#define WM97XX_PRP_DET 0x8000 /* detect on, digitise off, no wake */
55#define WM97XX_PRP_DET_DIG 0xc000 /* setect on, digitise on */
56#define WM97XX_RPR 0x2000 /* wake up on pen down */
57#define WM97XX_PEN_DOWN 0x8000 /* pen is down */
58#define WM97XX_ADCSRC_MASK 0x7000 /* ADC source mask */
59
60#define WM97XX_AUX_ID1 0x8001
61#define WM97XX_AUX_ID2 0x8002
62#define WM97XX_AUX_ID3 0x8003
63#define WM97XX_AUX_ID4 0x8004
64
65
66/* WM9712 Bits */
67#define WM9712_45W 0x1000 /* set for 5-wire touchscreen */
68#define WM9712_PDEN 0x0800 /* measure only when pen down */
69#define WM9712_WAIT 0x0200 /* wait until adc is read before next sample */
70#define WM9712_PIL 0x0100 /* current used for pressure measurement. set 400uA else 200uA */
71#define WM9712_MASK_HI 0x0040 /* hi on mask pin (47) stops conversions */
72#define WM9712_MASK_EDGE 0x0080 /* rising/falling edge on pin delays sample */
73#define WM9712_MASK_SYNC 0x00c0 /* rising/falling edge on mask initiates sample */
74#define WM9712_RPU(i) (i&0x3f) /* internal pull up on pen detect (64k / rpu) */
75#define WM9712_PD(i) (0x1 << i) /* power management */
76
77/* WM9712 Registers */
78#define AC97_WM9712_POWER 0x24
79#define AC97_WM9712_REV 0x58
80
81/* WM9705 Bits */
82#define WM9705_PDEN 0x1000 /* measure only when pen is down */
83#define WM9705_PINV 0x0800 /* inverts sense of pen down output */
84#define WM9705_BSEN 0x0400 /* BUSY flag enable, pin47 is 1 when busy */
85#define WM9705_BINV 0x0200 /* invert BUSY (pin47) output */
86#define WM9705_WAIT 0x0100 /* wait until adc is read before next sample */
87#define WM9705_PIL 0x0080 /* current used for pressure measurement. set 400uA else 200uA */
88#define WM9705_PHIZ 0x0040 /* set PHONE and PCBEEP inputs to high impedance */
89#define WM9705_MASK_HI 0x0010 /* hi on mask stops conversions */
90#define WM9705_MASK_EDGE 0x0020 /* rising/falling edge on pin delays sample */
91#define WM9705_MASK_SYNC 0x0030 /* rising/falling edge on mask initiates sample */
92#define WM9705_PDD(i) (i & 0x000f) /* pen detect comparator threshold */
93
94
95/* WM9713 Bits */
96#define WM9713_PDPOL 0x0400 /* Pen down polarity */
97#define WM9713_POLL 0x0200 /* initiate a polling measurement */
98#define WM9713_CTC 0x0100 /* enable continuous mode */
99#define WM9713_ADCSEL_X 0x0002 /* X measurement */
100#define WM9713_ADCSEL_Y 0x0004 /* Y measurement */
101#define WM9713_ADCSEL_PRES 0x0008 /* Pressure measurement */
102#define WM9713_COO 0x0001 /* enable coordinate mode */
103#define WM9713_PDEN 0x0800 /* measure only when pen down */
104#define WM9713_ADCSEL_MASK 0x00fe /* ADC selection mask */
105#define WM9713_WAIT 0x0200 /* coordinate wait */
106
107/* AUX ADC ID's */
108#define TS_COMP1 0x0
109#define TS_COMP2 0x1
110#define TS_BMON 0x2
111#define TS_WIPER 0x3
112
113/* ID numbers */
114#define WM97XX_ID1 0x574d
115#define WM9712_ID2 0x4c12
116#define WM9705_ID2 0x4c05
117#define WM9713_ID2 0x4c13
118
119/* Codec GPIO's */
120#define WM97XX_MAX_GPIO 16
121#define WM97XX_GPIO_1 (1 << 1)
122#define WM97XX_GPIO_2 (1 << 2)
123#define WM97XX_GPIO_3 (1 << 3)
124#define WM97XX_GPIO_4 (1 << 4)
125#define WM97XX_GPIO_5 (1 << 5)
126#define WM97XX_GPIO_6 (1 << 6)
127#define WM97XX_GPIO_7 (1 << 7)
128#define WM97XX_GPIO_8 (1 << 8)
129#define WM97XX_GPIO_9 (1 << 9)
130#define WM97XX_GPIO_10 (1 << 10)
131#define WM97XX_GPIO_11 (1 << 11)
132#define WM97XX_GPIO_12 (1 << 12)
133#define WM97XX_GPIO_13 (1 << 13)
134#define WM97XX_GPIO_14 (1 << 14)
135#define WM97XX_GPIO_15 (1 << 15)
136
137
138#define AC97_LINK_FRAME 21 /* time in uS for AC97 link frame */
139
140
141/*---------------- Return codes from sample reading functions ---------------*/
142
143/* More data is available; call the sample gathering function again */
144#define RC_AGAIN 0x00000001
145/* The returned sample is valid */
146#define RC_VALID 0x00000002
147/* The pen is up (the first RC_VALID without RC_PENUP means pen is down) */
148#define RC_PENUP 0x00000004
149/* The pen is down (RC_VALID implies RC_PENDOWN, but sometimes it is helpful
150 to tell the handler that the pen is down but we don't know yet his coords,
151 so the handler should not sleep or wait for pendown irq) */
152#define RC_PENDOWN 0x00000008
153
154/*
155 * The wm97xx driver provides a private API for writing platform-specific
156 * drivers.
157 */
158
159/* The structure used to return arch specific sampled data into */
160struct wm97xx_data {
161 int x;
162 int y;
163 int p;
164};
165
166/*
167 * Codec GPIO status
168 */
169enum wm97xx_gpio_status {
170 WM97XX_GPIO_HIGH,
171 WM97XX_GPIO_LOW
172};
173
174/*
175 * Codec GPIO direction
176 */
177enum wm97xx_gpio_dir {
178 WM97XX_GPIO_IN,
179 WM97XX_GPIO_OUT
180};
181
182/*
183 * Codec GPIO polarity
184 */
185enum wm97xx_gpio_pol {
186 WM97XX_GPIO_POL_HIGH,
187 WM97XX_GPIO_POL_LOW
188};
189
190/*
191 * Codec GPIO sticky
192 */
193enum wm97xx_gpio_sticky {
194 WM97XX_GPIO_STICKY,
195 WM97XX_GPIO_NOTSTICKY
196};
197
198/*
199 * Codec GPIO wake
200 */
201enum wm97xx_gpio_wake {
202 WM97XX_GPIO_WAKE,
203 WM97XX_GPIO_NOWAKE
204};
205
206/*
207 * Digitiser ioctl commands
208 */
209#define WM97XX_DIG_START 0x1
210#define WM97XX_DIG_STOP 0x2
211#define WM97XX_PHY_INIT 0x3
212#define WM97XX_AUX_PREPARE 0x4
213#define WM97XX_DIG_RESTORE 0x5
214
215struct wm97xx;
216
217extern struct wm97xx_codec_drv wm9705_codec;
218extern struct wm97xx_codec_drv wm9712_codec;
219extern struct wm97xx_codec_drv wm9713_codec;
220
221/*
222 * Codec driver interface - allows mapping to WM9705/12/13 and newer codecs
223 */
224struct wm97xx_codec_drv {
225 u16 id;
226 char *name;
227
228 /* read 1 sample */
229 int (*poll_sample) (struct wm97xx *, int adcsel, int *sample);
230
231 /* read X,Y,[P] in poll */
232 int (*poll_touch) (struct wm97xx *, struct wm97xx_data *);
233
234 int (*acc_enable) (struct wm97xx *, int enable);
235 void (*phy_init) (struct wm97xx *);
236 void (*dig_enable) (struct wm97xx *, int enable);
237 void (*dig_restore) (struct wm97xx *);
238 void (*aux_prepare) (struct wm97xx *);
239};
240
241
242/* Machine specific and accelerated touch operations */
243struct wm97xx_mach_ops {
244
245 /* accelerated touch readback - coords are transmited on AC97 link */
246 int acc_enabled;
247 void (*acc_pen_up) (struct wm97xx *);
248 int (*acc_pen_down) (struct wm97xx *);
249 int (*acc_startup) (struct wm97xx *);
250 void (*acc_shutdown) (struct wm97xx *);
251
252 /* interrupt mask control - required for accelerated operation */
253 void (*irq_enable) (struct wm97xx *, int enable);
254
255 /* GPIO pin used for accelerated operation */
256 int irq_gpio;
257
258 /* pre and post sample - can be used to minimise any analog noise */
259 void (*pre_sample) (int); /* function to run before sampling */
260 void (*post_sample) (int); /* function to run after sampling */
261};
262
263struct wm97xx {
264 u16 dig[3], id, gpio[6], misc; /* Cached codec registers */
265 u16 dig_save[3]; /* saved during aux reading */
266 struct wm97xx_codec_drv *codec; /* attached codec driver*/
267 struct input_dev *input_dev; /* touchscreen input device */
268 struct snd_ac97 *ac97; /* ALSA codec access */
269 struct device *dev; /* ALSA device */
270 struct platform_device *battery_dev;
271 struct platform_device *touch_dev;
272 struct wm97xx_mach_ops *mach_ops;
273 struct mutex codec_mutex;
274 struct delayed_work ts_reader; /* Used to poll touchscreen */
275 unsigned long ts_reader_interval; /* Current interval for timer */
276 unsigned long ts_reader_min_interval; /* Minimum interval */
277 unsigned int pen_irq; /* Pen IRQ number in use */
278 struct workqueue_struct *ts_workq;
279 struct work_struct pen_event_work;
280 u16 acc_slot; /* AC97 slot used for acc touch data */
281 u16 acc_rate; /* acc touch data rate */
282 unsigned pen_is_down:1; /* Pen is down */
283 unsigned aux_waiting:1; /* aux measurement waiting */
284 unsigned pen_probably_down:1; /* used in polling mode */
285 u16 suspend_mode; /* PRP in suspend mode */
286};
287
288/*
289 * Codec GPIO access (not supported on WM9705)
290 * This can be used to set/get codec GPIO and Virtual GPIO status.
291 */
292enum wm97xx_gpio_status wm97xx_get_gpio(struct wm97xx *wm, u32 gpio);
293void wm97xx_set_gpio(struct wm97xx *wm, u32 gpio,
294 enum wm97xx_gpio_status status);
295void wm97xx_config_gpio(struct wm97xx *wm, u32 gpio,
296 enum wm97xx_gpio_dir dir,
297 enum wm97xx_gpio_pol pol,
298 enum wm97xx_gpio_sticky sticky,
299 enum wm97xx_gpio_wake wake);
300
301void wm97xx_set_suspend_mode(struct wm97xx *wm, u16 mode);
302
303/* codec AC97 IO access */
304int wm97xx_reg_read(struct wm97xx *wm, u16 reg);
305void wm97xx_reg_write(struct wm97xx *wm, u16 reg, u16 val);
306
307/* aux adc readback */
308int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel);
309
310/* machine ops */
311int wm97xx_register_mach_ops(struct wm97xx *, struct wm97xx_mach_ops *);
312void wm97xx_unregister_mach_ops(struct wm97xx *);
313
314#endif
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index b7b3362f7717..f462439cc288 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -114,6 +114,9 @@ struct file;
114int dirty_writeback_centisecs_handler(struct ctl_table *, int, struct file *, 114int dirty_writeback_centisecs_handler(struct ctl_table *, int, struct file *,
115 void __user *, size_t *, loff_t *); 115 void __user *, size_t *, loff_t *);
116 116
117void get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty,
118 struct backing_dev_info *bdi);
119
117void page_writeback_init(void); 120void page_writeback_init(void);
118void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, 121void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
119 unsigned long nr_pages_dirtied); 122 unsigned long nr_pages_dirtied);
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index df6b95d2218e..d131e352cfe1 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -47,10 +47,10 @@ struct xattr_handler {
47}; 47};
48 48
49ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t); 49ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
50ssize_t vfs_getxattr(struct dentry *, char *, void *, size_t); 50ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
51ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size); 51ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
52int vfs_setxattr(struct dentry *, char *, void *, size_t, int); 52int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int);
53int vfs_removexattr(struct dentry *, char *); 53int vfs_removexattr(struct dentry *, const char *);
54 54
55ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size); 55ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size);
56ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size); 56ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index e31b8c84f2c9..2ca6bae88721 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -97,10 +97,10 @@ struct xfrm_algo {
97}; 97};
98 98
99struct xfrm_algo_aead { 99struct xfrm_algo_aead {
100 char alg_name[64]; 100 char alg_name[64];
101 int alg_key_len; /* in bits */ 101 unsigned int alg_key_len; /* in bits */
102 int alg_icv_len; /* in bits */ 102 unsigned int alg_icv_len; /* in bits */
103 char alg_key[0]; 103 char alg_key[0];
104}; 104};
105 105
106struct xfrm_stats { 106struct xfrm_stats {
@@ -113,7 +113,8 @@ enum
113{ 113{
114 XFRM_POLICY_TYPE_MAIN = 0, 114 XFRM_POLICY_TYPE_MAIN = 0,
115 XFRM_POLICY_TYPE_SUB = 1, 115 XFRM_POLICY_TYPE_SUB = 1,
116 XFRM_POLICY_TYPE_MAX = 2 116 XFRM_POLICY_TYPE_MAX = 2,
117 XFRM_POLICY_TYPE_ANY = 255
117}; 118};
118 119
119enum 120enum
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index a4274203f252..bfee8be5d63f 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -107,6 +107,7 @@ extern IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE];
107extern IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE]; 107extern IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE];
108extern IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE]; 108extern IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE];
109extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE]; 109extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE];
110extern IR_KEYTAB_TYPE ir_codes_pixelview_new[IR_KEYTAB_SIZE];
110extern IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE]; 111extern IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE];
111extern IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE]; 112extern IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE];
112extern IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE]; 113extern IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE];
@@ -141,8 +142,10 @@ extern IR_KEYTAB_TYPE ir_codes_encore_enltv[IR_KEYTAB_SIZE];
141extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE]; 142extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE];
142extern IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE]; 143extern 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_behold[IR_KEYTAB_SIZE];
145extern IR_KEYTAB_TYPE ir_codes_behold_columbus[IR_KEYTAB_SIZE];
144extern IR_KEYTAB_TYPE ir_codes_pinnacle_pctv_hd[IR_KEYTAB_SIZE]; 146extern IR_KEYTAB_TYPE ir_codes_pinnacle_pctv_hd[IR_KEYTAB_SIZE];
145extern IR_KEYTAB_TYPE ir_codes_genius_tvgo_a11mce[IR_KEYTAB_SIZE]; 147extern IR_KEYTAB_TYPE ir_codes_genius_tvgo_a11mce[IR_KEYTAB_SIZE];
148extern IR_KEYTAB_TYPE ir_codes_powercolor_real_angel[IR_KEYTAB_SIZE];
146 149
147#endif 150#endif
148 151
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
new file mode 100644
index 000000000000..6a8c8be7a1ae
--- /dev/null
+++ b/include/media/soc_camera.h
@@ -0,0 +1,179 @@
1/*
2 * camera image capture (abstract) bus driver header
3 *
4 * Copyright (C) 2006, Sascha Hauer, Pengutronix
5 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@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 version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef SOC_CAMERA_H
13#define SOC_CAMERA_H
14
15#include <linux/videodev2.h>
16#include <media/videobuf-dma-sg.h>
17
18struct soc_camera_device {
19 struct list_head list;
20 struct device dev;
21 struct device *control;
22 unsigned short width; /* Current window */
23 unsigned short height; /* sizes */
24 unsigned short x_min; /* Camera capabilities */
25 unsigned short y_min;
26 unsigned short x_current; /* Current window location */
27 unsigned short y_current;
28 unsigned short width_min;
29 unsigned short width_max;
30 unsigned short height_min;
31 unsigned short height_max;
32 unsigned short y_skip_top; /* Lines to skip at the top */
33 unsigned short gain;
34 unsigned short exposure;
35 unsigned char iface; /* Host number */
36 unsigned char devnum; /* Device number per host */
37 unsigned char buswidth; /* See comment in .c */
38 struct soc_camera_ops *ops;
39 struct video_device *vdev;
40 const struct soc_camera_data_format *current_fmt;
41 const struct soc_camera_data_format *formats;
42 int num_formats;
43 struct module *owner;
44 /* soc_camera.c private count. Only accessed with video_lock held */
45 int use_count;
46};
47
48struct soc_camera_file {
49 struct soc_camera_device *icd;
50 struct videobuf_queue vb_vidq;
51 spinlock_t *lock;
52};
53
54struct soc_camera_host {
55 struct list_head list;
56 struct device dev;
57 unsigned char nr; /* Host number */
58 size_t msize;
59 struct videobuf_queue_ops *vbq_ops;
60 void *priv;
61 char *drv_name;
62 struct soc_camera_host_ops *ops;
63};
64
65struct soc_camera_host_ops {
66 struct module *owner;
67 int (*add)(struct soc_camera_device *);
68 void (*remove)(struct soc_camera_device *);
69 int (*set_fmt_cap)(struct soc_camera_device *, __u32,
70 struct v4l2_rect *);
71 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
72 int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *);
73 int (*querycap)(struct soc_camera_host *, struct v4l2_capability *);
74 int (*try_bus_param)(struct soc_camera_device *, __u32);
75 int (*set_bus_param)(struct soc_camera_device *, __u32);
76 unsigned int (*poll)(struct file *, poll_table *);
77 spinlock_t* (*spinlock_alloc)(struct soc_camera_file *);
78 void (*spinlock_free)(spinlock_t *);
79};
80
81struct soc_camera_link {
82 /* Camera bus id, used to match a camera and a bus */
83 int bus_id;
84 /* GPIO number to switch between 8 and 10 bit modes */
85 unsigned int gpio;
86};
87
88static inline struct soc_camera_device *to_soc_camera_dev(struct device *dev)
89{
90 return container_of(dev, struct soc_camera_device, dev);
91}
92
93static inline struct soc_camera_host *to_soc_camera_host(struct device *dev)
94{
95 return container_of(dev, struct soc_camera_host, dev);
96}
97
98extern int soc_camera_host_register(struct soc_camera_host *ici);
99extern void soc_camera_host_unregister(struct soc_camera_host *ici);
100extern int soc_camera_device_register(struct soc_camera_device *icd);
101extern void soc_camera_device_unregister(struct soc_camera_device *icd);
102
103extern int soc_camera_video_start(struct soc_camera_device *icd);
104extern void soc_camera_video_stop(struct soc_camera_device *icd);
105
106struct soc_camera_data_format {
107 char *name;
108 unsigned int depth;
109 __u32 fourcc;
110 enum v4l2_colorspace colorspace;
111};
112
113struct soc_camera_ops {
114 struct module *owner;
115 int (*probe)(struct soc_camera_device *);
116 void (*remove)(struct soc_camera_device *);
117 int (*init)(struct soc_camera_device *);
118 int (*release)(struct soc_camera_device *);
119 int (*start_capture)(struct soc_camera_device *);
120 int (*stop_capture)(struct soc_camera_device *);
121 int (*set_fmt_cap)(struct soc_camera_device *, __u32,
122 struct v4l2_rect *);
123 int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
124 unsigned long (*query_bus_param)(struct soc_camera_device *);
125 int (*set_bus_param)(struct soc_camera_device *, unsigned long);
126 int (*get_chip_id)(struct soc_camera_device *,
127 struct v4l2_chip_ident *);
128#ifdef CONFIG_VIDEO_ADV_DEBUG
129 int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
130 int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
131#endif
132 int (*get_control)(struct soc_camera_device *, struct v4l2_control *);
133 int (*set_control)(struct soc_camera_device *, struct v4l2_control *);
134 const struct v4l2_queryctrl *controls;
135 int num_controls;
136};
137
138static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
139 struct soc_camera_ops *ops, int id)
140{
141 int i;
142
143 for (i = 0; i < ops->num_controls; i++)
144 if (ops->controls[i].id == id)
145 return &ops->controls[i];
146
147 return NULL;
148}
149
150#define SOCAM_MASTER (1 << 0)
151#define SOCAM_SLAVE (1 << 1)
152#define SOCAM_HSYNC_ACTIVE_HIGH (1 << 2)
153#define SOCAM_HSYNC_ACTIVE_LOW (1 << 3)
154#define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4)
155#define SOCAM_VSYNC_ACTIVE_LOW (1 << 5)
156#define SOCAM_DATAWIDTH_8 (1 << 6)
157#define SOCAM_DATAWIDTH_9 (1 << 7)
158#define SOCAM_DATAWIDTH_10 (1 << 8)
159#define SOCAM_PCLK_SAMPLE_RISING (1 << 9)
160#define SOCAM_PCLK_SAMPLE_FALLING (1 << 10)
161
162#define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_9 | \
163 SOCAM_DATAWIDTH_10)
164
165static inline unsigned long soc_camera_bus_param_compatible(
166 unsigned long camera_flags, unsigned long bus_flags)
167{
168 unsigned long common_flags, hsync, vsync, pclk;
169
170 common_flags = camera_flags & bus_flags;
171
172 hsync = common_flags & (SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW);
173 vsync = common_flags & (SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW);
174 pclk = common_flags & (SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING);
175
176 return (!hsync || !vsync || !pclk) ? 0 : common_flags;
177}
178
179#endif
diff --git a/include/media/tuner-types.h b/include/media/tuner-types.h
index b201371416a0..ab03c5344209 100644
--- a/include/media/tuner-types.h
+++ b/include/media/tuner-types.h
@@ -6,10 +6,11 @@
6#define __TUNER_TYPES_H__ 6#define __TUNER_TYPES_H__
7 7
8enum param_type { 8enum param_type {
9 TUNER_PARAM_TYPE_RADIO, \ 9 TUNER_PARAM_TYPE_RADIO,
10 TUNER_PARAM_TYPE_PAL, \ 10 TUNER_PARAM_TYPE_PAL,
11 TUNER_PARAM_TYPE_SECAM, \ 11 TUNER_PARAM_TYPE_SECAM,
12 TUNER_PARAM_TYPE_NTSC 12 TUNER_PARAM_TYPE_NTSC,
13 TUNER_PARAM_TYPE_DIGITAL,
13}; 14};
14 15
15struct tuner_range { 16struct tuner_range {
@@ -105,6 +106,7 @@ struct tuner_params {
105 the SECAM-L/L' standards. Range: -16:+15 */ 106 the SECAM-L/L' standards. Range: -16:+15 */
106 signed int default_top_secam_high:5; 107 signed int default_top_secam_high:5;
107 108
109 u16 iffreq;
108 110
109 unsigned int count; 111 unsigned int count;
110 struct tuner_range *ranges; 112 struct tuner_range *ranges;
@@ -114,6 +116,13 @@ struct tunertype {
114 char *name; 116 char *name;
115 unsigned int count; 117 unsigned int count;
116 struct tuner_params *params; 118 struct tuner_params *params;
119
120 u16 min;
121 u16 max;
122 u32 stepsize;
123
124 u8 *initdata;
125 u8 *sleepdata;
117}; 126};
118 127
119extern struct tunertype tuners[]; 128extern struct tunertype tuners[];
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 1bf24a6ed8f1..77068fcc86bd 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -78,7 +78,7 @@
78 78
79#define TUNER_HITACHI_NTSC 40 79#define TUNER_HITACHI_NTSC 40
80#define TUNER_PHILIPS_PAL_MK 41 80#define TUNER_PHILIPS_PAL_MK 41
81#define TUNER_PHILIPS_ATSC 42 81#define TUNER_PHILIPS_FCV1236D 42
82#define TUNER_PHILIPS_FM1236_MK3 43 82#define TUNER_PHILIPS_FM1236_MK3 43
83 83
84#define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */ 84#define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 032bb75f69c2..2a527742701a 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -64,6 +64,7 @@ enum {
64 /* Conexant MPEG encoder/decoders: reserved range 410-420 */ 64 /* Conexant MPEG encoder/decoders: reserved range 410-420 */
65 V4L2_IDENT_CX23415 = 415, 65 V4L2_IDENT_CX23415 = 415,
66 V4L2_IDENT_CX23416 = 416, 66 V4L2_IDENT_CX23416 = 416,
67 V4L2_IDENT_CX23418 = 418,
67 68
68 /* module vp27smpx: just ident 2700 */ 69 /* module vp27smpx: just ident 2700 */
69 V4L2_IDENT_VP27SMPX = 2700, 70 V4L2_IDENT_VP27SMPX = 2700,
@@ -153,6 +154,12 @@ enum {
153 V4L2_IDENT_MSP4428G = 44287, 154 V4L2_IDENT_MSP4428G = 44287,
154 V4L2_IDENT_MSP4448G = 44487, 155 V4L2_IDENT_MSP4448G = 44487,
155 V4L2_IDENT_MSP4458G = 44587, 156 V4L2_IDENT_MSP4458G = 44587,
157
158 /* Micron CMOS sensor chips: 45000-45099 */
159 V4L2_IDENT_MT9M001C12ST = 45000,
160 V4L2_IDENT_MT9M001C12STM = 45005,
161 V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */
162 V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */
156}; 163};
157 164
158#endif 165#endif
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 316a58453134..020d05758bd8 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -107,9 +107,11 @@ int v4l2_chip_match_host(u32 id_type, u32 chip_id);
107struct i2c_driver; 107struct i2c_driver;
108struct i2c_adapter; 108struct i2c_adapter;
109struct i2c_client; 109struct i2c_client;
110struct i2c_device_id;
110 111
111int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, 112int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
112 const char *name, int (*probe)(struct i2c_client *)); 113 const char *name,
114 int (*probe)(struct i2c_client *, const struct i2c_device_id *));
113 115
114/* ------------------------------------------------------------------------- */ 116/* ------------------------------------------------------------------------- */
115 117
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index f2114459995d..a807d2f86ee8 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -318,6 +318,10 @@ struct video_device
318 int (*vidioc_g_chip_ident) (struct file *file, void *fh, 318 int (*vidioc_g_chip_ident) (struct file *file, void *fh,
319 struct v4l2_chip_ident *chip); 319 struct v4l2_chip_ident *chip);
320 320
321 /* For other private ioctls */
322 int (*vidioc_default) (struct file *file, void *fh,
323 int cmd, void *arg);
324
321 325
322#ifdef OBSOLETE_OWNER /* to be removed soon */ 326#ifdef OBSOLETE_OWNER /* to be removed soon */
323/* obsolete -- fops->owner is used instead */ 327/* obsolete -- fops->owner is used instead */
diff --git a/include/media/v4l2-i2c-drv-legacy.h b/include/media/v4l2-i2c-drv-legacy.h
index e7645578fc22..347b6f8beb23 100644
--- a/include/media/v4l2-i2c-drv-legacy.h
+++ b/include/media/v4l2-i2c-drv-legacy.h
@@ -25,7 +25,7 @@ struct v4l2_i2c_driver_data {
25 const char * const name; 25 const char * const name;
26 int driverid; 26 int driverid;
27 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); 27 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
28 int (*probe)(struct i2c_client *client); 28 int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
29 int (*remove)(struct i2c_client *client); 29 int (*remove)(struct i2c_client *client);
30 int (*suspend)(struct i2c_client *client, pm_message_t state); 30 int (*suspend)(struct i2c_client *client, pm_message_t state);
31 int (*resume)(struct i2c_client *client); 31 int (*resume)(struct i2c_client *client);
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h
index 9e4bab276915..7b6f06be7950 100644
--- a/include/media/v4l2-i2c-drv.h
+++ b/include/media/v4l2-i2c-drv.h
@@ -30,7 +30,7 @@ struct v4l2_i2c_driver_data {
30 const char * const name; 30 const char * const name;
31 int driverid; 31 int driverid;
32 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); 32 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
33 int (*probe)(struct i2c_client *client); 33 int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
34 int (*remove)(struct i2c_client *client); 34 int (*remove)(struct i2c_client *client);
35 int (*suspend)(struct i2c_client *client, pm_message_t state); 35 int (*suspend)(struct i2c_client *client, pm_message_t state);
36 int (*resume)(struct i2c_client *client); 36 int (*resume)(struct i2c_client *client);
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h
index 99033945cdee..5b39a22533fe 100644
--- a/include/media/videobuf-core.h
+++ b/include/media/videobuf-core.h
@@ -13,6 +13,9 @@
13 * the Free Software Foundation; either version 2 13 * the Free Software Foundation; either version 2
14 */ 14 */
15 15
16#ifndef _VIDEOBUF_CORE_H
17#define _VIDEOBUF_CORE_H
18
16#include <linux/poll.h> 19#include <linux/poll.h>
17#ifdef CONFIG_VIDEO_V4L1_COMPAT 20#ifdef CONFIG_VIDEO_V4L1_COMPAT
18#include <linux/videodev.h> 21#include <linux/videodev.h>
@@ -123,7 +126,8 @@ struct videobuf_queue_ops {
123struct videobuf_qtype_ops { 126struct videobuf_qtype_ops {
124 u32 magic; 127 u32 magic;
125 128
126 void* (*alloc) (size_t size); 129 void *(*alloc) (size_t size);
130 void *(*vmalloc) (struct videobuf_buffer *buf);
127 int (*iolock) (struct videobuf_queue* q, 131 int (*iolock) (struct videobuf_queue* q,
128 struct videobuf_buffer *vb, 132 struct videobuf_buffer *vb,
129 struct v4l2_framebuffer *fbuf); 133 struct v4l2_framebuffer *fbuf);
@@ -151,7 +155,9 @@ struct videobuf_qtype_ops {
151struct videobuf_queue { 155struct videobuf_queue {
152 struct mutex vb_lock; 156 struct mutex vb_lock;
153 spinlock_t *irqlock; 157 spinlock_t *irqlock;
154 void *dev; /* on pci, points to struct pci_dev */ 158 struct device *dev;
159
160 wait_queue_head_t wait; /* wait if queue is empty */
155 161
156 enum v4l2_buf_type type; 162 enum v4l2_buf_type type;
157 unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */ 163 unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */
@@ -183,9 +189,13 @@ int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
183 189
184void *videobuf_alloc(struct videobuf_queue* q); 190void *videobuf_alloc(struct videobuf_queue* q);
185 191
192/* Used on videobuf-dvb */
193void *videobuf_queue_to_vmalloc (struct videobuf_queue* q,
194 struct videobuf_buffer *buf);
195
186void videobuf_queue_core_init(struct videobuf_queue *q, 196void videobuf_queue_core_init(struct videobuf_queue *q,
187 struct videobuf_queue_ops *ops, 197 struct videobuf_queue_ops *ops,
188 void *dev, 198 struct device *dev,
189 spinlock_t *irqlock, 199 spinlock_t *irqlock,
190 enum v4l2_buf_type type, 200 enum v4l2_buf_type type,
191 enum v4l2_field field, 201 enum v4l2_field field,
@@ -231,10 +241,4 @@ int videobuf_mmap_free(struct videobuf_queue *q);
231int videobuf_mmap_mapper(struct videobuf_queue *q, 241int videobuf_mmap_mapper(struct videobuf_queue *q,
232 struct vm_area_struct *vma); 242 struct vm_area_struct *vma);
233 243
234/* --------------------------------------------------------------------- */ 244#endif
235
236/*
237 * Local variables:
238 * c-basic-offset: 8
239 * End:
240 */
diff --git a/include/media/videobuf-dma-sg.h b/include/media/videobuf-dma-sg.h
index 38105031db23..be8da269ee33 100644
--- a/include/media/videobuf-dma-sg.h
+++ b/include/media/videobuf-dma-sg.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * helper functions for PCI DMA video4linux capture buffers 2 * helper functions for SG DMA video4linux capture buffers
3 * 3 *
4 * The functions expect the hardware being able to scatter gatter 4 * The functions expect the hardware being able to scatter gatter
5 * (i.e. the buffers are not linear in physical memory, but fragmented 5 * (i.e. the buffers are not linear in physical memory, but fragmented
@@ -68,9 +68,6 @@ struct videobuf_dmabuf {
68 /* for kernel buffers */ 68 /* for kernel buffers */
69 void *vmalloc; 69 void *vmalloc;
70 70
71 /* Stores the userspace pointer to vmalloc area */
72 void *varea;
73
74 /* for overlay buffers (pci-pci dma) */ 71 /* for overlay buffers (pci-pci dma) */
75 dma_addr_t bus_addr; 72 dma_addr_t bus_addr;
76 73
@@ -81,7 +78,7 @@ struct videobuf_dmabuf {
81 int direction; 78 int direction;
82}; 79};
83 80
84struct videbuf_pci_sg_memory 81struct videobuf_dma_sg_memory
85{ 82{
86 u32 magic; 83 u32 magic;
87 84
@@ -103,11 +100,11 @@ int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
103int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma); 100int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
104struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf); 101struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf);
105 102
106void *videobuf_pci_alloc (size_t size); 103void *videobuf_sg_alloc(size_t size);
107 104
108void videobuf_queue_pci_init(struct videobuf_queue* q, 105void videobuf_queue_sg_init(struct videobuf_queue* q,
109 struct videobuf_queue_ops *ops, 106 struct videobuf_queue_ops *ops,
110 void *dev, 107 struct device *dev,
111 spinlock_t *irqlock, 108 spinlock_t *irqlock,
112 enum v4l2_buf_type type, 109 enum v4l2_buf_type type,
113 enum v4l2_field field, 110 enum v4l2_field field,
@@ -117,6 +114,6 @@ void videobuf_queue_pci_init(struct videobuf_queue* q,
117 /*FIXME: these variants are used only on *-alsa code, where videobuf is 114 /*FIXME: these variants are used only on *-alsa code, where videobuf is
118 * used without queue 115 * used without queue
119 */ 116 */
120int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma); 117int videobuf_sg_dma_map(struct device *dev, struct videobuf_dmabuf *dma);
121int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma); 118int videobuf_sg_dma_unmap(struct device *dev, struct videobuf_dmabuf *dma);
122 119
diff --git a/include/media/videobuf-dvb.h b/include/media/videobuf-dvb.h
index 8233cafdeef6..b77748696329 100644
--- a/include/media/videobuf-dvb.h
+++ b/include/media/videobuf-dvb.h
@@ -27,7 +27,8 @@ struct videobuf_dvb {
27int videobuf_dvb_register(struct videobuf_dvb *dvb, 27int videobuf_dvb_register(struct videobuf_dvb *dvb,
28 struct module *module, 28 struct module *module,
29 void *adapter_priv, 29 void *adapter_priv,
30 struct device *device); 30 struct device *device,
31 short *adapter_nr);
31void videobuf_dvb_unregister(struct videobuf_dvb *dvb); 32void videobuf_dvb_unregister(struct videobuf_dvb *dvb);
32 33
33/* 34/*
diff --git a/include/media/videobuf-vmalloc.h b/include/media/videobuf-vmalloc.h
index ec63ab0fab93..aed39460c154 100644
--- a/include/media/videobuf-vmalloc.h
+++ b/include/media/videobuf-vmalloc.h
@@ -12,6 +12,8 @@
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 13 * the Free Software Foundation; either version 2
14 */ 14 */
15#ifndef _VIDEOBUF_VMALLOC_H
16#define _VIDEOBUF_VMALLOC_H
15 17
16#include <media/videobuf-core.h> 18#include <media/videobuf-core.h>
17 19
@@ -39,3 +41,5 @@ void videobuf_queue_vmalloc_init(struct videobuf_queue* q,
39void *videobuf_to_vmalloc (struct videobuf_buffer *buf); 41void *videobuf_to_vmalloc (struct videobuf_buffer *buf);
40 42
41void videobuf_vmalloc_free (struct videobuf_buffer *buf); 43void videobuf_vmalloc_free (struct videobuf_buffer *buf);
44
45#endif
diff --git a/include/mtd/Kbuild b/include/mtd/Kbuild
index 4d46b3bdebd8..8eb018f96002 100644
--- a/include/mtd/Kbuild
+++ b/include/mtd/Kbuild
@@ -3,5 +3,4 @@ header-y += jffs2-user.h
3header-y += mtd-abi.h 3header-y += mtd-abi.h
4header-y += mtd-user.h 4header-y += mtd-user.h
5header-y += nftl-user.h 5header-y += nftl-user.h
6header-y += ubi-header.h
7header-y += ubi-user.h 6header-y += ubi-user.h
diff --git a/include/mtd/ubi-header.h b/include/mtd/ubi-header.h
deleted file mode 100644
index 292f916ea564..000000000000
--- a/include/mtd/ubi-header.h
+++ /dev/null
@@ -1,372 +0,0 @@
1/*
2 * Copyright (c) International Business Machines Corp., 2006
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
12 * the 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 * Authors: Artem Bityutskiy (Битюцкий Артём)
19 * Thomas Gleixner
20 * Frank Haverkamp
21 * Oliver Lohmann
22 * Andreas Arnez
23 */
24
25/*
26 * This file defines the layout of UBI headers and all the other UBI on-flash
27 * data structures. May be included by user-space.
28 */
29
30#ifndef __UBI_HEADER_H__
31#define __UBI_HEADER_H__
32
33#include <asm/byteorder.h>
34
35/* The version of UBI images supported by this implementation */
36#define UBI_VERSION 1
37
38/* The highest erase counter value supported by this implementation */
39#define UBI_MAX_ERASECOUNTER 0x7FFFFFFF
40
41/* The initial CRC32 value used when calculating CRC checksums */
42#define UBI_CRC32_INIT 0xFFFFFFFFU
43
44/* Erase counter header magic number (ASCII "UBI#") */
45#define UBI_EC_HDR_MAGIC 0x55424923
46/* Volume identifier header magic number (ASCII "UBI!") */
47#define UBI_VID_HDR_MAGIC 0x55424921
48
49/*
50 * Volume type constants used in the volume identifier header.
51 *
52 * @UBI_VID_DYNAMIC: dynamic volume
53 * @UBI_VID_STATIC: static volume
54 */
55enum {
56 UBI_VID_DYNAMIC = 1,
57 UBI_VID_STATIC = 2
58};
59
60/*
61 * Volume flags used in the volume table record.
62 *
63 * @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume
64 *
65 * %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume
66 * table. UBI automatically re-sizes the volume which has this flag and makes
67 * the volume to be of largest possible size. This means that if after the
68 * initialization UBI finds out that there are available physical eraseblocks
69 * present on the device, it automatically appends all of them to the volume
70 * (the physical eraseblocks reserved for bad eraseblocks handling and other
71 * reserved physical eraseblocks are not taken). So, if there is a volume with
72 * the %UBI_VTBL_AUTORESIZE_FLG flag set, the amount of available logical
73 * eraseblocks will be zero after UBI is loaded, because all of them will be
74 * reserved for this volume. Note, the %UBI_VTBL_AUTORESIZE_FLG bit is cleared
75 * after the volume had been initialized.
76 *
77 * The auto-resize feature is useful for device production purposes. For
78 * example, different NAND flash chips may have different amount of initial bad
79 * eraseblocks, depending of particular chip instance. Manufacturers of NAND
80 * chips usually guarantee that the amount of initial bad eraseblocks does not
81 * exceed certain percent, e.g. 2%. When one creates an UBI image which will be
82 * flashed to the end devices in production, he does not know the exact amount
83 * of good physical eraseblocks the NAND chip on the device will have, but this
84 * number is required to calculate the volume sized and put them to the volume
85 * table of the UBI image. In this case, one of the volumes (e.g., the one
86 * which will store the root file system) is marked as "auto-resizable", and
87 * UBI will adjust its size on the first boot if needed.
88 *
89 * Note, first UBI reserves some amount of physical eraseblocks for bad
90 * eraseblock handling, and then re-sizes the volume, not vice-versa. This
91 * means that the pool of reserved physical eraseblocks will always be present.
92 */
93enum {
94 UBI_VTBL_AUTORESIZE_FLG = 0x01,
95};
96
97/*
98 * Compatibility constants used by internal volumes.
99 *
100 * @UBI_COMPAT_DELETE: delete this internal volume before anything is written
101 * to the flash
102 * @UBI_COMPAT_RO: attach this device in read-only mode
103 * @UBI_COMPAT_PRESERVE: preserve this internal volume - do not touch its
104 * physical eraseblocks, don't allow the wear-leveling unit to move them
105 * @UBI_COMPAT_REJECT: reject this UBI image
106 */
107enum {
108 UBI_COMPAT_DELETE = 1,
109 UBI_COMPAT_RO = 2,
110 UBI_COMPAT_PRESERVE = 4,
111 UBI_COMPAT_REJECT = 5
112};
113
114/* Sizes of UBI headers */
115#define UBI_EC_HDR_SIZE sizeof(struct ubi_ec_hdr)
116#define UBI_VID_HDR_SIZE sizeof(struct ubi_vid_hdr)
117
118/* Sizes of UBI headers without the ending CRC */
119#define UBI_EC_HDR_SIZE_CRC (UBI_EC_HDR_SIZE - sizeof(__be32))
120#define UBI_VID_HDR_SIZE_CRC (UBI_VID_HDR_SIZE - sizeof(__be32))
121
122/**
123 * struct ubi_ec_hdr - UBI erase counter header.
124 * @magic: erase counter header magic number (%UBI_EC_HDR_MAGIC)
125 * @version: version of UBI implementation which is supposed to accept this
126 * UBI image
127 * @padding1: reserved for future, zeroes
128 * @ec: the erase counter
129 * @vid_hdr_offset: where the VID header starts
130 * @data_offset: where the user data start
131 * @padding2: reserved for future, zeroes
132 * @hdr_crc: erase counter header CRC checksum
133 *
134 * The erase counter header takes 64 bytes and has a plenty of unused space for
135 * future usage. The unused fields are zeroed. The @version field is used to
136 * indicate the version of UBI implementation which is supposed to be able to
137 * work with this UBI image. If @version is greater then the current UBI
138 * version, the image is rejected. This may be useful in future if something
139 * is changed radically. This field is duplicated in the volume identifier
140 * header.
141 *
142 * The @vid_hdr_offset and @data_offset fields contain the offset of the the
143 * volume identifier header and user data, relative to the beginning of the
144 * physical eraseblock. These values have to be the same for all physical
145 * eraseblocks.
146 */
147struct ubi_ec_hdr {
148 __be32 magic;
149 __u8 version;
150 __u8 padding1[3];
151 __be64 ec; /* Warning: the current limit is 31-bit anyway! */
152 __be32 vid_hdr_offset;
153 __be32 data_offset;
154 __u8 padding2[36];
155 __be32 hdr_crc;
156} __attribute__ ((packed));
157
158/**
159 * struct ubi_vid_hdr - on-flash UBI volume identifier header.
160 * @magic: volume identifier header magic number (%UBI_VID_HDR_MAGIC)
161 * @version: UBI implementation version which is supposed to accept this UBI
162 * image (%UBI_VERSION)
163 * @vol_type: volume type (%UBI_VID_DYNAMIC or %UBI_VID_STATIC)
164 * @copy_flag: if this logical eraseblock was copied from another physical
165 * eraseblock (for wear-leveling reasons)
166 * @compat: compatibility of this volume (%0, %UBI_COMPAT_DELETE,
167 * %UBI_COMPAT_IGNORE, %UBI_COMPAT_PRESERVE, or %UBI_COMPAT_REJECT)
168 * @vol_id: ID of this volume
169 * @lnum: logical eraseblock number
170 * @leb_ver: version of this logical eraseblock (IMPORTANT: obsolete, to be
171 * removed, kept only for not breaking older UBI users)
172 * @data_size: how many bytes of data this logical eraseblock contains
173 * @used_ebs: total number of used logical eraseblocks in this volume
174 * @data_pad: how many bytes at the end of this physical eraseblock are not
175 * used
176 * @data_crc: CRC checksum of the data stored in this logical eraseblock
177 * @padding1: reserved for future, zeroes
178 * @sqnum: sequence number
179 * @padding2: reserved for future, zeroes
180 * @hdr_crc: volume identifier header CRC checksum
181 *
182 * The @sqnum is the value of the global sequence counter at the time when this
183 * VID header was created. The global sequence counter is incremented each time
184 * UBI writes a new VID header to the flash, i.e. when it maps a logical
185 * eraseblock to a new physical eraseblock. The global sequence counter is an
186 * unsigned 64-bit integer and we assume it never overflows. The @sqnum
187 * (sequence number) is used to distinguish between older and newer versions of
188 * logical eraseblocks.
189 *
190 * There are 2 situations when there may be more then one physical eraseblock
191 * corresponding to the same logical eraseblock, i.e., having the same @vol_id
192 * and @lnum values in the volume identifier header. Suppose we have a logical
193 * eraseblock L and it is mapped to the physical eraseblock P.
194 *
195 * 1. Because UBI may erase physical eraseblocks asynchronously, the following
196 * situation is possible: L is asynchronously erased, so P is scheduled for
197 * erasure, then L is written to,i.e. mapped to another physical eraseblock P1,
198 * so P1 is written to, then an unclean reboot happens. Result - there are 2
199 * physical eraseblocks P and P1 corresponding to the same logical eraseblock
200 * L. But P1 has greater sequence number, so UBI picks P1 when it attaches the
201 * flash.
202 *
203 * 2. From time to time UBI moves logical eraseblocks to other physical
204 * eraseblocks for wear-leveling reasons. If, for example, UBI moves L from P
205 * to P1, and an unclean reboot happens before P is physically erased, there
206 * are two physical eraseblocks P and P1 corresponding to L and UBI has to
207 * select one of them when the flash is attached. The @sqnum field says which
208 * PEB is the original (obviously P will have lower @sqnum) and the copy. But
209 * it is not enough to select the physical eraseblock with the higher sequence
210 * number, because the unclean reboot could have happen in the middle of the
211 * copying process, so the data in P is corrupted. It is also not enough to
212 * just select the physical eraseblock with lower sequence number, because the
213 * data there may be old (consider a case if more data was added to P1 after
214 * the copying). Moreover, the unclean reboot may happen when the erasure of P
215 * was just started, so it result in unstable P, which is "mostly" OK, but
216 * still has unstable bits.
217 *
218 * UBI uses the @copy_flag field to indicate that this logical eraseblock is a
219 * copy. UBI also calculates data CRC when the data is moved and stores it at
220 * the @data_crc field of the copy (P1). So when UBI needs to pick one physical
221 * eraseblock of two (P or P1), the @copy_flag of the newer one (P1) is
222 * examined. If it is cleared, the situation* is simple and the newer one is
223 * picked. If it is set, the data CRC of the copy (P1) is examined. If the CRC
224 * checksum is correct, this physical eraseblock is selected (P1). Otherwise
225 * the older one (P) is selected.
226 *
227 * Note, there is an obsolete @leb_ver field which was used instead of @sqnum
228 * in the past. But it is not used anymore and we keep it in order to be able
229 * to deal with old UBI images. It will be removed at some point.
230 *
231 * There are 2 sorts of volumes in UBI: user volumes and internal volumes.
232 * Internal volumes are not seen from outside and are used for various internal
233 * UBI purposes. In this implementation there is only one internal volume - the
234 * layout volume. Internal volumes are the main mechanism of UBI extensions.
235 * For example, in future one may introduce a journal internal volume. Internal
236 * volumes have their own reserved range of IDs.
237 *
238 * The @compat field is only used for internal volumes and contains the "degree
239 * of their compatibility". It is always zero for user volumes. This field
240 * provides a mechanism to introduce UBI extensions and to be still compatible
241 * with older UBI binaries. For example, if someone introduced a journal in
242 * future, he would probably use %UBI_COMPAT_DELETE compatibility for the
243 * journal volume. And in this case, older UBI binaries, which know nothing
244 * about the journal volume, would just delete this volume and work perfectly
245 * fine. This is similar to what Ext2fs does when it is fed by an Ext3fs image
246 * - it just ignores the Ext3fs journal.
247 *
248 * The @data_crc field contains the CRC checksum of the contents of the logical
249 * eraseblock if this is a static volume. In case of dynamic volumes, it does
250 * not contain the CRC checksum as a rule. The only exception is when the
251 * data of the physical eraseblock was moved by the wear-leveling unit, then
252 * the wear-leveling unit calculates the data CRC and stores it in the
253 * @data_crc field. And of course, the @copy_flag is %in this case.
254 *
255 * The @data_size field is used only for static volumes because UBI has to know
256 * how many bytes of data are stored in this eraseblock. For dynamic volumes,
257 * this field usually contains zero. The only exception is when the data of the
258 * physical eraseblock was moved to another physical eraseblock for
259 * wear-leveling reasons. In this case, UBI calculates CRC checksum of the
260 * contents and uses both @data_crc and @data_size fields. In this case, the
261 * @data_size field contains data size.
262 *
263 * The @used_ebs field is used only for static volumes and indicates how many
264 * eraseblocks the data of the volume takes. For dynamic volumes this field is
265 * not used and always contains zero.
266 *
267 * The @data_pad is calculated when volumes are created using the alignment
268 * parameter. So, effectively, the @data_pad field reduces the size of logical
269 * eraseblocks of this volume. This is very handy when one uses block-oriented
270 * software (say, cramfs) on top of the UBI volume.
271 */
272struct ubi_vid_hdr {
273 __be32 magic;
274 __u8 version;
275 __u8 vol_type;
276 __u8 copy_flag;
277 __u8 compat;
278 __be32 vol_id;
279 __be32 lnum;
280 __be32 leb_ver; /* obsolete, to be removed, don't use */
281 __be32 data_size;
282 __be32 used_ebs;
283 __be32 data_pad;
284 __be32 data_crc;
285 __u8 padding1[4];
286 __be64 sqnum;
287 __u8 padding2[12];
288 __be32 hdr_crc;
289} __attribute__ ((packed));
290
291/* Internal UBI volumes count */
292#define UBI_INT_VOL_COUNT 1
293
294/*
295 * Starting ID of internal volumes. There is reserved room for 4096 internal
296 * volumes.
297 */
298#define UBI_INTERNAL_VOL_START (0x7FFFFFFF - 4096)
299
300/* The layout volume contains the volume table */
301
302#define UBI_LAYOUT_VOLUME_ID UBI_INTERNAL_VOL_START
303#define UBI_LAYOUT_VOLUME_TYPE UBI_VID_DYNAMIC
304#define UBI_LAYOUT_VOLUME_ALIGN 1
305#define UBI_LAYOUT_VOLUME_EBS 2
306#define UBI_LAYOUT_VOLUME_NAME "layout volume"
307#define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT
308
309/* The maximum number of volumes per one UBI device */
310#define UBI_MAX_VOLUMES 128
311
312/* The maximum volume name length */
313#define UBI_VOL_NAME_MAX 127
314
315/* Size of the volume table record */
316#define UBI_VTBL_RECORD_SIZE sizeof(struct ubi_vtbl_record)
317
318/* Size of the volume table record without the ending CRC */
319#define UBI_VTBL_RECORD_SIZE_CRC (UBI_VTBL_RECORD_SIZE - sizeof(__be32))
320
321/**
322 * struct ubi_vtbl_record - a record in the volume table.
323 * @reserved_pebs: how many physical eraseblocks are reserved for this volume
324 * @alignment: volume alignment
325 * @data_pad: how many bytes are unused at the end of the each physical
326 * eraseblock to satisfy the requested alignment
327 * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
328 * @upd_marker: if volume update was started but not finished
329 * @name_len: volume name length
330 * @name: the volume name
331 * @flags: volume flags (%UBI_VTBL_AUTORESIZE_FLG)
332 * @padding: reserved, zeroes
333 * @crc: a CRC32 checksum of the record
334 *
335 * The volume table records are stored in the volume table, which is stored in
336 * the layout volume. The layout volume consists of 2 logical eraseblock, each
337 * of which contains a copy of the volume table (i.e., the volume table is
338 * duplicated). The volume table is an array of &struct ubi_vtbl_record
339 * objects indexed by the volume ID.
340 *
341 * If the size of the logical eraseblock is large enough to fit
342 * %UBI_MAX_VOLUMES records, the volume table contains %UBI_MAX_VOLUMES
343 * records. Otherwise, it contains as many records as it can fit (i.e., size of
344 * logical eraseblock divided by sizeof(struct ubi_vtbl_record)).
345 *
346 * The @upd_marker flag is used to implement volume update. It is set to %1
347 * before update and set to %0 after the update. So if the update operation was
348 * interrupted, UBI knows that the volume is corrupted.
349 *
350 * The @alignment field is specified when the volume is created and cannot be
351 * later changed. It may be useful, for example, when a block-oriented file
352 * system works on top of UBI. The @data_pad field is calculated using the
353 * logical eraseblock size and @alignment. The alignment must be multiple to the
354 * minimal flash I/O unit. If @alignment is 1, all the available space of
355 * the physical eraseblocks is used.
356 *
357 * Empty records contain all zeroes and the CRC checksum of those zeroes.
358 */
359struct ubi_vtbl_record {
360 __be32 reserved_pebs;
361 __be32 alignment;
362 __be32 data_pad;
363 __u8 vol_type;
364 __u8 upd_marker;
365 __be16 name_len;
366 __u8 name[UBI_VOL_NAME_MAX+1];
367 __u8 flags;
368 __u8 padding[23];
369 __be32 crc;
370} __attribute__ ((packed));
371
372#endif /* !__UBI_HEADER_H__ */
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 496503c03846..0a2f0372df31 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -55,9 +55,12 @@ struct prefix_info {
55extern int addrconf_init(void); 55extern int addrconf_init(void);
56extern void addrconf_cleanup(void); 56extern void addrconf_cleanup(void);
57 57
58extern int addrconf_add_ifaddr(void __user *arg); 58extern int addrconf_add_ifaddr(struct net *net,
59extern int addrconf_del_ifaddr(void __user *arg); 59 void __user *arg);
60extern int addrconf_set_dstaddr(void __user *arg); 60extern int addrconf_del_ifaddr(struct net *net,
61 void __user *arg);
62extern int addrconf_set_dstaddr(struct net *net,
63 void __user *arg);
61 64
62extern int ipv6_chk_addr(struct net *net, 65extern int ipv6_chk_addr(struct net *net,
63 struct in6_addr *addr, 66 struct in6_addr *addr,
@@ -68,16 +71,18 @@ extern int ipv6_chk_addr(struct net *net,
68extern int ipv6_chk_home_addr(struct net *net, 71extern int ipv6_chk_home_addr(struct net *net,
69 struct in6_addr *addr); 72 struct in6_addr *addr);
70#endif 73#endif
74
75extern int ipv6_chk_prefix(struct in6_addr *addr,
76 struct net_device *dev);
77
71extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, 78extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
72 struct in6_addr *addr, 79 const struct in6_addr *addr,
73 struct net_device *dev, 80 struct net_device *dev,
74 int strict); 81 int strict);
75 82
76extern int ipv6_get_saddr(struct dst_entry *dst,
77 struct in6_addr *daddr,
78 struct in6_addr *saddr);
79extern int ipv6_dev_get_saddr(struct net_device *dev, 83extern int ipv6_dev_get_saddr(struct net_device *dev,
80 struct in6_addr *daddr, 84 const struct in6_addr *daddr,
85 unsigned int srcprefs,
81 struct in6_addr *saddr); 86 struct in6_addr *saddr);
82extern int ipv6_get_lladdr(struct net_device *dev, 87extern int ipv6_get_lladdr(struct net_device *dev,
83 struct in6_addr *addr, 88 struct in6_addr *addr,
@@ -100,31 +105,31 @@ extern u32 ipv6_addr_label(const struct in6_addr *addr,
100/* 105/*
101 * multicast prototypes (mcast.c) 106 * multicast prototypes (mcast.c)
102 */ 107 */
103extern int ipv6_sock_mc_join(struct sock *sk, int ifindex, 108extern int ipv6_sock_mc_join(struct sock *sk, int ifindex,
104 struct in6_addr *addr); 109 const struct in6_addr *addr);
105extern int ipv6_sock_mc_drop(struct sock *sk, int ifindex, 110extern int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
106 struct in6_addr *addr); 111 const struct in6_addr *addr);
107extern void ipv6_sock_mc_close(struct sock *sk); 112extern void ipv6_sock_mc_close(struct sock *sk);
108extern int inet6_mc_check(struct sock *sk, struct in6_addr *mc_addr, 113extern int inet6_mc_check(struct sock *sk,
109 struct in6_addr *src_addr); 114 const struct in6_addr *mc_addr,
115 const struct in6_addr *src_addr);
110 116
111extern int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr); 117extern int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr);
112extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, struct in6_addr *addr); 118extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr);
113extern int ipv6_dev_mc_dec(struct net_device *dev, struct in6_addr *addr); 119extern int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr);
114extern void ipv6_mc_up(struct inet6_dev *idev); 120extern void ipv6_mc_up(struct inet6_dev *idev);
115extern void ipv6_mc_down(struct inet6_dev *idev); 121extern void ipv6_mc_down(struct inet6_dev *idev);
116extern void ipv6_mc_init_dev(struct inet6_dev *idev); 122extern void ipv6_mc_init_dev(struct inet6_dev *idev);
117extern void ipv6_mc_destroy_dev(struct inet6_dev *idev); 123extern void ipv6_mc_destroy_dev(struct inet6_dev *idev);
118extern void addrconf_dad_failure(struct inet6_ifaddr *ifp); 124extern void addrconf_dad_failure(struct inet6_ifaddr *ifp);
119 125
120extern int ipv6_chk_mcast_addr(struct net_device *dev, struct in6_addr *group, 126extern int ipv6_chk_mcast_addr(struct net_device *dev,
121 struct in6_addr *src_addr); 127 const struct in6_addr *group,
128 const struct in6_addr *src_addr);
122extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr); 129extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr);
123 130
124extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len); 131extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len);
125 132
126extern int ipv6_get_hoplimit(struct net_device *dev);
127
128/* 133/*
129 * anycast prototypes (anycast.c) 134 * anycast prototypes (anycast.c)
130 */ 135 */
@@ -135,7 +140,8 @@ extern int inet6_ac_check(struct sock *sk, struct in6_addr *addr, int ifindex);
135 140
136extern int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr); 141extern int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr);
137extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, struct in6_addr *addr); 142extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, struct in6_addr *addr);
138extern int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr); 143extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
144 struct in6_addr *addr);
139 145
140 146
141/* Device notifier */ 147/* Device notifier */
@@ -185,26 +191,6 @@ static inline void in6_ifa_put(struct inet6_ifaddr *ifp)
185#define in6_ifa_hold(ifp) atomic_inc(&(ifp)->refcnt) 191#define in6_ifa_hold(ifp) atomic_inc(&(ifp)->refcnt)
186 192
187 193
188extern void addrconf_forwarding_on(void);
189/*
190 * Hash function taken from net_alias.c
191 */
192
193static __inline__ u8 ipv6_addr_hash(const struct in6_addr *addr)
194{
195 __u32 word;
196
197 /*
198 * We perform the hash function over the last 64 bits of the address
199 * This will include the IEEE address token on links that support it.
200 */
201
202 word = (__force u32)(addr->s6_addr32[2] ^ addr->s6_addr32[3]);
203 word ^= (word >> 16);
204 word ^= (word >> 8);
205
206 return ((word ^ (word >> 4)) & 0x0f);
207}
208 194
209/* 195/*
210 * compute link-local solicited-node multicast address 196 * compute link-local solicited-node multicast address
@@ -214,61 +200,31 @@ static inline void addrconf_addr_solict_mult(const struct in6_addr *addr,
214 struct in6_addr *solicited) 200 struct in6_addr *solicited)
215{ 201{
216 ipv6_addr_set(solicited, 202 ipv6_addr_set(solicited,
217 __constant_htonl(0xFF020000), 0, 203 htonl(0xFF020000), 0,
218 __constant_htonl(0x1), 204 htonl(0x1),
219 __constant_htonl(0xFF000000) | addr->s6_addr32[3]); 205 htonl(0xFF000000) | addr->s6_addr32[3]);
220}
221
222
223static inline void ipv6_addr_all_nodes(struct in6_addr *addr)
224{
225 ipv6_addr_set(addr,
226 __constant_htonl(0xFF020000), 0, 0,
227 __constant_htonl(0x1));
228}
229
230static inline void ipv6_addr_all_routers(struct in6_addr *addr)
231{
232 ipv6_addr_set(addr,
233 __constant_htonl(0xFF020000), 0, 0,
234 __constant_htonl(0x2));
235} 206}
236 207
237static inline int ipv6_addr_is_multicast(const struct in6_addr *addr) 208static inline int ipv6_addr_is_multicast(const struct in6_addr *addr)
238{ 209{
239 return (addr->s6_addr32[0] & __constant_htonl(0xFF000000)) == __constant_htonl(0xFF000000); 210 return (addr->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
240} 211}
241 212
242static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) 213static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr)
243{ 214{
244 return (addr->s6_addr32[0] == htonl(0xff020000) && 215 return (((addr->s6_addr32[0] ^ htonl(0xff020000)) |
245 addr->s6_addr32[1] == 0 && 216 addr->s6_addr32[1] | addr->s6_addr32[2] |
246 addr->s6_addr32[2] == 0 && 217 (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0);
247 addr->s6_addr32[3] == htonl(0x00000001));
248} 218}
249 219
250static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) 220static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr)
251{ 221{
252 return (addr->s6_addr32[0] == htonl(0xff020000) && 222 return (((addr->s6_addr32[0] ^ htonl(0xff020000)) |
253 addr->s6_addr32[1] == 0 && 223 addr->s6_addr32[1] | addr->s6_addr32[2] |
254 addr->s6_addr32[2] == 0 && 224 (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0);
255 addr->s6_addr32[3] == htonl(0x00000002));
256} 225}
257 226
258static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr) 227extern int __ipv6_isatap_ifid(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 228
273static inline int ipv6_addr_is_isatap(const struct in6_addr *addr) 229static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
274{ 230{
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bcc480b8892a..e00750836ba5 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -12,6 +12,16 @@
12 * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net> 12 * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
13 */ 13 */
14 14
15/**
16 * struct vif_params - describes virtual interface parameters
17 * @mesh_id: mesh ID to use
18 * @mesh_id_len: length of the mesh ID
19 */
20struct vif_params {
21 u8 *mesh_id;
22 int mesh_id_len;
23};
24
15/* Radiotap header iteration 25/* Radiotap header iteration
16 * implemented in net/wireless/radiotap.c 26 * implemented in net/wireless/radiotap.c
17 * docs in Documentation/networking/radiotap-headers.txt 27 * docs in Documentation/networking/radiotap-headers.txt
@@ -109,6 +119,19 @@ enum station_flags {
109}; 119};
110 120
111/** 121/**
122 * enum plink_action - actions to perform in mesh peers
123 *
124 * @PLINK_ACTION_INVALID: action 0 is reserved
125 * @PLINK_ACTION_OPEN: start mesh peer link establishment
126 * @PLINK_ACTION_BLOCL: block traffic from this mesh peer
127 */
128enum plink_actions {
129 PLINK_ACTION_INVALID,
130 PLINK_ACTION_OPEN,
131 PLINK_ACTION_BLOCK,
132};
133
134/**
112 * struct station_parameters - station parameters 135 * struct station_parameters - station parameters
113 * 136 *
114 * Used to change and create a new station. 137 * Used to change and create a new station.
@@ -128,41 +151,124 @@ struct station_parameters {
128 int listen_interval; 151 int listen_interval;
129 u16 aid; 152 u16 aid;
130 u8 supported_rates_len; 153 u8 supported_rates_len;
154 u8 plink_action;
131}; 155};
132 156
133/** 157/**
134 * enum station_stats_flags - station statistics flags 158 * enum station_info_flags - station information flags
135 * 159 *
136 * Used by the driver to indicate which info in &struct station_stats 160 * Used by the driver to indicate which info in &struct station_info
137 * it has filled in during get_station(). 161 * it has filled in during get_station() or dump_station().
138 * 162 *
139 * @STATION_STAT_INACTIVE_TIME: @inactive_time filled 163 * @STATION_INFO_INACTIVE_TIME: @inactive_time filled
140 * @STATION_STAT_RX_BYTES: @rx_bytes filled 164 * @STATION_INFO_RX_BYTES: @rx_bytes filled
141 * @STATION_STAT_TX_BYTES: @tx_bytes filled 165 * @STATION_INFO_TX_BYTES: @tx_bytes filled
166 * @STATION_INFO_LLID: @llid filled
167 * @STATION_INFO_PLID: @plid filled
168 * @STATION_INFO_PLINK_STATE: @plink_state filled
142 */ 169 */
143enum station_stats_flags { 170enum station_info_flags {
144 STATION_STAT_INACTIVE_TIME = 1<<0, 171 STATION_INFO_INACTIVE_TIME = 1<<0,
145 STATION_STAT_RX_BYTES = 1<<1, 172 STATION_INFO_RX_BYTES = 1<<1,
146 STATION_STAT_TX_BYTES = 1<<2, 173 STATION_INFO_TX_BYTES = 1<<2,
174 STATION_INFO_LLID = 1<<3,
175 STATION_INFO_PLID = 1<<4,
176 STATION_INFO_PLINK_STATE = 1<<5,
147}; 177};
148 178
149/** 179/**
150 * struct station_stats - station statistics 180 * struct station_info - station information
151 * 181 *
152 * Station information filled by driver for get_station(). 182 * Station information filled by driver for get_station() and dump_station.
153 * 183 *
154 * @filled: bitflag of flags from &enum station_stats_flags 184 * @filled: bitflag of flags from &enum station_info_flags
155 * @inactive_time: time since last station activity (tx/rx) in milliseconds 185 * @inactive_time: time since last station activity (tx/rx) in milliseconds
156 * @rx_bytes: bytes received from this station 186 * @rx_bytes: bytes received from this station
157 * @tx_bytes: bytes transmitted to this station 187 * @tx_bytes: bytes transmitted to this station
188 * @llid: mesh local link id
189 * @plid: mesh peer link id
190 * @plink_state: mesh peer link state
158 */ 191 */
159struct station_stats { 192struct station_info {
160 u32 filled; 193 u32 filled;
161 u32 inactive_time; 194 u32 inactive_time;
162 u32 rx_bytes; 195 u32 rx_bytes;
163 u32 tx_bytes; 196 u32 tx_bytes;
197 u16 llid;
198 u16 plid;
199 u8 plink_state;
200};
201
202/**
203 * enum monitor_flags - monitor flags
204 *
205 * Monitor interface configuration flags. Note that these must be the bits
206 * according to the nl80211 flags.
207 *
208 * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
209 * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
210 * @MONITOR_FLAG_CONTROL: pass control frames
211 * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
212 * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
213 */
214enum monitor_flags {
215 MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
216 MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
217 MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
218 MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
219 MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
164}; 220};
165 221
222/**
223 * enum mpath_info_flags - mesh path information flags
224 *
225 * Used by the driver to indicate which info in &struct mpath_info it has filled
226 * in during get_station() or dump_station().
227 *
228 * MPATH_INFO_FRAME_QLEN: @frame_qlen filled
229 * MPATH_INFO_DSN: @dsn filled
230 * MPATH_INFO_METRIC: @metric filled
231 * MPATH_INFO_EXPTIME: @exptime filled
232 * MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
233 * MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
234 * MPATH_INFO_FLAGS: @flags filled
235 */
236enum mpath_info_flags {
237 MPATH_INFO_FRAME_QLEN = BIT(0),
238 MPATH_INFO_DSN = BIT(1),
239 MPATH_INFO_METRIC = BIT(2),
240 MPATH_INFO_EXPTIME = BIT(3),
241 MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
242 MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
243 MPATH_INFO_FLAGS = BIT(6),
244};
245
246/**
247 * struct mpath_info - mesh path information
248 *
249 * Mesh path information filled by driver for get_mpath() and dump_mpath().
250 *
251 * @filled: bitfield of flags from &enum mpath_info_flags
252 * @frame_qlen: number of queued frames for this destination
253 * @dsn: destination sequence number
254 * @metric: metric (cost) of this mesh path
255 * @exptime: expiration time for the mesh path from now, in msecs
256 * @flags: mesh path flags
257 * @discovery_timeout: total mesh path discovery timeout, in msecs
258 * @discovery_retries: mesh path discovery retries
259 */
260struct mpath_info {
261 u32 filled;
262 u32 frame_qlen;
263 u32 dsn;
264 u32 metric;
265 u32 exptime;
266 u32 discovery_timeout;
267 u8 discovery_retries;
268 u8 flags;
269};
270
271
166/* from net/wireless.h */ 272/* from net/wireless.h */
167struct wiphy; 273struct wiphy;
168 274
@@ -210,13 +316,17 @@ struct wiphy;
210 * @del_station: Remove a station; @mac may be NULL to remove all stations. 316 * @del_station: Remove a station; @mac may be NULL to remove all stations.
211 * 317 *
212 * @change_station: Modify a given station. 318 * @change_station: Modify a given station.
319 *
320 * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
213 */ 321 */
214struct cfg80211_ops { 322struct cfg80211_ops {
215 int (*add_virtual_intf)(struct wiphy *wiphy, char *name, 323 int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
216 enum nl80211_iftype type); 324 enum nl80211_iftype type, u32 *flags,
325 struct vif_params *params);
217 int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex); 326 int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
218 int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex, 327 int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
219 enum nl80211_iftype type); 328 enum nl80211_iftype type, u32 *flags,
329 struct vif_params *params);
220 330
221 int (*add_key)(struct wiphy *wiphy, struct net_device *netdev, 331 int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
222 u8 key_index, u8 *mac_addr, 332 u8 key_index, u8 *mac_addr,
@@ -244,7 +354,22 @@ struct cfg80211_ops {
244 int (*change_station)(struct wiphy *wiphy, struct net_device *dev, 354 int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
245 u8 *mac, struct station_parameters *params); 355 u8 *mac, struct station_parameters *params);
246 int (*get_station)(struct wiphy *wiphy, struct net_device *dev, 356 int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
247 u8 *mac, struct station_stats *stats); 357 u8 *mac, struct station_info *sinfo);
358 int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
359 int idx, u8 *mac, struct station_info *sinfo);
360
361 int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
362 u8 *dst, u8 *next_hop);
363 int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
364 u8 *dst);
365 int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
366 u8 *dst, u8 *next_hop);
367 int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
368 u8 *dst, u8 *next_hop,
369 struct mpath_info *pinfo);
370 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
371 int idx, u8 *dst, u8 *next_hop,
372 struct mpath_info *pinfo);
248}; 373};
249 374
250#endif /* __NET_CFG80211_H */ 375#endif /* __NET_CFG80211_H */
diff --git a/include/net/compat.h b/include/net/compat.h
index 406db242f73a..164cb682e220 100644
--- a/include/net/compat.h
+++ b/include/net/compat.h
@@ -40,4 +40,10 @@ extern int put_cmsg_compat(struct msghdr*, int, int, int, void *);
40 40
41extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, unsigned char *, int); 41extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, unsigned char *, int);
42 42
43extern int compat_mc_setsockopt(struct sock *, int, int, char __user *, int,
44 int (*)(struct sock *, int, int, char __user *, int));
45extern int compat_mc_getsockopt(struct sock *, int, int, char __user *,
46 int __user *, int (*)(struct sock *, int, int, char __user *,
47 int __user *));
48
43#endif /* NET_COMPAT_H */ 49#endif /* NET_COMPAT_H */
diff --git a/include/net/dst.h b/include/net/dst.h
index ae13370e8484..002500e631f5 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -163,15 +163,7 @@ struct dst_entry * dst_clone(struct dst_entry * dst)
163 return dst; 163 return dst;
164} 164}
165 165
166static inline 166extern void dst_release(struct dst_entry *dst);
167void dst_release(struct dst_entry * dst)
168{
169 if (dst) {
170 WARN_ON(atomic_read(&dst->__refcnt) < 1);
171 smp_mb__before_atomic_dec();
172 atomic_dec(&dst->__refcnt);
173 }
174}
175 167
176/* Children define the path of the packet through the 168/* Children define the path of the packet through the
177 * Linux networking. Thus, destinations are stackable. 169 * Linux networking. Thus, destinations are stackable.
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 34349f9f4331..a5c6ccc5bb19 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -87,6 +87,7 @@ static inline void fib_rule_get(struct fib_rule *rule)
87static inline void fib_rule_put_rcu(struct rcu_head *head) 87static inline void fib_rule_put_rcu(struct rcu_head *head)
88{ 88{
89 struct fib_rule *rule = container_of(head, struct fib_rule, rcu); 89 struct fib_rule *rule = container_of(head, struct fib_rule, rcu);
90 release_net(rule->fr_net);
90 kfree(rule); 91 kfree(rule);
91} 92}
92 93
diff --git a/include/net/icmp.h b/include/net/icmp.h
index 9f7ef3c8baef..dddb839ff4b5 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -48,7 +48,7 @@ struct sk_buff;
48extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info); 48extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info);
49extern int icmp_rcv(struct sk_buff *skb); 49extern int icmp_rcv(struct sk_buff *skb);
50extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg); 50extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg);
51extern void icmp_init(struct net_proto_family *ops); 51extern int icmp_init(void);
52extern void icmp_out_count(unsigned char type); 52extern void icmp_out_count(unsigned char type);
53 53
54/* Move into dst.h ? */ 54/* Move into dst.h ? */
@@ -65,11 +65,4 @@ static inline struct raw_sock *raw_sk(const struct sock *sk)
65 return (struct raw_sock *)sk; 65 return (struct raw_sock *)sk;
66} 66}
67 67
68extern int sysctl_icmp_echo_ignore_all;
69extern int sysctl_icmp_echo_ignore_broadcasts;
70extern int sysctl_icmp_ignore_bogus_error_responses;
71extern int sysctl_icmp_errors_use_inbound_ifaddr;
72extern int sysctl_icmp_ratelimit;
73extern int sysctl_icmp_ratemask;
74
75#endif /* _ICMP_H */ 68#endif /* _ICMP_H */
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index 285b2adfa648..529816bfbc52 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -183,7 +183,6 @@ const char *escape_essid(const char *essid, u8 essid_len);
183#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a) 183#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
184#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a) 184#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
185#include <linux/netdevice.h> 185#include <linux/netdevice.h>
186#include <linux/wireless.h>
187#include <linux/if_arp.h> /* ARPHRD_ETHER */ 186#include <linux/if_arp.h> /* ARPHRD_ETHER */
188 187
189#ifndef WIRELESS_SPY 188#ifndef WIRELESS_SPY
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
deleted file mode 100644
index 1ef6282fdded..000000000000
--- a/include/net/ieee80211softmac.h
+++ /dev/null
@@ -1,373 +0,0 @@
1/*
2 * ieee80211softmac.h - public interface to the softmac
3 *
4 * Copyright (c) 2005 Johannes Berg <johannes@sipsolutions.net>
5 * Joseph Jezak <josejx@gentoo.org>
6 * Larry Finger <Larry.Finger@lwfinger.net>
7 * Danny van Dyk <kugelfang@gentoo.org>
8 * Michael Buesch <mbuesch@freenet.de>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * The full GNU General Public License is included in this distribution in the
24 * file called COPYING.
25 */
26
27#ifndef IEEE80211SOFTMAC_H_
28#define IEEE80211SOFTMAC_H_
29
30#include <linux/kernel.h>
31#include <linux/spinlock.h>
32#include <linux/workqueue.h>
33#include <linux/list.h>
34#include <net/ieee80211.h>
35
36/* Once the API is considered more or less stable,
37 * this should be incremented on API incompatible changes.
38 */
39#define IEEE80211SOFTMAC_API 0
40
41#define IEEE80211SOFTMAC_MAX_RATES_LEN 8
42#define IEEE80211SOFTMAC_MAX_EX_RATES_LEN 255
43
44struct ieee80211softmac_ratesinfo {
45 u8 count;
46 u8 rates[IEEE80211SOFTMAC_MAX_RATES_LEN + IEEE80211SOFTMAC_MAX_EX_RATES_LEN];
47};
48
49/* internal structures */
50struct ieee80211softmac_network;
51struct ieee80211softmac_scaninfo;
52
53struct ieee80211softmac_essid {
54 u8 len;
55 char data[IW_ESSID_MAX_SIZE+1];
56};
57
58struct ieee80211softmac_wpa {
59 char *IE;
60 int IElen;
61 int IEbuflen;
62};
63
64/*
65 * Information about association
66 */
67struct ieee80211softmac_assoc_info {
68
69 struct mutex mutex;
70
71 /*
72 * This is the requested ESSID. It is written
73 * only by the WX handlers.
74 *
75 */
76 struct ieee80211softmac_essid req_essid;
77 /*
78 * the ESSID of the network we're currently
79 * associated (or trying) to. This is
80 * updated to the network's actual ESSID
81 * even if the requested ESSID was 'ANY'
82 */
83 struct ieee80211softmac_essid associate_essid;
84
85 /* BSSID we're trying to associate to */
86 char bssid[ETH_ALEN];
87
88 /* some flags.
89 * static_essid is valid if the essid is constant,
90 * this is for use by the wx handlers only.
91 *
92 * associating is true, if the network has been
93 * auth'ed on and we are in the process of associating.
94 *
95 * bssvalid is true if we found a matching network
96 * and saved it's BSSID into the bssid above.
97 *
98 * bssfixed is used for SIOCSIWAP.
99 */
100 u8 static_essid;
101 u8 short_preamble_available;
102 u8 associating;
103 u8 associated;
104 u8 assoc_wait;
105 u8 bssvalid;
106 u8 bssfixed;
107
108 /* Scan retries remaining */
109 int scan_retry;
110
111 struct delayed_work work;
112 struct delayed_work timeout;
113};
114
115struct ieee80211softmac_bss_info {
116 /* Rates supported by the network */
117 struct ieee80211softmac_ratesinfo supported_rates;
118
119 /* This indicates whether frames can currently be transmitted with
120 * short preamble (only use this variable during TX at CCK rates) */
121 u8 short_preamble:1;
122
123 /* This indicates whether protection (e.g. self-CTS) should be used
124 * when transmitting with OFDM modulation */
125 u8 use_protection:1;
126};
127
128enum {
129 IEEE80211SOFTMAC_AUTH_OPEN_REQUEST = 1,
130 IEEE80211SOFTMAC_AUTH_OPEN_RESPONSE = 2,
131};
132
133enum {
134 IEEE80211SOFTMAC_AUTH_SHARED_REQUEST = 1,
135 IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE = 2,
136 IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE = 3,
137 IEEE80211SOFTMAC_AUTH_SHARED_PASS = 4,
138};
139
140/* We should make these tunable
141 * AUTH_TIMEOUT seems really long, but that's what it is in BSD */
142#define IEEE80211SOFTMAC_AUTH_TIMEOUT (12 * HZ)
143#define IEEE80211SOFTMAC_AUTH_RETRY_LIMIT 5
144#define IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT 3
145
146struct ieee80211softmac_txrates {
147 /* The Bit-Rate to be used for multicast frames. */
148 u8 mcast_rate;
149
150 /* The Bit-Rate to be used for multicast management frames. */
151 u8 mgt_mcast_rate;
152
153 /* The Bit-Rate to be used for any other (normal) data packet. */
154 u8 default_rate;
155 /* The Bit-Rate to be used for default fallback
156 * (If the device supports fallback and hardware-retry)
157 */
158 u8 default_fallback;
159
160 /* This is the rate that the user asked for */
161 u8 user_rate;
162};
163
164/* Bits for txrates_change callback. */
165#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT (1 << 0) /* default_rate */
166#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /* default_fallback */
167#define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate */
168#define IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST (1 << 3) /* mgt_mcast_rate */
169
170#define IEEE80211SOFTMAC_BSSINFOCHG_RATES (1 << 0) /* supported_rates */
171#define IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE (1 << 1) /* short_preamble */
172#define IEEE80211SOFTMAC_BSSINFOCHG_PROTECTION (1 << 2) /* use_protection */
173
174struct ieee80211softmac_device {
175 /* 802.11 structure for data stuff */
176 struct ieee80211_device *ieee;
177 struct net_device *dev;
178
179 /* only valid if associated, then holds the Association ID */
180 u16 association_id;
181
182 /* the following methods are callbacks that the driver
183 * using this framework has to assign
184 */
185
186 /* always assign these */
187 void (*set_bssid_filter)(struct net_device *dev, const u8 *bssid);
188 void (*set_channel)(struct net_device *dev, u8 channel);
189
190 /* assign if you need it, informational only */
191 void (*link_change)(struct net_device *dev);
192
193 /* If the hardware can do scanning, assign _all_ three of these callbacks.
194 * When the scan finishes, call ieee80211softmac_scan_finished().
195 */
196
197 /* when called, start_scan is guaranteed to not be called again
198 * until you call ieee80211softmac_scan_finished.
199 * Return 0 if scanning could start, error otherwise.
200 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_start_scan */
201 int (*start_scan)(struct net_device *dev);
202 /* this should block until after ieee80211softmac_scan_finished was called
203 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_wait_for_scan */
204 void (*wait_for_scan)(struct net_device *dev);
205 /* stop_scan aborts a scan, but is asynchronous.
206 * if you want to wait for it too, use wait_for_scan
207 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_stop_scan */
208 void (*stop_scan)(struct net_device *dev);
209
210 /* we'll need something about beacons here too, for AP or ad-hoc modes */
211
212 /* Transmission rates to be used by the driver.
213 * The SoftMAC figures out the best possible rates.
214 * The driver just needs to read them.
215 */
216 struct ieee80211softmac_txrates txrates;
217
218 /* If the driver needs to do stuff on TX rate changes, assign this
219 * callback. See IEEE80211SOFTMAC_TXRATECHG for change flags. */
220 void (*txrates_change)(struct net_device *dev,
221 u32 changes);
222
223 /* If the driver needs to do stuff when BSS properties change, assign
224 * this callback. see IEEE80211SOFTMAC_BSSINFOCHG for change flags. */
225 void (*bssinfo_change)(struct net_device *dev,
226 u32 changes);
227
228 /* private stuff follows */
229 /* this lock protects this structure */
230 spinlock_t lock;
231
232 struct workqueue_struct *wq;
233
234 u8 running; /* SoftMAC started? */
235 u8 scanning;
236
237 struct ieee80211softmac_scaninfo *scaninfo;
238 struct ieee80211softmac_assoc_info associnfo;
239 struct ieee80211softmac_bss_info bssinfo;
240
241 struct list_head auth_queue;
242 struct list_head events;
243
244 struct ieee80211softmac_ratesinfo ratesinfo;
245 int txrate_badness;
246
247 /* WPA stuff */
248 struct ieee80211softmac_wpa wpa;
249
250 /* we need to keep a list of network structs we copied */
251 struct list_head network_list;
252
253 /* This must be the last item so that it points to the data
254 * allocated beyond this structure by alloc_ieee80211 */
255 u8 priv[0];
256};
257
258extern void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm);
259
260static inline void * ieee80211softmac_priv(struct net_device *dev)
261{
262 return ((struct ieee80211softmac_device *)ieee80211_priv(dev))->priv;
263}
264
265extern struct net_device * alloc_ieee80211softmac(int sizeof_priv);
266extern void free_ieee80211softmac(struct net_device *dev);
267
268/* Call this function if you detect a lost TX fragment.
269 * (If the device indicates failure of ACK RX, for example.)
270 * It is wise to call this function if you are able to detect lost packets,
271 * because it contributes to the TX Rates auto adjustment.
272 */
273extern void ieee80211softmac_fragment_lost(struct net_device *dev,
274 u16 wireless_sequence_number);
275/* Call this function before _start to tell the softmac what rates
276 * the hw supports. The rates parameter is copied, so you can
277 * free it right after calling this function.
278 * Note that the rates need to be sorted. */
279extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates);
280
281/* Finds the highest rate which is:
282 * 1. Present in ri (optionally a basic rate)
283 * 2. Supported by the device
284 * 3. Less than or equal to the user-defined rate
285 */
286extern u8 ieee80211softmac_highest_supported_rate(struct ieee80211softmac_device *mac,
287 struct ieee80211softmac_ratesinfo *ri, int basic_only);
288
289/* Helper function which advises you the rate at which a frame should be
290 * transmitted at. */
291static inline u8 ieee80211softmac_suggest_txrate(struct ieee80211softmac_device *mac,
292 int is_multicast,
293 int is_mgt)
294{
295 struct ieee80211softmac_txrates *txrates = &mac->txrates;
296
297 if (!mac->associnfo.associated)
298 return txrates->mgt_mcast_rate;
299
300 /* We are associated, sending unicast frame */
301 if (!is_multicast)
302 return txrates->default_rate;
303
304 /* We are associated, sending multicast frame */
305 if (is_mgt)
306 return txrates->mgt_mcast_rate;
307 else
308 return txrates->mcast_rate;
309}
310
311/* Helper function which advises you when it is safe to transmit with short
312 * preamble.
313 * You should only call this function when transmitting at CCK rates. */
314static inline int ieee80211softmac_short_preamble_ok(struct ieee80211softmac_device *mac,
315 int is_multicast,
316 int is_mgt)
317{
318 return (is_multicast && is_mgt) ? 0 : mac->bssinfo.short_preamble;
319}
320
321/* Helper function which advises you whether protection (e.g. self-CTS) is
322 * needed. 1 = protection needed, 0 = no protection needed
323 * Only use this function when transmitting with OFDM modulation. */
324static inline int ieee80211softmac_protection_needed(struct ieee80211softmac_device *mac)
325{
326 return mac->bssinfo.use_protection;
327}
328
329/* Start the SoftMAC. Call this after you initialized the device
330 * and it is ready to run.
331 */
332extern void ieee80211softmac_start(struct net_device *dev);
333/* Stop the SoftMAC. Call this before you shutdown the device. */
334extern void ieee80211softmac_stop(struct net_device *dev);
335
336/*
337 * Event system
338 */
339
340/* valid event types */
341#define IEEE80211SOFTMAC_EVENT_ANY -1 /*private use only*/
342#define IEEE80211SOFTMAC_EVENT_SCAN_FINISHED 0
343#define IEEE80211SOFTMAC_EVENT_ASSOCIATED 1
344#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED 2
345#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT 3
346#define IEEE80211SOFTMAC_EVENT_AUTHENTICATED 4
347#define IEEE80211SOFTMAC_EVENT_AUTH_FAILED 5
348#define IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT 6
349#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND 7
350#define IEEE80211SOFTMAC_EVENT_DISASSOCIATED 8
351/* keep this updated! */
352#define IEEE80211SOFTMAC_EVENT_LAST 8
353/*
354 * If you want to be notified of certain events, you can call
355 * ieee80211softmac_notify[_atomic] with
356 * - event set to one of the constants below
357 * - fun set to a function pointer of the appropriate type
358 * - context set to the context data you want passed
359 * The return value is 0, or an error.
360 */
361typedef void (*notify_function_ptr)(struct net_device *dev, int event_type, void *context);
362
363#define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL);
364#define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC);
365
366extern int ieee80211softmac_notify_gfp(struct net_device *dev,
367 int event, notify_function_ptr fun, void *context, gfp_t gfp_mask);
368
369/* To clear pending work (for ifconfig down, etc.) */
370extern void
371ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm);
372
373#endif /* IEEE80211SOFTMAC_H_ */
diff --git a/include/net/ieee80211softmac_wx.h b/include/net/ieee80211softmac_wx.h
deleted file mode 100644
index 4ee3ad57283f..000000000000
--- a/include/net/ieee80211softmac_wx.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * This file contains the prototypes for the wireless extension
3 * handlers that the softmac API provides. Include this file to
4 * use the wx handlers, you can assign these directly.
5 *
6 * Copyright (c) 2005 Johannes Berg <johannes@sipsolutions.net>
7 * Joseph Jezak <josejx@gentoo.org>
8 * Larry Finger <Larry.Finger@lwfinger.net>
9 * Danny van Dyk <kugelfang@gentoo.org>
10 * Michael Buesch <mbuesch@freenet.de>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * more 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 *
25 * The full GNU General Public License is included in this distribution in the
26 * file called COPYING.
27 */
28
29#ifndef _IEEE80211SOFTMAC_WX_H
30#define _IEEE80211SOFTMAC_WX_H
31
32#include <net/ieee80211softmac.h>
33#include <net/iw_handler.h>
34
35extern int
36ieee80211softmac_wx_trigger_scan(struct net_device *net_dev,
37 struct iw_request_info *info,
38 union iwreq_data *data,
39 char *extra);
40
41extern int
42ieee80211softmac_wx_get_scan_results(struct net_device *net_dev,
43 struct iw_request_info *info,
44 union iwreq_data *data,
45 char *extra);
46
47extern int
48ieee80211softmac_wx_set_essid(struct net_device *net_dev,
49 struct iw_request_info *info,
50 union iwreq_data *data,
51 char *extra);
52
53extern int
54ieee80211softmac_wx_get_essid(struct net_device *net_dev,
55 struct iw_request_info *info,
56 union iwreq_data *data,
57 char *extra);
58
59extern int
60ieee80211softmac_wx_set_rate(struct net_device *net_dev,
61 struct iw_request_info *info,
62 union iwreq_data *data,
63 char *extra);
64
65extern int
66ieee80211softmac_wx_get_rate(struct net_device *net_dev,
67 struct iw_request_info *info,
68 union iwreq_data *data,
69 char *extra);
70
71extern int
72ieee80211softmac_wx_get_wap(struct net_device *net_dev,
73 struct iw_request_info *info,
74 union iwreq_data *data,
75 char *extra);
76
77extern int
78ieee80211softmac_wx_set_wap(struct net_device *net_dev,
79 struct iw_request_info *info,
80 union iwreq_data *data,
81 char *extra);
82
83extern int
84ieee80211softmac_wx_set_genie(struct net_device *dev,
85 struct iw_request_info *info,
86 union iwreq_data *wrqu,
87 char *extra);
88
89extern int
90ieee80211softmac_wx_get_genie(struct net_device *dev,
91 struct iw_request_info *info,
92 union iwreq_data *wrqu,
93 char *extra);
94extern int
95ieee80211softmac_wx_set_mlme(struct net_device *dev,
96 struct iw_request_info *info,
97 union iwreq_data *wrqu,
98 char *extra);
99#endif /* _IEEE80211SOFTMAC_WX */
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index 38d5a1e9980d..18c773286b91 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -39,6 +39,17 @@ extern int inet_getname(struct socket *sock,
39extern int inet_ioctl(struct socket *sock, 39extern int inet_ioctl(struct socket *sock,
40 unsigned int cmd, unsigned long arg); 40 unsigned int cmd, unsigned long arg);
41 41
42extern int inet_ctl_sock_create(struct sock **sk,
43 unsigned short family,
44 unsigned short type,
45 unsigned char protocol,
46 struct net *net);
47
48static inline void inet_ctl_sock_destroy(struct sock *sk)
49{
50 sk_release_kernel(sk);
51}
52
42#endif 53#endif
43 54
44 55
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index f00f0573627b..2ff545a56fb5 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -327,11 +327,6 @@ extern void inet_csk_listen_stop(struct sock *sk);
327 327
328extern void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); 328extern void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
329 329
330extern int inet_csk_ctl_sock_create(struct socket **sock,
331 unsigned short family,
332 unsigned short type,
333 unsigned char protocol);
334
335extern int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname, 330extern int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname,
336 char __user *optval, int __user *optlen); 331 char __user *optval, int __user *optlen);
337extern int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, 332extern int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname,
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 7374251b9787..e081eefd6f47 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -25,9 +25,9 @@ struct inet_frag_queue {
25 int meat; 25 int meat;
26 __u8 last_in; /* first/last segment arrived? */ 26 __u8 last_in; /* first/last segment arrived? */
27 27
28#define COMPLETE 4 28#define INET_FRAG_COMPLETE 4
29#define FIRST_IN 2 29#define INET_FRAG_FIRST_IN 2
30#define LAST_IN 1 30#define INET_FRAG_LAST_IN 1
31}; 31};
32 32
33#define INETFRAGS_HASHSZ 64 33#define INETFRAGS_HASHSZ 64
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 97dc35ad09be..735b926a3497 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -221,26 +221,7 @@ static inline int inet_sk_listen_hashfn(const struct sock *sk)
221} 221}
222 222
223/* Caller must disable local BH processing. */ 223/* Caller must disable local BH processing. */
224static inline void __inet_inherit_port(struct sock *sk, struct sock *child) 224extern void __inet_inherit_port(struct sock *sk, struct sock *child);
225{
226 struct inet_hashinfo *table = sk->sk_prot->hashinfo;
227 const int bhash = inet_bhashfn(inet_sk(child)->num, table->bhash_size);
228 struct inet_bind_hashbucket *head = &table->bhash[bhash];
229 struct inet_bind_bucket *tb;
230
231 spin_lock(&head->lock);
232 tb = inet_csk(sk)->icsk_bind_hash;
233 sk_add_bind_node(child, &tb->owners);
234 inet_csk(child)->icsk_bind_hash = tb;
235 spin_unlock(&head->lock);
236}
237
238static inline void inet_inherit_port(struct sock *sk, struct sock *child)
239{
240 local_bh_disable();
241 __inet_inherit_port(sk, child);
242 local_bh_enable();
243}
244 225
245extern void inet_put_port(struct sock *sk); 226extern void inet_put_port(struct sock *sk);
246 227
@@ -314,25 +295,25 @@ typedef __u64 __bitwise __addrpair;
314 ((__force __u64)(__be32)(__saddr))); 295 ((__force __u64)(__be32)(__saddr)));
315#endif /* __BIG_ENDIAN */ 296#endif /* __BIG_ENDIAN */
316#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ 297#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
317 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ 298 (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \
318 ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ 299 ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \
319 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 300 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \
320 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 301 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
321#define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ 302#define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
322 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ 303 (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \
323 ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ 304 ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \
324 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ 305 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \
325 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 306 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
326#else /* 32-bit arch */ 307#else /* 32-bit arch */
327#define INET_ADDR_COOKIE(__name, __saddr, __daddr) 308#define INET_ADDR_COOKIE(__name, __saddr, __daddr)
328#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ 309#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \
329 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ 310 (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \
330 (inet_sk(__sk)->daddr == (__saddr)) && \ 311 (inet_sk(__sk)->daddr == (__saddr)) && \
331 (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ 312 (inet_sk(__sk)->rcv_saddr == (__daddr)) && \
332 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 313 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \
333 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 314 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
334#define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ 315#define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \
335 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ 316 (((__sk)->sk_hash == (__hash)) && sock_net((__sk)) == (__net) && \
336 (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ 317 (inet_twsk(__sk)->tw_daddr == (__saddr)) && \
337 (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ 318 (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \
338 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ 319 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 89cd011edb99..a42cd63d241a 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -43,8 +43,7 @@ struct ip_options {
43 unsigned char srr; 43 unsigned char srr;
44 unsigned char rr; 44 unsigned char rr;
45 unsigned char ts; 45 unsigned char ts;
46 unsigned char is_data:1, 46 unsigned char is_strictroute:1,
47 is_strictroute:1,
48 srr_is_hit:1, 47 srr_is_hit:1,
49 is_changed:1, 48 is_changed:1,
50 rr_needaddr:1, 49 rr_needaddr:1,
@@ -137,7 +136,7 @@ struct inet_sock {
137 unsigned int flags; 136 unsigned int flags;
138 unsigned int fragsize; 137 unsigned int fragsize;
139 struct ip_options *opt; 138 struct ip_options *opt;
140 struct rtable *rt; 139 struct dst_entry *dst;
141 int length; /* Total length of all frames */ 140 int length; /* Total length of all frames */
142 __be32 addr; 141 __be32 addr;
143 struct flowi fl; 142 struct flowi fl;
@@ -195,7 +194,7 @@ static inline int inet_sk_ehashfn(const struct sock *sk)
195 194
196static inline int inet_iif(const struct sk_buff *skb) 195static inline int inet_iif(const struct sk_buff *skb)
197{ 196{
198 return ((struct rtable *)skb->dst)->rt_iif; 197 return skb->rtable->rt_iif;
199} 198}
200 199
201#endif /* _INET_SOCK_H */ 200#endif /* _INET_SOCK_H */
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 296547bfb0b7..95c660c9719b 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -207,4 +207,22 @@ extern void inet_twsk_schedule(struct inet_timewait_sock *tw,
207 const int timeo, const int timewait_len); 207 const int timeo, const int timewait_len);
208extern void inet_twsk_deschedule(struct inet_timewait_sock *tw, 208extern void inet_twsk_deschedule(struct inet_timewait_sock *tw,
209 struct inet_timewait_death_row *twdr); 209 struct inet_timewait_death_row *twdr);
210
211static inline
212struct net *twsk_net(const struct inet_timewait_sock *twsk)
213{
214#ifdef CONFIG_NET_NS
215 return twsk->tw_net;
216#else
217 return &init_net;
218#endif
219}
220
221static inline
222void twsk_net_set(struct inet_timewait_sock *twsk, struct net *net)
223{
224#ifdef CONFIG_NET_NS
225 twsk->tw_net = net;
226#endif
227}
210#endif /* _INET_TIMEWAIT_SOCK_ */ 228#endif /* _INET_TIMEWAIT_SOCK_ */
diff --git a/include/net/ip.h b/include/net/ip.h
index 9f50d4f1f157..6d7bcd5e62d4 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -347,10 +347,11 @@ extern int ip_forward(struct sk_buff *skb);
347extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, __be32 daddr, struct rtable *rt, int is_frag); 347extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, __be32 daddr, struct rtable *rt, int is_frag);
348extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); 348extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb);
349extern void ip_options_fragment(struct sk_buff *skb); 349extern void ip_options_fragment(struct sk_buff *skb);
350extern int ip_options_compile(struct ip_options *opt, struct sk_buff *skb); 350extern int ip_options_compile(struct net *net,
351extern int ip_options_get(struct ip_options **optp, 351 struct ip_options *opt, struct sk_buff *skb);
352extern int ip_options_get(struct net *net, struct ip_options **optp,
352 unsigned char *data, int optlen); 353 unsigned char *data, int optlen);
353extern int ip_options_get_from_user(struct ip_options **optp, 354extern int ip_options_get_from_user(struct net *net, struct ip_options **optp,
354 unsigned char __user *data, int optlen); 355 unsigned char __user *data, int optlen);
355extern void ip_options_undo(struct ip_options * opt); 356extern void ip_options_undo(struct ip_options * opt);
356extern void ip_forward_options(struct sk_buff *skb); 357extern void ip_forward_options(struct sk_buff *skb);
@@ -361,7 +362,8 @@ extern int ip_options_rcv_srr(struct sk_buff *skb);
361 */ 362 */
362 363
363extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); 364extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb);
364extern int ip_cmsg_send(struct msghdr *msg, struct ipcm_cookie *ipc); 365extern int ip_cmsg_send(struct net *net,
366 struct msghdr *msg, struct ipcm_cookie *ipc);
365extern int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, int optlen); 367extern int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, int optlen);
366extern int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); 368extern int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen);
367extern int compat_ip_setsockopt(struct sock *sk, int level, 369extern int compat_ip_setsockopt(struct sock *sk, int level,
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 953d6040ff50..7c5c0f79168a 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -174,17 +174,19 @@ struct fib6_table {
174#define RT6_TABLE_LOCAL RT6_TABLE_MAIN 174#define RT6_TABLE_LOCAL RT6_TABLE_MAIN
175#endif 175#endif
176 176
177typedef struct rt6_info *(*pol_lookup_t)(struct fib6_table *, 177typedef struct rt6_info *(*pol_lookup_t)(struct net *,
178 struct fib6_table *,
178 struct flowi *, int); 179 struct flowi *, int);
179 180
180/* 181/*
181 * exported functions 182 * exported functions
182 */ 183 */
183 184
184extern struct fib6_table * fib6_get_table(u32 id); 185extern struct fib6_table *fib6_get_table(struct net *net, u32 id);
185extern struct fib6_table * fib6_new_table(u32 id); 186extern struct fib6_table *fib6_new_table(struct net *net, u32 id);
186extern struct dst_entry * fib6_rule_lookup(struct flowi *fl, int flags, 187extern struct dst_entry *fib6_rule_lookup(struct net *net,
187 pol_lookup_t lookup); 188 struct flowi *fl, int flags,
189 pol_lookup_t lookup);
188 190
189extern struct fib6_node *fib6_lookup(struct fib6_node *root, 191extern struct fib6_node *fib6_lookup(struct fib6_node *root,
190 struct in6_addr *daddr, 192 struct in6_addr *daddr,
@@ -194,7 +196,8 @@ struct fib6_node *fib6_locate(struct fib6_node *root,
194 struct in6_addr *daddr, int dst_len, 196 struct in6_addr *daddr, int dst_len,
195 struct in6_addr *saddr, int src_len); 197 struct in6_addr *saddr, int src_len);
196 198
197extern void fib6_clean_all(int (*func)(struct rt6_info *, void *arg), 199extern void fib6_clean_all(struct net *net,
200 int (*func)(struct rt6_info *, void *arg),
198 int prune, void *arg); 201 int prune, void *arg);
199 202
200extern int fib6_add(struct fib6_node *root, 203extern int fib6_add(struct fib6_node *root,
@@ -207,7 +210,8 @@ extern int fib6_del(struct rt6_info *rt,
207extern void inet6_rt_notify(int event, struct rt6_info *rt, 210extern void inet6_rt_notify(int event, struct rt6_info *rt,
208 struct nl_info *info); 211 struct nl_info *info);
209 212
210extern void fib6_run_gc(unsigned long dummy); 213extern void fib6_run_gc(unsigned long expires,
214 struct net *net);
211 215
212extern void fib6_gc_cleanup(void); 216extern void fib6_gc_cleanup(void);
213 217
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index f99e4f0f568f..9313491e3dad 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -30,60 +30,54 @@ struct route_info {
30#include <linux/ip.h> 30#include <linux/ip.h>
31#include <linux/ipv6.h> 31#include <linux/ipv6.h>
32 32
33#define RT6_LOOKUP_F_IFACE 0x1 33#define RT6_LOOKUP_F_IFACE 0x00000001
34#define RT6_LOOKUP_F_REACHABLE 0x2 34#define RT6_LOOKUP_F_REACHABLE 0x00000002
35#define RT6_LOOKUP_F_HAS_SADDR 0x4 35#define RT6_LOOKUP_F_HAS_SADDR 0x00000004
36#define RT6_LOOKUP_F_SRCPREF_TMP 0x00000008
37#define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010
38#define RT6_LOOKUP_F_SRCPREF_COA 0x00000020
36 39
37extern struct rt6_info ip6_null_entry;
38 40
39#ifdef CONFIG_IPV6_MULTIPLE_TABLES 41#ifdef CONFIG_IPV6_MULTIPLE_TABLES
40extern struct rt6_info ip6_prohibit_entry; 42extern struct rt6_info *ip6_prohibit_entry;
41extern struct rt6_info ip6_blk_hole_entry; 43extern struct rt6_info *ip6_blk_hole_entry;
42#endif 44#endif
43 45
44extern void ip6_route_input(struct sk_buff *skb); 46extern void ip6_route_input(struct sk_buff *skb);
45 47
46extern struct dst_entry * ip6_route_output(struct sock *sk, 48extern struct dst_entry * ip6_route_output(struct net *net,
49 struct sock *sk,
47 struct flowi *fl); 50 struct flowi *fl);
48 51
49extern int ip6_route_init(void); 52extern int ip6_route_init(void);
50extern void ip6_route_cleanup(void); 53extern void ip6_route_cleanup(void);
51 54
52extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg); 55extern int ipv6_route_ioctl(struct net *net,
56 unsigned int cmd,
57 void __user *arg);
53 58
54extern int ip6_route_add(struct fib6_config *cfg); 59extern int ip6_route_add(struct fib6_config *cfg);
55extern int ip6_ins_rt(struct rt6_info *); 60extern int ip6_ins_rt(struct rt6_info *);
56extern int ip6_del_rt(struct rt6_info *); 61extern int ip6_del_rt(struct rt6_info *);
57 62
58extern int ip6_rt_addr_add(struct in6_addr *addr, 63extern struct rt6_info *rt6_lookup(struct net *net,
59 struct net_device *dev, 64 const struct in6_addr *daddr,
60 int anycast); 65 const struct in6_addr *saddr,
61
62extern int ip6_rt_addr_del(struct in6_addr *addr,
63 struct net_device *dev);
64
65extern void rt6_sndmsg(int type, struct in6_addr *dst,
66 struct in6_addr *src,
67 struct in6_addr *gw,
68 struct net_device *dev,
69 int dstlen, int srclen,
70 int metric, __u32 flags);
71
72extern struct rt6_info *rt6_lookup(struct in6_addr *daddr,
73 struct in6_addr *saddr,
74 int oif, int flags); 66 int oif, int flags);
75 67
76extern struct dst_entry *ndisc_dst_alloc(struct net_device *dev, 68extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
77 struct neighbour *neigh, 69 struct neighbour *neigh,
78 struct in6_addr *addr, 70 const struct in6_addr *addr);
79 int (*output)(struct sk_buff *)); 71extern int icmp6_dst_gc(int *more);
80extern int ndisc_dst_gc(int *more); 72
81extern void fib6_force_start_gc(void); 73extern void fib6_force_start_gc(struct net *net);
82 74
83extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, 75extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
84 const struct in6_addr *addr, 76 const struct in6_addr *addr,
85 int anycast); 77 int anycast);
86 78
79extern int ip6_dst_hoplimit(struct dst_entry *dst);
80
87/* 81/*
88 * support functions for ND 82 * support functions for ND
89 * 83 *
@@ -94,7 +88,7 @@ extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr,
94 struct net_device *dev, 88 struct net_device *dev,
95 unsigned int pref); 89 unsigned int pref);
96 90
97extern void rt6_purge_dflt_routers(void); 91extern void rt6_purge_dflt_routers(struct net *net);
98 92
99extern int rt6_route_rcv(struct net_device *dev, 93extern int rt6_route_rcv(struct net_device *dev,
100 u8 *opt, int len, 94 u8 *opt, int len,
@@ -121,7 +115,7 @@ struct rt6_rtnl_dump_arg
121}; 115};
122 116
123extern int rt6_dump_route(struct rt6_info *rt, void *p_arg); 117extern int rt6_dump_route(struct rt6_info *rt, void *p_arg);
124extern void rt6_ifdown(struct net_device *dev); 118extern void rt6_ifdown(struct net *net, struct net_device *dev);
125extern void rt6_mtu_change(struct net_device *dev, unsigned mtu); 119extern void rt6_mtu_change(struct net_device *dev, unsigned mtu);
126 120
127extern rwlock_t rt6_lock; 121extern rwlock_t rt6_lock;
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 56f3c94ae620..9a51ebad3f1f 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -405,7 +405,8 @@ struct sk_buff;
405struct ip_vs_protocol { 405struct ip_vs_protocol {
406 struct ip_vs_protocol *next; 406 struct ip_vs_protocol *next;
407 char *name; 407 char *name;
408 __u16 protocol; 408 u16 protocol;
409 u16 num_states;
409 int dont_defrag; 410 int dont_defrag;
410 atomic_t appcnt; /* counter of proto app incs */ 411 atomic_t appcnt; /* counter of proto app incs */
411 int *timeout_table; /* protocol timeout table */ 412 int *timeout_table; /* protocol timeout table */
diff --git a/include/net/ipip.h b/include/net/ipip.h
index 549e132bca9c..633ed4def8e3 100644
--- a/include/net/ipip.h
+++ b/include/net/ipip.h
@@ -24,6 +24,16 @@ struct ip_tunnel
24 int mlink; 24 int mlink;
25 25
26 struct ip_tunnel_parm parms; 26 struct ip_tunnel_parm parms;
27
28 struct ip_tunnel_prl_entry *prl; /* potential router list */
29 unsigned int prl_count; /* # of entries in PRL */
30};
31
32struct ip_tunnel_prl_entry
33{
34 struct ip_tunnel_prl_entry *next;
35 __be32 addr;
36 u16 flags;
27}; 37};
28 38
29#define IPTUNNEL_XMIT() do { \ 39#define IPTUNNEL_XMIT() do { \
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index c0c019f72ba9..e0a612bc9c4e 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -202,6 +202,7 @@ struct ip6_flowlabel
202 u32 owner; 202 u32 owner;
203 unsigned long lastuse; 203 unsigned long lastuse;
204 unsigned long expires; 204 unsigned long expires;
205 struct net *fl_net;
205}; 206};
206 207
207#define IPV6_FLOWINFO_MASK __constant_htonl(0x0FFFFFFF) 208#define IPV6_FLOWINFO_MASK __constant_htonl(0x0FFFFFFF)
@@ -249,15 +250,6 @@ int ip6_frag_mem(struct net *net);
249 250
250#define IPV6_FRAG_TIMEOUT (60*HZ) /* 60 seconds */ 251#define IPV6_FRAG_TIMEOUT (60*HZ) /* 60 seconds */
251 252
252/*
253 * Function prototype for build_xmit
254 */
255
256typedef int (*inet_getfrag_t) (const void *data,
257 struct in6_addr *addr,
258 char *,
259 unsigned int, unsigned int);
260
261extern int __ipv6_addr_type(const struct in6_addr *addr); 253extern int __ipv6_addr_type(const struct in6_addr *addr);
262static inline int ipv6_addr_type(const struct in6_addr *addr) 254static inline int ipv6_addr_type(const struct in6_addr *addr)
263{ 255{
@@ -288,12 +280,10 @@ static inline int
288ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m, 280ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m,
289 const struct in6_addr *a2) 281 const struct in6_addr *a2)
290{ 282{
291 unsigned int i; 283 return (!!(((a1->s6_addr32[0] ^ a2->s6_addr32[0]) & m->s6_addr32[0]) |
292 284 ((a1->s6_addr32[1] ^ a2->s6_addr32[1]) & m->s6_addr32[1]) |
293 for (i = 0; i < 4; i++) 285 ((a1->s6_addr32[2] ^ a2->s6_addr32[2]) & m->s6_addr32[2]) |
294 if ((a1->s6_addr32[i] ^ a2->s6_addr32[i]) & m->s6_addr32[i]) 286 ((a1->s6_addr32[3] ^ a2->s6_addr32[3]) & m->s6_addr32[3])));
295 return 1;
296 return 0;
297} 287}
298 288
299static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) 289static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2)
@@ -328,10 +318,10 @@ static inline void ipv6_addr_set(struct in6_addr *addr,
328static inline int ipv6_addr_equal(const struct in6_addr *a1, 318static inline int ipv6_addr_equal(const struct in6_addr *a1,
329 const struct in6_addr *a2) 319 const struct in6_addr *a2)
330{ 320{
331 return (a1->s6_addr32[0] == a2->s6_addr32[0] && 321 return (((a1->s6_addr32[0] ^ a2->s6_addr32[0]) |
332 a1->s6_addr32[1] == a2->s6_addr32[1] && 322 (a1->s6_addr32[1] ^ a2->s6_addr32[1]) |
333 a1->s6_addr32[2] == a2->s6_addr32[2] && 323 (a1->s6_addr32[2] ^ a2->s6_addr32[2]) |
334 a1->s6_addr32[3] == a2->s6_addr32[3]); 324 (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0);
335} 325}
336 326
337static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, 327static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2,
@@ -379,8 +369,27 @@ static inline int ipv6_addr_any(const struct in6_addr *a)
379 369
380static inline int ipv6_addr_v4mapped(const struct in6_addr *a) 370static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
381{ 371{
382 return ((a->s6_addr32[0] | a->s6_addr32[1]) == 0 && 372 return ((a->s6_addr32[0] | a->s6_addr32[1] |
383 a->s6_addr32[2] == htonl(0x0000ffff)); 373 (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0);
374}
375
376/*
377 * Check for a RFC 4843 ORCHID address
378 * (Overlay Routable Cryptographic Hash Identifiers)
379 */
380static inline int ipv6_addr_orchid(const struct in6_addr *a)
381{
382 return ((a->s6_addr32[0] & htonl(0xfffffff0))
383 == htonl(0x20010010));
384}
385
386static inline void ipv6_addr_set_v4mapped(const __be32 addr,
387 struct in6_addr *v4mapped)
388{
389 ipv6_addr_set(v4mapped,
390 0, 0,
391 htonl(0x0000FFFF),
392 addr);
384} 393}
385 394
386/* 395/*
@@ -451,8 +460,8 @@ extern int ip6_xmit(struct sock *sk,
451extern int ip6_nd_hdr(struct sock *sk, 460extern int ip6_nd_hdr(struct sock *sk,
452 struct sk_buff *skb, 461 struct sk_buff *skb,
453 struct net_device *dev, 462 struct net_device *dev,
454 struct in6_addr *saddr, 463 const struct in6_addr *saddr,
455 struct in6_addr *daddr, 464 const struct in6_addr *daddr,
456 int proto, int len); 465 int proto, int len);
457 466
458extern int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr); 467extern int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr);
@@ -499,14 +508,6 @@ extern int ip6_local_out(struct sk_buff *skb);
499 * Extension header (options) processing 508 * Extension header (options) processing
500 */ 509 */
501 510
502extern u8 * ipv6_build_nfrag_opts(struct sk_buff *skb,
503 u8 *prev_hdr,
504 struct ipv6_txoptions *opt,
505 struct in6_addr *daddr,
506 u32 jumbolen);
507extern u8 * ipv6_build_frag_opts(struct sk_buff *skb,
508 u8 *prev_hdr,
509 struct ipv6_txoptions *opt);
510extern void ipv6_push_nfrag_opts(struct sk_buff *skb, 511extern void ipv6_push_nfrag_opts(struct sk_buff *skb,
511 struct ipv6_txoptions *opt, 512 struct ipv6_txoptions *opt,
512 u8 *proto, 513 u8 *proto,
@@ -545,10 +546,6 @@ extern int compat_ipv6_getsockopt(struct sock *sk,
545 char __user *optval, 546 char __user *optval,
546 int __user *optlen); 547 int __user *optlen);
547 548
548extern int ipv6_packet_init(void);
549
550extern void ipv6_packet_cleanup(void);
551
552extern int ip6_datagram_connect(struct sock *sk, 549extern int ip6_datagram_connect(struct sock *sk,
553 struct sockaddr *addr, int addr_len); 550 struct sockaddr *addr, int addr_len);
554 551
@@ -585,14 +582,14 @@ extern int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
585 int __user *optlen); 582 int __user *optlen);
586 583
587#ifdef CONFIG_PROC_FS 584#ifdef CONFIG_PROC_FS
588extern int ac6_proc_init(void); 585extern int ac6_proc_init(struct net *net);
589extern void ac6_proc_exit(void); 586extern void ac6_proc_exit(struct net *net);
590extern int raw6_proc_init(void); 587extern int raw6_proc_init(void);
591extern void raw6_proc_exit(void); 588extern void raw6_proc_exit(void);
592extern int tcp6_proc_init(void); 589extern int tcp6_proc_init(struct net *net);
593extern void tcp6_proc_exit(void); 590extern void tcp6_proc_exit(struct net *net);
594extern int udp6_proc_init(void); 591extern int udp6_proc_init(struct net *net);
595extern void udp6_proc_exit(void); 592extern void udp6_proc_exit(struct net *net);
596extern int udplite6_proc_init(void); 593extern int udplite6_proc_init(void);
597extern void udplite6_proc_exit(void); 594extern void udplite6_proc_exit(void);
598extern int ipv6_misc_proc_init(void); 595extern int ipv6_misc_proc_init(void);
@@ -600,17 +597,11 @@ extern void ipv6_misc_proc_exit(void);
600extern int snmp6_register_dev(struct inet6_dev *idev); 597extern int snmp6_register_dev(struct inet6_dev *idev);
601extern int snmp6_unregister_dev(struct inet6_dev *idev); 598extern int snmp6_unregister_dev(struct inet6_dev *idev);
602 599
603extern struct rt6_statistics rt6_stats;
604#else 600#else
605static inline int snmp6_register_dev(struct inet6_dev *idev) 601static inline int ac6_proc_init(struct net *net) { return 0; }
606{ 602static inline void ac6_proc_exit(struct net *net) { }
607 return 0; 603static inline int snmp6_register_dev(struct inet6_dev *idev) { return 0; }
608} 604static inline int snmp6_unregister_dev(struct inet6_dev *idev) { return 0; }
609
610static inline int snmp6_unregister_dev(struct inet6_dev *idev)
611{
612 return 0;
613}
614#endif 605#endif
615 606
616#ifdef CONFIG_SYSCTL 607#ifdef CONFIG_SYSCTL
diff --git a/include/net/irda/irlan_eth.h b/include/net/irda/irlan_eth.h
index 0062347600b9..de5c81691f33 100644
--- a/include/net/irda/irlan_eth.h
+++ b/include/net/irda/irlan_eth.h
@@ -29,5 +29,4 @@ struct net_device *alloc_irlandev(const char *name);
29int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb); 29int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb);
30 30
31void irlan_eth_flow_indication( void *instance, void *sap, LOCAL_FLOW flow); 31void irlan_eth_flow_indication( void *instance, void *sap, LOCAL_FLOW flow);
32void irlan_eth_send_gratuitous_arp(struct net_device *dev);
33#endif 32#endif
diff --git a/include/net/llc_if.h b/include/net/llc_if.h
index c608812a8e89..b595a004d31b 100644
--- a/include/net/llc_if.h
+++ b/include/net/llc_if.h
@@ -74,11 +74,6 @@ static inline int llc_mac_null(const u8 *mac)
74 return is_zero_ether_addr(mac); 74 return is_zero_ether_addr(mac);
75} 75}
76 76
77static inline int llc_addrany(const struct llc_addr *addr)
78{
79 return llc_mac_null(addr->mac) && !addr->lsap;
80}
81
82static inline int llc_mac_multicast(const u8 *mac) 77static inline int llc_mac_multicast(const u8 *mac)
83{ 78{
84 return is_multicast_ether_addr(mac); 79 return is_multicast_ether_addr(mac);
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 9083bafb63ca..4a80d74975e8 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -38,7 +38,11 @@
38 * called in hardware interrupt context. The low-level driver must not call any 38 * called in hardware interrupt context. The low-level driver must not call any
39 * other functions in hardware interrupt context. If there is a need for such 39 * other functions in hardware interrupt context. If there is a need for such
40 * call, the low-level driver should first ACK the interrupt and perform the 40 * call, the low-level driver should first ACK the interrupt and perform the
41 * IEEE 802.11 code call after this, e.g. from a scheduled workqueue function. 41 * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even
42 * tasklet function.
43 *
44 * NOTE: If the driver opts to use the _irqsafe() functions, it may not also
45 * use the non-irqsafe functions!
42 */ 46 */
43 47
44/** 48/**
@@ -69,93 +73,12 @@
69 * not do so then mac80211 may add this under certain circumstances. 73 * not do so then mac80211 may add this under certain circumstances.
70 */ 74 */
71 75
72#define IEEE80211_CHAN_W_SCAN 0x00000001
73#define IEEE80211_CHAN_W_ACTIVE_SCAN 0x00000002
74#define IEEE80211_CHAN_W_IBSS 0x00000004
75
76/* Channel information structure. Low-level driver is expected to fill in chan,
77 * freq, and val fields. Other fields will be filled in by 80211.o based on
78 * hostapd information and low-level driver does not need to use them. The
79 * limits for each channel will be provided in 'struct ieee80211_conf' when
80 * configuring the low-level driver with hw->config callback. If a device has
81 * a default regulatory domain, IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED
82 * can be set to let the driver configure all fields */
83struct ieee80211_channel {
84 short chan; /* channel number (IEEE 802.11) */
85 short freq; /* frequency in MHz */
86 int val; /* hw specific value for the channel */
87 int flag; /* flag for hostapd use (IEEE80211_CHAN_*) */
88 unsigned char power_level;
89 unsigned char antenna_max;
90};
91
92#define IEEE80211_RATE_ERP 0x00000001
93#define IEEE80211_RATE_BASIC 0x00000002
94#define IEEE80211_RATE_PREAMBLE2 0x00000004
95#define IEEE80211_RATE_SUPPORTED 0x00000010
96#define IEEE80211_RATE_OFDM 0x00000020
97#define IEEE80211_RATE_CCK 0x00000040
98#define IEEE80211_RATE_MANDATORY 0x00000100
99
100#define IEEE80211_RATE_CCK_2 (IEEE80211_RATE_CCK | IEEE80211_RATE_PREAMBLE2)
101#define IEEE80211_RATE_MODULATION(f) \
102 (f & (IEEE80211_RATE_CCK | IEEE80211_RATE_OFDM))
103
104/* Low-level driver should set PREAMBLE2, OFDM and CCK flags.
105 * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the
106 * configuration. */
107struct ieee80211_rate {
108 int rate; /* rate in 100 kbps */
109 int val; /* hw specific value for the rate */
110 int flags; /* IEEE80211_RATE_ flags */
111 int val2; /* hw specific value for the rate when using short preamble
112 * (only when IEEE80211_RATE_PREAMBLE2 flag is set, i.e., for
113 * 2, 5.5, and 11 Mbps) */
114 signed char min_rssi_ack;
115 unsigned char min_rssi_ack_delta;
116
117 /* following fields are set by 80211.o and need not be filled by the
118 * low-level driver */
119 int rate_inv; /* inverse of the rate (LCM(all rates) / rate) for
120 * optimizing channel utilization estimates */
121};
122
123/** 76/**
124 * enum ieee80211_phymode - PHY modes 77 * enum ieee80211_notification_type - Low level driver notification
125 * 78 * @IEEE80211_NOTIFY_RE_ASSOC: start the re-association sequence
126 * @MODE_IEEE80211A: 5GHz as defined by 802.11a/802.11h
127 * @MODE_IEEE80211B: 2.4 GHz as defined by 802.11b
128 * @MODE_IEEE80211G: 2.4 GHz as defined by 802.11g (with OFDM),
129 * backwards compatible with 11b mode
130 * @NUM_IEEE80211_MODES: internal
131 */ 79 */
132enum ieee80211_phymode { 80enum ieee80211_notification_types {
133 MODE_IEEE80211A, 81 IEEE80211_NOTIFY_RE_ASSOC,
134 MODE_IEEE80211B,
135 MODE_IEEE80211G,
136
137 /* keep last */
138 NUM_IEEE80211_MODES
139};
140
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}; 82};
160 83
161/** 84/**
@@ -175,46 +98,22 @@ struct ieee80211_ht_bss_info {
175}; 98};
176 99
177/** 100/**
178 * struct ieee80211_hw_mode - PHY mode definition
179 *
180 * This structure describes the capabilities supported by the device
181 * in a single PHY mode.
182 *
183 * @list: internal
184 * @channels: pointer to array of supported channels
185 * @rates: pointer to array of supported bitrates
186 * @mode: the PHY mode for this definition
187 * @num_channels: number of supported channels
188 * @num_rates: number of supported bitrates
189 * @ht_info: PHY's 802.11n HT abilities for this mode
190 */
191struct ieee80211_hw_mode {
192 struct list_head list;
193 struct ieee80211_channel *channels;
194 struct ieee80211_rate *rates;
195 enum ieee80211_phymode mode;
196 int num_channels;
197 int num_rates;
198 struct ieee80211_ht_info ht_info;
199};
200
201/**
202 * struct ieee80211_tx_queue_params - transmit queue configuration 101 * struct ieee80211_tx_queue_params - transmit queue configuration
203 * 102 *
204 * The information provided in this structure is required for QoS 103 * The information provided in this structure is required for QoS
205 * transmit queue configuration. 104 * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
206 * 105 *
207 * @aifs: arbitration interface space [0..255, -1: use default] 106 * @aifs: arbitration interface space [0..255, -1: use default]
208 * @cw_min: minimum contention window [will be a value of the form 107 * @cw_min: minimum contention window [will be a value of the form
209 * 2^n-1 in the range 1..1023; 0: use default] 108 * 2^n-1 in the range 1..1023; 0: use default]
210 * @cw_max: maximum contention window [like @cw_min] 109 * @cw_max: maximum contention window [like @cw_min]
211 * @burst_time: maximum burst time in units of 0.1ms, 0 meaning disabled 110 * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
212 */ 111 */
213struct ieee80211_tx_queue_params { 112struct ieee80211_tx_queue_params {
214 int aifs; 113 s16 aifs;
215 int cw_min; 114 u16 cw_min;
216 int cw_max; 115 u16 cw_max;
217 int burst_time; 116 u16 txop;
218}; 117};
219 118
220/** 119/**
@@ -246,6 +145,7 @@ struct ieee80211_tx_queue_stats_data {
246 * @IEEE80211_TX_QUEUE_AFTER_BEACON: transmit queue for frames to be 145 * @IEEE80211_TX_QUEUE_AFTER_BEACON: transmit queue for frames to be
247 * sent after a beacon 146 * sent after a beacon
248 * @IEEE80211_TX_QUEUE_BEACON: transmit queue for beacon frames 147 * @IEEE80211_TX_QUEUE_BEACON: transmit queue for beacon frames
148 * @NUM_TX_DATA_QUEUES_AMPDU: adding more queues for A-MPDU
249 */ 149 */
250enum ieee80211_tx_queue { 150enum ieee80211_tx_queue {
251 IEEE80211_TX_QUEUE_DATA0, 151 IEEE80211_TX_QUEUE_DATA0,
@@ -261,11 +161,12 @@ enum ieee80211_tx_queue {
261 * this struct need to have fixed values. As soon as it is removed, we can 161 * this struct need to have fixed values. As soon as it is removed, we can
262 * fix these entries. */ 162 * fix these entries. */
263 IEEE80211_TX_QUEUE_AFTER_BEACON = 6, 163 IEEE80211_TX_QUEUE_AFTER_BEACON = 6,
264 IEEE80211_TX_QUEUE_BEACON = 7 164 IEEE80211_TX_QUEUE_BEACON = 7,
165 NUM_TX_DATA_QUEUES_AMPDU = 16
265}; 166};
266 167
267struct ieee80211_tx_queue_stats { 168struct ieee80211_tx_queue_stats {
268 struct ieee80211_tx_queue_stats_data data[NUM_TX_DATA_QUEUES]; 169 struct ieee80211_tx_queue_stats_data data[NUM_TX_DATA_QUEUES_AMPDU];
269}; 170};
270 171
271struct ieee80211_low_level_stats { 172struct ieee80211_low_level_stats {
@@ -285,11 +186,13 @@ struct ieee80211_low_level_stats {
285 * also implies a change in the AID. 186 * also implies a change in the AID.
286 * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed 187 * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
287 * @BSS_CHANGED_ERP_PREAMBLE: preamble changed 188 * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
189 * @BSS_CHANGED_HT: 802.11n parameters changed
288 */ 190 */
289enum ieee80211_bss_change { 191enum ieee80211_bss_change {
290 BSS_CHANGED_ASSOC = 1<<0, 192 BSS_CHANGED_ASSOC = 1<<0,
291 BSS_CHANGED_ERP_CTS_PROT = 1<<1, 193 BSS_CHANGED_ERP_CTS_PROT = 1<<1,
292 BSS_CHANGED_ERP_PREAMBLE = 1<<2, 194 BSS_CHANGED_ERP_PREAMBLE = 1<<2,
195 BSS_CHANGED_HT = 1<<4,
293}; 196};
294 197
295/** 198/**
@@ -302,6 +205,12 @@ enum ieee80211_bss_change {
302 * @aid: association ID number, valid only when @assoc is true 205 * @aid: association ID number, valid only when @assoc is true
303 * @use_cts_prot: use CTS protection 206 * @use_cts_prot: use CTS protection
304 * @use_short_preamble: use 802.11b short preamble 207 * @use_short_preamble: use 802.11b short preamble
208 * @timestamp: beacon timestamp
209 * @beacon_int: beacon interval
210 * @assoc_capability: capabbilities taken from assoc resp
211 * @assoc_ht: association in HT mode
212 * @ht_conf: ht capabilities
213 * @ht_bss_conf: ht extended capabilities
305 */ 214 */
306struct ieee80211_bss_conf { 215struct ieee80211_bss_conf {
307 /* association related data */ 216 /* association related data */
@@ -310,6 +219,69 @@ struct ieee80211_bss_conf {
310 /* erp related data */ 219 /* erp related data */
311 bool use_cts_prot; 220 bool use_cts_prot;
312 bool use_short_preamble; 221 bool use_short_preamble;
222 u16 beacon_int;
223 u16 assoc_capability;
224 u64 timestamp;
225 /* ht related data */
226 bool assoc_ht;
227 struct ieee80211_ht_info *ht_conf;
228 struct ieee80211_ht_bss_info *ht_bss_conf;
229};
230
231/**
232 * enum mac80211_tx_control_flags - flags to describe Tx configuration for
233 * the Tx frame
234 *
235 * These flags are used with the @flags member of &ieee80211_tx_control
236 *
237 * @IEEE80211_TXCTL_REQ_TX_STATUS: request TX status callback for this frame.
238 * @IEEE80211_TXCTL_DO_NOT_ENCRYPT: send this frame without encryption;
239 * e.g., for EAPOL frame
240 * @IEEE80211_TXCTL_USE_RTS_CTS: use RTS-CTS before sending frame
241 * @IEEE80211_TXCTL_USE_CTS_PROTECT: use CTS protection for the frame (e.g.,
242 * for combined 802.11g / 802.11b networks)
243 * @IEEE80211_TXCTL_NO_ACK: tell the low level not to wait for an ack
244 * @IEEE80211_TXCTL_RATE_CTRL_PROBE
245 * @EEE80211_TXCTL_CLEAR_PS_FILT: clear powersave filter
246 * for destination station
247 * @IEEE80211_TXCTL_REQUEUE:
248 * @IEEE80211_TXCTL_FIRST_FRAGMENT: this is a first fragment of the frame
249 * @IEEE80211_TXCTL_LONG_RETRY_LIMIT: this frame should be send using the
250 * through set_retry_limit configured long
251 * retry value
252 * @IEEE80211_TXCTL_EAPOL_FRAME: internal to mac80211
253 * @IEEE80211_TXCTL_SEND_AFTER_DTIM: send this frame after DTIM beacon
254 * @IEEE80211_TXCTL_AMPDU: this frame should be sent as part of an A-MPDU
255 * @IEEE80211_TXCTL_OFDM_HT: this frame can be sent in HT OFDM rates. number
256 * of streams when this flag is on can be extracted
257 * from antenna_sel_tx, so if 1 antenna is marked
258 * use SISO, 2 antennas marked use MIMO, n antennas
259 * marked use MIMO_n.
260 * @IEEE80211_TXCTL_GREEN_FIELD: use green field protection for this frame
261 * @IEEE80211_TXCTL_40_MHZ_WIDTH: send this frame using 40 Mhz channel width
262 * @IEEE80211_TXCTL_DUP_DATA: duplicate data frame on both 20 Mhz channels
263 * @IEEE80211_TXCTL_SHORT_GI: send this frame using short guard interval
264 */
265enum mac80211_tx_control_flags {
266 IEEE80211_TXCTL_REQ_TX_STATUS = (1<<0),
267 IEEE80211_TXCTL_DO_NOT_ENCRYPT = (1<<1),
268 IEEE80211_TXCTL_USE_RTS_CTS = (1<<2),
269 IEEE80211_TXCTL_USE_CTS_PROTECT = (1<<3),
270 IEEE80211_TXCTL_NO_ACK = (1<<4),
271 IEEE80211_TXCTL_RATE_CTRL_PROBE = (1<<5),
272 IEEE80211_TXCTL_CLEAR_PS_FILT = (1<<6),
273 IEEE80211_TXCTL_REQUEUE = (1<<7),
274 IEEE80211_TXCTL_FIRST_FRAGMENT = (1<<8),
275 IEEE80211_TXCTL_SHORT_PREAMBLE = (1<<9),
276 IEEE80211_TXCTL_LONG_RETRY_LIMIT = (1<<10),
277 IEEE80211_TXCTL_EAPOL_FRAME = (1<<11),
278 IEEE80211_TXCTL_SEND_AFTER_DTIM = (1<<12),
279 IEEE80211_TXCTL_AMPDU = (1<<13),
280 IEEE80211_TXCTL_OFDM_HT = (1<<14),
281 IEEE80211_TXCTL_GREEN_FIELD = (1<<15),
282 IEEE80211_TXCTL_40_MHZ_WIDTH = (1<<16),
283 IEEE80211_TXCTL_DUP_DATA = (1<<17),
284 IEEE80211_TXCTL_SHORT_GI = (1<<18),
313}; 285};
314 286
315/* Transmit control fields. This data structure is passed to low-level driver 287/* Transmit control fields. This data structure is passed to low-level driver
@@ -318,57 +290,27 @@ struct ieee80211_bss_conf {
318 290
319struct ieee80211_tx_control { 291struct ieee80211_tx_control {
320 struct ieee80211_vif *vif; 292 struct ieee80211_vif *vif;
321 int tx_rate; /* Transmit rate, given as the hw specific value for the 293 struct ieee80211_rate *tx_rate;
322 * rate (from struct ieee80211_rate) */ 294
323 int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw 295 /* Transmit rate for RTS/CTS frame */
324 * specific value for the rate (from 296 struct ieee80211_rate *rts_cts_rate;
325 * struct ieee80211_rate) */ 297
326 298 /* retry rate for the last retries */
327#define IEEE80211_TXCTL_REQ_TX_STATUS (1<<0)/* request TX status callback for 299 struct ieee80211_rate *alt_retry_rate;
328 * this frame */ 300
329#define IEEE80211_TXCTL_DO_NOT_ENCRYPT (1<<1) /* send this frame without 301 u32 flags; /* tx control flags defined above */
330 * encryption; e.g., for EAPOL
331 * frames */
332#define IEEE80211_TXCTL_USE_RTS_CTS (1<<2) /* use RTS-CTS before sending
333 * frame */
334#define IEEE80211_TXCTL_USE_CTS_PROTECT (1<<3) /* use CTS protection for the
335 * frame (e.g., for combined
336 * 802.11g / 802.11b networks) */
337#define IEEE80211_TXCTL_NO_ACK (1<<4) /* tell the low level not to
338 * wait for an ack */
339#define IEEE80211_TXCTL_RATE_CTRL_PROBE (1<<5)
340#define IEEE80211_TXCTL_CLEAR_DST_MASK (1<<6)
341#define IEEE80211_TXCTL_REQUEUE (1<<7)
342#define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of
343 * the frame */
344#define IEEE80211_TXCTL_LONG_RETRY_LIMIT (1<<10) /* this frame should be send
345 * using the through
346 * set_retry_limit configured
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 */
351 u32 flags; /* tx control flags defined
352 * above */
353 u8 key_idx; /* keyidx from hw->set_key(), undefined if 302 u8 key_idx; /* keyidx from hw->set_key(), undefined if
354 * IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */ 303 * IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */
355 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. 304 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, ..
356 * This could be used when set_retry_limit 305 * This could be used when set_retry_limit
357 * is not implemented by the driver */ 306 * is not implemented by the driver */
358 u8 power_level; /* per-packet transmit power level, in dBm */ 307 u8 antenna_sel_tx; /* 0 = default/diversity, otherwise bit
359 u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */ 308 * position represents antenna number used */
360 u8 icv_len; /* length of the ICV/MIC field in octets */ 309 u8 icv_len; /* length of the ICV/MIC field in octets */
361 u8 iv_len; /* length of the IV field in octets */ 310 u8 iv_len; /* length of the IV field in octets */
362 u8 queue; /* hardware queue to use for this frame; 311 u8 queue; /* hardware queue to use for this frame;
363 * 0 = highest, hw->queues-1 = lowest */ 312 * 0 = highest, hw->queues-1 = lowest */
364 struct ieee80211_rate *rate; /* internal 80211.o rate */ 313 u16 aid; /* Station AID */
365 struct ieee80211_rate *rts_rate; /* internal 80211.o rate
366 * for RTS/CTS */
367 int alt_retry_rate; /* retry rate for the last retries, given as the
368 * hw specific value for the rate (from
369 * struct ieee80211_rate). To be used to limit
370 * packet dropping when probing higher rates, if hw
371 * supports multiple retry rates. -1 = not used */
372 int type; /* internal */ 314 int type; /* internal */
373}; 315};
374 316
@@ -391,7 +333,8 @@ struct ieee80211_tx_control {
391 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on 333 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
392 * the frame. 334 * the frame.
393 * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field) 335 * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field)
394 * is valid. 336 * is valid. This is useful in monitor mode and necessary for beacon frames
337 * to enable IBSS merging.
395 */ 338 */
396enum mac80211_rx_flags { 339enum mac80211_rx_flags {
397 RX_FLAG_MMIC_ERROR = 1<<0, 340 RX_FLAG_MMIC_ERROR = 1<<0,
@@ -410,27 +353,26 @@ enum mac80211_rx_flags {
410 * The low-level driver should provide this information (the subset 353 * The low-level driver should provide this information (the subset
411 * supported by hardware) to the 802.11 code with each received 354 * supported by hardware) to the 802.11 code with each received
412 * frame. 355 * frame.
413 * @mactime: MAC timestamp as defined by 802.11 356 * @mactime: value in microseconds of the 64-bit Time Synchronization Function
357 * (TSF) timer when the first data symbol (MPDU) arrived at the hardware.
358 * @band: the active band when this frame was received
414 * @freq: frequency the radio was tuned to when receiving this frame, in MHz 359 * @freq: frequency the radio was tuned to when receiving this frame, in MHz
415 * @channel: channel the radio was tuned to
416 * @phymode: active PHY mode
417 * @ssi: signal strength when receiving this frame 360 * @ssi: signal strength when receiving this frame
418 * @signal: used as 'qual' in statistics reporting 361 * @signal: used as 'qual' in statistics reporting
419 * @noise: PHY noise when receiving this frame 362 * @noise: PHY noise when receiving this frame
420 * @antenna: antenna used 363 * @antenna: antenna used
421 * @rate: data rate 364 * @rate_idx: index of data rate into band's supported rates
422 * @flag: %RX_FLAG_* 365 * @flag: %RX_FLAG_*
423 */ 366 */
424struct ieee80211_rx_status { 367struct ieee80211_rx_status {
425 u64 mactime; 368 u64 mactime;
369 enum ieee80211_band band;
426 int freq; 370 int freq;
427 int channel;
428 enum ieee80211_phymode phymode;
429 int ssi; 371 int ssi;
430 int signal; 372 int signal;
431 int noise; 373 int noise;
432 int antenna; 374 int antenna;
433 int rate; 375 int rate_idx;
434 int flag; 376 int flag;
435}; 377};
436 378
@@ -441,12 +383,14 @@ struct ieee80211_rx_status {
441 * 383 *
442 * @IEEE80211_TX_STATUS_TX_FILTERED: The frame was not transmitted 384 * @IEEE80211_TX_STATUS_TX_FILTERED: The frame was not transmitted
443 * because the destination STA was in powersave mode. 385 * because the destination STA was in powersave mode.
444 *
445 * @IEEE80211_TX_STATUS_ACK: Frame was acknowledged 386 * @IEEE80211_TX_STATUS_ACK: Frame was acknowledged
387 * @IEEE80211_TX_STATUS_AMPDU: The frame was aggregated, so status
388 * is for the whole aggregation.
446 */ 389 */
447enum ieee80211_tx_status_flags { 390enum ieee80211_tx_status_flags {
448 IEEE80211_TX_STATUS_TX_FILTERED = 1<<0, 391 IEEE80211_TX_STATUS_TX_FILTERED = 1<<0,
449 IEEE80211_TX_STATUS_ACK = 1<<1, 392 IEEE80211_TX_STATUS_ACK = 1<<1,
393 IEEE80211_TX_STATUS_AMPDU = 1<<2,
450}; 394};
451 395
452/** 396/**
@@ -457,24 +401,25 @@ enum ieee80211_tx_status_flags {
457 * 401 *
458 * @control: a copy of the &struct ieee80211_tx_control passed to the driver 402 * @control: a copy of the &struct ieee80211_tx_control passed to the driver
459 * in the tx() callback. 403 * in the tx() callback.
460 *
461 * @flags: transmit status flags, defined above 404 * @flags: transmit status flags, defined above
462 * 405 * @retry_count: number of retries
463 * @ack_signal: signal strength of the ACK frame
464 *
465 * @excessive_retries: set to 1 if the frame was retried many times 406 * @excessive_retries: set to 1 if the frame was retried many times
466 * but not acknowledged 407 * but not acknowledged
467 * 408 * @ampdu_ack_len: number of aggregated frames.
468 * @retry_count: number of retries 409 * relevant only if IEEE80211_TX_STATUS_AMPDU was set.
469 * 410 * @ampdu_ack_map: block ack bit map for the aggregation.
411 * relevant only if IEEE80211_TX_STATUS_AMPDU was set.
412 * @ack_signal: signal strength of the ACK frame
470 * @queue_length: ?? REMOVE 413 * @queue_length: ?? REMOVE
471 * @queue_number: ?? REMOVE 414 * @queue_number: ?? REMOVE
472 */ 415 */
473struct ieee80211_tx_status { 416struct ieee80211_tx_status {
474 struct ieee80211_tx_control control; 417 struct ieee80211_tx_control control;
475 u8 flags; 418 u8 flags;
476 bool excessive_retries;
477 u8 retry_count; 419 u8 retry_count;
420 bool excessive_retries;
421 u8 ampdu_ack_len;
422 u64 ampdu_ack_map;
478 int ack_signal; 423 int ack_signal;
479 int queue_length; 424 int queue_length;
480 int queue_number; 425 int queue_number;
@@ -502,41 +447,29 @@ enum ieee80211_conf_flags {
502 * 447 *
503 * @radio_enabled: when zero, driver is required to switch off the radio. 448 * @radio_enabled: when zero, driver is required to switch off the radio.
504 * TODO make a flag 449 * TODO make a flag
505 * @channel: IEEE 802.11 channel number
506 * @freq: frequency in MHz
507 * @channel_val: hardware specific channel value for the channel
508 * @phymode: PHY mode to activate (REMOVE)
509 * @chan: channel to switch to, pointer to the channel information
510 * @mode: pointer to mode definition
511 * @regulatory_domain: ??
512 * @beacon_int: beacon interval (TODO make interface config) 450 * @beacon_int: beacon interval (TODO make interface config)
513 * @flags: configuration flags defined above 451 * @flags: configuration flags defined above
514 * @power_level: transmit power limit for current regulatory domain in dBm 452 * @power_level: requested transmit power (in dBm)
515 * @antenna_max: maximum antenna gain 453 * @max_antenna_gain: maximum antenna gain (in dBi)
516 * @antenna_sel_tx: transmit antenna selection, 0: default/diversity, 454 * @antenna_sel_tx: transmit antenna selection, 0: default/diversity,
517 * 1/2: antenna 0/1 455 * 1/2: antenna 0/1
518 * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx 456 * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx
519 * @ht_conf: describes current self configuration of 802.11n HT capabilies 457 * @ht_conf: describes current self configuration of 802.11n HT capabilies
520 * @ht_bss_conf: describes current BSS configuration of 802.11n HT parameters 458 * @ht_bss_conf: describes current BSS configuration of 802.11n HT parameters
459 * @channel: the channel to tune to
521 */ 460 */
522struct ieee80211_conf { 461struct ieee80211_conf {
523 int channel; /* IEEE 802.11 channel number */
524 int freq; /* MHz */
525 int channel_val; /* hw specific value for the channel */
526
527 enum ieee80211_phymode phymode;
528 struct ieee80211_channel *chan;
529 struct ieee80211_hw_mode *mode;
530 unsigned int regulatory_domain;
531 int radio_enabled; 462 int radio_enabled;
532 463
533 int beacon_int; 464 int beacon_int;
534 u32 flags; 465 u32 flags;
535 u8 power_level; 466 int power_level;
536 u8 antenna_max; 467 int max_antenna_gain;
537 u8 antenna_sel_tx; 468 u8 antenna_sel_tx;
538 u8 antenna_sel_rx; 469 u8 antenna_sel_rx;
539 470
471 struct ieee80211_channel *channel;
472
540 struct ieee80211_ht_info ht_conf; 473 struct ieee80211_ht_info ht_conf;
541 struct ieee80211_ht_bss_info ht_bss_conf; 474 struct ieee80211_ht_bss_info ht_bss_conf;
542}; 475};
@@ -555,12 +488,14 @@ struct ieee80211_conf {
555 * @IEEE80211_IF_TYPE_WDS: interface in WDS mode. 488 * @IEEE80211_IF_TYPE_WDS: interface in WDS mode.
556 * @IEEE80211_IF_TYPE_VLAN: VLAN interface bound to an AP, drivers 489 * @IEEE80211_IF_TYPE_VLAN: VLAN interface bound to an AP, drivers
557 * will never see this type. 490 * will never see this type.
491 * @IEEE80211_IF_TYPE_MESH_POINT: 802.11s mesh point
558 */ 492 */
559enum ieee80211_if_types { 493enum ieee80211_if_types {
560 IEEE80211_IF_TYPE_INVALID, 494 IEEE80211_IF_TYPE_INVALID,
561 IEEE80211_IF_TYPE_AP, 495 IEEE80211_IF_TYPE_AP,
562 IEEE80211_IF_TYPE_STA, 496 IEEE80211_IF_TYPE_STA,
563 IEEE80211_IF_TYPE_IBSS, 497 IEEE80211_IF_TYPE_IBSS,
498 IEEE80211_IF_TYPE_MESH_POINT,
564 IEEE80211_IF_TYPE_MNTR, 499 IEEE80211_IF_TYPE_MNTR,
565 IEEE80211_IF_TYPE_WDS, 500 IEEE80211_IF_TYPE_WDS,
566 IEEE80211_IF_TYPE_VLAN, 501 IEEE80211_IF_TYPE_VLAN,
@@ -582,6 +517,14 @@ struct ieee80211_vif {
582 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); 517 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
583}; 518};
584 519
520static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
521{
522#ifdef CONFIG_MAC80211_MESH
523 return vif->type == IEEE80211_IF_TYPE_MESH_POINT;
524#endif
525 return false;
526}
527
585/** 528/**
586 * struct ieee80211_if_init_conf - initial configuration of an interface 529 * struct ieee80211_if_init_conf - initial configuration of an interface
587 * 530 *
@@ -725,6 +668,21 @@ enum sta_notify_cmd {
725}; 668};
726 669
727/** 670/**
671 * enum ieee80211_tkip_key_type - get tkip key
672 *
673 * Used by drivers which need to get a tkip key for skb. Some drivers need a
674 * phase 1 key, others need a phase 2 key. A single function allows the driver
675 * to get the key, this enum indicates what type of key is required.
676 *
677 * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key
678 * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key
679 */
680enum ieee80211_tkip_key_type {
681 IEEE80211_TKIP_P1_KEY,
682 IEEE80211_TKIP_P2_KEY,
683};
684
685/**
728 * enum ieee80211_hw_flags - hardware flags 686 * enum ieee80211_hw_flags - hardware flags
729 * 687 *
730 * These flags are used to indicate hardware capabilities to 688 * These flags are used to indicate hardware capabilities to
@@ -757,15 +715,19 @@ enum sta_notify_cmd {
757 * %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is also not set because 715 * %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is also not set because
758 * otherwise the stack will not know when the DTIM beacon was sent. 716 * otherwise the stack will not know when the DTIM beacon was sent.
759 * 717 *
760 * @IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED: 718 * @IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE:
761 * Channels are already configured to the default regulatory domain 719 * Hardware is not capable of short slot operation on the 2.4 GHz band.
762 * specified in the device's EEPROM 720 *
721 * @IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE:
722 * Hardware is not capable of receiving frames with short preamble on
723 * the 2.4 GHz band.
763 */ 724 */
764enum ieee80211_hw_flags { 725enum ieee80211_hw_flags {
765 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE = 1<<0, 726 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE = 1<<0,
766 IEEE80211_HW_RX_INCLUDES_FCS = 1<<1, 727 IEEE80211_HW_RX_INCLUDES_FCS = 1<<1,
767 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2, 728 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2,
768 IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED = 1<<3, 729 IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE = 1<<3,
730 IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE = 1<<4,
769}; 731};
770 732
771/** 733/**
@@ -777,7 +739,8 @@ enum ieee80211_hw_flags {
777 * @wiphy: This points to the &struct wiphy allocated for this 739 * @wiphy: This points to the &struct wiphy allocated for this
778 * 802.11 PHY. You must fill in the @perm_addr and @dev 740 * 802.11 PHY. You must fill in the @perm_addr and @dev
779 * members of this structure using SET_IEEE80211_DEV() 741 * members of this structure using SET_IEEE80211_DEV()
780 * and SET_IEEE80211_PERM_ADDR(). 742 * and SET_IEEE80211_PERM_ADDR(). Additionally, all supported
743 * bands (with channels, bitrates) are registered here.
781 * 744 *
782 * @conf: &struct ieee80211_conf, device configuration, don't use. 745 * @conf: &struct ieee80211_conf, device configuration, don't use.
783 * 746 *
@@ -888,6 +851,16 @@ static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
888 * parameter is guaranteed to be valid until another call to set_key() 851 * parameter is guaranteed to be valid until another call to set_key()
889 * removes it, but it can only be used as a cookie to differentiate 852 * removes it, but it can only be used as a cookie to differentiate
890 * keys. 853 * keys.
854 *
855 * In TKIP some HW need to be provided a phase 1 key, for RX decryption
856 * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
857 * handler.
858 * The update_tkip_key() call updates the driver with the new phase 1 key.
859 * This happens everytime the iv16 wraps around (every 65536 packets). The
860 * set_key() call will happen only once for each key (unless the AP did
861 * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
862 * provided by udpate_tkip_key only. The trigger that makes mac80211 call this
863 * handler is software decryption with wrap around of iv16.
891 */ 864 */
892 865
893/** 866/**
@@ -913,8 +886,18 @@ static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
913 * parameter to see whether multicast frames should be accepted 886 * parameter to see whether multicast frames should be accepted
914 * or dropped. 887 * or dropped.
915 * 888 *
916 * All unsupported flags in @total_flags must be cleared, i.e. you 889 * All unsupported flags in @total_flags must be cleared.
917 * should clear all bits except those you honoured. 890 * Hardware does not support a flag if it is incapable of _passing_
891 * the frame to the stack. Otherwise the driver must ignore
892 * the flag, but not clear it.
893 * You must _only_ clear the flag (announce no support for the
894 * flag to mac80211) if you are not able to pass the packet type
895 * to the stack (so the hardware always filters it).
896 * So for example, you should clear @FIF_CONTROL, if your hardware
897 * always filters control frames. If your hardware always passes
898 * control frames to the kernel and is incapable of filtering them,
899 * you do _not_ clear the @FIF_CONTROL flag.
900 * This rule applies to all other FIF flags as well.
918 */ 901 */
919 902
920/** 903/**
@@ -967,10 +950,14 @@ enum ieee80211_filter_flags {
967 * &struct ieee80211_ops to indicate which action is needed. 950 * &struct ieee80211_ops to indicate which action is needed.
968 * @IEEE80211_AMPDU_RX_START: start Rx aggregation 951 * @IEEE80211_AMPDU_RX_START: start Rx aggregation
969 * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation 952 * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation
953 * @IEEE80211_AMPDU_TX_START: start Tx aggregation
954 * @IEEE80211_AMPDU_TX_STOP: stop Tx aggregation
970 */ 955 */
971enum ieee80211_ampdu_mlme_action { 956enum ieee80211_ampdu_mlme_action {
972 IEEE80211_AMPDU_RX_START, 957 IEEE80211_AMPDU_RX_START,
973 IEEE80211_AMPDU_RX_STOP, 958 IEEE80211_AMPDU_RX_STOP,
959 IEEE80211_AMPDU_TX_START,
960 IEEE80211_AMPDU_TX_STOP,
974}; 961};
975 962
976/** 963/**
@@ -1033,8 +1020,7 @@ enum ieee80211_ampdu_mlme_action {
1033 * level driver (e.g. assoc/disassoc status, erp parameters). 1020 * level driver (e.g. assoc/disassoc status, erp parameters).
1034 * This function should not be used if no BSS has been set, unless 1021 * This function should not be used if no BSS has been set, unless
1035 * for association indication. The @changed parameter indicates which 1022 * for association indication. The @changed parameter indicates which
1036 * of the bss parameters has changed when a call is made. This callback 1023 * of the bss parameters has changed when a call is made.
1037 * has to be atomic.
1038 * 1024 *
1039 * @configure_filter: Configure the device's RX filter. 1025 * @configure_filter: Configure the device's RX filter.
1040 * See the section "Frame filtering" for more information. 1026 * See the section "Frame filtering" for more information.
@@ -1050,8 +1036,14 @@ enum ieee80211_ampdu_mlme_action {
1050 * and remove_interface calls, i.e. while the interface with the 1036 * and remove_interface calls, i.e. while the interface with the
1051 * given local_address is enabled. 1037 * given local_address is enabled.
1052 * 1038 *
1039 * @update_tkip_key: See the section "Hardware crypto acceleration"
1040 * This callback will be called in the context of Rx. Called for drivers
1041 * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY.
1042 *
1053 * @hw_scan: Ask the hardware to service the scan request, no need to start 1043 * @hw_scan: Ask the hardware to service the scan request, no need to start
1054 * the scan state machine in stack. 1044 * the scan state machine in stack. The scan must honour the channel
1045 * configuration done by the regulatory agent in the wiphy's registered
1046 * bands.
1055 * 1047 *
1056 * @get_stats: return low-level statistics 1048 * @get_stats: return low-level statistics
1057 * 1049 *
@@ -1111,7 +1103,8 @@ enum ieee80211_ampdu_mlme_action {
1111 * The RA/TID combination determines the destination and TID we want 1103 * The RA/TID combination determines the destination and TID we want
1112 * the ampdu action to be performed for. The action is defined through 1104 * the ampdu action to be performed for. The action is defined through
1113 * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn) 1105 * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
1114 * is the first frame we expect to perform the action on. 1106 * is the first frame we expect to perform the action on. notice
1107 * that TX/RX_STOP can pass NULL for this parameter.
1115 */ 1108 */
1116struct ieee80211_ops { 1109struct ieee80211_ops {
1117 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb, 1110 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
@@ -1138,6 +1131,9 @@ struct ieee80211_ops {
1138 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, 1131 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1139 const u8 *local_address, const u8 *address, 1132 const u8 *local_address, const u8 *address,
1140 struct ieee80211_key_conf *key); 1133 struct ieee80211_key_conf *key);
1134 void (*update_tkip_key)(struct ieee80211_hw *hw,
1135 struct ieee80211_key_conf *conf, const u8 *address,
1136 u32 iv32, u16 *phase1key);
1141 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); 1137 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
1142 int (*get_stats)(struct ieee80211_hw *hw, 1138 int (*get_stats)(struct ieee80211_hw *hw,
1143 struct ieee80211_low_level_stats *stats); 1139 struct ieee80211_low_level_stats *stats);
@@ -1159,10 +1155,9 @@ struct ieee80211_ops {
1159 struct sk_buff *skb, 1155 struct sk_buff *skb,
1160 struct ieee80211_tx_control *control); 1156 struct ieee80211_tx_control *control);
1161 int (*tx_last_beacon)(struct ieee80211_hw *hw); 1157 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, 1158 int (*ampdu_action)(struct ieee80211_hw *hw,
1164 enum ieee80211_ampdu_mlme_action action, 1159 enum ieee80211_ampdu_mlme_action action,
1165 const u8 *ra, u16 tid, u16 ssn); 1160 const u8 *addr, u16 tid, u16 *ssn);
1166}; 1161};
1167 1162
1168/** 1163/**
@@ -1183,8 +1178,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
1183/** 1178/**
1184 * ieee80211_register_hw - Register hardware device 1179 * ieee80211_register_hw - Register hardware device
1185 * 1180 *
1186 * You must call this function before any other functions 1181 * You must call this function before any other functions in
1187 * except ieee80211_register_hwmode. 1182 * mac80211. Note that before a hardware can be registered, you
1183 * need to fill the contained wiphy's information.
1188 * 1184 *
1189 * @hw: the device to register as returned by ieee80211_alloc_hw() 1185 * @hw: the device to register as returned by ieee80211_alloc_hw()
1190 */ 1186 */
@@ -1272,10 +1268,6 @@ static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
1272#endif 1268#endif
1273} 1269}
1274 1270
1275/* Register a new hardware PHYMODE capability to the stack. */
1276int ieee80211_register_hwmode(struct ieee80211_hw *hw,
1277 struct ieee80211_hw_mode *mode);
1278
1279/** 1271/**
1280 * ieee80211_unregister_hw - Unregister a hardware device 1272 * ieee80211_unregister_hw - Unregister a hardware device
1281 * 1273 *
@@ -1308,7 +1300,10 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
1308 * buffer in @skb must start with an IEEE 802.11 header or a radiotap 1300 * buffer in @skb must start with an IEEE 802.11 header or a radiotap
1309 * header if %RX_FLAG_RADIOTAP is set in the @status flags. 1301 * header if %RX_FLAG_RADIOTAP is set in the @status flags.
1310 * 1302 *
1311 * This function may not be called in IRQ context. 1303 * This function may not be called in IRQ context. Calls to this function
1304 * for a single hardware must be synchronized against each other. Calls
1305 * to this function and ieee80211_rx_irqsafe() may not be mixed for a
1306 * single hardware.
1312 * 1307 *
1313 * @hw: the hardware this frame came in on 1308 * @hw: the hardware this frame came in on
1314 * @skb: the buffer to receive, owned by mac80211 after this call 1309 * @skb: the buffer to receive, owned by mac80211 after this call
@@ -1325,7 +1320,10 @@ static inline void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
1325 * ieee80211_rx_irqsafe - receive frame 1320 * ieee80211_rx_irqsafe - receive frame
1326 * 1321 *
1327 * Like ieee80211_rx() but can be called in IRQ context 1322 * Like ieee80211_rx() but can be called in IRQ context
1328 * (internally defers to a workqueue.) 1323 * (internally defers to a tasklet.)
1324 *
1325 * Calls to this function and ieee80211_rx() may not be mixed for a
1326 * single hardware.
1329 * 1327 *
1330 * @hw: the hardware this frame came in on 1328 * @hw: the hardware this frame came in on
1331 * @skb: the buffer to receive, owned by mac80211 after this call 1329 * @skb: the buffer to receive, owned by mac80211 after this call
@@ -1344,6 +1342,11 @@ void ieee80211_rx_irqsafe(struct ieee80211_hw *hw,
1344 * transmitted. It is permissible to not call this function for 1342 * transmitted. It is permissible to not call this function for
1345 * multicast frames but this can affect statistics. 1343 * multicast frames but this can affect statistics.
1346 * 1344 *
1345 * This function may not be called in IRQ context. Calls to this function
1346 * for a single hardware must be synchronized against each other. Calls
1347 * to this function and ieee80211_tx_status_irqsafe() may not be mixed
1348 * for a single hardware.
1349 *
1347 * @hw: the hardware the frame was transmitted by 1350 * @hw: the hardware the frame was transmitted by
1348 * @skb: the frame that was transmitted, owned by mac80211 after this call 1351 * @skb: the frame that was transmitted, owned by mac80211 after this call
1349 * @status: status information for this frame; the status pointer need not 1352 * @status: status information for this frame; the status pointer need not
@@ -1353,6 +1356,22 @@ void ieee80211_rx_irqsafe(struct ieee80211_hw *hw,
1353void ieee80211_tx_status(struct ieee80211_hw *hw, 1356void ieee80211_tx_status(struct ieee80211_hw *hw,
1354 struct sk_buff *skb, 1357 struct sk_buff *skb,
1355 struct ieee80211_tx_status *status); 1358 struct ieee80211_tx_status *status);
1359
1360/**
1361 * ieee80211_tx_status_irqsafe - irq-safe transmit status callback
1362 *
1363 * Like ieee80211_tx_status() but can be called in IRQ context
1364 * (internally defers to a tasklet.)
1365 *
1366 * Calls to this function and ieee80211_tx_status() may not be mixed for a
1367 * single hardware.
1368 *
1369 * @hw: the hardware the frame was transmitted by
1370 * @skb: the frame that was transmitted, owned by mac80211 after this call
1371 * @status: status information for this frame; the status pointer need not
1372 * be valid after this function returns and is not freed by mac80211,
1373 * it is recommended that it points to a stack area
1374 */
1356void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, 1375void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1357 struct sk_buff *skb, 1376 struct sk_buff *skb,
1358 struct ieee80211_tx_status *status); 1377 struct ieee80211_tx_status *status);
@@ -1449,7 +1468,7 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
1449 * @hw: pointer obtained from ieee80211_alloc_hw(). 1468 * @hw: pointer obtained from ieee80211_alloc_hw().
1450 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. 1469 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1451 * @frame_len: the length of the frame. 1470 * @frame_len: the length of the frame.
1452 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. 1471 * @rate: the rate at which the frame is going to be transmitted.
1453 * 1472 *
1454 * Calculate the duration field of some generic frame, given its 1473 * Calculate the duration field of some generic frame, given its
1455 * length and transmission rate (in 100kbps). 1474 * length and transmission rate (in 100kbps).
@@ -1457,7 +1476,7 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
1457__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, 1476__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
1458 struct ieee80211_vif *vif, 1477 struct ieee80211_vif *vif,
1459 size_t frame_len, 1478 size_t frame_len,
1460 int rate); 1479 struct ieee80211_rate *rate);
1461 1480
1462/** 1481/**
1463 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames 1482 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
@@ -1507,6 +1526,21 @@ int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
1507int ieee80211_get_hdrlen(u16 fc); 1526int ieee80211_get_hdrlen(u16 fc);
1508 1527
1509/** 1528/**
1529 * ieee80211_get_tkip_key - get a TKIP rc4 for skb
1530 *
1531 * This function computes a TKIP rc4 key for an skb. It computes
1532 * a phase 1 key if needed (iv16 wraps around). This function is to
1533 * be used by drivers which can do HW encryption but need to compute
1534 * to phase 1/2 key in SW.
1535 *
1536 * @keyconf: the parameter passed with the set key
1537 * @skb: the skb for which the key is needed
1538 * @rc4key: a buffer to which the key will be written
1539 */
1540void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf,
1541 struct sk_buff *skb,
1542 enum ieee80211_tkip_key_type type, u8 *key);
1543/**
1510 * ieee80211_wake_queue - wake specific queue 1544 * ieee80211_wake_queue - wake specific queue
1511 * @hw: pointer as obtained from ieee80211_alloc_hw(). 1545 * @hw: pointer as obtained from ieee80211_alloc_hw().
1512 * @queue: queue number (counted from zero). 1546 * @queue: queue number (counted from zero).
@@ -1574,4 +1608,92 @@ void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
1574 struct ieee80211_vif *vif), 1608 struct ieee80211_vif *vif),
1575 void *data); 1609 void *data);
1576 1610
1611/**
1612 * ieee80211_start_tx_ba_session - Start a tx Block Ack session.
1613 * @hw: pointer as obtained from ieee80211_alloc_hw().
1614 * @ra: receiver address of the BA session recipient
1615 * @tid: the TID to BA on.
1616 * @return: success if addBA request was sent, failure otherwise
1617 *
1618 * Although mac80211/low level driver/user space application can estimate
1619 * the need to start aggregation on a certain RA/TID, the session level
1620 * will be managed by the mac80211.
1621 */
1622int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid);
1623
1624/**
1625 * ieee80211_start_tx_ba_cb - low level driver ready to aggregate.
1626 * @hw: pointer as obtained from ieee80211_alloc_hw().
1627 * @ra: receiver address of the BA session recipient.
1628 * @tid: the TID to BA on.
1629 *
1630 * This function must be called by low level driver once it has
1631 * finished with preparations for the BA session.
1632 */
1633void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid);
1634
1635/**
1636 * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate.
1637 * @hw: pointer as obtained from ieee80211_alloc_hw().
1638 * @ra: receiver address of the BA session recipient.
1639 * @tid: the TID to BA on.
1640 *
1641 * This function must be called by low level driver once it has
1642 * finished with preparations for the BA session.
1643 * This version of the function is irq safe.
1644 */
1645void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
1646 u16 tid);
1647
1648/**
1649 * ieee80211_stop_tx_ba_session - Stop a Block Ack session.
1650 * @hw: pointer as obtained from ieee80211_alloc_hw().
1651 * @ra: receiver address of the BA session recipient
1652 * @tid: the TID to stop BA.
1653 * @initiator: if indicates initiator DELBA frame will be sent.
1654 * @return: error if no sta with matching da found, success otherwise
1655 *
1656 * Although mac80211/low level driver/user space application can estimate
1657 * the need to stop aggregation on a certain RA/TID, the session level
1658 * will be managed by the mac80211.
1659 */
1660int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
1661 u8 *ra, u16 tid,
1662 enum ieee80211_back_parties initiator);
1663
1664/**
1665 * ieee80211_stop_tx_ba_cb - low level driver ready to stop aggregate.
1666 * @hw: pointer as obtained from ieee80211_alloc_hw().
1667 * @ra: receiver address of the BA session recipient.
1668 * @tid: the desired TID to BA on.
1669 *
1670 * This function must be called by low level driver once it has
1671 * finished with preparations for the BA session tear down.
1672 */
1673void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid);
1674
1675/**
1676 * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate.
1677 * @hw: pointer as obtained from ieee80211_alloc_hw().
1678 * @ra: receiver address of the BA session recipient.
1679 * @tid: the desired TID to BA on.
1680 *
1681 * This function must be called by low level driver once it has
1682 * finished with preparations for the BA session tear down.
1683 * This version of the function is irq safe.
1684 */
1685void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
1686 u16 tid);
1687
1688/**
1689 * ieee80211_notify_mac - low level driver notification
1690 * @hw: pointer as obtained from ieee80211_alloc_hw().
1691 * @notification_types: enum ieee80211_notification_types
1692 *
1693 * This function must be called by low level driver to inform mac80211 of
1694 * low level driver status change or force mac80211 to re-assoc for low
1695 * level driver internal error that require re-assoc.
1696 */
1697void ieee80211_notify_mac(struct ieee80211_hw *hw,
1698 enum ieee80211_notification_types notif_type);
1577#endif /* MAC80211_H */ 1699#endif /* MAC80211_H */
diff --git a/include/net/mip6.h b/include/net/mip6.h
index 63272610a24a..a83ad1982a90 100644
--- a/include/net/mip6.h
+++ b/include/net/mip6.h
@@ -28,9 +28,6 @@
28#include <linux/skbuff.h> 28#include <linux/skbuff.h>
29#include <net/sock.h> 29#include <net/sock.h>
30 30
31#define MIP6_OPT_PAD_1 0
32#define MIP6_OPT_PAD_N 1
33
34/* 31/*
35 * Mobility Header 32 * Mobility Header
36 */ 33 */
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 59b70624b056..9c451ff2f4f4 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -12,6 +12,15 @@
12#define NDISC_REDIRECT 137 12#define NDISC_REDIRECT 137
13 13
14/* 14/*
15 * Router type: cross-layer information from link-layer to
16 * IPv6 layer reported by certain link types (e.g., RFC4214).
17 */
18#define NDISC_NODETYPE_UNSPEC 0 /* unspecified (default) */
19#define NDISC_NODETYPE_HOST 1 /* host or unauthorized router */
20#define NDISC_NODETYPE_NODEFAULT 2 /* non-default router */
21#define NDISC_NODETYPE_DEFAULT 3 /* default router */
22
23/*
15 * ndisc options 24 * ndisc options
16 */ 25 */
17 26
@@ -77,7 +86,7 @@ struct nd_opt_hdr {
77} __attribute__((__packed__)); 86} __attribute__((__packed__));
78 87
79 88
80extern int ndisc_init(struct net_proto_family *ops); 89extern int ndisc_init(void);
81 90
82extern void ndisc_cleanup(void); 91extern void ndisc_cleanup(void);
83 92
@@ -85,20 +94,17 @@ extern int ndisc_rcv(struct sk_buff *skb);
85 94
86extern void ndisc_send_ns(struct net_device *dev, 95extern void ndisc_send_ns(struct net_device *dev,
87 struct neighbour *neigh, 96 struct neighbour *neigh,
88 struct in6_addr *solicit, 97 const struct in6_addr *solicit,
89 struct in6_addr *daddr, 98 const struct in6_addr *daddr,
90 struct in6_addr *saddr); 99 const struct in6_addr *saddr);
91 100
92extern void ndisc_send_rs(struct net_device *dev, 101extern void ndisc_send_rs(struct net_device *dev,
93 struct in6_addr *saddr, 102 const struct in6_addr *saddr,
94 struct in6_addr *daddr); 103 const struct in6_addr *daddr);
95
96extern void ndisc_forwarding_on(void);
97extern void ndisc_forwarding_off(void);
98 104
99extern void ndisc_send_redirect(struct sk_buff *skb, 105extern void ndisc_send_redirect(struct sk_buff *skb,
100 struct neighbour *neigh, 106 struct neighbour *neigh,
101 struct in6_addr *target); 107 const struct in6_addr *target);
102 108
103extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir); 109extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir);
104 110
@@ -107,7 +113,7 @@ extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *d
107/* 113/*
108 * IGMP 114 * IGMP
109 */ 115 */
110extern int igmp6_init(struct net_proto_family *ops); 116extern int igmp6_init(void);
111 117
112extern void igmp6_cleanup(void); 118extern void igmp6_cleanup(void);
113 119
@@ -115,7 +121,6 @@ extern int igmp6_event_query(struct sk_buff *skb);
115 121
116extern int igmp6_event_report(struct sk_buff *skb); 122extern int igmp6_event_report(struct sk_buff *skb);
117 123
118extern void igmp6_cleanup(void);
119 124
120#ifdef CONFIG_SYSCTL 125#ifdef CONFIG_SYSCTL
121extern int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, 126extern int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl,
@@ -129,7 +134,7 @@ extern int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl,
129extern void inet6_ifinfo_notify(int event, 134extern void inet6_ifinfo_notify(int event,
130 struct inet6_dev *idev); 135 struct inet6_dev *idev);
131 136
132static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, struct in6_addr *addr) 137static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, const struct in6_addr *addr)
133{ 138{
134 139
135 if (dev) 140 if (dev)
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 64a5f0120b52..dc420fecafb9 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -38,7 +38,9 @@ struct neighbour;
38 38
39struct neigh_parms 39struct neigh_parms
40{ 40{
41#ifdef CONFIG_NET_NS
41 struct net *net; 42 struct net *net;
43#endif
42 struct net_device *dev; 44 struct net_device *dev;
43 struct neigh_parms *next; 45 struct neigh_parms *next;
44 int (*neigh_setup)(struct neighbour *); 46 int (*neigh_setup)(struct neighbour *);
@@ -131,7 +133,9 @@ struct neigh_ops
131struct pneigh_entry 133struct pneigh_entry
132{ 134{
133 struct pneigh_entry *next; 135 struct pneigh_entry *next;
136#ifdef CONFIG_NET_NS
134 struct net *net; 137 struct net *net;
138#endif
135 struct net_device *dev; 139 struct net_device *dev;
136 u8 flags; 140 u8 flags;
137 u8 key[0]; 141 u8 key[0];
@@ -213,6 +217,17 @@ extern struct neighbour *neigh_event_ns(struct neigh_table *tbl,
213 217
214extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); 218extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl);
215extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); 219extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms);
220
221static inline
222struct net *neigh_parms_net(const struct neigh_parms *parms)
223{
224#ifdef CONFIG_NET_NS
225 return parms->net;
226#else
227 return &init_net;
228#endif
229}
230
216extern unsigned long neigh_rand_reach_time(unsigned long base); 231extern unsigned long neigh_rand_reach_time(unsigned long base);
217 232
218extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, 233extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
@@ -224,6 +239,16 @@ extern struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl,
224 struct net_device *dev); 239 struct net_device *dev);
225extern int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev); 240extern int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev);
226 241
242static inline
243struct net *pneigh_net(const struct pneigh_entry *pneigh)
244{
245#ifdef CONFIG_NET_NS
246 return pneigh->net;
247#else
248 return &init_net;
249#endif
250}
251
227extern void neigh_app_ns(struct neighbour *n); 252extern void neigh_app_ns(struct neighbour *n);
228extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie); 253extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie);
229extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *)); 254extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *));
@@ -288,12 +313,6 @@ static inline void neigh_confirm(struct neighbour *neigh)
288 neigh->confirmed = jiffies; 313 neigh->confirmed = jiffies;
289} 314}
290 315
291static inline int neigh_is_connected(struct neighbour *neigh)
292{
293 return neigh->nud_state&NUD_CONNECTED;
294}
295
296
297static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) 316static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
298{ 317{
299 neigh->used = jiffies; 318 neigh->used = jiffies;
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 923f2b8b9096..aa540e6be502 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -8,24 +8,29 @@
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/core.h>
11#include <net/netns/unix.h> 12#include <net/netns/unix.h>
12#include <net/netns/packet.h> 13#include <net/netns/packet.h>
13#include <net/netns/ipv4.h> 14#include <net/netns/ipv4.h>
14#include <net/netns/ipv6.h> 15#include <net/netns/ipv6.h>
16#include <net/netns/dccp.h>
15#include <net/netns/x_tables.h> 17#include <net/netns/x_tables.h>
16 18
17struct proc_dir_entry; 19struct proc_dir_entry;
18struct net_device; 20struct net_device;
19struct sock; 21struct sock;
20struct ctl_table_header; 22struct ctl_table_header;
23struct net_generic;
21 24
22struct net { 25struct net {
23 atomic_t count; /* To decided when the network 26 atomic_t count; /* To decided when the network
24 * namespace should be freed. 27 * namespace should be freed.
25 */ 28 */
29#ifdef NETNS_REFCNT_DEBUG
26 atomic_t use_count; /* To track references we 30 atomic_t use_count; /* To track references we
27 * destroy on demand 31 * destroy on demand
28 */ 32 */
33#endif
29 struct list_head list; /* list of network namespaces */ 34 struct list_head list; /* list of network namespaces */
30 struct work_struct work; /* work struct for freeing */ 35 struct work_struct work; /* work struct for freeing */
31 36
@@ -46,40 +51,46 @@ struct net {
46 51
47 struct sock *rtnl; /* rtnetlink socket */ 52 struct sock *rtnl; /* rtnetlink socket */
48 53
49 /* core sysctls */ 54 struct netns_core core;
50 struct ctl_table_header *sysctl_core_hdr;
51 int sysctl_somaxconn;
52
53 struct netns_packet packet; 55 struct netns_packet packet;
54 struct netns_unix unx; 56 struct netns_unix unx;
55 struct netns_ipv4 ipv4; 57 struct netns_ipv4 ipv4;
56#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 58#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
57 struct netns_ipv6 ipv6; 59 struct netns_ipv6 ipv6;
58#endif 60#endif
61#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
62 struct netns_dccp dccp;
63#endif
59#ifdef CONFIG_NETFILTER 64#ifdef CONFIG_NETFILTER
60 struct netns_xt xt; 65 struct netns_xt xt;
61#endif 66#endif
67 struct net_generic *gen;
62}; 68};
63 69
64#ifdef CONFIG_NET 70
71#include <linux/seq_file_net.h>
72
65/* Init's network namespace */ 73/* Init's network namespace */
66extern struct net init_net; 74extern struct net init_net;
67#define INIT_NET_NS(net_ns) .net_ns = &init_net,
68#else
69#define INIT_NET_NS(net_ns)
70#endif
71
72extern struct list_head net_namespace_list;
73 75
74#ifdef CONFIG_NET 76#ifdef CONFIG_NET
77#define INIT_NET_NS(net_ns) .net_ns = &init_net,
78
75extern struct net *copy_net_ns(unsigned long flags, struct net *net_ns); 79extern struct net *copy_net_ns(unsigned long flags, struct net *net_ns);
76#else 80
81#else /* CONFIG_NET */
82
83#define INIT_NET_NS(net_ns)
84
77static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns) 85static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns)
78{ 86{
79 /* There is nothing to copy so this is a noop */ 87 /* There is nothing to copy so this is a noop */
80 return net_ns; 88 return net_ns;
81} 89}
82#endif 90#endif /* CONFIG_NET */
91
92
93extern struct list_head net_namespace_list;
83 94
84#ifdef CONFIG_NET_NS 95#ifdef CONFIG_NET_NS
85extern void __put_net(struct net *net); 96extern void __put_net(struct net *net);
@@ -108,41 +119,59 @@ static inline void put_net(struct net *net)
108 __put_net(net); 119 __put_net(net);
109} 120}
110 121
111static inline struct net *hold_net(struct net *net) 122static inline
123int net_eq(const struct net *net1, const struct net *net2)
124{
125 return net1 == net2;
126}
127#else
128static inline struct net *get_net(struct net *net)
112{ 129{
113 atomic_inc(&net->use_count);
114 return net; 130 return net;
115} 131}
116 132
117static inline void release_net(struct net *net) 133static inline void put_net(struct net *net)
118{ 134{
119 atomic_dec(&net->use_count);
120} 135}
121#else 136
122static inline struct net *get_net(struct net *net) 137static inline struct net *maybe_get_net(struct net *net)
123{ 138{
124 return net; 139 return net;
125} 140}
126 141
127static inline void put_net(struct net *net) 142static inline
143int net_eq(const struct net *net1, const struct net *net2)
128{ 144{
145 return 1;
129} 146}
147#endif
148
130 149
150#ifdef NETNS_REFCNT_DEBUG
131static inline struct net *hold_net(struct net *net) 151static inline struct net *hold_net(struct net *net)
132{ 152{
153 if (net)
154 atomic_inc(&net->use_count);
133 return net; 155 return net;
134} 156}
135 157
136static inline void release_net(struct net *net) 158static inline void release_net(struct net *net)
137{ 159{
160 if (net)
161 atomic_dec(&net->use_count);
138} 162}
139 163#else
140static inline struct net *maybe_get_net(struct net *net) 164static inline struct net *hold_net(struct net *net)
141{ 165{
142 return net; 166 return net;
143} 167}
168
169static inline void release_net(struct net *net)
170{
171}
144#endif 172#endif
145 173
174
146#define for_each_net(VAR) \ 175#define for_each_net(VAR) \
147 list_for_each_entry(VAR, &net_namespace_list, list) 176 list_for_each_entry(VAR, &net_namespace_list, list)
148 177
@@ -166,6 +195,8 @@ extern int register_pernet_subsys(struct pernet_operations *);
166extern void unregister_pernet_subsys(struct pernet_operations *); 195extern void unregister_pernet_subsys(struct pernet_operations *);
167extern int register_pernet_device(struct pernet_operations *); 196extern int register_pernet_device(struct pernet_operations *);
168extern void unregister_pernet_device(struct pernet_operations *); 197extern void unregister_pernet_device(struct pernet_operations *);
198extern int register_pernet_gen_device(int *id, struct pernet_operations *);
199extern void unregister_pernet_gen_device(int id, struct pernet_operations *);
169 200
170struct ctl_path; 201struct ctl_path;
171struct ctl_table; 202struct ctl_table;
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 90b3e7f5df5f..2dbd6c015b94 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -20,6 +20,7 @@
20#include <asm/atomic.h> 20#include <asm/atomic.h>
21 21
22#include <linux/netfilter/nf_conntrack_tcp.h> 22#include <linux/netfilter/nf_conntrack_tcp.h>
23#include <linux/netfilter/nf_conntrack_dccp.h>
23#include <linux/netfilter/nf_conntrack_sctp.h> 24#include <linux/netfilter/nf_conntrack_sctp.h>
24#include <linux/netfilter/nf_conntrack_proto_gre.h> 25#include <linux/netfilter/nf_conntrack_proto_gre.h>
25#include <net/netfilter/ipv4/nf_conntrack_icmp.h> 26#include <net/netfilter/ipv4/nf_conntrack_icmp.h>
@@ -30,6 +31,7 @@
30/* per conntrack: protocol private data */ 31/* per conntrack: protocol private data */
31union nf_conntrack_proto { 32union nf_conntrack_proto {
32 /* insert conntrack proto private data here */ 33 /* insert conntrack proto private data here */
34 struct nf_ct_dccp dccp;
33 struct ip_ct_sctp sctp; 35 struct ip_ct_sctp sctp;
34 struct ip_ct_tcp tcp; 36 struct ip_ct_tcp tcp;
35 struct ip_ct_icmp icmp; 37 struct ip_ct_icmp icmp;
@@ -46,6 +48,7 @@ union nf_conntrack_expect_proto {
46#include <linux/netfilter/nf_conntrack_pptp.h> 48#include <linux/netfilter/nf_conntrack_pptp.h>
47#include <linux/netfilter/nf_conntrack_h323.h> 49#include <linux/netfilter/nf_conntrack_h323.h>
48#include <linux/netfilter/nf_conntrack_sane.h> 50#include <linux/netfilter/nf_conntrack_sane.h>
51#include <linux/netfilter/nf_conntrack_sip.h>
49 52
50/* per conntrack: application helper private data */ 53/* per conntrack: application helper private data */
51union nf_conntrack_help { 54union nf_conntrack_help {
@@ -54,6 +57,7 @@ union nf_conntrack_help {
54 struct nf_ct_pptp_master ct_pptp_info; 57 struct nf_ct_pptp_master ct_pptp_info;
55 struct nf_ct_h323_master ct_h323_info; 58 struct nf_ct_h323_master ct_h323_info;
56 struct nf_ct_sane_master ct_sane_info; 59 struct nf_ct_sane_master ct_sane_info;
60 struct nf_ct_sip_master ct_sip_info;
57}; 61};
58 62
59#include <linux/types.h> 63#include <linux/types.h>
@@ -61,20 +65,16 @@ union nf_conntrack_help {
61#include <linux/timer.h> 65#include <linux/timer.h>
62 66
63#ifdef CONFIG_NETFILTER_DEBUG 67#ifdef CONFIG_NETFILTER_DEBUG
64#define NF_CT_ASSERT(x) \ 68#define NF_CT_ASSERT(x) WARN_ON(!(x))
65do { \
66 if (!(x)) \
67 /* Wooah! I'm tripping my conntrack in a frenzy of \
68 netplay... */ \
69 printk("NF_CT_ASSERT: %s:%i(%s)\n", \
70 __FILE__, __LINE__, __FUNCTION__); \
71} while(0)
72#else 69#else
73#define NF_CT_ASSERT(x) 70#define NF_CT_ASSERT(x)
74#endif 71#endif
75 72
76struct nf_conntrack_helper; 73struct nf_conntrack_helper;
77 74
75/* Must be kept in sync with the classes defined by helpers */
76#define NF_CT_MAX_EXPECT_CLASSES 3
77
78/* nf_conn feature for connections that have a helper */ 78/* nf_conn feature for connections that have a helper */
79struct nf_conn_help { 79struct nf_conn_help {
80 /* Helper. if any */ 80 /* Helper. if any */
@@ -85,7 +85,7 @@ struct nf_conn_help {
85 struct hlist_head expectations; 85 struct hlist_head expectations;
86 86
87 /* Current number of expected connections */ 87 /* Current number of expected connections */
88 unsigned int expecting; 88 u8 expecting[NF_CT_MAX_EXPECT_CLASSES];
89}; 89};
90 90
91 91
@@ -140,6 +140,16 @@ nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash)
140 tuplehash[hash->tuple.dst.dir]); 140 tuplehash[hash->tuple.dst.dir]);
141} 141}
142 142
143static inline u_int16_t nf_ct_l3num(const struct nf_conn *ct)
144{
145 return ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
146}
147
148static inline u_int8_t nf_ct_protonum(const struct nf_conn *ct)
149{
150 return ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum;
151}
152
143/* get master conntrack via master expectation */ 153/* get master conntrack via master expectation */
144#define master_ct(conntr) (conntr->master) 154#define master_ct(conntr) (conntr->master)
145 155
@@ -184,12 +194,11 @@ extern void nf_conntrack_hash_insert(struct nf_conn *ct);
184 194
185extern void nf_conntrack_flush(void); 195extern void nf_conntrack_flush(void);
186 196
187extern int nf_ct_get_tuplepr(const struct sk_buff *skb, 197extern bool nf_ct_get_tuplepr(const struct sk_buff *skb,
188 unsigned int nhoff, 198 unsigned int nhoff, u_int16_t l3num,
189 u_int16_t l3num, 199 struct nf_conntrack_tuple *tuple);
190 struct nf_conntrack_tuple *tuple); 200extern bool nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
191extern int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse, 201 const struct nf_conntrack_tuple *orig);
192 const struct nf_conntrack_tuple *orig);
193 202
194extern void __nf_ct_refresh_acct(struct nf_conn *ct, 203extern void __nf_ct_refresh_acct(struct nf_conn *ct,
195 enum ip_conntrack_info ctinfo, 204 enum ip_conntrack_info ctinfo,
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index 9ee26469c759..a81771210934 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -30,7 +30,7 @@ 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 33extern bool
34nf_ct_get_tuple(const struct sk_buff *skb, 34nf_ct_get_tuple(const struct sk_buff *skb,
35 unsigned int nhoff, 35 unsigned int nhoff,
36 unsigned int dataoff, 36 unsigned int dataoff,
@@ -40,7 +40,7 @@ nf_ct_get_tuple(const struct sk_buff *skb,
40 const struct nf_conntrack_l3proto *l3proto, 40 const struct nf_conntrack_l3proto *l3proto,
41 const struct nf_conntrack_l4proto *l4proto); 41 const struct nf_conntrack_l4proto *l4proto);
42 42
43extern int 43extern bool
44nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, 44nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
45 const struct nf_conntrack_tuple *orig, 45 const struct nf_conntrack_tuple *orig,
46 const struct nf_conntrack_l3proto *l3proto, 46 const struct nf_conntrack_l3proto *l3proto,
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index cb608a1b44e5..dfdf4b459475 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -41,6 +41,9 @@ struct nf_conntrack_expect
41 /* Flags */ 41 /* Flags */
42 unsigned int flags; 42 unsigned int flags;
43 43
44 /* Expectation class */
45 unsigned int class;
46
44#ifdef CONFIG_NF_NAT_NEEDED 47#ifdef CONFIG_NF_NAT_NEEDED
45 __be32 saved_ip; 48 __be32 saved_ip;
46 /* This is the original per-proto part, used to map the 49 /* This is the original per-proto part, used to map the
@@ -53,7 +56,16 @@ struct nf_conntrack_expect
53 struct rcu_head rcu; 56 struct rcu_head rcu;
54}; 57};
55 58
56#define NF_CT_EXPECT_PERMANENT 0x1 59struct nf_conntrack_expect_policy
60{
61 unsigned int max_expected;
62 unsigned int timeout;
63};
64
65#define NF_CT_EXPECT_CLASS_DEFAULT 0
66
67#define NF_CT_EXPECT_PERMANENT 0x1
68#define NF_CT_EXPECT_INACTIVE 0x2
57 69
58int nf_conntrack_expect_init(void); 70int nf_conntrack_expect_init(void);
59void nf_conntrack_expect_fini(void); 71void nf_conntrack_expect_fini(void);
@@ -74,10 +86,10 @@ void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
74/* Allocate space for an expectation: this is mandatory before calling 86/* Allocate space for an expectation: this is mandatory before calling
75 nf_ct_expect_related. You will have to call put afterwards. */ 87 nf_ct_expect_related. You will have to call put afterwards. */
76struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me); 88struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me);
77void nf_ct_expect_init(struct nf_conntrack_expect *, int, 89void nf_ct_expect_init(struct nf_conntrack_expect *, unsigned int, int,
78 union nf_inet_addr *, 90 const union nf_inet_addr *,
79 union nf_inet_addr *, 91 const union nf_inet_addr *,
80 u_int8_t, __be16 *, __be16 *); 92 u_int8_t, const __be16 *, const __be16 *);
81void nf_ct_expect_put(struct nf_conntrack_expect *exp); 93void nf_ct_expect_put(struct nf_conntrack_expect *exp);
82int nf_ct_expect_related(struct nf_conntrack_expect *expect); 94int nf_ct_expect_related(struct nf_conntrack_expect *expect);
83 95
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
index 4ca125e9b3ce..f8060ab5a083 100644
--- a/include/net/netfilter/nf_conntrack_helper.h
+++ b/include/net/netfilter/nf_conntrack_helper.h
@@ -20,9 +20,7 @@ struct nf_conntrack_helper
20 20
21 const char *name; /* name of the module */ 21 const char *name; /* name of the module */
22 struct module *me; /* pointer to self */ 22 struct module *me; /* pointer to self */
23 unsigned int max_expected; /* Maximum number of concurrent 23 const struct nf_conntrack_expect_policy *expect_policy;
24 * expected connections */
25 unsigned int timeout; /* timeout for expecteds */
26 24
27 /* Tuple of things we will help (compared against server response) */ 25 /* Tuple of things we will help (compared against server response) */
28 struct nf_conntrack_tuple tuple; 26 struct nf_conntrack_tuple tuple;
@@ -37,6 +35,7 @@ struct nf_conntrack_helper
37 void (*destroy)(struct nf_conn *ct); 35 void (*destroy)(struct nf_conn *ct);
38 36
39 int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct); 37 int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct);
38 unsigned int expect_class_max;
40}; 39};
41 40
42extern struct nf_conntrack_helper * 41extern struct nf_conntrack_helper *
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index b886e3ae6cad..0378676c3dd8 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -28,31 +28,20 @@ struct nf_conntrack_l3proto
28 * Try to fill in the third arg: nhoff is offset of l3 proto 28 * Try to fill in the third arg: nhoff is offset of l3 proto
29 * hdr. Return true if possible. 29 * hdr. Return true if possible.
30 */ 30 */
31 int (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff, 31 bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff,
32 struct nf_conntrack_tuple *tuple); 32 struct nf_conntrack_tuple *tuple);
33 33
34 /* 34 /*
35 * Invert the per-proto part of the tuple: ie. turn xmit into reply. 35 * Invert the per-proto part of the tuple: ie. turn xmit into reply.
36 * Some packets can't be inverted: return 0 in that case. 36 * Some packets can't be inverted: return 0 in that case.
37 */ 37 */
38 int (*invert_tuple)(struct nf_conntrack_tuple *inverse, 38 bool (*invert_tuple)(struct nf_conntrack_tuple *inverse,
39 const struct nf_conntrack_tuple *orig); 39 const struct nf_conntrack_tuple *orig);
40 40
41 /* Print out the per-protocol part of the tuple. */ 41 /* Print out the per-protocol part of the tuple. */
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 /* Returns verdict for packet, or -1 for invalid. */
46 int (*packet)(struct nf_conn *ct,
47 const struct sk_buff *skb,
48 enum ip_conntrack_info ctinfo);
49
50 /*
51 * Called when a new connection for this protocol found;
52 * returns TRUE if it's OK. If so, packet() called next.
53 */
54 int (*new)(struct nf_conn *ct, const struct sk_buff *skb);
55
56 /* 45 /*
57 * Called before tracking. 46 * Called before tracking.
58 * *dataoff: offset of protocol header (TCP, UDP,...) in skb 47 * *dataoff: offset of protocol header (TCP, UDP,...) in skb
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index efc16eccddb1..723df9d1cc35 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -25,15 +25,14 @@ struct nf_conntrack_l4proto
25 25
26 /* 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
27 hdr. Return true if possible. */ 27 hdr. Return true if possible. */
28 int (*pkt_to_tuple)(const struct sk_buff *skb, 28 bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int dataoff,
29 unsigned int dataoff, 29 struct nf_conntrack_tuple *tuple);
30 struct nf_conntrack_tuple *tuple);
31 30
32 /* Invert the per-proto part of the tuple: ie. turn xmit into reply. 31 /* Invert the per-proto part of the tuple: ie. turn xmit into reply.
33 * Some packets can't be inverted: return 0 in that case. 32 * Some packets can't be inverted: return 0 in that case.
34 */ 33 */
35 int (*invert_tuple)(struct nf_conntrack_tuple *inverse, 34 bool (*invert_tuple)(struct nf_conntrack_tuple *inverse,
36 const struct nf_conntrack_tuple *orig); 35 const struct nf_conntrack_tuple *orig);
37 36
38 /* Returns verdict for packet, or -1 for invalid. */ 37 /* Returns verdict for packet, or -1 for invalid. */
39 int (*packet)(struct nf_conn *ct, 38 int (*packet)(struct nf_conn *ct,
@@ -45,8 +44,8 @@ struct nf_conntrack_l4proto
45 44
46 /* Called when a new connection for this protocol found; 45 /* Called when a new connection for this protocol found;
47 * returns TRUE if it's OK. If so, packet() called next. */ 46 * returns TRUE if it's OK. If so, packet() called next. */
48 int (*new)(struct nf_conn *ct, const struct sk_buff *skb, 47 bool (*new)(struct nf_conn *ct, const struct sk_buff *skb,
49 unsigned int dataoff); 48 unsigned int dataoff);
50 49
51 /* Called when a conntrack entry is destroyed */ 50 /* Called when a conntrack entry is destroyed */
52 void (*destroy)(struct nf_conn *ct); 51 void (*destroy)(struct nf_conn *ct);
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h
index e69ab2e87597..a6874ba22d54 100644
--- a/include/net/netfilter/nf_conntrack_tuple.h
+++ b/include/net/netfilter/nf_conntrack_tuple.h
@@ -41,6 +41,9 @@ union nf_conntrack_man_proto
41 } icmp; 41 } icmp;
42 struct { 42 struct {
43 __be16 port; 43 __be16 port;
44 } dccp;
45 struct {
46 __be16 port;
44 } sctp; 47 } sctp;
45 struct { 48 struct {
46 __be16 key; /* GRE key is 32bit, PPtP only uses 16bit */ 49 __be16 key; /* GRE key is 32bit, PPtP only uses 16bit */
@@ -79,6 +82,9 @@ struct nf_conntrack_tuple
79 } icmp; 82 } icmp;
80 struct { 83 struct {
81 __be16 port; 84 __be16 port;
85 } dccp;
86 struct {
87 __be16 port;
82 } sctp; 88 } sctp;
83 struct { 89 struct {
84 __be16 key; 90 __be16 key;
@@ -101,23 +107,39 @@ struct nf_conntrack_tuple_mask
101 } src; 107 } src;
102}; 108};
103 109
104/* This is optimized opposed to a memset of the whole structure. Everything we
105 * really care about is the source/destination unions */
106#define NF_CT_TUPLE_U_BLANK(tuple) \
107 do { \
108 (tuple)->src.u.all = 0; \
109 (tuple)->dst.u.all = 0; \
110 memset(&(tuple)->src.u3, 0, sizeof((tuple)->src.u3)); \
111 memset(&(tuple)->dst.u3, 0, sizeof((tuple)->dst.u3)); \
112 } while (0)
113
114#ifdef __KERNEL__ 110#ifdef __KERNEL__
115 111
116#define NF_CT_DUMP_TUPLE(tp) \ 112static inline void nf_ct_dump_tuple_ip(const struct nf_conntrack_tuple *t)
117pr_debug("tuple %p: %u %u " NIP6_FMT " %hu -> " NIP6_FMT " %hu\n", \ 113{
118 (tp), (tp)->src.l3num, (tp)->dst.protonum, \ 114#ifdef DEBUG
119 NIP6(*(struct in6_addr *)(tp)->src.u3.all), ntohs((tp)->src.u.all), \ 115 printk("tuple %p: %u " NIPQUAD_FMT ":%hu -> " NIPQUAD_FMT ":%hu\n",
120 NIP6(*(struct in6_addr *)(tp)->dst.u3.all), ntohs((tp)->dst.u.all)) 116 t, t->dst.protonum,
117 NIPQUAD(t->src.u3.ip), ntohs(t->src.u.all),
118 NIPQUAD(t->dst.u3.ip), ntohs(t->dst.u.all));
119#endif
120}
121
122static inline void nf_ct_dump_tuple_ipv6(const struct nf_conntrack_tuple *t)
123{
124#ifdef DEBUG
125 printk("tuple %p: %u " NIP6_FMT " %hu -> " NIP6_FMT " %hu\n",
126 t, t->dst.protonum,
127 NIP6(*(struct in6_addr *)t->src.u3.all), ntohs(t->src.u.all),
128 NIP6(*(struct in6_addr *)t->dst.u3.all), ntohs(t->dst.u.all));
129#endif
130}
131
132static inline void nf_ct_dump_tuple(const struct nf_conntrack_tuple *t)
133{
134 switch (t->src.l3num) {
135 case AF_INET:
136 nf_ct_dump_tuple_ip(t);
137 break;
138 case AF_INET6:
139 nf_ct_dump_tuple_ipv6(t);
140 break;
141 }
142}
121 143
122/* If we're the first tuple, it's the original dir. */ 144/* If we're the first tuple, it's the original dir. */
123#define NF_CT_DIRECTION(h) \ 145#define NF_CT_DIRECTION(h) \
@@ -132,70 +154,64 @@ struct nf_conntrack_tuple_hash
132 154
133#endif /* __KERNEL__ */ 155#endif /* __KERNEL__ */
134 156
135static inline int __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, 157static inline bool __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1,
136 const struct nf_conntrack_tuple *t2) 158 const struct nf_conntrack_tuple *t2)
137{ 159{
138 return (t1->src.u3.all[0] == t2->src.u3.all[0] && 160 return (nf_inet_addr_cmp(&t1->src.u3, &t2->src.u3) &&
139 t1->src.u3.all[1] == t2->src.u3.all[1] &&
140 t1->src.u3.all[2] == t2->src.u3.all[2] &&
141 t1->src.u3.all[3] == t2->src.u3.all[3] &&
142 t1->src.u.all == t2->src.u.all && 161 t1->src.u.all == t2->src.u.all &&
143 t1->src.l3num == t2->src.l3num); 162 t1->src.l3num == t2->src.l3num);
144} 163}
145 164
146static inline int __nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1, 165static inline bool __nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1,
147 const struct nf_conntrack_tuple *t2) 166 const struct nf_conntrack_tuple *t2)
148{ 167{
149 return (t1->dst.u3.all[0] == t2->dst.u3.all[0] && 168 return (nf_inet_addr_cmp(&t1->dst.u3, &t2->dst.u3) &&
150 t1->dst.u3.all[1] == t2->dst.u3.all[1] &&
151 t1->dst.u3.all[2] == t2->dst.u3.all[2] &&
152 t1->dst.u3.all[3] == t2->dst.u3.all[3] &&
153 t1->dst.u.all == t2->dst.u.all && 169 t1->dst.u.all == t2->dst.u.all &&
154 t1->dst.protonum == t2->dst.protonum); 170 t1->dst.protonum == t2->dst.protonum);
155} 171}
156 172
157static inline int nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1, 173static inline bool nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1,
158 const struct nf_conntrack_tuple *t2) 174 const struct nf_conntrack_tuple *t2)
159{ 175{
160 return __nf_ct_tuple_src_equal(t1, t2) && 176 return __nf_ct_tuple_src_equal(t1, t2) &&
161 __nf_ct_tuple_dst_equal(t1, t2); 177 __nf_ct_tuple_dst_equal(t1, t2);
162} 178}
163 179
164static inline int nf_ct_tuple_mask_equal(const struct nf_conntrack_tuple_mask *m1, 180static inline bool
165 const struct nf_conntrack_tuple_mask *m2) 181nf_ct_tuple_mask_equal(const struct nf_conntrack_tuple_mask *m1,
182 const struct nf_conntrack_tuple_mask *m2)
166{ 183{
167 return (m1->src.u3.all[0] == m2->src.u3.all[0] && 184 return (nf_inet_addr_cmp(&m1->src.u3, &m2->src.u3) &&
168 m1->src.u3.all[1] == m2->src.u3.all[1] &&
169 m1->src.u3.all[2] == m2->src.u3.all[2] &&
170 m1->src.u3.all[3] == m2->src.u3.all[3] &&
171 m1->src.u.all == m2->src.u.all); 185 m1->src.u.all == m2->src.u.all);
172} 186}
173 187
174static inline int nf_ct_tuple_src_mask_cmp(const struct nf_conntrack_tuple *t1, 188static inline bool
175 const struct nf_conntrack_tuple *t2, 189nf_ct_tuple_src_mask_cmp(const struct nf_conntrack_tuple *t1,
176 const struct nf_conntrack_tuple_mask *mask) 190 const struct nf_conntrack_tuple *t2,
191 const struct nf_conntrack_tuple_mask *mask)
177{ 192{
178 int count; 193 int count;
179 194
180 for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++) { 195 for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++) {
181 if ((t1->src.u3.all[count] ^ t2->src.u3.all[count]) & 196 if ((t1->src.u3.all[count] ^ t2->src.u3.all[count]) &
182 mask->src.u3.all[count]) 197 mask->src.u3.all[count])
183 return 0; 198 return false;
184 } 199 }
185 200
186 if ((t1->src.u.all ^ t2->src.u.all) & mask->src.u.all) 201 if ((t1->src.u.all ^ t2->src.u.all) & mask->src.u.all)
187 return 0; 202 return false;
188 203
189 if (t1->src.l3num != t2->src.l3num || 204 if (t1->src.l3num != t2->src.l3num ||
190 t1->dst.protonum != t2->dst.protonum) 205 t1->dst.protonum != t2->dst.protonum)
191 return 0; 206 return false;
192 207
193 return 1; 208 return true;
194} 209}
195 210
196static inline int nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t, 211static inline bool
197 const struct nf_conntrack_tuple *tuple, 212nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t,
198 const struct nf_conntrack_tuple_mask *mask) 213 const struct nf_conntrack_tuple *tuple,
214 const struct nf_conntrack_tuple_mask *mask)
199{ 215{
200 return nf_ct_tuple_src_mask_cmp(t, tuple, mask) && 216 return nf_ct_tuple_src_mask_cmp(t, tuple, mask) &&
201 __nf_ct_tuple_dst_equal(t, tuple); 217 __nf_ct_tuple_dst_equal(t, tuple);
diff --git a/include/net/netfilter/nf_nat_helper.h b/include/net/netfilter/nf_nat_helper.h
index 58dd22687949..237a961f40e1 100644
--- a/include/net/netfilter/nf_nat_helper.h
+++ b/include/net/netfilter/nf_nat_helper.h
@@ -24,6 +24,9 @@ extern int nf_nat_mangle_udp_packet(struct sk_buff *skb,
24extern int nf_nat_seq_adjust(struct sk_buff *skb, 24extern int nf_nat_seq_adjust(struct sk_buff *skb,
25 struct nf_conn *ct, 25 struct nf_conn *ct,
26 enum ip_conntrack_info ctinfo); 26 enum ip_conntrack_info ctinfo);
27extern int (*nf_nat_seq_adjust_hook)(struct sk_buff *skb,
28 struct nf_conn *ct,
29 enum ip_conntrack_info ctinfo);
27 30
28/* Setup NAT on this expected conntrack so it follows master, but goes 31/* Setup NAT on this expected conntrack so it follows master, but goes
29 * to port ct->master->saved_proto. */ 32 * to port ct->master->saved_proto. */
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h
index 4aa0edbb5b96..f3662c4394ef 100644
--- a/include/net/netfilter/nf_nat_protocol.h
+++ b/include/net/netfilter/nf_nat_protocol.h
@@ -8,9 +8,6 @@ struct nf_nat_range;
8 8
9struct nf_nat_protocol 9struct nf_nat_protocol
10{ 10{
11 /* Protocol name */
12 const char *name;
13
14 /* Protocol number. */ 11 /* Protocol number. */
15 unsigned int protonum; 12 unsigned int protonum;
16 13
@@ -18,25 +15,25 @@ struct nf_nat_protocol
18 15
19 /* Translate a packet to the target according to manip type. 16 /* Translate a packet to the target according to manip type.
20 Return true if succeeded. */ 17 Return true if succeeded. */
21 int (*manip_pkt)(struct sk_buff *skb, 18 bool (*manip_pkt)(struct sk_buff *skb,
22 unsigned int iphdroff, 19 unsigned int iphdroff,
23 const struct nf_conntrack_tuple *tuple, 20 const struct nf_conntrack_tuple *tuple,
24 enum nf_nat_manip_type maniptype); 21 enum nf_nat_manip_type maniptype);
25 22
26 /* Is the manipable part of the tuple between min and max incl? */ 23 /* Is the manipable part of the tuple between min and max incl? */
27 int (*in_range)(const struct nf_conntrack_tuple *tuple, 24 bool (*in_range)(const struct nf_conntrack_tuple *tuple,
28 enum nf_nat_manip_type maniptype, 25 enum nf_nat_manip_type maniptype,
29 const union nf_conntrack_man_proto *min, 26 const union nf_conntrack_man_proto *min,
30 const union nf_conntrack_man_proto *max); 27 const union nf_conntrack_man_proto *max);
31 28
32 /* Alter the per-proto part of the tuple (depending on 29 /* Alter the per-proto part of the tuple (depending on
33 maniptype), to give a unique tuple in the given range if 30 maniptype), to give a unique tuple in the given range if
34 possible; return false if not. Per-protocol part of tuple 31 possible; return false if not. Per-protocol part of tuple
35 is initialized to the incoming packet. */ 32 is initialized to the incoming packet. */
36 int (*unique_tuple)(struct nf_conntrack_tuple *tuple, 33 bool (*unique_tuple)(struct nf_conntrack_tuple *tuple,
37 const struct nf_nat_range *range, 34 const struct nf_nat_range *range,
38 enum nf_nat_manip_type maniptype, 35 enum nf_nat_manip_type maniptype,
39 const struct nf_conn *ct); 36 const struct nf_conn *ct);
40 37
41 int (*range_to_nlattr)(struct sk_buff *skb, 38 int (*range_to_nlattr)(struct sk_buff *skb,
42 const struct nf_nat_range *range); 39 const struct nf_nat_range *range);
@@ -62,9 +59,20 @@ extern int init_protocols(void) __init;
62extern void cleanup_protocols(void); 59extern void cleanup_protocols(void);
63extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); 60extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
64 61
65extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb, 62extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
66 const struct nf_nat_range *range); 63 enum nf_nat_manip_type maniptype,
67extern int nf_nat_port_nlattr_to_range(struct nlattr *tb[], 64 const union nf_conntrack_man_proto *min,
68 struct nf_nat_range *range); 65 const union nf_conntrack_man_proto *max);
66
67extern bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
68 const struct nf_nat_range *range,
69 enum nf_nat_manip_type maniptype,
70 const struct nf_conn *ct,
71 u_int16_t *rover);
72
73extern int nf_nat_proto_range_to_nlattr(struct sk_buff *skb,
74 const struct nf_nat_range *range);
75extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[],
76 struct nf_nat_range *range);
69 77
70#endif /*_NF_NAT_PROTO_H*/ 78#endif /*_NF_NAT_PROTO_H*/
diff --git a/include/net/netfilter/nf_nat_rule.h b/include/net/netfilter/nf_nat_rule.h
index 75d1825031d7..e4a18ae361c6 100644
--- a/include/net/netfilter/nf_nat_rule.h
+++ b/include/net/netfilter/nf_nat_rule.h
@@ -14,7 +14,4 @@ extern int nf_nat_rule_find(struct sk_buff *skb,
14 14
15extern unsigned int 15extern unsigned int
16alloc_null_binding(struct nf_conn *ct, unsigned int hooknum); 16alloc_null_binding(struct nf_conn *ct, unsigned int hooknum);
17
18extern unsigned int
19alloc_null_binding_confirmed(struct nf_conn *ct, unsigned int hooknum);
20#endif /* _NF_NAT_RULE_H */ 17#endif /* _NF_NAT_RULE_H */
diff --git a/include/net/netlabel.h b/include/net/netlabel.h
index 0ca67d73c7ad..e4d2d6baa983 100644
--- a/include/net/netlabel.h
+++ b/include/net/netlabel.h
@@ -103,6 +103,7 @@ struct cipso_v4_doi;
103struct netlbl_audit { 103struct netlbl_audit {
104 u32 secid; 104 u32 secid;
105 uid_t loginuid; 105 uid_t loginuid;
106 u32 sessionid;
106}; 107};
107 108
108/* 109/*
@@ -162,7 +163,7 @@ struct netlbl_lsm_secattr_catmap {
162 163
163/** 164/**
164 * struct netlbl_lsm_secattr - NetLabel LSM security attributes 165 * struct netlbl_lsm_secattr - NetLabel LSM security attributes
165 * @flags: indicate which attributes are contained in this structure 166 * @flags: indicate structure attributes, see NETLBL_SECATTR_*
166 * @type: indicate the NLTYPE of the attributes 167 * @type: indicate the NLTYPE of the attributes
167 * @domain: the NetLabel LSM domain 168 * @domain: the NetLabel LSM domain
168 * @cache: NetLabel LSM specific cache 169 * @cache: NetLabel LSM specific cache
@@ -180,17 +181,22 @@ struct netlbl_lsm_secattr_catmap {
180 * NetLabel itself when returning security attributes to the LSM. 181 * NetLabel itself when returning security attributes to the LSM.
181 * 182 *
182 */ 183 */
184struct netlbl_lsm_secattr {
185 u32 flags;
186 /* bitmap values for 'flags' */
183#define NETLBL_SECATTR_NONE 0x00000000 187#define NETLBL_SECATTR_NONE 0x00000000
184#define NETLBL_SECATTR_DOMAIN 0x00000001 188#define NETLBL_SECATTR_DOMAIN 0x00000001
189#define NETLBL_SECATTR_DOMAIN_CPY (NETLBL_SECATTR_DOMAIN | \
190 NETLBL_SECATTR_FREE_DOMAIN)
185#define NETLBL_SECATTR_CACHE 0x00000002 191#define NETLBL_SECATTR_CACHE 0x00000002
186#define NETLBL_SECATTR_MLS_LVL 0x00000004 192#define NETLBL_SECATTR_MLS_LVL 0x00000004
187#define NETLBL_SECATTR_MLS_CAT 0x00000008 193#define NETLBL_SECATTR_MLS_CAT 0x00000008
188#define NETLBL_SECATTR_SECID 0x00000010 194#define NETLBL_SECATTR_SECID 0x00000010
195 /* bitmap meta-values for 'flags' */
196#define NETLBL_SECATTR_FREE_DOMAIN 0x01000000
189#define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \ 197#define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \
190 NETLBL_SECATTR_MLS_CAT | \ 198 NETLBL_SECATTR_MLS_CAT | \
191 NETLBL_SECATTR_SECID) 199 NETLBL_SECATTR_SECID)
192struct netlbl_lsm_secattr {
193 u32 flags;
194 u32 type; 200 u32 type;
195 char *domain; 201 char *domain;
196 struct netlbl_lsm_cache *cache; 202 struct netlbl_lsm_cache *cache;
@@ -303,7 +309,8 @@ static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
303 */ 309 */
304static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr) 310static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
305{ 311{
306 kfree(secattr->domain); 312 if (secattr->flags & NETLBL_SECATTR_FREE_DOMAIN)
313 kfree(secattr->domain);
307 if (secattr->flags & NETLBL_SECATTR_CACHE) 314 if (secattr->flags & NETLBL_SECATTR_CACHE)
308 netlbl_secattr_cache_free(secattr->cache); 315 netlbl_secattr_cache_free(secattr->cache);
309 if (secattr->flags & NETLBL_SECATTR_MLS_CAT) 316 if (secattr->flags & NETLBL_SECATTR_MLS_CAT)
diff --git a/include/net/netns/core.h b/include/net/netns/core.h
new file mode 100644
index 000000000000..24d4be76bbd1
--- /dev/null
+++ b/include/net/netns/core.h
@@ -0,0 +1,16 @@
1#ifndef __NETNS_CORE_H__
2#define __NETNS_CORE_H__
3
4struct ctl_table_header;
5struct prot_inuse;
6
7struct netns_core {
8 /* core sysctls */
9 struct ctl_table_header *sysctl_hdr;
10
11 int sysctl_somaxconn;
12
13 struct prot_inuse *inuse;
14};
15
16#endif
diff --git a/include/net/netns/dccp.h b/include/net/netns/dccp.h
new file mode 100644
index 000000000000..98d2a7ce1f71
--- /dev/null
+++ b/include/net/netns/dccp.h
@@ -0,0 +1,11 @@
1#ifndef __NETNS_DCCP_H__
2#define __NETNS_DCCP_H__
3
4struct sock;
5
6struct netns_dccp {
7 struct sock *v4_ctl_sk;
8 struct sock *v6_ctl_sk;
9};
10
11#endif
diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h
new file mode 100644
index 000000000000..0c04fd2a700b
--- /dev/null
+++ b/include/net/netns/generic.h
@@ -0,0 +1,49 @@
1/*
2 * generic net pointers
3 */
4
5#ifndef __NET_GENERIC_H__
6#define __NET_GENERIC_H__
7
8#include <linux/rcupdate.h>
9
10/*
11 * Generic net pointers are to be used by modules to put some private
12 * stuff on the struct net without explicit struct net modification
13 *
14 * The rules are simple:
15 * 1. register the ops with register_pernet_gen_device to get the id
16 * of your private pointer;
17 * 2. call net_assign_generic() to put the private data on the struct
18 * net (most preferably this should be done in the ->init callback
19 * of the ops registered);
20 * 3. do not change this pointer while the net is alive;
21 * 4. do not try to have any private reference on the net_generic object.
22 *
23 * After accomplishing all of the above, the private pointer can be
24 * accessed with the net_generic() call.
25 */
26
27struct net_generic {
28 unsigned int len;
29 struct rcu_head rcu;
30
31 void *ptr[0];
32};
33
34static inline void *net_generic(struct net *net, int id)
35{
36 struct net_generic *ng;
37 void *ptr;
38
39 rcu_read_lock();
40 ng = rcu_dereference(net->gen);
41 BUG_ON(id == 0 || id > ng->len);
42 ptr = ng->ptr[id - 1];
43 rcu_read_unlock();
44
45 return ptr;
46}
47
48extern int net_assign_generic(struct net *net, int id, void *data);
49#endif
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index a9b4f6086294..34ee348a2cf2 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -17,6 +17,7 @@ struct netns_ipv4 {
17#ifdef CONFIG_SYSCTL 17#ifdef CONFIG_SYSCTL
18 struct ctl_table_header *forw_hdr; 18 struct ctl_table_header *forw_hdr;
19 struct ctl_table_header *frags_hdr; 19 struct ctl_table_header *frags_hdr;
20 struct ctl_table_header *ipv4_hdr;
20#endif 21#endif
21 struct ipv4_devconf *devconf_all; 22 struct ipv4_devconf *devconf_all;
22 struct ipv4_devconf *devconf_dflt; 23 struct ipv4_devconf *devconf_dflt;
@@ -26,6 +27,9 @@ struct netns_ipv4 {
26 struct hlist_head *fib_table_hash; 27 struct hlist_head *fib_table_hash;
27 struct sock *fibnl; 28 struct sock *fibnl;
28 29
30 struct sock **icmp_sk;
31 struct sock *tcp_sock;
32
29 struct netns_frags frags; 33 struct netns_frags frags;
30#ifdef CONFIG_NETFILTER 34#ifdef CONFIG_NETFILTER
31 struct xt_table *iptable_filter; 35 struct xt_table *iptable_filter;
@@ -33,5 +37,12 @@ struct netns_ipv4 {
33 struct xt_table *iptable_raw; 37 struct xt_table *iptable_raw;
34 struct xt_table *arptable_filter; 38 struct xt_table *arptable_filter;
35#endif 39#endif
40
41 int sysctl_icmp_echo_ignore_all;
42 int sysctl_icmp_echo_ignore_broadcasts;
43 int sysctl_icmp_ignore_bogus_error_responses;
44 int sysctl_icmp_ratelimit;
45 int sysctl_icmp_ratemask;
46 int sysctl_icmp_errors_use_inbound_ifaddr;
36}; 47};
37#endif 48#endif
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index 1dd7de4e4195..ac053be6c256 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -36,5 +36,23 @@ struct netns_ipv6 {
36 struct xt_table *ip6table_mangle; 36 struct xt_table *ip6table_mangle;
37 struct xt_table *ip6table_raw; 37 struct xt_table *ip6table_raw;
38#endif 38#endif
39 struct rt6_info *ip6_null_entry;
40 struct rt6_statistics *rt6_stats;
41 struct timer_list *ip6_fib_timer;
42 struct hlist_head *fib_table_hash;
43 struct fib6_table *fib6_main_tbl;
44 struct dst_ops *ip6_dst_ops;
45 unsigned int ip6_rt_gc_expire;
46 unsigned long ip6_rt_last_gc;
47#ifdef CONFIG_IPV6_MULTIPLE_TABLES
48 struct rt6_info *ip6_prohibit_entry;
49 struct rt6_info *ip6_blk_hole_entry;
50 struct fib6_table *fib6_local_tbl;
51 struct fib_rules_ops *fib6_rules_ops;
52#endif
53 struct sock **icmp_sk;
54 struct sock *ndisc_sk;
55 struct sock *tcp_sk;
56 struct sock *igmp_sk;
39}; 57};
40#endif 58#endif
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index d349c66ef828..aa9e282db485 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -353,7 +353,7 @@ tcf_match_indev(struct sk_buff *skb, char *indev)
353 if (indev[0]) { 353 if (indev[0]) {
354 if (!skb->iif) 354 if (!skb->iif)
355 return 0; 355 return 0;
356 dev = __dev_get_by_index(&init_net, skb->iif); 356 dev = __dev_get_by_index(dev_net(skb->dev), skb->iif);
357 if (!dev || strcmp(indev, dev->name)) 357 if (!dev || strcmp(indev, dev->name))
358 return 0; 358 return 0;
359 } 359 }
diff --git a/include/net/protocol.h b/include/net/protocol.h
index ad8c584233a6..8d024d7cb741 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -39,7 +39,8 @@ struct net_protocol {
39 int (*gso_send_check)(struct sk_buff *skb); 39 int (*gso_send_check)(struct sk_buff *skb);
40 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 40 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
41 int features); 41 int features);
42 int no_policy; 42 unsigned int no_policy:1,
43 netns_ok:1;
43}; 44};
44 45
45#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 46#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
diff --git a/include/net/raw.h b/include/net/raw.h
index 1828f81fe374..6c14a656357a 100644
--- a/include/net/raw.h
+++ b/include/net/raw.h
@@ -53,7 +53,7 @@ int raw_seq_open(struct inode *ino, struct file *file,
53 53
54#endif 54#endif
55 55
56void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h); 56void raw_hash_sk(struct sock *sk);
57void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h); 57void raw_unhash_sk(struct sock *sk);
58 58
59#endif /* _RAW_H */ 59#endif /* _RAW_H */
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index cff4608179c1..b220b5f624de 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -31,8 +31,7 @@ struct request_sock_ops {
31 int obj_size; 31 int obj_size;
32 struct kmem_cache *slab; 32 struct kmem_cache *slab;
33 int (*rtx_syn_ack)(struct sock *sk, 33 int (*rtx_syn_ack)(struct sock *sk,
34 struct request_sock *req, 34 struct request_sock *req);
35 struct dst_entry *dst);
36 void (*send_ack)(struct sk_buff *skb, 35 void (*send_ack)(struct sk_buff *skb,
37 struct request_sock *req); 36 struct request_sock *req);
38 void (*send_reset)(struct sock *sk, 37 void (*send_reset)(struct sock *sk,
@@ -46,7 +45,7 @@ struct request_sock {
46 struct request_sock *dl_next; /* Must be first member! */ 45 struct request_sock *dl_next; /* Must be first member! */
47 u16 mss; 46 u16 mss;
48 u8 retrans; 47 u8 retrans;
49 u8 __pad; 48 u8 cookie_ts; /* syncookie: encode tcpopts in timestamp */
50 /* The following two fields can be easily recomputed I think -AK */ 49 /* The following two fields can be easily recomputed I think -AK */
51 u32 window_clamp; /* window clamp at creation time */ 50 u32 window_clamp; /* window clamp at creation time */
52 u32 rcv_wnd; /* rcv_wnd offered first time */ 51 u32 rcv_wnd; /* rcv_wnd offered first time */
@@ -116,8 +115,8 @@ struct request_sock_queue {
116 struct request_sock *rskq_accept_head; 115 struct request_sock *rskq_accept_head;
117 struct request_sock *rskq_accept_tail; 116 struct request_sock *rskq_accept_tail;
118 rwlock_t syn_wait_lock; 117 rwlock_t syn_wait_lock;
119 u8 rskq_defer_accept; 118 u16 rskq_defer_accept;
120 /* 3 bytes hole, try to pack */ 119 /* 2 bytes hole, try to pack */
121 struct listen_sock *listen_opt; 120 struct listen_sock *listen_opt;
122}; 121};
123 122
diff --git a/include/net/route.h b/include/net/route.h
index eadad5901429..fc836ff824cc 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -34,7 +34,6 @@
34#include <linux/ip.h> 34#include <linux/ip.h>
35#include <linux/cache.h> 35#include <linux/cache.h>
36#include <linux/security.h> 36#include <linux/security.h>
37#include <net/sock.h>
38 37
39#ifndef __KERNEL__ 38#ifndef __KERNEL__
40#warning This file is not supposed to be used outside of kernel. 39#warning This file is not supposed to be used outside of kernel.
@@ -117,7 +116,7 @@ extern int __ip_route_output_key(struct net *, struct rtable **, const struct f
117extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp); 116extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp);
118extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); 117extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags);
119extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin); 118extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin);
120extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu); 119extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev);
121extern void ip_rt_send_redirect(struct sk_buff *skb); 120extern void ip_rt_send_redirect(struct sk_buff *skb);
122 121
123extern unsigned inet_addr_type(struct net *net, __be32 addr); 122extern unsigned inet_addr_type(struct net *net, __be32 addr);
@@ -161,7 +160,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
161 .dport = dport } } }; 160 .dport = dport } } };
162 161
163 int err; 162 int err;
164 struct net *net = sk->sk_net; 163 struct net *net = sock_net(sk);
165 if (!dst || !src) { 164 if (!dst || !src) {
166 err = __ip_route_output_key(net, rp, &fl); 165 err = __ip_route_output_key(net, rp, &fl);
167 if (err) 166 if (err)
@@ -189,7 +188,7 @@ static inline int ip_route_newports(struct rtable **rp, u8 protocol,
189 ip_rt_put(*rp); 188 ip_rt_put(*rp);
190 *rp = NULL; 189 *rp = NULL;
191 security_sk_classify_flow(sk, &fl); 190 security_sk_classify_flow(sk, &fl);
192 return ip_route_output_flow(sk->sk_net, rp, &fl, sk, 0); 191 return ip_route_output_flow(sock_net(sk), rp, &fl, sk, 0);
193 } 192 }
194 return 0; 193 return 0;
195} 194}
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 793863e09c69..3c1895e54b7f 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -74,6 +74,7 @@ struct rtnl_link_ops {
74 74
75extern int __rtnl_link_register(struct rtnl_link_ops *ops); 75extern int __rtnl_link_register(struct rtnl_link_ops *ops);
76extern void __rtnl_link_unregister(struct rtnl_link_ops *ops); 76extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
77extern void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops);
77 78
78extern int rtnl_link_register(struct rtnl_link_ops *ops); 79extern int rtnl_link_register(struct rtnl_link_ops *ops);
79extern void rtnl_link_unregister(struct rtnl_link_ops *ops); 80extern void rtnl_link_unregister(struct rtnl_link_ops *ops);
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 35b1e83fb96a..88988ab03d75 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -206,12 +206,11 @@ typedef struct {
206int sctp_init_cmd_seq(sctp_cmd_seq_t *seq); 206int sctp_init_cmd_seq(sctp_cmd_seq_t *seq);
207 207
208/* Add a command to an sctp_cmd_seq_t. 208/* Add a command to an sctp_cmd_seq_t.
209 * Return 0 if the command sequence is full.
210 * 209 *
211 * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above 210 * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
212 * to wrap data which goes in the obj argument. 211 * to wrap data which goes in the obj argument.
213 */ 212 */
214int sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj); 213void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj);
215 214
216/* Return the next command structure in an sctp_cmd_seq. 215/* Return the next command structure in an sctp_cmd_seq.
217 * Return NULL at the end of the sequence. 216 * Return NULL at the end of the sequence.
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index ea806732b084..90b1e8d23b16 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -368,11 +368,6 @@ void sctp_sysctl_unregister(void);
368#else 368#else
369static inline void sctp_sysctl_register(void) { return; } 369static inline void sctp_sysctl_register(void) { return; }
370static inline void sctp_sysctl_unregister(void) { return; } 370static inline void sctp_sysctl_unregister(void) { return; }
371static inline int sctp_sysctl_jiffies_ms(ctl_table *table, int __user *name, int nlen,
372 void __user *oldval, size_t __user *oldlenp,
373 void __user *newval, size_t newlen) {
374 return -ENOSYS;
375}
376#endif 371#endif
377 372
378/* Size of Supported Address Parameter for 'x' address types. */ 373/* Size of Supported Address Parameter for 'x' address types. */
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index ef9e7ed2c82e..24811732bdb2 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -385,14 +385,6 @@ static inline int ADDIP_SERIAL_gte(__u16 s, __u16 t)
385 return (((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT)); 385 return (((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT));
386} 386}
387 387
388
389/* Run sctp_add_cmd() generating a BUG() if there is a failure. */
390static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
391{
392 if (unlikely(!sctp_add_cmd(seq, verb, obj)))
393 BUG();
394}
395
396/* Check VTAG of the packet matches the sender's own tag. */ 388/* Check VTAG of the packet matches the sender's own tag. */
397static inline int 389static inline int
398sctp_vtag_verify(const struct sctp_chunk *chunk, 390sctp_vtag_verify(const struct sctp_chunk *chunk,
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 9c827a749b6f..0ce0443c5b79 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -637,8 +637,6 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *,
637 struct sctp_sndrcvinfo *, 637 struct sctp_sndrcvinfo *,
638 struct msghdr *, int len); 638 struct msghdr *, int len);
639void sctp_datamsg_put(struct sctp_datamsg *); 639void sctp_datamsg_put(struct sctp_datamsg *);
640void sctp_datamsg_free(struct sctp_datamsg *);
641void sctp_datamsg_track(struct sctp_chunk *);
642void sctp_chunk_fail(struct sctp_chunk *, int error); 640void sctp_chunk_fail(struct sctp_chunk *, int error);
643int sctp_chunk_abandoned(struct sctp_chunk *); 641int sctp_chunk_abandoned(struct sctp_chunk *);
644 642
@@ -1661,6 +1659,9 @@ struct sctp_association {
1661 /* Transport to which SHUTDOWN chunk was last sent. */ 1659 /* Transport to which SHUTDOWN chunk was last sent. */
1662 struct sctp_transport *shutdown_last_sent_to; 1660 struct sctp_transport *shutdown_last_sent_to;
1663 1661
1662 /* How many times have we resent a SHUTDOWN */
1663 int shutdown_retries;
1664
1664 /* Transport to which INIT chunk was last sent. */ 1665 /* Transport to which INIT chunk was last sent. */
1665 struct sctp_transport *init_last_sent_to; 1666 struct sctp_transport *init_last_sent_to;
1666 1667
@@ -1695,6 +1696,11 @@ struct sctp_association {
1695 */ 1696 */
1696 __u16 unack_data; 1697 __u16 unack_data;
1697 1698
1699 /* The total number of data chunks that we've had to retransmit
1700 * as the result of a T3 timer expiration
1701 */
1702 __u32 rtx_data_chunks;
1703
1698 /* This is the association's receive buffer space. This value is used 1704 /* This is the association's receive buffer space. This value is used
1699 * to set a_rwnd field in an INIT or a SACK chunk. 1705 * to set a_rwnd field in an INIT or a SACK chunk.
1700 */ 1706 */
diff --git a/include/net/sock.h b/include/net/sock.h
index fd9876087651..dc42b44c2aa1 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -47,7 +47,6 @@
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>
51#include <linux/skbuff.h> /* struct sk_buff */ 50#include <linux/skbuff.h> /* struct sk_buff */
52#include <linux/mm.h> 51#include <linux/mm.h>
53#include <linux/security.h> 52#include <linux/security.h>
@@ -70,7 +69,11 @@
70#define SOCK_DEBUG(sk, msg...) do { if ((sk) && sock_flag((sk), SOCK_DBG)) \ 69#define SOCK_DEBUG(sk, msg...) do { if ((sk) && sock_flag((sk), SOCK_DBG)) \
71 printk(KERN_DEBUG msg); } while (0) 70 printk(KERN_DEBUG msg); } while (0)
72#else 71#else
73#define SOCK_DEBUG(sk, msg...) do { } while (0) 72/* Validate arguments and do nothing */
73static void inline int __attribute__ ((format (printf, 2, 3)))
74SOCK_DEBUG(struct sock *sk, const char *msg, ...)
75{
76}
74#endif 77#endif
75 78
76/* This is the per-socket lock. The spinlock provides a synchronization 79/* This is the per-socket lock. The spinlock provides a synchronization
@@ -122,7 +125,9 @@ struct sock_common {
122 atomic_t skc_refcnt; 125 atomic_t skc_refcnt;
123 unsigned int skc_hash; 126 unsigned int skc_hash;
124 struct proto *skc_prot; 127 struct proto *skc_prot;
128#ifdef CONFIG_NET_NS
125 struct net *skc_net; 129 struct net *skc_net;
130#endif
126}; 131};
127 132
128/** 133/**
@@ -151,6 +156,7 @@ struct sock_common {
151 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets 156 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
152 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) 157 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
153 * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4) 158 * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
159 * @sk_gso_max_size: Maximum GSO segment size to build
154 * @sk_lingertime: %SO_LINGER l_linger setting 160 * @sk_lingertime: %SO_LINGER l_linger setting
155 * @sk_backlog: always used with the per-socket spinlock held 161 * @sk_backlog: always used with the per-socket spinlock held
156 * @sk_callback_lock: used with the callbacks in the end of this struct 162 * @sk_callback_lock: used with the callbacks in the end of this struct
@@ -237,6 +243,7 @@ struct sock {
237 gfp_t sk_allocation; 243 gfp_t sk_allocation;
238 int sk_route_caps; 244 int sk_route_caps;
239 int sk_gso_type; 245 int sk_gso_type;
246 unsigned int sk_gso_max_size;
240 int sk_rcvlowat; 247 int sk_rcvlowat;
241 unsigned long sk_flags; 248 unsigned long sk_flags;
242 unsigned long sk_lingertime; 249 unsigned long sk_lingertime;
@@ -498,6 +505,7 @@ extern int sk_wait_data(struct sock *sk, long *timeo);
498struct request_sock_ops; 505struct request_sock_ops;
499struct timewait_sock_ops; 506struct timewait_sock_ops;
500struct inet_hashinfo; 507struct inet_hashinfo;
508struct raw_hashinfo;
501 509
502/* Networking protocol blocks we attach to sockets. 510/* Networking protocol blocks we attach to sockets.
503 * socket layer -> transport layer interface 511 * socket layer -> transport layer interface
@@ -553,7 +561,7 @@ struct proto {
553 561
554 /* Keeping track of sockets in use */ 562 /* Keeping track of sockets in use */
555#ifdef CONFIG_PROC_FS 563#ifdef CONFIG_PROC_FS
556 struct pcounter inuse; 564 unsigned int inuse_idx;
557#endif 565#endif
558 566
559 /* Memory pressure */ 567 /* Memory pressure */
@@ -580,7 +588,11 @@ struct proto {
580 struct request_sock_ops *rsk_prot; 588 struct request_sock_ops *rsk_prot;
581 struct timewait_sock_ops *twsk_prot; 589 struct timewait_sock_ops *twsk_prot;
582 590
583 struct inet_hashinfo *hashinfo; 591 union {
592 struct inet_hashinfo *hashinfo;
593 struct hlist_head *udp_hash;
594 struct raw_hashinfo *raw_hash;
595 } h;
584 596
585 struct module *owner; 597 struct module *owner;
586 598
@@ -622,36 +634,12 @@ static inline void sk_refcnt_debug_release(const struct sock *sk)
622 634
623 635
624#ifdef CONFIG_PROC_FS 636#ifdef CONFIG_PROC_FS
625# define DEFINE_PROTO_INUSE(NAME) DEFINE_PCOUNTER(NAME)
626# define REF_PROTO_INUSE(NAME) PCOUNTER_MEMBER_INITIALIZER(NAME, .inuse)
627/* Called with local bh disabled */ 637/* Called with local bh disabled */
628static inline void sock_prot_inuse_add(struct proto *prot, int inc) 638extern void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc);
629{ 639extern int sock_prot_inuse_get(struct net *net, struct proto *proto);
630 pcounter_add(&prot->inuse, inc);
631}
632static inline int sock_prot_inuse_init(struct proto *proto)
633{
634 return pcounter_alloc(&proto->inuse);
635}
636static inline int sock_prot_inuse_get(struct proto *proto)
637{
638 return pcounter_getval(&proto->inuse);
639}
640static inline void sock_prot_inuse_free(struct proto *proto)
641{
642 pcounter_free(&proto->inuse);
643}
644#else 640#else
645# define DEFINE_PROTO_INUSE(NAME) 641static void inline sock_prot_inuse_add(struct net *net, struct proto *prot,
646# define REF_PROTO_INUSE(NAME) 642 int inc)
647static void inline sock_prot_inuse_add(struct proto *prot, int inc)
648{
649}
650static int inline sock_prot_inuse_init(struct proto *proto)
651{
652 return 0;
653}
654static void inline sock_prot_inuse_free(struct proto *proto)
655{ 643{
656} 644}
657#endif 645#endif
@@ -850,6 +838,7 @@ extern struct sock *sk_alloc(struct net *net, int family,
850 gfp_t priority, 838 gfp_t priority,
851 struct proto *prot); 839 struct proto *prot);
852extern void sk_free(struct sock *sk); 840extern void sk_free(struct sock *sk);
841extern void sk_release_kernel(struct sock *sk);
853extern struct sock *sk_clone(const struct sock *sk, 842extern struct sock *sk_clone(const struct sock *sk,
854 const gfp_t priority); 843 const gfp_t priority);
855 844
@@ -939,41 +928,6 @@ extern void sk_common_release(struct sock *sk);
939extern void sock_init_data(struct socket *sock, struct sock *sk); 928extern void sock_init_data(struct socket *sock, struct sock *sk);
940 929
941/** 930/**
942 * sk_filter - run a packet through a socket filter
943 * @sk: sock associated with &sk_buff
944 * @skb: buffer to filter
945 * @needlock: set to 1 if the sock is not locked by caller.
946 *
947 * Run the filter code and then cut skb->data to correct size returned by
948 * sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller
949 * than pkt_len we keep whole skb->data. This is the socket level
950 * wrapper to sk_run_filter. It returns 0 if the packet should
951 * be accepted or -EPERM if the packet should be tossed.
952 *
953 */
954
955static inline int sk_filter(struct sock *sk, struct sk_buff *skb)
956{
957 int err;
958 struct sk_filter *filter;
959
960 err = security_sock_rcv_skb(sk, skb);
961 if (err)
962 return err;
963
964 rcu_read_lock_bh();
965 filter = rcu_dereference(sk->sk_filter);
966 if (filter) {
967 unsigned int pkt_len = sk_run_filter(skb, filter->insns,
968 filter->len);
969 err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM;
970 }
971 rcu_read_unlock_bh();
972
973 return err;
974}
975
976/**
977 * sk_filter_release: Release a socket filter 931 * sk_filter_release: Release a socket filter
978 * @sk: socket 932 * @sk: socket
979 * @fp: filter to remove 933 * @fp: filter to remove
@@ -1333,6 +1287,36 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e
1333} 1287}
1334#endif 1288#endif
1335 1289
1290static inline
1291struct net *sock_net(const struct sock *sk)
1292{
1293#ifdef CONFIG_NET_NS
1294 return sk->sk_net;
1295#else
1296 return &init_net;
1297#endif
1298}
1299
1300static inline
1301void sock_net_set(struct sock *sk, struct net *net)
1302{
1303#ifdef CONFIG_NET_NS
1304 sk->sk_net = net;
1305#endif
1306}
1307
1308/*
1309 * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace.
1310 * They should not hold a referrence to a namespace in order to allow
1311 * to stop it.
1312 * Sockets after sk_change_net should be released using sk_release_kernel
1313 */
1314static inline void sk_change_net(struct sock *sk, struct net *net)
1315{
1316 put_net(sock_net(sk));
1317 sock_net_set(sk, hold_net(net));
1318}
1319
1336extern void sock_enable_timestamp(struct sock *sk); 1320extern void sock_enable_timestamp(struct sock *sk);
1337extern int sock_get_timestamp(struct sock *, struct timeval __user *); 1321extern int sock_get_timestamp(struct sock *, struct timeval __user *);
1338extern int sock_get_timestampns(struct sock *, struct timespec __user *); 1322extern int sock_get_timestampns(struct sock *, struct timespec __user *);
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 4fd3eb2f8ec2..633147cb6bbc 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -29,6 +29,7 @@
29#include <linux/skbuff.h> 29#include <linux/skbuff.h>
30#include <linux/dmaengine.h> 30#include <linux/dmaengine.h>
31#include <linux/crypto.h> 31#include <linux/crypto.h>
32#include <linux/cryptohash.h>
32 33
33#include <net/inet_connection_sock.h> 34#include <net/inet_connection_sock.h>
34#include <net/inet_timewait_sock.h> 35#include <net/inet_timewait_sock.h>
@@ -138,6 +139,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
138#define MAX_TCP_KEEPINTVL 32767 139#define MAX_TCP_KEEPINTVL 32767
139#define MAX_TCP_KEEPCNT 127 140#define MAX_TCP_KEEPCNT 127
140#define MAX_TCP_SYNCNT 127 141#define MAX_TCP_SYNCNT 127
142#define MAX_TCP_ACCEPT_DEFERRED 65535
141 143
142#define TCP_SYNQ_INTERVAL (HZ/5) /* Period of SYNACK timer */ 144#define TCP_SYNQ_INTERVAL (HZ/5) /* Period of SYNACK timer */
143 145
@@ -434,11 +436,20 @@ extern int tcp_disconnect(struct sock *sk, int flags);
434extern void tcp_unhash(struct sock *sk); 436extern void tcp_unhash(struct sock *sk);
435 437
436/* From syncookies.c */ 438/* From syncookies.c */
439extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
437extern struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, 440extern struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
438 struct ip_options *opt); 441 struct ip_options *opt);
439extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, 442extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb,
440 __u16 *mss); 443 __u16 *mss);
441 444
445extern __u32 cookie_init_timestamp(struct request_sock *req);
446extern void cookie_check_timestamp(struct tcp_options_received *tcp_opt);
447
448/* From net/ipv6/syncookies.c */
449extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb);
450extern __u32 cookie_v6_init_sequence(struct sock *sk, struct sk_buff *skb,
451 __u16 *mss);
452
442/* tcp_output.c */ 453/* tcp_output.c */
443 454
444extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, 455extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
@@ -776,11 +787,14 @@ extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh);
776extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); 787extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst);
777 788
778/* Slow start with delack produces 3 packets of burst, so that 789/* Slow start with delack produces 3 packets of burst, so that
779 * it is safe "de facto". 790 * it is safe "de facto". This will be the default - same as
791 * the default reordering threshold - but if reordering increases,
792 * we must be able to allow cwnd to burst at least this much in order
793 * to not pull it back when holes are filled.
780 */ 794 */
781static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp) 795static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp)
782{ 796{
783 return 3; 797 return tp->reordering;
784} 798}
785 799
786/* Returns end sequence number of the receiver's advertised window */ 800/* Returns end sequence number of the receiver's advertised window */
@@ -950,6 +964,7 @@ static inline void tcp_openreq_init(struct request_sock *req,
950 struct inet_request_sock *ireq = inet_rsk(req); 964 struct inet_request_sock *ireq = inet_rsk(req);
951 965
952 req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */ 966 req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */
967 req->cookie_ts = 0;
953 tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq; 968 tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq;
954 req->mss = rx_opt->mss_clamp; 969 req->mss = rx_opt->mss_clamp;
955 req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; 970 req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0;
@@ -1237,7 +1252,7 @@ static inline void tcp_insert_write_queue_after(struct sk_buff *skb,
1237 struct sk_buff *buff, 1252 struct sk_buff *buff,
1238 struct sock *sk) 1253 struct sock *sk)
1239{ 1254{
1240 __skb_append(skb, buff, &sk->sk_write_queue); 1255 __skb_queue_after(&sk->sk_write_queue, skb, buff);
1241} 1256}
1242 1257
1243/* Insert skb between prev and next on the write queue of sk. */ 1258/* Insert skb between prev and next on the write queue of sk. */
@@ -1315,25 +1330,25 @@ enum tcp_seq_states {
1315}; 1330};
1316 1331
1317struct tcp_seq_afinfo { 1332struct tcp_seq_afinfo {
1318 struct module *owner;
1319 char *name; 1333 char *name;
1320 sa_family_t family; 1334 sa_family_t family;
1321 int (*seq_show) (struct seq_file *m, void *v); 1335 struct file_operations seq_fops;
1322 struct file_operations *seq_fops; 1336 struct seq_operations seq_ops;
1323}; 1337};
1324 1338
1325struct tcp_iter_state { 1339struct tcp_iter_state {
1340 struct seq_net_private p;
1326 sa_family_t family; 1341 sa_family_t family;
1327 enum tcp_seq_states state; 1342 enum tcp_seq_states state;
1328 struct sock *syn_wait_sk; 1343 struct sock *syn_wait_sk;
1329 int bucket, sbucket, num, uid; 1344 int bucket, sbucket, num, uid;
1330 struct seq_operations seq_ops;
1331}; 1345};
1332 1346
1333extern int tcp_proc_register(struct tcp_seq_afinfo *afinfo); 1347extern int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo);
1334extern void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo); 1348extern void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo);
1335 1349
1336extern struct request_sock_ops tcp_request_sock_ops; 1350extern struct request_sock_ops tcp_request_sock_ops;
1351extern struct request_sock_ops tcp6_request_sock_ops;
1337 1352
1338extern int tcp_v4_destroy_sock(struct sock *sk); 1353extern int tcp_v4_destroy_sock(struct sock *sk);
1339 1354
@@ -1375,7 +1390,7 @@ struct tcp_request_sock_ops {
1375#endif 1390#endif
1376}; 1391};
1377 1392
1378extern void tcp_v4_init(struct net_proto_family *ops); 1393extern void tcp_v4_init(void);
1379extern void tcp_init(void); 1394extern void tcp_init(void);
1380 1395
1381#endif /* _TCP_H */ 1396#endif /* _TCP_H */
diff --git a/include/net/tipc/tipc_bearer.h b/include/net/tipc/tipc_bearer.h
index 2151a80cdf30..ee2f304e4919 100644
--- a/include/net/tipc/tipc_bearer.h
+++ b/include/net/tipc/tipc_bearer.h
@@ -99,6 +99,9 @@ struct tipc_bearer {
99 char name[TIPC_MAX_BEARER_NAME]; 99 char name[TIPC_MAX_BEARER_NAME];
100}; 100};
101 101
102/*
103 * TIPC routines available to supported media types
104 */
102 105
103int tipc_register_media(u32 media_type, 106int tipc_register_media(u32 media_type,
104 char *media_name, 107 char *media_name,
@@ -123,6 +126,12 @@ void tipc_continue(struct tipc_bearer *tb_ptr);
123int tipc_enable_bearer(const char *bearer_name, u32 bcast_scope, u32 priority); 126int tipc_enable_bearer(const char *bearer_name, u32 bcast_scope, u32 priority);
124int tipc_disable_bearer(const char *name); 127int tipc_disable_bearer(const char *name);
125 128
129/*
130 * Routines made available to TIPC by supported media types
131 */
132
133int tipc_eth_media_start(void);
134void tipc_eth_media_stop(void);
126 135
127#endif 136#endif
128 137
diff --git a/include/net/tipc/tipc_port.h b/include/net/tipc/tipc_port.h
index cfc4ba46de8f..11105bcc4457 100644
--- a/include/net/tipc/tipc_port.h
+++ b/include/net/tipc/tipc_port.h
@@ -86,13 +86,6 @@ u32 tipc_createport_raw(void *usr_handle,
86 void (*wakeup)(struct tipc_port *), 86 void (*wakeup)(struct tipc_port *),
87 const u32 importance); 87 const u32 importance);
88 88
89/*
90 * tipc_set_msg_option(): port must be locked.
91 */
92int tipc_set_msg_option(struct tipc_port *tp_ptr,
93 const char *opt,
94 const u32 len);
95
96int tipc_reject_msg(struct sk_buff *buf, u32 err); 89int tipc_reject_msg(struct sk_buff *buf, u32 err);
97 90
98int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode); 91int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode);
@@ -103,6 +96,12 @@ struct tipc_port *tipc_get_port(const u32 ref);
103 96
104void *tipc_get_handle(const u32 ref); 97void *tipc_get_handle(const u32 ref);
105 98
99/*
100 * The following routines require that the port be locked on entry
101 */
102
103int tipc_disconnect_port(struct tipc_port *tp_ptr);
104
106 105
107#endif 106#endif
108 107
diff --git a/include/net/udp.h b/include/net/udp.h
index c6669c0a74c7..3e55a99b0ba3 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -115,7 +115,7 @@ static inline void udp_lib_unhash(struct sock *sk)
115 write_lock_bh(&udp_hash_lock); 115 write_lock_bh(&udp_hash_lock);
116 if (sk_del_node_init(sk)) { 116 if (sk_del_node_init(sk)) {
117 inet_sk(sk)->num = 0; 117 inet_sk(sk)->num = 0;
118 sock_prot_inuse_add(sk->sk_prot, -1); 118 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
119 } 119 }
120 write_unlock_bh(&udp_hash_lock); 120 write_unlock_bh(&udp_hash_lock);
121} 121}
@@ -125,6 +125,8 @@ static inline void udp_lib_close(struct sock *sk, long timeout)
125 sk_common_release(sk); 125 sk_common_release(sk);
126} 126}
127 127
128extern int udp_lib_get_port(struct sock *sk, unsigned short snum,
129 int (*)(const struct sock*,const struct sock*));
128 130
129/* net/ipv4/udp.c */ 131/* net/ipv4/udp.c */
130extern int udp_get_port(struct sock *sk, unsigned short snum, 132extern int udp_get_port(struct sock *sk, unsigned short snum,
@@ -183,24 +185,23 @@ DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
183 185
184/* /proc */ 186/* /proc */
185struct udp_seq_afinfo { 187struct udp_seq_afinfo {
186 struct module *owner;
187 char *name; 188 char *name;
188 sa_family_t family; 189 sa_family_t family;
189 struct hlist_head *hashtable; 190 struct hlist_head *hashtable;
190 int (*seq_show) (struct seq_file *m, void *v); 191 struct file_operations seq_fops;
191 struct file_operations *seq_fops; 192 struct seq_operations seq_ops;
192}; 193};
193 194
194struct udp_iter_state { 195struct udp_iter_state {
196 struct seq_net_private p;
195 sa_family_t family; 197 sa_family_t family;
196 struct hlist_head *hashtable; 198 struct hlist_head *hashtable;
197 int bucket; 199 int bucket;
198 struct seq_operations seq_ops;
199}; 200};
200 201
201#ifdef CONFIG_PROC_FS 202#ifdef CONFIG_PROC_FS
202extern int udp_proc_register(struct udp_seq_afinfo *afinfo); 203extern int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo);
203extern void udp_proc_unregister(struct udp_seq_afinfo *afinfo); 204extern void udp_proc_unregister(struct net *net, struct udp_seq_afinfo *afinfo);
204 205
205extern int udp4_proc_init(void); 206extern int udp4_proc_init(void);
206extern void udp4_proc_exit(void); 207extern void udp4_proc_exit(void);
diff --git a/include/net/wireless.h b/include/net/wireless.h
index d30c4ba8fd99..667b4080d30f 100644
--- a/include/net/wireless.h
+++ b/include/net/wireless.h
@@ -13,6 +13,162 @@
13#include <net/cfg80211.h> 13#include <net/cfg80211.h>
14 14
15/** 15/**
16 * enum ieee80211_band - supported frequency bands
17 *
18 * The bands are assigned this way because the supported
19 * bitrates differ in these bands.
20 *
21 * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band
22 * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7)
23 */
24enum ieee80211_band {
25 IEEE80211_BAND_2GHZ,
26 IEEE80211_BAND_5GHZ,
27
28 /* keep last */
29 IEEE80211_NUM_BANDS
30};
31
32/**
33 * enum ieee80211_channel_flags - channel flags
34 *
35 * Channel flags set by the regulatory control code.
36 *
37 * @IEEE80211_CHAN_DISABLED: This channel is disabled.
38 * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
39 * on this channel.
40 * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
41 * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
42 */
43enum ieee80211_channel_flags {
44 IEEE80211_CHAN_DISABLED = 1<<0,
45 IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
46 IEEE80211_CHAN_NO_IBSS = 1<<2,
47 IEEE80211_CHAN_RADAR = 1<<3,
48};
49
50/**
51 * struct ieee80211_channel - channel definition
52 *
53 * This structure describes a single channel for use
54 * with cfg80211.
55 *
56 * @center_freq: center frequency in MHz
57 * @hw_value: hardware-specific value for the channel
58 * @flags: channel flags from &enum ieee80211_channel_flags.
59 * @orig_flags: channel flags at registration time, used by regulatory
60 * code to support devices with additional restrictions
61 * @band: band this channel belongs to.
62 * @max_antenna_gain: maximum antenna gain in dBi
63 * @max_power: maximum transmission power (in dBm)
64 * @orig_mag: internal use
65 * @orig_mpwr: internal use
66 */
67struct ieee80211_channel {
68 enum ieee80211_band band;
69 u16 center_freq;
70 u16 hw_value;
71 u32 flags;
72 int max_antenna_gain;
73 int max_power;
74 u32 orig_flags;
75 int orig_mag, orig_mpwr;
76};
77
78/**
79 * enum ieee80211_rate_flags - rate flags
80 *
81 * Hardware/specification flags for rates. These are structured
82 * in a way that allows using the same bitrate structure for
83 * different bands/PHY modes.
84 *
85 * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
86 * preamble on this bitrate; only relevant in 2.4GHz band and
87 * with CCK rates.
88 * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
89 * when used with 802.11a (on the 5 GHz band); filled by the
90 * core code when registering the wiphy.
91 * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
92 * when used with 802.11b (on the 2.4 GHz band); filled by the
93 * core code when registering the wiphy.
94 * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
95 * when used with 802.11g (on the 2.4 GHz band); filled by the
96 * core code when registering the wiphy.
97 * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
98 */
99enum ieee80211_rate_flags {
100 IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
101 IEEE80211_RATE_MANDATORY_A = 1<<1,
102 IEEE80211_RATE_MANDATORY_B = 1<<2,
103 IEEE80211_RATE_MANDATORY_G = 1<<3,
104 IEEE80211_RATE_ERP_G = 1<<4,
105};
106
107/**
108 * struct ieee80211_rate - bitrate definition
109 *
110 * This structure describes a bitrate that an 802.11 PHY can
111 * operate with. The two values @hw_value and @hw_value_short
112 * are only for driver use when pointers to this structure are
113 * passed around.
114 *
115 * @flags: rate-specific flags
116 * @bitrate: bitrate in units of 100 Kbps
117 * @hw_value: driver/hardware value for this rate
118 * @hw_value_short: driver/hardware value for this rate when
119 * short preamble is used
120 */
121struct ieee80211_rate {
122 u32 flags;
123 u16 bitrate;
124 u16 hw_value, hw_value_short;
125};
126
127/**
128 * struct ieee80211_ht_info - describing STA's HT capabilities
129 *
130 * This structure describes most essential parameters needed
131 * to describe 802.11n HT capabilities for an STA.
132 *
133 * @ht_supported: is HT supported by STA, 0: no, 1: yes
134 * @cap: HT capabilities map as described in 802.11n spec
135 * @ampdu_factor: Maximum A-MPDU length factor
136 * @ampdu_density: Minimum A-MPDU spacing
137 * @supp_mcs_set: Supported MCS set as described in 802.11n spec
138 */
139struct ieee80211_ht_info {
140 u16 cap; /* use IEEE80211_HT_CAP_ */
141 u8 ht_supported;
142 u8 ampdu_factor;
143 u8 ampdu_density;
144 u8 supp_mcs_set[16];
145};
146
147/**
148 * struct ieee80211_supported_band - frequency band definition
149 *
150 * This structure describes a frequency band a wiphy
151 * is able to operate in.
152 *
153 * @channels: Array of channels the hardware can operate in
154 * in this band.
155 * @band: the band this structure represents
156 * @n_channels: Number of channels in @channels
157 * @bitrates: Array of bitrates the hardware can operate with
158 * in this band. Must be sorted to give a valid "supported
159 * rates" IE, i.e. CCK rates first, then OFDM.
160 * @n_bitrates: Number of bitrates in @bitrates
161 */
162struct ieee80211_supported_band {
163 struct ieee80211_channel *channels;
164 struct ieee80211_rate *bitrates;
165 enum ieee80211_band band;
166 int n_channels;
167 int n_bitrates;
168 struct ieee80211_ht_info ht_info;
169};
170
171/**
16 * struct wiphy - wireless hardware description 172 * struct wiphy - wireless hardware description
17 * @idx: the wiphy index assigned to this item 173 * @idx: the wiphy index assigned to this item
18 * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name> 174 * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
@@ -30,6 +186,8 @@ struct wiphy {
30 * help determine whether you own this wiphy or not. */ 186 * help determine whether you own this wiphy or not. */
31 void *privid; 187 void *privid;
32 188
189 struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
190
33 /* fields below are read-only, assigned by cfg80211 */ 191 /* fields below are read-only, assigned by cfg80211 */
34 192
35 /* the item in /sys/class/ieee80211/ points to this, 193 /* the item in /sys/class/ieee80211/ points to this,
@@ -136,4 +294,32 @@ extern void wiphy_unregister(struct wiphy *wiphy);
136 */ 294 */
137extern void wiphy_free(struct wiphy *wiphy); 295extern void wiphy_free(struct wiphy *wiphy);
138 296
297/**
298 * ieee80211_channel_to_frequency - convert channel number to frequency
299 */
300extern int ieee80211_channel_to_frequency(int chan);
301
302/**
303 * ieee80211_frequency_to_channel - convert frequency to channel number
304 */
305extern int ieee80211_frequency_to_channel(int freq);
306
307/*
308 * Name indirection necessary because the ieee80211 code also has
309 * a function named "ieee80211_get_channel", so if you include
310 * cfg80211's header file you get cfg80211's version, if you try
311 * to include both header files you'll (rightfully!) get a symbol
312 * clash.
313 */
314extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
315 int freq);
316
317/**
318 * ieee80211_get_channel - get channel struct from wiphy for specified frequency
319 */
320static inline struct ieee80211_channel *
321ieee80211_get_channel(struct wiphy *wiphy, int freq)
322{
323 return __ieee80211_get_channel(wiphy, freq);
324}
139#endif /* __NET_WIRELESS_H */ 325#endif /* __NET_WIRELESS_H */
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 0d255ae008b6..d1350bcccb03 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -121,6 +121,7 @@ extern struct mutex xfrm_cfg_mutex;
121struct xfrm_state 121struct xfrm_state
122{ 122{
123 /* Note: bydst is re-used during gc */ 123 /* Note: bydst is re-used during gc */
124 struct list_head all;
124 struct hlist_node bydst; 125 struct hlist_node bydst;
125 struct hlist_node bysrc; 126 struct hlist_node bysrc;
126 struct hlist_node byspi; 127 struct hlist_node byspi;
@@ -435,6 +436,9 @@ struct xfrm_tmpl
435/* May skip this transfomration if no SA is found */ 436/* May skip this transfomration if no SA is found */
436 __u8 optional; 437 __u8 optional;
437 438
439/* Skip aalgos/ealgos/calgos checks. */
440 __u8 allalgs;
441
438/* Bit mask of algos allowed for acquisition */ 442/* Bit mask of algos allowed for acquisition */
439 __u32 aalgos; 443 __u32 aalgos;
440 __u32 ealgos; 444 __u32 ealgos;
@@ -446,6 +450,7 @@ struct xfrm_tmpl
446struct xfrm_policy 450struct xfrm_policy
447{ 451{
448 struct xfrm_policy *next; 452 struct xfrm_policy *next;
453 struct list_head bytype;
449 struct hlist_node bydst; 454 struct hlist_node bydst;
450 struct hlist_node byidx; 455 struct hlist_node byidx;
451 456
@@ -592,8 +597,9 @@ struct xfrm_spi_skb_cb {
592/* Audit Information */ 597/* Audit Information */
593struct xfrm_audit 598struct xfrm_audit
594{ 599{
595 u32 loginuid;
596 u32 secid; 600 u32 secid;
601 uid_t loginuid;
602 u32 sessionid;
597}; 603};
598 604
599#ifdef CONFIG_AUDITSYSCALL 605#ifdef CONFIG_AUDITSYSCALL
@@ -611,13 +617,13 @@ static inline struct audit_buffer *xfrm_audit_start(const char *op)
611 return audit_buf; 617 return audit_buf;
612} 618}
613 619
614static inline void xfrm_audit_helper_usrinfo(u32 auid, u32 secid, 620static inline void xfrm_audit_helper_usrinfo(uid_t auid, u32 ses, u32 secid,
615 struct audit_buffer *audit_buf) 621 struct audit_buffer *audit_buf)
616{ 622{
617 char *secctx; 623 char *secctx;
618 u32 secctx_len; 624 u32 secctx_len;
619 625
620 audit_log_format(audit_buf, " auid=%u", auid); 626 audit_log_format(audit_buf, " auid=%u ses=%u", auid, ses);
621 if (secid != 0 && 627 if (secid != 0 &&
622 security_secid_to_secctx(secid, &secctx, &secctx_len) == 0) { 628 security_secid_to_secctx(secid, &secctx, &secctx_len) == 0) {
623 audit_log_format(audit_buf, " subj=%s", secctx); 629 audit_log_format(audit_buf, " subj=%s", secctx);
@@ -627,13 +633,13 @@ static inline void xfrm_audit_helper_usrinfo(u32 auid, u32 secid,
627} 633}
628 634
629extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, 635extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result,
630 u32 auid, u32 secid); 636 u32 auid, u32 ses, u32 secid);
631extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, 637extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result,
632 u32 auid, u32 secid); 638 u32 auid, u32 ses, u32 secid);
633extern void xfrm_audit_state_add(struct xfrm_state *x, int result, 639extern void xfrm_audit_state_add(struct xfrm_state *x, int result,
634 u32 auid, u32 secid); 640 u32 auid, u32 ses, u32 secid);
635extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, 641extern void xfrm_audit_state_delete(struct xfrm_state *x, int result,
636 u32 auid, u32 secid); 642 u32 auid, u32 ses, u32 secid);
637extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, 643extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x,
638 struct sk_buff *skb); 644 struct sk_buff *skb);
639extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family); 645extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family);
@@ -642,10 +648,10 @@ extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family,
642extern void xfrm_audit_state_icvfail(struct xfrm_state *x, 648extern void xfrm_audit_state_icvfail(struct xfrm_state *x,
643 struct sk_buff *skb, u8 proto); 649 struct sk_buff *skb, u8 proto);
644#else 650#else
645#define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0) 651#define xfrm_audit_policy_add(x, r, a, se, s) do { ; } while (0)
646#define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0) 652#define xfrm_audit_policy_delete(x, r, a, se, s) do { ; } while (0)
647#define xfrm_audit_state_add(x, r, a, s) do { ; } while (0) 653#define xfrm_audit_state_add(x, r, a, se, s) do { ; } while (0)
648#define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0) 654#define xfrm_audit_state_delete(x, r, a, se, s) do { ; } while (0)
649#define xfrm_audit_state_replay_overflow(x, s) do { ; } while (0) 655#define xfrm_audit_state_replay_overflow(x, s) do { ; } while (0)
650#define xfrm_audit_state_notfound_simple(s, f) do { ; } while (0) 656#define xfrm_audit_state_notfound_simple(s, f) do { ; } while (0)
651#define xfrm_audit_state_notfound(s, f, sp, sq) do { ; } while (0) 657#define xfrm_audit_state_notfound(s, f, sp, sq) do { ; } while (0)
@@ -1071,6 +1077,23 @@ xfrm_address_t *xfrm_flowi_saddr(struct flowi *fl, unsigned short family)
1071 return NULL; 1077 return NULL;
1072} 1078}
1073 1079
1080static __inline__
1081void xfrm_flowi_addr_get(struct flowi *fl,
1082 xfrm_address_t *saddr, xfrm_address_t *daddr,
1083 unsigned short family)
1084{
1085 switch(family) {
1086 case AF_INET:
1087 memcpy(&saddr->a4, &fl->fl4_src, sizeof(saddr->a4));
1088 memcpy(&daddr->a4, &fl->fl4_dst, sizeof(daddr->a4));
1089 break;
1090 case AF_INET6:
1091 ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->fl6_src);
1092 ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->fl6_dst);
1093 break;
1094 }
1095}
1096
1074static __inline__ int 1097static __inline__ int
1075__xfrm4_state_addr_check(struct xfrm_state *x, 1098__xfrm4_state_addr_check(struct xfrm_state *x,
1076 xfrm_address_t *daddr, xfrm_address_t *saddr) 1099 xfrm_address_t *daddr, xfrm_address_t *saddr)
@@ -1188,6 +1211,18 @@ struct xfrm6_tunnel {
1188 int priority; 1211 int priority;
1189}; 1212};
1190 1213
1214struct xfrm_state_walk {
1215 struct xfrm_state *state;
1216 int count;
1217 u8 proto;
1218};
1219
1220struct xfrm_policy_walk {
1221 struct xfrm_policy *policy;
1222 int count;
1223 u8 type, cur_type;
1224};
1225
1191extern void xfrm_init(void); 1226extern void xfrm_init(void);
1192extern void xfrm4_init(void); 1227extern void xfrm4_init(void);
1193extern void xfrm_state_init(void); 1228extern void xfrm_state_init(void);
@@ -1212,7 +1247,23 @@ static inline void xfrm6_fini(void)
1212extern int xfrm_proc_init(void); 1247extern int xfrm_proc_init(void);
1213#endif 1248#endif
1214 1249
1215extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); 1250static inline void xfrm_state_walk_init(struct xfrm_state_walk *walk, u8 proto)
1251{
1252 walk->proto = proto;
1253 walk->state = NULL;
1254 walk->count = 0;
1255}
1256
1257static inline void xfrm_state_walk_done(struct xfrm_state_walk *walk)
1258{
1259 if (walk->state != NULL) {
1260 xfrm_state_put(walk->state);
1261 walk->state = NULL;
1262 }
1263}
1264
1265extern int xfrm_state_walk(struct xfrm_state_walk *walk,
1266 int (*func)(struct xfrm_state *, int, void*), void *);
1216extern struct xfrm_state *xfrm_state_alloc(void); 1267extern struct xfrm_state *xfrm_state_alloc(void);
1217extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, 1268extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
1218 struct flowi *fl, struct xfrm_tmpl *tmpl, 1269 struct flowi *fl, struct xfrm_tmpl *tmpl,
@@ -1335,7 +1386,25 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb)
1335#endif 1386#endif
1336 1387
1337struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); 1388struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp);
1338extern int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, void*), void *); 1389
1390static inline void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type)
1391{
1392 walk->cur_type = XFRM_POLICY_TYPE_MAIN;
1393 walk->type = type;
1394 walk->policy = NULL;
1395 walk->count = 0;
1396}
1397
1398static inline void xfrm_policy_walk_done(struct xfrm_policy_walk *walk)
1399{
1400 if (walk->policy != NULL) {
1401 xfrm_pol_put(walk->policy);
1402 walk->policy = NULL;
1403 }
1404}
1405
1406extern int xfrm_policy_walk(struct xfrm_policy_walk *walk,
1407 int (*func)(struct xfrm_policy *, int, int, void*), void *);
1339int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); 1408int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl);
1340struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir, 1409struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir,
1341 struct xfrm_selector *sel, 1410 struct xfrm_selector *sel,
diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h
index 22298423cf0b..9ee0d2e51b16 100644
--- a/include/rdma/ib_umem.h
+++ b/include/rdma/ib_umem.h
@@ -62,7 +62,7 @@ struct ib_umem_chunk {
62#ifdef CONFIG_INFINIBAND_USER_MEM 62#ifdef CONFIG_INFINIBAND_USER_MEM
63 63
64struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, 64struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
65 size_t size, int access); 65 size_t size, int access, int dmasync);
66void ib_umem_release(struct ib_umem *umem); 66void ib_umem_release(struct ib_umem *umem);
67int ib_umem_page_count(struct ib_umem *umem); 67int ib_umem_page_count(struct ib_umem *umem);
68 68
@@ -72,7 +72,7 @@ int ib_umem_page_count(struct ib_umem *umem);
72 72
73static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context, 73static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context,
74 unsigned long addr, size_t size, 74 unsigned long addr, size_t size,
75 int access) { 75 int access, int dmasync) {
76 return ERR_PTR(-EINVAL); 76 return ERR_PTR(-EINVAL);
77} 77}
78static inline void ib_umem_release(struct ib_umem *umem) { } 78static inline void ib_umem_release(struct ib_umem *umem) { }
diff --git a/include/rdma/ib_user_verbs.h b/include/rdma/ib_user_verbs.h
index 64a721fcbc1c..8d65bf0a625b 100644
--- a/include/rdma/ib_user_verbs.h
+++ b/include/rdma/ib_user_verbs.h
@@ -533,7 +533,10 @@ struct ib_uverbs_send_wr {
533 __u32 num_sge; 533 __u32 num_sge;
534 __u32 opcode; 534 __u32 opcode;
535 __u32 send_flags; 535 __u32 send_flags;
536 __u32 imm_data; 536 union {
537 __u32 imm_data;
538 __u32 invalidate_rkey;
539 } ex;
537 union { 540 union {
538 struct { 541 struct {
539 __u64 remote_addr; 542 __u64 remote_addr;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 701e7b40560a..911a661b7278 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -94,7 +94,7 @@ enum ib_device_cap_flags {
94 IB_DEVICE_SRQ_RESIZE = (1<<13), 94 IB_DEVICE_SRQ_RESIZE = (1<<13),
95 IB_DEVICE_N_NOTIFY_CQ = (1<<14), 95 IB_DEVICE_N_NOTIFY_CQ = (1<<14),
96 IB_DEVICE_ZERO_STAG = (1<<15), 96 IB_DEVICE_ZERO_STAG = (1<<15),
97 IB_DEVICE_SEND_W_INV = (1<<16), 97 IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */
98 IB_DEVICE_MEM_WINDOW = (1<<17), 98 IB_DEVICE_MEM_WINDOW = (1<<17),
99 /* 99 /*
100 * Devices should set IB_DEVICE_UD_IP_SUM if they support 100 * Devices should set IB_DEVICE_UD_IP_SUM if they support
@@ -104,6 +104,8 @@ enum ib_device_cap_flags {
104 * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode. 104 * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode.
105 */ 105 */
106 IB_DEVICE_UD_IP_CSUM = (1<<18), 106 IB_DEVICE_UD_IP_CSUM = (1<<18),
107 IB_DEVICE_UD_TSO = (1<<19),
108 IB_DEVICE_SEND_W_INV = (1<<21),
107}; 109};
108 110
109enum ib_atomic_cap { 111enum ib_atomic_cap {
@@ -411,6 +413,7 @@ enum ib_wc_opcode {
411 IB_WC_COMP_SWAP, 413 IB_WC_COMP_SWAP,
412 IB_WC_FETCH_ADD, 414 IB_WC_FETCH_ADD,
413 IB_WC_BIND_MW, 415 IB_WC_BIND_MW,
416 IB_WC_LSO,
414/* 417/*
415 * Set value of IB_WC_RECV so consumers can test if a completion is a 418 * Set value of IB_WC_RECV so consumers can test if a completion is a
416 * receive by testing (opcode & IB_WC_RECV). 419 * receive by testing (opcode & IB_WC_RECV).
@@ -495,6 +498,10 @@ enum ib_qp_type {
495 IB_QPT_RAW_ETY 498 IB_QPT_RAW_ETY
496}; 499};
497 500
501enum ib_qp_create_flags {
502 IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0,
503};
504
498struct ib_qp_init_attr { 505struct ib_qp_init_attr {
499 void (*event_handler)(struct ib_event *, void *); 506 void (*event_handler)(struct ib_event *, void *);
500 void *qp_context; 507 void *qp_context;
@@ -504,6 +511,7 @@ struct ib_qp_init_attr {
504 struct ib_qp_cap cap; 511 struct ib_qp_cap cap;
505 enum ib_sig_type sq_sig_type; 512 enum ib_sig_type sq_sig_type;
506 enum ib_qp_type qp_type; 513 enum ib_qp_type qp_type;
514 enum ib_qp_create_flags create_flags;
507 u8 port_num; /* special QP types only */ 515 u8 port_num; /* special QP types only */
508}; 516};
509 517
@@ -617,7 +625,9 @@ enum ib_wr_opcode {
617 IB_WR_SEND_WITH_IMM, 625 IB_WR_SEND_WITH_IMM,
618 IB_WR_RDMA_READ, 626 IB_WR_RDMA_READ,
619 IB_WR_ATOMIC_CMP_AND_SWP, 627 IB_WR_ATOMIC_CMP_AND_SWP,
620 IB_WR_ATOMIC_FETCH_AND_ADD 628 IB_WR_ATOMIC_FETCH_AND_ADD,
629 IB_WR_LSO,
630 IB_WR_SEND_WITH_INV,
621}; 631};
622 632
623enum ib_send_flags { 633enum ib_send_flags {
@@ -641,7 +651,10 @@ struct ib_send_wr {
641 int num_sge; 651 int num_sge;
642 enum ib_wr_opcode opcode; 652 enum ib_wr_opcode opcode;
643 int send_flags; 653 int send_flags;
644 __be32 imm_data; 654 union {
655 __be32 imm_data;
656 u32 invalidate_rkey;
657 } ex;
645 union { 658 union {
646 struct { 659 struct {
647 u64 remote_addr; 660 u64 remote_addr;
@@ -655,6 +668,9 @@ struct ib_send_wr {
655 } atomic; 668 } atomic;
656 struct { 669 struct {
657 struct ib_ah *ah; 670 struct ib_ah *ah;
671 void *header;
672 int hlen;
673 int mss;
658 u32 remote_qpn; 674 u32 remote_qpn;
659 u32 remote_qkey; 675 u32 remote_qkey;
660 u16 pkey_index; /* valid for GSI only */ 676 u16 pkey_index; /* valid for GSI only */
@@ -730,7 +746,7 @@ struct ib_uobject {
730 struct ib_ucontext *context; /* associated user context */ 746 struct ib_ucontext *context; /* associated user context */
731 void *object; /* containing object */ 747 void *object; /* containing object */
732 struct list_head list; /* link to context's list */ 748 struct list_head list; /* link to context's list */
733 u32 id; /* index into kernel idr */ 749 int id; /* index into kernel idr */
734 struct kref ref; 750 struct kref ref;
735 struct rw_semaphore mutex; /* protects .live */ 751 struct rw_semaphore mutex; /* protects .live */
736 int live; 752 int live;
@@ -971,6 +987,8 @@ struct ib_device {
971 int comp_vector, 987 int comp_vector,
972 struct ib_ucontext *context, 988 struct ib_ucontext *context,
973 struct ib_udata *udata); 989 struct ib_udata *udata);
990 int (*modify_cq)(struct ib_cq *cq, u16 cq_count,
991 u16 cq_period);
974 int (*destroy_cq)(struct ib_cq *cq); 992 int (*destroy_cq)(struct ib_cq *cq);
975 int (*resize_cq)(struct ib_cq *cq, int cqe, 993 int (*resize_cq)(struct ib_cq *cq, int cqe,
976 struct ib_udata *udata); 994 struct ib_udata *udata);
@@ -1033,7 +1051,7 @@ struct ib_device {
1033 struct ib_dma_mapping_ops *dma_ops; 1051 struct ib_dma_mapping_ops *dma_ops;
1034 1052
1035 struct module *owner; 1053 struct module *owner;
1036 struct class_device class_dev; 1054 struct device dev;
1037 struct kobject *ports_parent; 1055 struct kobject *ports_parent;
1038 struct list_head port_list; 1056 struct list_head port_list;
1039 1057
@@ -1376,6 +1394,15 @@ struct ib_cq *ib_create_cq(struct ib_device *device,
1376int ib_resize_cq(struct ib_cq *cq, int cqe); 1394int ib_resize_cq(struct ib_cq *cq, int cqe);
1377 1395
1378/** 1396/**
1397 * ib_modify_cq - Modifies moderation params of the CQ
1398 * @cq: The CQ to modify.
1399 * @cq_count: number of CQEs that will trigger an event
1400 * @cq_period: max period of time in usec before triggering an event
1401 *
1402 */
1403int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
1404
1405/**
1379 * ib_destroy_cq - Destroys the specified CQ. 1406 * ib_destroy_cq - Destroys the specified CQ.
1380 * @cq: The CQ to destroy. 1407 * @cq: The CQ to destroy.
1381 */ 1408 */
@@ -1515,6 +1542,24 @@ static inline void ib_dma_unmap_single(struct ib_device *dev,
1515 dma_unmap_single(dev->dma_device, addr, size, direction); 1542 dma_unmap_single(dev->dma_device, addr, size, direction);
1516} 1543}
1517 1544
1545static inline u64 ib_dma_map_single_attrs(struct ib_device *dev,
1546 void *cpu_addr, size_t size,
1547 enum dma_data_direction direction,
1548 struct dma_attrs *attrs)
1549{
1550 return dma_map_single_attrs(dev->dma_device, cpu_addr, size,
1551 direction, attrs);
1552}
1553
1554static inline void ib_dma_unmap_single_attrs(struct ib_device *dev,
1555 u64 addr, size_t size,
1556 enum dma_data_direction direction,
1557 struct dma_attrs *attrs)
1558{
1559 return dma_unmap_single_attrs(dev->dma_device, addr, size,
1560 direction, attrs);
1561}
1562
1518/** 1563/**
1519 * ib_dma_map_page - Map a physical page to DMA address 1564 * ib_dma_map_page - Map a physical page to DMA address
1520 * @dev: The device for which the dma_addr is to be created 1565 * @dev: The device for which the dma_addr is to be created
@@ -1584,6 +1629,21 @@ static inline void ib_dma_unmap_sg(struct ib_device *dev,
1584 dma_unmap_sg(dev->dma_device, sg, nents, direction); 1629 dma_unmap_sg(dev->dma_device, sg, nents, direction);
1585} 1630}
1586 1631
1632static inline int ib_dma_map_sg_attrs(struct ib_device *dev,
1633 struct scatterlist *sg, int nents,
1634 enum dma_data_direction direction,
1635 struct dma_attrs *attrs)
1636{
1637 return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, attrs);
1638}
1639
1640static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev,
1641 struct scatterlist *sg, int nents,
1642 enum dma_data_direction direction,
1643 struct dma_attrs *attrs)
1644{
1645 dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, attrs);
1646}
1587/** 1647/**
1588 * ib_sg_dma_address - Return the DMA address from a scatter/gather entry 1648 * ib_sg_dma_address - Return the DMA address from a scatter/gather entry
1589 * @dev: The device for which the DMA addresses were created 1649 * @dev: The device for which the DMA addresses were created
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index 5ffec8ad6964..e0593bfae622 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -112,6 +112,7 @@ struct iscsi_ahs_hdr {
112 112
113#define ISCSI_AHSTYPE_CDB 1 113#define ISCSI_AHSTYPE_CDB 1
114#define ISCSI_AHSTYPE_RLENGTH 2 114#define ISCSI_AHSTYPE_RLENGTH 2
115#define ISCSI_CDB_SIZE 16
115 116
116/* iSCSI PDU Header */ 117/* iSCSI PDU Header */
117struct iscsi_cmd { 118struct iscsi_cmd {
@@ -125,7 +126,7 @@ struct iscsi_cmd {
125 __be32 data_length; 126 __be32 data_length;
126 __be32 cmdsn; 127 __be32 cmdsn;
127 __be32 exp_statsn; 128 __be32 exp_statsn;
128 uint8_t cdb[16]; /* SCSI Command Block */ 129 uint8_t cdb[ISCSI_CDB_SIZE]; /* SCSI Command Block */
129 /* Additional Data (Command Dependent) */ 130 /* Additional Data (Command Dependent) */
130}; 131};
131 132
@@ -154,7 +155,8 @@ struct iscsi_ecdb_ahdr {
154 __be16 ahslength; /* CDB length - 15, including reserved byte */ 155 __be16 ahslength; /* CDB length - 15, including reserved byte */
155 uint8_t ahstype; 156 uint8_t ahstype;
156 uint8_t reserved; 157 uint8_t reserved;
157 uint8_t ecdb[260 - 16]; /* 4-byte aligned extended CDB spillover */ 158 /* 4-byte aligned extended CDB spillover */
159 uint8_t ecdb[260 - ISCSI_CDB_SIZE];
158}; 160};
159 161
160/* SCSI Response Header */ 162/* SCSI Response Header */
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 7b90b63fb5c7..cd3ca63d4fb1 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -225,6 +225,7 @@ struct iscsi_conn {
225 225
226 /* custom statistics */ 226 /* custom statistics */
227 uint32_t eh_abort_cnt; 227 uint32_t eh_abort_cnt;
228 uint32_t fmr_unalign_cnt;
228}; 229};
229 230
230struct iscsi_pool { 231struct iscsi_pool {
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 39e1cac24bb7..e78d3b62d8ec 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -32,7 +32,6 @@
32#include <scsi/sas.h> 32#include <scsi/sas.h>
33#include <linux/libata.h> 33#include <linux/libata.h>
34#include <linux/list.h> 34#include <linux/list.h>
35#include <asm/semaphore.h>
36#include <scsi/scsi_device.h> 35#include <scsi/scsi_device.h>
37#include <scsi/scsi_cmnd.h> 36#include <scsi/scsi_cmnd.h>
38#include <scsi/scsi_transport_sas.h> 37#include <scsi/scsi_transport_sas.h>
@@ -677,4 +676,6 @@ extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
677 struct ssp_response_iu *iu); 676 struct ssp_response_iu *iu);
678struct sas_phy *sas_find_local_phy(struct domain_device *dev); 677struct sas_phy *sas_find_local_phy(struct domain_device *dev);
679 678
679int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
680
680#endif /* _SASLIB_H_ */ 681#endif /* _SASLIB_H_ */
diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h
index dd5edc915417..c583193ae929 100644
--- a/include/scsi/sas_ata.h
+++ b/include/scsi/sas_ata.h
@@ -47,12 +47,12 @@ static inline int dev_is_sata(struct domain_device *dev)
47{ 47{
48 return 0; 48 return 0;
49} 49}
50int sas_ata_init_host_and_port(struct domain_device *found_dev, 50static inline int sas_ata_init_host_and_port(struct domain_device *found_dev,
51 struct scsi_target *starget) 51 struct scsi_target *starget)
52{ 52{
53 return 0; 53 return 0;
54} 54}
55void sas_ata_task_abort(struct sas_task *task) 55static inline void sas_ata_task_abort(struct sas_task *task)
56{ 56{
57} 57}
58#endif 58#endif
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index de28aab820b0..8d20e60a94b7 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -130,6 +130,9 @@ extern void scsi_release_buffers(struct scsi_cmnd *cmd);
130extern int scsi_dma_map(struct scsi_cmnd *cmd); 130extern int scsi_dma_map(struct scsi_cmnd *cmd);
131extern void scsi_dma_unmap(struct scsi_cmnd *cmd); 131extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
132 132
133struct scsi_cmnd *scsi_allocate_command(gfp_t gfp_mask);
134void scsi_free_command(gfp_t gfp_mask, struct scsi_cmnd *cmd);
135
133static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd) 136static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd)
134{ 137{
135 return cmd->sdb.table.nents; 138 return cmd->sdb.table.nents;
@@ -175,4 +178,18 @@ static inline struct scsi_data_buffer *scsi_out(struct scsi_cmnd *cmd)
175 return &cmd->sdb; 178 return &cmd->sdb;
176} 179}
177 180
181static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd,
182 void *buf, int buflen)
183{
184 return sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd),
185 buf, buflen);
186}
187
188static inline int scsi_sg_copy_to_buffer(struct scsi_cmnd *cmd,
189 void *buf, int buflen)
190{
191 return sg_copy_to_buffer(scsi_sglist(cmd), scsi_sg_count(cmd),
192 buf, buflen);
193}
194
178#endif /* _SCSI_SCSI_CMND_H */ 195#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index ab7acbe80960..f6a9fe0ef09c 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -156,8 +156,8 @@ struct scsi_device {
156 156
157 int timeout; 157 int timeout;
158 158
159 struct device sdev_gendev; 159 struct device sdev_gendev,
160 struct class_device sdev_classdev; 160 sdev_dev;
161 161
162 struct execute_work ew; /* used to get process context on put */ 162 struct execute_work ew; /* used to get process context on put */
163 163
@@ -167,9 +167,9 @@ struct scsi_device {
167#define to_scsi_device(d) \ 167#define to_scsi_device(d) \
168 container_of(d, struct scsi_device, sdev_gendev) 168 container_of(d, struct scsi_device, sdev_gendev)
169#define class_to_sdev(d) \ 169#define class_to_sdev(d) \
170 container_of(d, struct scsi_device, sdev_classdev) 170 container_of(d, struct scsi_device, sdev_dev)
171#define transport_class_to_sdev(class_dev) \ 171#define transport_class_to_sdev(class_dev) \
172 to_scsi_device(class_dev->dev) 172 to_scsi_device(class_dev->parent)
173 173
174#define sdev_printk(prefix, sdev, fmt, a...) \ 174#define sdev_printk(prefix, sdev, fmt, a...) \
175 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a) 175 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a)
@@ -181,7 +181,8 @@ struct scsi_device {
181 sdev_printk(prefix, (scmd)->device, fmt, ##a) 181 sdev_printk(prefix, (scmd)->device, fmt, ##a)
182 182
183enum scsi_target_state { 183enum scsi_target_state {
184 STARGET_RUNNING = 1, 184 STARGET_CREATED = 1,
185 STARGET_RUNNING,
185 STARGET_DEL, 186 STARGET_DEL,
186}; 187};
187 188
@@ -220,7 +221,7 @@ static inline struct scsi_target *scsi_target(struct scsi_device *sdev)
220 return to_scsi_target(sdev->sdev_gendev.parent); 221 return to_scsi_target(sdev->sdev_gendev.parent);
221} 222}
222#define transport_class_to_starget(class_dev) \ 223#define transport_class_to_starget(class_dev) \
223 to_scsi_target(class_dev->dev) 224 to_scsi_target(class_dev->parent)
224 225
225#define starget_printk(prefix, starget, fmt, a...) \ 226#define starget_printk(prefix, starget, fmt, a...) \
226 dev_printk(prefix, &(starget)->dev, fmt, ##a) 227 dev_printk(prefix, &(starget)->dev, fmt, ##a)
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 25071d5d9bf8..d3a133b4a072 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -57,13 +57,16 @@ extern const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
57 57
58extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len, 58extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
59 u64 * info_out); 59 u64 * info_out);
60 60
61extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq);
62
61/* 63/*
62 * Reset request from external source 64 * Reset request from external source
63 */ 65 */
64#define SCSI_TRY_RESET_DEVICE 1 66#define SCSI_TRY_RESET_DEVICE 1
65#define SCSI_TRY_RESET_BUS 2 67#define SCSI_TRY_RESET_BUS 2
66#define SCSI_TRY_RESET_HOST 3 68#define SCSI_TRY_RESET_HOST 3
69#define SCSI_TRY_RESET_TARGET 4
67 70
68extern int scsi_reset_provider(struct scsi_device *, int); 71extern int scsi_reset_provider(struct scsi_device *, int);
69 72
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 530ff4c553f8..d967d6dc7a28 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -172,6 +172,7 @@ struct scsi_host_template {
172 */ 172 */
173 int (* eh_abort_handler)(struct scsi_cmnd *); 173 int (* eh_abort_handler)(struct scsi_cmnd *);
174 int (* eh_device_reset_handler)(struct scsi_cmnd *); 174 int (* eh_device_reset_handler)(struct scsi_cmnd *);
175 int (* eh_target_reset_handler)(struct scsi_cmnd *);
175 int (* eh_bus_reset_handler)(struct scsi_cmnd *); 176 int (* eh_bus_reset_handler)(struct scsi_cmnd *);
176 int (* eh_host_reset_handler)(struct scsi_cmnd *); 177 int (* eh_host_reset_handler)(struct scsi_cmnd *);
177 178
@@ -469,7 +470,7 @@ struct scsi_host_template {
469 /* 470 /*
470 * Pointer to the sysfs class properties for this host, NULL terminated. 471 * Pointer to the sysfs class properties for this host, NULL terminated.
471 */ 472 */
472 struct class_device_attribute **shost_attrs; 473 struct device_attribute **shost_attrs;
473 474
474 /* 475 /*
475 * Pointer to the SCSI device properties for this host, NULL terminated. 476 * Pointer to the SCSI device properties for this host, NULL terminated.
@@ -654,8 +655,7 @@ struct Scsi_Host {
654 enum scsi_host_state shost_state; 655 enum scsi_host_state shost_state;
655 656
656 /* ldm bits */ 657 /* ldm bits */
657 struct device shost_gendev; 658 struct device shost_gendev, shost_dev;
658 struct class_device shost_classdev;
659 659
660 /* 660 /*
661 * List of hosts per template. 661 * List of hosts per template.
@@ -682,7 +682,7 @@ struct Scsi_Host {
682}; 682};
683 683
684#define class_to_shost(d) \ 684#define class_to_shost(d) \
685 container_of(d, struct Scsi_Host, shost_classdev) 685 container_of(d, struct Scsi_Host, shost_dev)
686 686
687#define shost_printk(prefix, shost, fmt, a...) \ 687#define shost_printk(prefix, shost, fmt, a...) \
688 dev_printk(prefix, &(shost)->shost_gendev, fmt, ##a) 688 dev_printk(prefix, &(shost)->shost_gendev, fmt, ##a)
diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h
index 0dfef752f0e2..490bd13a634c 100644
--- a/include/scsi/scsi_transport.h
+++ b/include/scsi/scsi_transport.h
@@ -80,7 +80,7 @@ struct scsi_transport_template {
80}; 80};
81 81
82#define transport_class_to_shost(tc) \ 82#define transport_class_to_shost(tc) \
83 dev_to_shost((tc)->dev) 83 dev_to_shost((tc)->parent)
84 84
85 85
86/* Private area maintenance. The driver requested allocations come 86/* Private area maintenance. The driver requested allocations come
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 4769efd4db24..06f72bab9df0 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -163,8 +163,8 @@ enum fc_tgtid_binding_type {
163 163
164 164
165/* Macro for use in defining Virtual Port attributes */ 165/* Macro for use in defining Virtual Port attributes */
166#define FC_VPORT_ATTR(_name,_mode,_show,_store) \ 166#define FC_VPORT_ATTR(_name,_mode,_show,_store) \
167struct class_device_attribute class_device_attr_vport_##_name = \ 167struct device_attribute dev_attr_vport_##_name = \
168 __ATTR(_name,_mode,_show,_store) 168 __ATTR(_name,_mode,_show,_store)
169 169
170 170
@@ -234,8 +234,8 @@ struct fc_vport {
234 234
235#define dev_to_vport(d) \ 235#define dev_to_vport(d) \
236 container_of(d, struct fc_vport, dev) 236 container_of(d, struct fc_vport, dev)
237#define transport_class_to_vport(classdev) \ 237#define transport_class_to_vport(dev) \
238 dev_to_vport(classdev->dev) 238 dev_to_vport(dev->parent)
239#define vport_to_shost(v) \ 239#define vport_to_shost(v) \
240 (v->shost) 240 (v->shost)
241#define vport_to_shost_channel(v) \ 241#define vport_to_shost_channel(v) \
@@ -271,7 +271,7 @@ struct fc_rport_identifiers {
271 271
272/* Macro for use in defining Remote Port attributes */ 272/* Macro for use in defining Remote Port attributes */
273#define FC_RPORT_ATTR(_name,_mode,_show,_store) \ 273#define FC_RPORT_ATTR(_name,_mode,_show,_store) \
274struct class_device_attribute class_device_attr_rport_##_name = \ 274struct device_attribute dev_attr_rport_##_name = \
275 __ATTR(_name,_mode,_show,_store) 275 __ATTR(_name,_mode,_show,_store)
276 276
277 277
@@ -341,8 +341,8 @@ struct fc_rport { /* aka fc_starget_attrs */
341 341
342#define dev_to_rport(d) \ 342#define dev_to_rport(d) \
343 container_of(d, struct fc_rport, dev) 343 container_of(d, struct fc_rport, dev)
344#define transport_class_to_rport(classdev) \ 344#define transport_class_to_rport(dev) \
345 dev_to_rport(classdev->dev) 345 dev_to_rport(dev->parent)
346#define rport_to_shost(r) \ 346#define rport_to_shost(r) \
347 dev_to_shost(r->dev.parent) 347 dev_to_shost(r->dev.parent)
348 348
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index 09125fa95b93..61ad3594aad6 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -80,8 +80,8 @@ struct sas_phy {
80 80
81#define dev_to_phy(d) \ 81#define dev_to_phy(d) \
82 container_of((d), struct sas_phy, dev) 82 container_of((d), struct sas_phy, dev)
83#define transport_class_to_phy(cdev) \ 83#define transport_class_to_phy(dev) \
84 dev_to_phy((cdev)->dev) 84 dev_to_phy((dev)->parent)
85#define phy_to_shost(phy) \ 85#define phy_to_shost(phy) \
86 dev_to_shost((phy)->dev.parent) 86 dev_to_shost((phy)->dev.parent)
87 87
@@ -96,8 +96,8 @@ struct sas_rphy {
96 96
97#define dev_to_rphy(d) \ 97#define dev_to_rphy(d) \
98 container_of((d), struct sas_rphy, dev) 98 container_of((d), struct sas_rphy, dev)
99#define transport_class_to_rphy(cdev) \ 99#define transport_class_to_rphy(dev) \
100 dev_to_rphy((cdev)->dev) 100 dev_to_rphy((dev)->parent)
101#define rphy_to_shost(rphy) \ 101#define rphy_to_shost(rphy) \
102 dev_to_shost((rphy)->dev.parent) 102 dev_to_shost((rphy)->dev.parent)
103#define target_to_rphy(targ) \ 103#define target_to_rphy(targ) \
@@ -152,8 +152,8 @@ struct sas_port {
152 152
153#define dev_to_sas_port(d) \ 153#define dev_to_sas_port(d) \
154 container_of((d), struct sas_port, dev) 154 container_of((d), struct sas_port, dev)
155#define transport_class_to_sas_port(cdev) \ 155#define transport_class_to_sas_port(dev) \
156 dev_to_sas_port((cdev)->dev) 156 dev_to_sas_port((dev)->parent)
157 157
158struct sas_phy_linkrates { 158struct sas_phy_linkrates {
159 enum sas_linkrate maximum_linkrate; 159 enum sas_linkrate maximum_linkrate;
diff --git a/include/scsi/sd.h b/include/scsi/sd.h
index 8ea9f7358ac1..4f032d48cb6e 100644
--- a/include/scsi/sd.h
+++ b/include/scsi/sd.h
@@ -34,7 +34,7 @@
34struct scsi_disk { 34struct scsi_disk {
35 struct scsi_driver *driver; /* always &sd_template */ 35 struct scsi_driver *driver; /* always &sd_template */
36 struct scsi_device *device; 36 struct scsi_device *device;
37 struct class_device cdev; 37 struct device dev;
38 struct gendisk *disk; 38 struct gendisk *disk;
39 unsigned int openers; /* protected by BKL for now, yuck */ 39 unsigned int openers; /* protected by BKL for now, yuck */
40 sector_t capacity; /* size in 512-byte sectors */ 40 sector_t capacity; /* size in 512-byte sectors */
@@ -46,7 +46,7 @@ struct scsi_disk {
46 unsigned RCD : 1; /* state of disk RCD bit, unused */ 46 unsigned RCD : 1; /* state of disk RCD bit, unused */
47 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ 47 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
48}; 48};
49#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev) 49#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
50 50
51#define sd_printk(prefix, sdsk, fmt, a...) \ 51#define sd_printk(prefix, sdsk, fmt, a...) \
52 (sdsk)->disk ? \ 52 (sdsk)->disk ? \
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 01480581f825..049edc5e6461 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -397,6 +397,7 @@
397#define AC97_HAS_NO_TONE (1<<16) /* no Tone volume */ 397#define AC97_HAS_NO_TONE (1<<16) /* no Tone volume */
398#define AC97_HAS_NO_STD_PCM (1<<17) /* no standard AC97 PCM volume and mute */ 398#define AC97_HAS_NO_STD_PCM (1<<17) /* no standard AC97 PCM volume and mute */
399#define AC97_HAS_NO_AUX (1<<18) /* no standard AC97 AUX volume and mute */ 399#define AC97_HAS_NO_AUX (1<<18) /* no standard AC97 AUX volume and mute */
400#define AC97_HAS_8CH (1<<19) /* supports 8-channel output */
400 401
401/* rates indexes */ 402/* rates indexes */
402#define AC97_RATES_FRONT_DAC 0 403#define AC97_RATES_FRONT_DAC 0
diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h
index 4e80d3fe7381..d293d36a66b8 100644
--- a/include/sound/ak4114.h
+++ b/include/sound/ak4114.h
@@ -182,6 +182,7 @@ struct ak4114 {
182 unsigned char rcs0; 182 unsigned char rcs0;
183 unsigned char rcs1; 183 unsigned char rcs1;
184 struct delayed_work work; 184 struct delayed_work work;
185 unsigned int check_flags;
185 void *change_callback_private; 186 void *change_callback_private;
186 void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1); 187 void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1);
187}; 188};
diff --git a/include/sound/ak4xxx-adda.h b/include/sound/ak4xxx-adda.h
index 6153b91cdc3e..891cf1aea8b1 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, NON_AKM 71 SND_AK5365
72 } type; 72 } type;
73 73
74 /* (array) information of combined codecs */ 74 /* (array) information of combined codecs */
diff --git a/include/sound/asoundef.h b/include/sound/asoundef.h
index 024ce62f7d16..a6e0facf8a37 100644
--- a/include/sound/asoundef.h
+++ b/include/sound/asoundef.h
@@ -112,6 +112,14 @@
112#define IEC958_AES3_CON_CLOCK_1000PPM (0<<4) /* 1000 ppm */ 112#define IEC958_AES3_CON_CLOCK_1000PPM (0<<4) /* 1000 ppm */
113#define IEC958_AES3_CON_CLOCK_50PPM (1<<4) /* 50 ppm */ 113#define IEC958_AES3_CON_CLOCK_50PPM (1<<4) /* 50 ppm */
114#define IEC958_AES3_CON_CLOCK_VARIABLE (2<<4) /* variable pitch */ 114#define IEC958_AES3_CON_CLOCK_VARIABLE (2<<4) /* variable pitch */
115#define IEC958_AES4_CON_MAX_WORDLEN_24 (1<<0) /* 0 = 20-bit, 1 = 24-bit */
116#define IEC958_AES4_CON_WORDLEN (7<<1) /* mask - sample word length */
117#define IEC958_AES4_CON_WORDLEN_NOTID (0<<1) /* not indicated */
118#define IEC958_AES4_CON_WORDLEN_20_16 (1<<1) /* 20-bit or 16-bit */
119#define IEC958_AES4_CON_WORDLEN_22_18 (2<<1) /* 22-bit or 18-bit */
120#define IEC958_AES4_CON_WORDLEN_23_19 (4<<1) /* 23-bit or 19-bit */
121#define IEC958_AES4_CON_WORDLEN_24_20 (5<<1) /* 24-bit or 20-bit */
122#define IEC958_AES4_CON_WORDLEN_21_17 (6<<1) /* 21-bit or 17-bit */
115 123
116/***************************************************************************** 124/*****************************************************************************
117 * * 125 * *
diff --git a/include/sound/control.h b/include/sound/control.h
index e79baa63912f..3dc1291f52db 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -169,4 +169,11 @@ int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol,
169int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol, 169int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol,
170 struct snd_ctl_elem_info *uinfo); 170 struct snd_ctl_elem_info *uinfo);
171 171
172/*
173 * virtual master control
174 */
175struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
176 const unsigned int *tlv);
177int snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave);
178
172#endif /* __SOUND_CONTROL_H */ 179#endif /* __SOUND_CONTROL_H */
diff --git a/include/sound/core.h b/include/sound/core.h
index 4fc0235ad784..695ee53488a3 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -277,8 +277,8 @@ int snd_minor_info_done(void);
277int snd_minor_info_oss_init(void); 277int snd_minor_info_oss_init(void);
278int snd_minor_info_oss_done(void); 278int snd_minor_info_oss_done(void);
279#else 279#else
280#define snd_minor_info_oss_init() /*NOP*/ 280static inline int snd_minor_info_oss_init(void) { return 0; }
281#define snd_minor_info_oss_done() /*NOP*/ 281static inline int snd_minor_info_oss_done(void) { return 0; }
282#endif 282#endif
283 283
284/* memory.c */ 284/* memory.c */
@@ -310,7 +310,7 @@ int snd_card_file_add(struct snd_card *card, struct file *file);
310int snd_card_file_remove(struct snd_card *card, struct file *file); 310int snd_card_file_remove(struct snd_card *card, struct file *file);
311 311
312#ifndef snd_card_set_dev 312#ifndef snd_card_set_dev
313#define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) 313#define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
314#endif 314#endif
315 315
316/* device.c */ 316/* device.c */
@@ -373,7 +373,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
373 * snd_printd - debug printk 373 * snd_printd - debug printk
374 * @fmt: format string 374 * @fmt: format string
375 * 375 *
376 * Compiled only when Works like snd_printk() for debugging purpose. 376 * Works like snd_printk() for debugging purposes.
377 * Ignored when CONFIG_SND_DEBUG is not set. 377 * Ignored when CONFIG_SND_DEBUG is not set.
378 */ 378 */
379#define snd_printd(fmt, args...) \ 379#define snd_printd(fmt, args...) \
@@ -417,7 +417,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
417 * snd_printdd - debug printk 417 * snd_printdd - debug printk
418 * @format: format string 418 * @format: format string
419 * 419 *
420 * Compiled only when Works like snd_printk() for debugging purpose. 420 * Works like snd_printk() for debugging purposes.
421 * Ignored when CONFIG_SND_DEBUG_DETECT is not set. 421 * Ignored when CONFIG_SND_DEBUG_DETECT is not set.
422 */ 422 */
423#define snd_printdd(format, args...) snd_printk(format, ##args) 423#define snd_printdd(format, args...) snd_printk(format, ##args)
diff --git a/include/sound/mpu401.h b/include/sound/mpu401.h
index d45218b44dfe..1f1d53f8830b 100644
--- a/include/sound/mpu401.h
+++ b/include/sound/mpu401.h
@@ -50,6 +50,7 @@
50#define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */ 50#define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */
51#define MPU401_INFO_MMIO (1 << 3) /* MMIO access */ 51#define MPU401_INFO_MMIO (1 << 3) /* MMIO access */
52#define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */ 52#define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */
53#define MPU401_INFO_NO_ACK (1 << 6) /* No ACK cmd needed */
53 54
54#define MPU401_MODE_BIT_INPUT 0 55#define MPU401_MODE_BIT_INPUT 0
55#define MPU401_MODE_BIT_OUTPUT 1 56#define MPU401_MODE_BIT_OUTPUT 1
@@ -103,6 +104,21 @@ struct snd_mpu401 {
103#define MPU401D(mpu) (mpu)->port 104#define MPU401D(mpu) (mpu)->port
104 105
105/* 106/*
107 * control register bits
108 */
109/* read MPU401C() */
110#define MPU401_RX_EMPTY 0x80
111#define MPU401_TX_FULL 0x40
112
113/* write MPU401C() */
114#define MPU401_RESET 0xff
115#define MPU401_ENTER_UART 0x3f
116
117/* read MPU401D() */
118#define MPU401_ACK 0xfe
119
120
121/*
106 122
107 */ 123 */
108 124
diff --git a/include/sound/version.h b/include/sound/version.h
index fac66c49445a..ed6fb2eb1eac 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.16rc2" 2#define CONFIG_SND_VERSION "1.0.16"
3#define CONFIG_SND_DATE " (Thu Jan 31 16:40:16 2008 UTC)" 3#define CONFIG_SND_DATE ""
diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h
index 336c20db87f8..ed64862c4e18 100644
--- a/include/video/atmel_lcdc.h
+++ b/include/video/atmel_lcdc.h
@@ -22,6 +22,15 @@
22#ifndef __ATMEL_LCDC_H__ 22#ifndef __ATMEL_LCDC_H__
23#define __ATMEL_LCDC_H__ 23#define __ATMEL_LCDC_H__
24 24
25
26/* Way LCD wires are connected to the chip:
27 * Some Atmel chips use BGR color mode (instead of standard RGB)
28 * A swapped wiring onboard can bring to RGB mode.
29 */
30#define ATMEL_LCDC_WIRING_BGR 0
31#define ATMEL_LCDC_WIRING_RGB 1
32
33
25 /* LCD Controller info data structure, stored in device platform_data */ 34 /* LCD Controller info data structure, stored in device platform_data */
26struct atmel_lcdfb_info { 35struct atmel_lcdfb_info {
27 spinlock_t lock; 36 spinlock_t lock;
@@ -39,8 +48,10 @@ struct atmel_lcdfb_info {
39 u8 bl_power; 48 u8 bl_power;
40#endif 49#endif
41 bool lcdcon_is_backlight; 50 bool lcdcon_is_backlight;
51 u8 saved_lcdcon;
42 52
43 u8 default_bpp; 53 u8 default_bpp;
54 u8 lcd_wiring_mode;
44 unsigned int default_lcdcon2; 55 unsigned int default_lcdcon2;
45 unsigned int default_dmacon; 56 unsigned int default_dmacon;
46 void (*atmel_lcdfb_power_control)(int on); 57 void (*atmel_lcdfb_power_control)(int on);
diff --git a/include/video/hecubafb.h b/include/video/hecubafb.h
new file mode 100644
index 000000000000..7b9952339762
--- /dev/null
+++ b/include/video/hecubafb.h
@@ -0,0 +1,51 @@
1/*
2 * hecubafb.h - definitions for the hecuba framebuffer driver
3 *
4 * Copyright (C) 2008 by Jaya Kumar
5 *
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 for
8 * more details.
9 *
10 */
11
12#ifndef _LINUX_HECUBAFB_H_
13#define _LINUX_HECUBAFB_H_
14
15/* Apollo controller specific defines */
16#define APOLLO_START_NEW_IMG 0xA0
17#define APOLLO_STOP_IMG_DATA 0xA1
18#define APOLLO_DISPLAY_IMG 0xA2
19#define APOLLO_ERASE_DISPLAY 0xA3
20#define APOLLO_INIT_DISPLAY 0xA4
21
22/* Hecuba interface specific defines */
23#define HCB_WUP_BIT 0x01
24#define HCB_DS_BIT 0x02
25#define HCB_RW_BIT 0x04
26#define HCB_CD_BIT 0x08
27#define HCB_ACK_BIT 0x80
28
29/* struct used by hecuba. board specific stuff comes from *board */
30struct hecubafb_par {
31 struct fb_info *info;
32 struct hecuba_board *board;
33 void (*send_command)(struct hecubafb_par *, unsigned char);
34 void (*send_data)(struct hecubafb_par *, unsigned char);
35};
36
37/* board specific routines
38board drivers can implement wait_for_ack with interrupts if desired. if
39wait_for_ack is called with clear=0, then go to sleep and return when ack
40goes hi or if wait_for_ack with clear=1, then return when ack goes lo */
41struct hecuba_board {
42 struct module *owner;
43 void (*remove)(struct hecubafb_par *);
44 void (*set_ctl)(struct hecubafb_par *, unsigned char, unsigned char);
45 void (*set_data)(struct hecubafb_par *, unsigned char);
46 void (*wait_for_ack)(struct hecubafb_par *, int);
47 int (*init)(struct hecubafb_par *);
48};
49
50
51#endif
diff --git a/include/video/metronomefb.h b/include/video/metronomefb.h
new file mode 100644
index 000000000000..dab04b4fad7f
--- /dev/null
+++ b/include/video/metronomefb.h
@@ -0,0 +1,62 @@
1/*
2 * metronomefb.h - definitions for the metronome framebuffer driver
3 *
4 * Copyright (C) 2008 by Jaya Kumar
5 *
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 for
8 * more details.
9 *
10 */
11
12#ifndef _LINUX_METRONOMEFB_H_
13#define _LINUX_METRONOMEFB_H_
14
15/* address and control descriptors used by metronome controller */
16struct metromem_desc {
17 u32 mFDADR0;
18 u32 mFSADR0;
19 u32 mFIDR0;
20 u32 mLDCMD0;
21};
22
23/* command structure used by metronome controller */
24struct metromem_cmd {
25 u16 opcode;
26 u16 args[((64-2)/2)];
27 u16 csum;
28};
29
30/* struct used by metronome. board specific stuff comes from *board */
31struct metronomefb_par {
32 unsigned char *metromem;
33 struct metromem_desc *metromem_desc;
34 struct metromem_cmd *metromem_cmd;
35 unsigned char *metromem_wfm;
36 unsigned char *metromem_img;
37 u16 *metromem_img_csum;
38 u16 *csum_table;
39 int metromemsize;
40 dma_addr_t metromem_dma;
41 dma_addr_t metromem_desc_dma;
42 struct fb_info *info;
43 struct metronome_board *board;
44 wait_queue_head_t waitq;
45 u8 frame_count;
46};
47
48/* board specific routines */
49struct metronome_board {
50 struct module *owner;
51 void (*free_irq)(struct fb_info *);
52 void (*init_gpio_regs)(struct metronomefb_par *);
53 void (*init_lcdc_regs)(struct metronomefb_par *);
54 void (*post_dma_setup)(struct metronomefb_par *);
55 void (*set_rst)(struct metronomefb_par *, int);
56 void (*set_stdby)(struct metronomefb_par *, int);
57 int (*met_wait_event)(struct metronomefb_par *);
58 int (*met_wait_event_intr)(struct metronomefb_par *);
59 int (*setup_irq)(struct fb_info *);
60};
61
62#endif
diff --git a/include/xen/balloon.h b/include/xen/balloon.h
new file mode 100644
index 000000000000..fe43b0f3c86a
--- /dev/null
+++ b/include/xen/balloon.h
@@ -0,0 +1,61 @@
1/******************************************************************************
2 * balloon.h
3 *
4 * Xen balloon driver - enables returning/claiming memory to/from Xen.
5 *
6 * Copyright (c) 2003, B Dragovic
7 * Copyright (c) 2003-2004, M Williamson, K Fraser
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation; or, when distributed
12 * separately from the Linux kernel or incorporated into other
13 * software packages, subject to the following license:
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a copy
16 * of this source file (the "Software"), to deal in the Software without
17 * restriction, including without limitation the rights to use, copy, modify,
18 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
19 * and to permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
21 *
22 * The above copyright notice and this permission notice shall be included in
23 * all copies or substantial portions of the Software.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 * IN THE SOFTWARE.
32 */
33
34#ifndef __XEN_BALLOON_H__
35#define __XEN_BALLOON_H__
36
37#include <linux/spinlock.h>
38
39#if 0
40/*
41 * Inform the balloon driver that it should allow some slop for device-driver
42 * memory activities.
43 */
44void balloon_update_driver_allowance(long delta);
45
46/* Allocate/free a set of empty pages in low memory (i.e., no RAM mapped). */
47struct page **alloc_empty_pages_and_pagevec(int nr_pages);
48void free_empty_pages_and_pagevec(struct page **pagevec, int nr_pages);
49
50void balloon_release_driver_page(struct page *page);
51
52/*
53 * Prevent the balloon driver from changing the memory reservation during
54 * a driver critical region.
55 */
56extern spinlock_t balloon_lock;
57#define balloon_lock(__flags) spin_lock_irqsave(&balloon_lock, __flags)
58#define balloon_unlock(__flags) spin_unlock_irqrestore(&balloon_lock, __flags)
59#endif
60
61#endif /* __XEN_BALLOON_H__ */
diff --git a/include/xen/events.h b/include/xen/events.h
index 2bde54d29be5..acd8e062c85f 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -5,13 +5,7 @@
5 5
6#include <xen/interface/event_channel.h> 6#include <xen/interface/event_channel.h>
7#include <asm/xen/hypercall.h> 7#include <asm/xen/hypercall.h>
8 8#include <asm/xen/events.h>
9enum ipi_vector {
10 XEN_RESCHEDULE_VECTOR,
11 XEN_CALL_FUNCTION_VECTOR,
12
13 XEN_NR_IPIS,
14};
15 9
16int bind_evtchn_to_irq(unsigned int evtchn); 10int bind_evtchn_to_irq(unsigned int evtchn);
17int bind_evtchn_to_irqhandler(unsigned int evtchn, 11int bind_evtchn_to_irqhandler(unsigned int evtchn,
@@ -37,6 +31,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
37void unbind_from_irqhandler(unsigned int irq, void *dev_id); 31void unbind_from_irqhandler(unsigned int irq, void *dev_id);
38 32
39void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector); 33void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector);
34int resend_irq_on_evtchn(unsigned int irq);
40 35
41static inline void notify_remote_via_evtchn(int port) 36static inline void notify_remote_via_evtchn(int port)
42{ 37{
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 761c83498e03..466204846121 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -39,6 +39,7 @@
39 39
40#include <asm/xen/hypervisor.h> 40#include <asm/xen/hypervisor.h>
41#include <xen/interface/grant_table.h> 41#include <xen/interface/grant_table.h>
42#include <asm/xen/grant_table.h>
42 43
43/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */ 44/* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
44#define NR_GRANT_FRAMES 4 45#define NR_GRANT_FRAMES 4
@@ -102,6 +103,12 @@ void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
102void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid, 103void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid,
103 unsigned long pfn); 104 unsigned long pfn);
104 105
106int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes,
107 unsigned long max_nr_gframes,
108 struct grant_entry **__shared);
109void arch_gnttab_unmap_shared(struct grant_entry *shared,
110 unsigned long nr_gframes);
111
105#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr)) 112#define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))
106 113
107#endif /* __ASM_GNTTAB_H__ */ 114#endif /* __ASM_GNTTAB_H__ */
diff --git a/include/xen/interface/callback.h b/include/xen/interface/callback.h
new file mode 100644
index 000000000000..4aadcba31af9
--- /dev/null
+++ b/include/xen/interface/callback.h
@@ -0,0 +1,102 @@
1/******************************************************************************
2 * callback.h
3 *
4 * Register guest OS callbacks with Xen.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Copyright (c) 2006, Ian Campbell
25 */
26
27#ifndef __XEN_PUBLIC_CALLBACK_H__
28#define __XEN_PUBLIC_CALLBACK_H__
29
30#include "xen.h"
31
32/*
33 * Prototype for this hypercall is:
34 * long callback_op(int cmd, void *extra_args)
35 * @cmd == CALLBACKOP_??? (callback operation).
36 * @extra_args == Operation-specific extra arguments (NULL if none).
37 */
38
39/* ia64, x86: Callback for event delivery. */
40#define CALLBACKTYPE_event 0
41
42/* x86: Failsafe callback when guest state cannot be restored by Xen. */
43#define CALLBACKTYPE_failsafe 1
44
45/* x86/64 hypervisor: Syscall by 64-bit guest app ('64-on-64-on-64'). */
46#define CALLBACKTYPE_syscall 2
47
48/*
49 * x86/32 hypervisor: Only available on x86/32 when supervisor_mode_kernel
50 * feature is enabled. Do not use this callback type in new code.
51 */
52#define CALLBACKTYPE_sysenter_deprecated 3
53
54/* x86: Callback for NMI delivery. */
55#define CALLBACKTYPE_nmi 4
56
57/*
58 * x86: sysenter is only available as follows:
59 * - 32-bit hypervisor: with the supervisor_mode_kernel feature enabled
60 * - 64-bit hypervisor: 32-bit guest applications on Intel CPUs
61 * ('32-on-32-on-64', '32-on-64-on-64')
62 * [nb. also 64-bit guest applications on Intel CPUs
63 * ('64-on-64-on-64'), but syscall is preferred]
64 */
65#define CALLBACKTYPE_sysenter 5
66
67/*
68 * x86/64 hypervisor: Syscall by 32-bit guest app on AMD CPUs
69 * ('32-on-32-on-64', '32-on-64-on-64')
70 */
71#define CALLBACKTYPE_syscall32 7
72
73/*
74 * Disable event deliver during callback? This flag is ignored for event and
75 * NMI callbacks: event delivery is unconditionally disabled.
76 */
77#define _CALLBACKF_mask_events 0
78#define CALLBACKF_mask_events (1U << _CALLBACKF_mask_events)
79
80/*
81 * Register a callback.
82 */
83#define CALLBACKOP_register 0
84struct callback_register {
85 uint16_t type;
86 uint16_t flags;
87 struct xen_callback address;
88};
89
90/*
91 * Unregister a callback.
92 *
93 * Not all callbacks can be unregistered. -EINVAL will be returned if
94 * you attempt to unregister such a callback.
95 */
96#define CALLBACKOP_unregister 1
97struct callback_unregister {
98 uint16_t type;
99 uint16_t _unused;
100};
101
102#endif /* __XEN_PUBLIC_CALLBACK_H__ */
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h
index 219049802cf2..39da93c21de0 100644
--- a/include/xen/interface/grant_table.h
+++ b/include/xen/interface/grant_table.h
@@ -185,6 +185,7 @@ struct gnttab_map_grant_ref {
185 grant_handle_t handle; 185 grant_handle_t handle;
186 uint64_t dev_bus_addr; 186 uint64_t dev_bus_addr;
187}; 187};
188DEFINE_GUEST_HANDLE_STRUCT(gnttab_map_grant_ref);
188 189
189/* 190/*
190 * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings 191 * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
@@ -206,6 +207,7 @@ struct gnttab_unmap_grant_ref {
206 /* OUT parameters. */ 207 /* OUT parameters. */
207 int16_t status; /* GNTST_* */ 208 int16_t status; /* GNTST_* */
208}; 209};
210DEFINE_GUEST_HANDLE_STRUCT(gnttab_unmap_grant_ref);
209 211
210/* 212/*
211 * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least 213 * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
@@ -223,8 +225,9 @@ struct gnttab_setup_table {
223 uint32_t nr_frames; 225 uint32_t nr_frames;
224 /* OUT parameters. */ 226 /* OUT parameters. */
225 int16_t status; /* GNTST_* */ 227 int16_t status; /* GNTST_* */
226 ulong *frame_list; 228 GUEST_HANDLE(ulong) frame_list;
227}; 229};
230DEFINE_GUEST_HANDLE_STRUCT(gnttab_setup_table);
228 231
229/* 232/*
230 * GNTTABOP_dump_table: Dump the contents of the grant table to the 233 * GNTTABOP_dump_table: Dump the contents of the grant table to the
@@ -237,6 +240,7 @@ struct gnttab_dump_table {
237 /* OUT parameters. */ 240 /* OUT parameters. */
238 int16_t status; /* GNTST_* */ 241 int16_t status; /* GNTST_* */
239}; 242};
243DEFINE_GUEST_HANDLE_STRUCT(gnttab_dump_table);
240 244
241/* 245/*
242 * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The 246 * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
@@ -255,7 +259,7 @@ struct gnttab_transfer {
255 /* OUT parameters. */ 259 /* OUT parameters. */
256 int16_t status; 260 int16_t status;
257}; 261};
258 262DEFINE_GUEST_HANDLE_STRUCT(gnttab_transfer);
259 263
260/* 264/*
261 * GNTTABOP_copy: Hypervisor based copy 265 * GNTTABOP_copy: Hypervisor based copy
@@ -296,6 +300,7 @@ struct gnttab_copy {
296 /* OUT parameters. */ 300 /* OUT parameters. */
297 int16_t status; 301 int16_t status;
298}; 302};
303DEFINE_GUEST_HANDLE_STRUCT(gnttab_copy);
299 304
300/* 305/*
301 * GNTTABOP_query_size: Query the current and maximum sizes of the shared 306 * GNTTABOP_query_size: Query the current and maximum sizes of the shared
@@ -313,7 +318,7 @@ struct gnttab_query_size {
313 uint32_t max_nr_frames; 318 uint32_t max_nr_frames;
314 int16_t status; /* GNTST_* */ 319 int16_t status; /* GNTST_* */
315}; 320};
316 321DEFINE_GUEST_HANDLE_STRUCT(gnttab_query_size);
317 322
318/* 323/*
319 * Bitfield values for update_pin_status.flags. 324 * Bitfield values for update_pin_status.flags.
diff --git a/include/xen/interface/io/fbif.h b/include/xen/interface/io/fbif.h
new file mode 100644
index 000000000000..5a934dd7796d
--- /dev/null
+++ b/include/xen/interface/io/fbif.h
@@ -0,0 +1,124 @@
1/*
2 * fbif.h -- Xen virtual frame buffer device
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 *
22 * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
23 * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
24 */
25
26#ifndef __XEN_PUBLIC_IO_FBIF_H__
27#define __XEN_PUBLIC_IO_FBIF_H__
28
29/* Out events (frontend -> backend) */
30
31/*
32 * Out events may be sent only when requested by backend, and receipt
33 * of an unknown out event is an error.
34 */
35
36/* Event type 1 currently not used */
37/*
38 * Framebuffer update notification event
39 * Capable frontend sets feature-update in xenstore.
40 * Backend requests it by setting request-update in xenstore.
41 */
42#define XENFB_TYPE_UPDATE 2
43
44struct xenfb_update {
45 uint8_t type; /* XENFB_TYPE_UPDATE */
46 int32_t x; /* source x */
47 int32_t y; /* source y */
48 int32_t width; /* rect width */
49 int32_t height; /* rect height */
50};
51
52#define XENFB_OUT_EVENT_SIZE 40
53
54union xenfb_out_event {
55 uint8_t type;
56 struct xenfb_update update;
57 char pad[XENFB_OUT_EVENT_SIZE];
58};
59
60/* In events (backend -> frontend) */
61
62/*
63 * Frontends should ignore unknown in events.
64 * No in events currently defined.
65 */
66
67#define XENFB_IN_EVENT_SIZE 40
68
69union xenfb_in_event {
70 uint8_t type;
71 char pad[XENFB_IN_EVENT_SIZE];
72};
73
74/* shared page */
75
76#define XENFB_IN_RING_SIZE 1024
77#define XENFB_IN_RING_LEN (XENFB_IN_RING_SIZE / XENFB_IN_EVENT_SIZE)
78#define XENFB_IN_RING_OFFS 1024
79#define XENFB_IN_RING(page) \
80 ((union xenfb_in_event *)((char *)(page) + XENFB_IN_RING_OFFS))
81#define XENFB_IN_RING_REF(page, idx) \
82 (XENFB_IN_RING((page))[(idx) % XENFB_IN_RING_LEN])
83
84#define XENFB_OUT_RING_SIZE 2048
85#define XENFB_OUT_RING_LEN (XENFB_OUT_RING_SIZE / XENFB_OUT_EVENT_SIZE)
86#define XENFB_OUT_RING_OFFS (XENFB_IN_RING_OFFS + XENFB_IN_RING_SIZE)
87#define XENFB_OUT_RING(page) \
88 ((union xenfb_out_event *)((char *)(page) + XENFB_OUT_RING_OFFS))
89#define XENFB_OUT_RING_REF(page, idx) \
90 (XENFB_OUT_RING((page))[(idx) % XENFB_OUT_RING_LEN])
91
92struct xenfb_page {
93 uint32_t in_cons, in_prod;
94 uint32_t out_cons, out_prod;
95
96 int32_t width; /* width of the framebuffer (in pixels) */
97 int32_t height; /* height of the framebuffer (in pixels) */
98 uint32_t line_length; /* length of a row of pixels (in bytes) */
99 uint32_t mem_length; /* length of the framebuffer (in bytes) */
100 uint8_t depth; /* depth of a pixel (in bits) */
101
102 /*
103 * Framebuffer page directory
104 *
105 * Each directory page holds PAGE_SIZE / sizeof(*pd)
106 * framebuffer pages, and can thus map up to PAGE_SIZE *
107 * PAGE_SIZE / sizeof(*pd) bytes. With PAGE_SIZE == 4096 and
108 * sizeof(unsigned long) == 4, that's 4 Megs. Two directory
109 * pages should be enough for a while.
110 */
111 unsigned long pd[2];
112};
113
114/*
115 * Wart: xenkbd needs to know resolution. Put it here until a better
116 * solution is found, but don't leak it to the backend.
117 */
118#ifdef __KERNEL__
119#define XENFB_WIDTH 800
120#define XENFB_HEIGHT 600
121#define XENFB_DEPTH 32
122#endif
123
124#endif
diff --git a/include/xen/interface/io/kbdif.h b/include/xen/interface/io/kbdif.h
new file mode 100644
index 000000000000..fb97f4284ffd
--- /dev/null
+++ b/include/xen/interface/io/kbdif.h
@@ -0,0 +1,114 @@
1/*
2 * kbdif.h -- Xen virtual keyboard/mouse
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 *
22 * Copyright (C) 2005 Anthony Liguori <aliguori@us.ibm.com>
23 * Copyright (C) 2006 Red Hat, Inc., Markus Armbruster <armbru@redhat.com>
24 */
25
26#ifndef __XEN_PUBLIC_IO_KBDIF_H__
27#define __XEN_PUBLIC_IO_KBDIF_H__
28
29/* In events (backend -> frontend) */
30
31/*
32 * Frontends should ignore unknown in events.
33 */
34
35/* Pointer movement event */
36#define XENKBD_TYPE_MOTION 1
37/* Event type 2 currently not used */
38/* Key event (includes pointer buttons) */
39#define XENKBD_TYPE_KEY 3
40/*
41 * Pointer position event
42 * Capable backend sets feature-abs-pointer in xenstore.
43 * Frontend requests ot instead of XENKBD_TYPE_MOTION by setting
44 * request-abs-update in xenstore.
45 */
46#define XENKBD_TYPE_POS 4
47
48struct xenkbd_motion {
49 uint8_t type; /* XENKBD_TYPE_MOTION */
50 int32_t rel_x; /* relative X motion */
51 int32_t rel_y; /* relative Y motion */
52};
53
54struct xenkbd_key {
55 uint8_t type; /* XENKBD_TYPE_KEY */
56 uint8_t pressed; /* 1 if pressed; 0 otherwise */
57 uint32_t keycode; /* KEY_* from linux/input.h */
58};
59
60struct xenkbd_position {
61 uint8_t type; /* XENKBD_TYPE_POS */
62 int32_t abs_x; /* absolute X position (in FB pixels) */
63 int32_t abs_y; /* absolute Y position (in FB pixels) */
64};
65
66#define XENKBD_IN_EVENT_SIZE 40
67
68union xenkbd_in_event {
69 uint8_t type;
70 struct xenkbd_motion motion;
71 struct xenkbd_key key;
72 struct xenkbd_position pos;
73 char pad[XENKBD_IN_EVENT_SIZE];
74};
75
76/* Out events (frontend -> backend) */
77
78/*
79 * Out events may be sent only when requested by backend, and receipt
80 * of an unknown out event is an error.
81 * No out events currently defined.
82 */
83
84#define XENKBD_OUT_EVENT_SIZE 40
85
86union xenkbd_out_event {
87 uint8_t type;
88 char pad[XENKBD_OUT_EVENT_SIZE];
89};
90
91/* shared page */
92
93#define XENKBD_IN_RING_SIZE 2048
94#define XENKBD_IN_RING_LEN (XENKBD_IN_RING_SIZE / XENKBD_IN_EVENT_SIZE)
95#define XENKBD_IN_RING_OFFS 1024
96#define XENKBD_IN_RING(page) \
97 ((union xenkbd_in_event *)((char *)(page) + XENKBD_IN_RING_OFFS))
98#define XENKBD_IN_RING_REF(page, idx) \
99 (XENKBD_IN_RING((page))[(idx) % XENKBD_IN_RING_LEN])
100
101#define XENKBD_OUT_RING_SIZE 1024
102#define XENKBD_OUT_RING_LEN (XENKBD_OUT_RING_SIZE / XENKBD_OUT_EVENT_SIZE)
103#define XENKBD_OUT_RING_OFFS (XENKBD_IN_RING_OFFS + XENKBD_IN_RING_SIZE)
104#define XENKBD_OUT_RING(page) \
105 ((union xenkbd_out_event *)((char *)(page) + XENKBD_OUT_RING_OFFS))
106#define XENKBD_OUT_RING_REF(page, idx) \
107 (XENKBD_OUT_RING((page))[(idx) % XENKBD_OUT_RING_LEN])
108
109struct xenkbd_page {
110 uint32_t in_cons, in_prod;
111 uint32_t out_cons, out_prod;
112};
113
114#endif
diff --git a/include/xen/interface/io/protocols.h b/include/xen/interface/io/protocols.h
new file mode 100644
index 000000000000..01fc8ae5f0b0
--- /dev/null
+++ b/include/xen/interface/io/protocols.h
@@ -0,0 +1,21 @@
1#ifndef __XEN_PROTOCOLS_H__
2#define __XEN_PROTOCOLS_H__
3
4#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi"
5#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi"
6#define XEN_IO_PROTO_ABI_IA64 "ia64-abi"
7#define XEN_IO_PROTO_ABI_POWERPC64 "powerpc64-abi"
8
9#if defined(__i386__)
10# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32
11#elif defined(__x86_64__)
12# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64
13#elif defined(__ia64__)
14# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64
15#elif defined(__powerpc64__)
16# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64
17#else
18# error arch fixup needed here
19#endif
20
21#endif
diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index af36ead16817..da768469aa92 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -29,7 +29,7 @@ struct xen_memory_reservation {
29 * OUT: GMFN bases of extents that were allocated 29 * OUT: GMFN bases of extents that were allocated
30 * (NB. This command also updates the mach_to_phys translation table) 30 * (NB. This command also updates the mach_to_phys translation table)
31 */ 31 */
32 GUEST_HANDLE(ulong) extent_start; 32 ulong extent_start;
33 33
34 /* Number of extents, and size/alignment of each (2^extent_order pages). */ 34 /* Number of extents, and size/alignment of each (2^extent_order pages). */
35 unsigned long nr_extents; 35 unsigned long nr_extents;
@@ -50,7 +50,6 @@ struct xen_memory_reservation {
50 domid_t domid; 50 domid_t domid;
51 51
52}; 52};
53DEFINE_GUEST_HANDLE_STRUCT(xen_memory_reservation);
54 53
55/* 54/*
56 * Returns the maximum machine frame number of mapped RAM in this system. 55 * Returns the maximum machine frame number of mapped RAM in this system.
@@ -86,7 +85,7 @@ struct xen_machphys_mfn_list {
86 * any large discontiguities in the machine address space, 2MB gaps in 85 * any large discontiguities in the machine address space, 2MB gaps in
87 * the machphys table will be represented by an MFN base of zero. 86 * the machphys table will be represented by an MFN base of zero.
88 */ 87 */
89 GUEST_HANDLE(ulong) extent_start; 88 ulong extent_start;
90 89
91 /* 90 /*
92 * Number of extents written to the above array. This will be smaller 91 * Number of extents written to the above array. This will be smaller
@@ -94,7 +93,6 @@ struct xen_machphys_mfn_list {
94 */ 93 */
95 unsigned int nr_extents; 94 unsigned int nr_extents;
96}; 95};
97DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);
98 96
99/* 97/*
100 * Sets the GPFN at which a particular page appears in the specified guest's 98 * Sets the GPFN at which a particular page appears in the specified guest's
@@ -117,7 +115,6 @@ struct xen_add_to_physmap {
117 /* GPFN where the source mapping page should appear. */ 115 /* GPFN where the source mapping page should appear. */
118 unsigned long gpfn; 116 unsigned long gpfn;
119}; 117};
120DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
121 118
122/* 119/*
123 * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error 120 * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
@@ -132,14 +129,13 @@ struct xen_translate_gpfn_list {
132 unsigned long nr_gpfns; 129 unsigned long nr_gpfns;
133 130
134 /* List of GPFNs to translate. */ 131 /* List of GPFNs to translate. */
135 GUEST_HANDLE(ulong) gpfn_list; 132 ulong gpfn_list;
136 133
137 /* 134 /*
138 * Output list to contain MFN translations. May be the same as the input 135 * Output list to contain MFN translations. May be the same as the input
139 * list (in which case each input GPFN is overwritten with the output MFN). 136 * list (in which case each input GPFN is overwritten with the output MFN).
140 */ 137 */
141 GUEST_HANDLE(ulong) mfn_list; 138 ulong mfn_list;
142}; 139};
143DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
144 140
145#endif /* __XEN_PUBLIC_MEMORY_H__ */ 141#endif /* __XEN_PUBLIC_MEMORY_H__ */
diff --git a/include/xen/interface/vcpu.h b/include/xen/interface/vcpu.h
index b05d8a6d9143..87e6f8a48661 100644
--- a/include/xen/interface/vcpu.h
+++ b/include/xen/interface/vcpu.h
@@ -85,6 +85,7 @@ struct vcpu_runstate_info {
85 */ 85 */
86 uint64_t time[4]; 86 uint64_t time[4];
87}; 87};
88DEFINE_GUEST_HANDLE_STRUCT(vcpu_runstate_info);
88 89
89/* VCPU is currently running on a physical CPU. */ 90/* VCPU is currently running on a physical CPU. */
90#define RUNSTATE_running 0 91#define RUNSTATE_running 0
@@ -119,6 +120,7 @@ struct vcpu_runstate_info {
119#define VCPUOP_register_runstate_memory_area 5 120#define VCPUOP_register_runstate_memory_area 5
120struct vcpu_register_runstate_memory_area { 121struct vcpu_register_runstate_memory_area {
121 union { 122 union {
123 GUEST_HANDLE(vcpu_runstate_info) h;
122 struct vcpu_runstate_info *v; 124 struct vcpu_runstate_info *v;
123 uint64_t p; 125 uint64_t p;
124 } addr; 126 } addr;
@@ -134,6 +136,7 @@ struct vcpu_register_runstate_memory_area {
134struct vcpu_set_periodic_timer { 136struct vcpu_set_periodic_timer {
135 uint64_t period_ns; 137 uint64_t period_ns;
136}; 138};
139DEFINE_GUEST_HANDLE_STRUCT(vcpu_set_periodic_timer);
137 140
138/* 141/*
139 * Set or stop a VCPU's single-shot timer. Every VCPU has one single-shot 142 * Set or stop a VCPU's single-shot timer. Every VCPU has one single-shot
@@ -145,6 +148,7 @@ struct vcpu_set_singleshot_timer {
145 uint64_t timeout_abs_ns; 148 uint64_t timeout_abs_ns;
146 uint32_t flags; /* VCPU_SSHOTTMR_??? */ 149 uint32_t flags; /* VCPU_SSHOTTMR_??? */
147}; 150};
151DEFINE_GUEST_HANDLE_STRUCT(vcpu_set_singleshot_timer);
148 152
149/* Flags to VCPUOP_set_singleshot_timer. */ 153/* Flags to VCPUOP_set_singleshot_timer. */
150 /* Require the timeout to be in the future (return -ETIME if it's passed). */ 154 /* Require the timeout to be in the future (return -ETIME if it's passed). */
@@ -164,5 +168,6 @@ struct vcpu_register_vcpu_info {
164 uint32_t offset; /* offset within page */ 168 uint32_t offset; /* offset within page */
165 uint32_t rsvd; /* unused */ 169 uint32_t rsvd; /* unused */
166}; 170};
171DEFINE_GUEST_HANDLE_STRUCT(vcpu_register_vcpu_info);
167 172
168#endif /* __XEN_PUBLIC_VCPU_H__ */ 173#endif /* __XEN_PUBLIC_VCPU_H__ */
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
index 518a5bf79ed3..9b018da48cf3 100644
--- a/include/xen/interface/xen.h
+++ b/include/xen/interface/xen.h
@@ -58,6 +58,16 @@
58#define __HYPERVISOR_physdev_op 33 58#define __HYPERVISOR_physdev_op 33
59#define __HYPERVISOR_hvm_op 34 59#define __HYPERVISOR_hvm_op 34
60 60
61/* Architecture-specific hypercall definitions. */
62#define __HYPERVISOR_arch_0 48
63#define __HYPERVISOR_arch_1 49
64#define __HYPERVISOR_arch_2 50
65#define __HYPERVISOR_arch_3 51
66#define __HYPERVISOR_arch_4 52
67#define __HYPERVISOR_arch_5 53
68#define __HYPERVISOR_arch_6 54
69#define __HYPERVISOR_arch_7 55
70
61/* 71/*
62 * VIRTUAL INTERRUPTS 72 * VIRTUAL INTERRUPTS
63 * 73 *
@@ -68,8 +78,18 @@
68#define VIRQ_CONSOLE 2 /* (DOM0) Bytes received on emergency console. */ 78#define VIRQ_CONSOLE 2 /* (DOM0) Bytes received on emergency console. */
69#define VIRQ_DOM_EXC 3 /* (DOM0) Exceptional event for some domain. */ 79#define VIRQ_DOM_EXC 3 /* (DOM0) Exceptional event for some domain. */
70#define VIRQ_DEBUGGER 6 /* (DOM0) A domain has paused for debugging. */ 80#define VIRQ_DEBUGGER 6 /* (DOM0) A domain has paused for debugging. */
71#define NR_VIRQS 8
72 81
82/* Architecture-specific VIRQ definitions. */
83#define VIRQ_ARCH_0 16
84#define VIRQ_ARCH_1 17
85#define VIRQ_ARCH_2 18
86#define VIRQ_ARCH_3 19
87#define VIRQ_ARCH_4 20
88#define VIRQ_ARCH_5 21
89#define VIRQ_ARCH_6 22
90#define VIRQ_ARCH_7 23
91
92#define NR_VIRQS 24
73/* 93/*
74 * MMU-UPDATE REQUESTS 94 * MMU-UPDATE REQUESTS
75 * 95 *
diff --git a/include/xen/interface/xencomm.h b/include/xen/interface/xencomm.h
new file mode 100644
index 000000000000..ac45e0712afa
--- /dev/null
+++ b/include/xen/interface/xencomm.h
@@ -0,0 +1,41 @@
1/*
2 * Permission is hereby granted, free of charge, to any person obtaining a copy
3 * of this software and associated documentation files (the "Software"), to
4 * deal in the Software without restriction, including without limitation the
5 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 * sell copies of the Software, and to permit persons to whom the Software is
7 * furnished to do so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 * DEALINGS IN THE SOFTWARE.
19 *
20 * Copyright (C) IBM Corp. 2006
21 */
22
23#ifndef _XEN_XENCOMM_H_
24#define _XEN_XENCOMM_H_
25
26/* A xencomm descriptor is a scatter/gather list containing physical
27 * addresses corresponding to a virtually contiguous memory area. The
28 * hypervisor translates these physical addresses to machine addresses to copy
29 * to and from the virtually contiguous area.
30 */
31
32#define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */
33#define XENCOMM_INVALID (~0UL)
34
35struct xencomm_desc {
36 uint32_t magic;
37 uint32_t nr_addrs; /* the number of entries in address[] */
38 uint64_t address[0];
39};
40
41#endif /* _XEN_XENCOMM_H_ */
diff --git a/include/xen/page.h b/include/xen/page.h
index 031ef22a971e..eaf85fab1263 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -1,180 +1 @@
1#ifndef __XEN_PAGE_H #include <asm/xen/page.h>
2#define __XEN_PAGE_H
3
4#include <linux/pfn.h>
5
6#include <asm/uaccess.h>
7#include <asm/pgtable.h>
8
9#include <xen/features.h>
10
11#ifdef CONFIG_X86_PAE
12/* Xen machine address */
13typedef struct xmaddr {
14 unsigned long long maddr;
15} xmaddr_t;
16
17/* Xen pseudo-physical address */
18typedef struct xpaddr {
19 unsigned long long paddr;
20} xpaddr_t;
21#else
22/* Xen machine address */
23typedef struct xmaddr {
24 unsigned long maddr;
25} xmaddr_t;
26
27/* Xen pseudo-physical address */
28typedef struct xpaddr {
29 unsigned long paddr;
30} xpaddr_t;
31#endif
32
33#define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
34#define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
35
36/**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
37#define INVALID_P2M_ENTRY (~0UL)
38#define FOREIGN_FRAME_BIT (1UL<<31)
39#define FOREIGN_FRAME(m) ((m) | FOREIGN_FRAME_BIT)
40
41extern unsigned long *phys_to_machine_mapping;
42
43static inline unsigned long pfn_to_mfn(unsigned long pfn)
44{
45 if (xen_feature(XENFEAT_auto_translated_physmap))
46 return pfn;
47
48 return phys_to_machine_mapping[(unsigned int)(pfn)] &
49 ~FOREIGN_FRAME_BIT;
50}
51
52static inline int phys_to_machine_mapping_valid(unsigned long pfn)
53{
54 if (xen_feature(XENFEAT_auto_translated_physmap))
55 return 1;
56
57 return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
58}
59
60static inline unsigned long mfn_to_pfn(unsigned long mfn)
61{
62 unsigned long pfn;
63
64 if (xen_feature(XENFEAT_auto_translated_physmap))
65 return mfn;
66
67#if 0
68 if (unlikely((mfn >> machine_to_phys_order) != 0))
69 return max_mapnr;
70#endif
71
72 pfn = 0;
73 /*
74 * The array access can fail (e.g., device space beyond end of RAM).
75 * In such cases it doesn't matter what we return (we return garbage),
76 * but we must handle the fault without crashing!
77 */
78 __get_user(pfn, &machine_to_phys_mapping[mfn]);
79
80 return pfn;
81}
82
83static inline xmaddr_t phys_to_machine(xpaddr_t phys)
84{
85 unsigned offset = phys.paddr & ~PAGE_MASK;
86 return XMADDR(PFN_PHYS((u64)pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
87}
88
89static inline xpaddr_t machine_to_phys(xmaddr_t machine)
90{
91 unsigned offset = machine.maddr & ~PAGE_MASK;
92 return XPADDR(PFN_PHYS((u64)mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
93}
94
95/*
96 * We detect special mappings in one of two ways:
97 * 1. If the MFN is an I/O page then Xen will set the m2p entry
98 * to be outside our maximum possible pseudophys range.
99 * 2. If the MFN belongs to a different domain then we will certainly
100 * not have MFN in our p2m table. Conversely, if the page is ours,
101 * then we'll have p2m(m2p(MFN))==MFN.
102 * If we detect a special mapping then it doesn't have a 'struct page'.
103 * We force !pfn_valid() by returning an out-of-range pointer.
104 *
105 * NB. These checks require that, for any MFN that is not in our reservation,
106 * there is no PFN such that p2m(PFN) == MFN. Otherwise we can get confused if
107 * we are foreign-mapping the MFN, and the other domain as m2p(MFN) == PFN.
108 * Yikes! Various places must poke in INVALID_P2M_ENTRY for safety.
109 *
110 * NB2. When deliberately mapping foreign pages into the p2m table, you *must*
111 * use FOREIGN_FRAME(). This will cause pte_pfn() to choke on it, as we
112 * require. In all the cases we care about, the FOREIGN_FRAME bit is
113 * masked (e.g., pfn_to_mfn()) so behaviour there is correct.
114 */
115static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
116{
117 extern unsigned long max_mapnr;
118 unsigned long pfn = mfn_to_pfn(mfn);
119 if ((pfn < max_mapnr)
120 && !xen_feature(XENFEAT_auto_translated_physmap)
121 && (phys_to_machine_mapping[pfn] != mfn))
122 return max_mapnr; /* force !pfn_valid() */
123 return pfn;
124}
125
126static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
127{
128 if (xen_feature(XENFEAT_auto_translated_physmap)) {
129 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
130 return;
131 }
132 phys_to_machine_mapping[pfn] = mfn;
133}
134
135/* VIRT <-> MACHINE conversion */
136#define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
137#define virt_to_mfn(v) (pfn_to_mfn(PFN_DOWN(__pa(v))))
138#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
139
140#ifdef CONFIG_X86_PAE
141#define pte_mfn(_pte) (((_pte).pte_low >> PAGE_SHIFT) | \
142 (((_pte).pte_high & 0xfff) << (32-PAGE_SHIFT)))
143
144static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot)
145{
146 pte_t pte;
147
148 pte.pte_high = (page_nr >> (32 - PAGE_SHIFT)) |
149 (pgprot_val(pgprot) >> 32);
150 pte.pte_high &= (__supported_pte_mask >> 32);
151 pte.pte_low = ((page_nr << PAGE_SHIFT) | pgprot_val(pgprot));
152 pte.pte_low &= __supported_pte_mask;
153
154 return pte;
155}
156
157static inline unsigned long long pte_val_ma(pte_t x)
158{
159 return x.pte;
160}
161#define pmd_val_ma(v) ((v).pmd)
162#define pud_val_ma(v) ((v).pgd.pgd)
163#define __pte_ma(x) ((pte_t) { .pte = (x) })
164#define __pmd_ma(x) ((pmd_t) { (x) } )
165#else /* !X86_PAE */
166#define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT)
167#define mfn_pte(pfn, prot) __pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
168#define pte_val_ma(x) ((x).pte)
169#define pmd_val_ma(v) ((v).pud.pgd.pgd)
170#define __pte_ma(x) ((pte_t) { (x) } )
171#endif /* CONFIG_X86_PAE */
172
173#define pgd_val_ma(x) ((x).pgd)
174
175
176xmaddr_t arbitrary_virt_to_machine(unsigned long address);
177void make_lowmem_page_readonly(void *vaddr);
178void make_lowmem_page_readwrite(void *vaddr);
179
180#endif /* __XEN_PAGE_H */
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
new file mode 100644
index 000000000000..10ddfe0142d0
--- /dev/null
+++ b/include/xen/xen-ops.h
@@ -0,0 +1,8 @@
1#ifndef INCLUDE_XEN_OPS_H
2#define INCLUDE_XEN_OPS_H
3
4#include <linux/percpu.h>
5
6DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
7
8#endif /* INCLUDE_XEN_OPS_H */
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index 6f7c290651ae..6369d89c25d5 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -97,6 +97,7 @@ struct xenbus_driver {
97 int (*uevent)(struct xenbus_device *, char **, int, char *, int); 97 int (*uevent)(struct xenbus_device *, char **, int, char *, int);
98 struct device_driver driver; 98 struct device_driver driver;
99 int (*read_otherend_details)(struct xenbus_device *dev); 99 int (*read_otherend_details)(struct xenbus_device *dev);
100 int (*is_ready)(struct xenbus_device *dev);
100}; 101};
101 102
102static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv) 103static inline struct xenbus_driver *to_xenbus_driver(struct device_driver *drv)
diff --git a/include/xen/xencomm.h b/include/xen/xencomm.h
new file mode 100644
index 000000000000..e43b039be112
--- /dev/null
+++ b/include/xen/xencomm.h
@@ -0,0 +1,77 @@
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, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 *
16 * Copyright (C) IBM Corp. 2006
17 *
18 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
19 * Jerone Young <jyoung5@us.ibm.com>
20 */
21
22#ifndef _LINUX_XENCOMM_H_
23#define _LINUX_XENCOMM_H_
24
25#include <xen/interface/xencomm.h>
26
27#define XENCOMM_MINI_ADDRS 3
28struct xencomm_mini {
29 struct xencomm_desc _desc;
30 uint64_t address[XENCOMM_MINI_ADDRS];
31};
32
33/* To avoid additionnal virt to phys conversion, an opaque structure is
34 presented. */
35struct xencomm_handle;
36
37extern void xencomm_free(struct xencomm_handle *desc);
38extern struct xencomm_handle *xencomm_map(void *ptr, unsigned long bytes);
39extern struct xencomm_handle *__xencomm_map_no_alloc(void *ptr,
40 unsigned long bytes, struct xencomm_mini *xc_area);
41
42#if 0
43#define XENCOMM_MINI_ALIGNED(xc_desc, n) \
44 struct xencomm_mini xc_desc ## _base[(n)] \
45 __attribute__((__aligned__(sizeof(struct xencomm_mini)))); \
46 struct xencomm_mini *xc_desc = &xc_desc ## _base[0];
47#else
48/*
49 * gcc bug workaround:
50 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660
51 * gcc doesn't handle properly stack variable with
52 * __attribute__((__align__(sizeof(struct xencomm_mini))))
53 */
54#define XENCOMM_MINI_ALIGNED(xc_desc, n) \
55 unsigned char xc_desc ## _base[((n) + 1 ) * \
56 sizeof(struct xencomm_mini)]; \
57 struct xencomm_mini *xc_desc = (struct xencomm_mini *) \
58 ((unsigned long)xc_desc ## _base + \
59 (sizeof(struct xencomm_mini) - \
60 ((unsigned long)xc_desc ## _base) % \
61 sizeof(struct xencomm_mini)));
62#endif
63#define xencomm_map_no_alloc(ptr, bytes) \
64 ({ XENCOMM_MINI_ALIGNED(xc_desc, 1); \
65 __xencomm_map_no_alloc(ptr, bytes, xc_desc); })
66
67/* provided by architecture code: */
68extern unsigned long xencomm_vtop(unsigned long vaddr);
69
70static inline void *xencomm_pa(void *ptr)
71{
72 return (void *)xencomm_vtop((unsigned long)ptr);
73}
74
75#define xen_guest_handle(hnd) ((hnd).p)
76
77#endif /* _LINUX_XENCOMM_H_ */